Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mozbrowsersecuritychange event #9244

Merged
merged 1 commit into from Feb 9, 2016
Merged

Conversation

@paulrouget
Copy link
Contributor

paulrouget commented Jan 11, 2016

Fixes #8544

No test yet. Is there a way to mock a https connection?

Also, I wish I could use the HTTPSState enum instead of a String when calling trigger_mozbrowser_event (https://github.com/servo/servo/compare/master...paulrouget:securitychange?expand=1#diff-30a18e04d7e0b66aafdf192e416cad44R306) but that would require constellation_msg.rs to know about HTTPSState, which is defined in document.rs, which would add a dependency to components/msg. I could define HTTPSState somewhere else maybe? Or maybe it's fine to use a String. But then, should I use the HTTPSState strings ("modern/deprecated/none") or the mozbrowser strings ("secure/insecure/broken") (as it is now)

Review on Reviewable

@paulrouget paulrouget force-pushed the paulrouget:securitychange branch from 5207986 to 3745913 Jan 11, 2016
@frewsxcv
Copy link
Member

frewsxcv commented Jan 11, 2016

@frewsxcv
Copy link
Member

frewsxcv commented Jan 11, 2016

components/script/dom/document.rs, line 126 [r1] (raw file):
Second PR link was supposed to be #9165


Comments from the review on Reviewable.io

@paulrouget paulrouget force-pushed the paulrouget:securitychange branch from 3745913 to 4aaf250 Jan 11, 2016
@paulrouget
Copy link
Contributor Author

paulrouget commented Jan 11, 2016

Using the existing HttpsState enum.

3 questions:

  • how do I test this feature? Anyway to mock a https connection?
  • as explained in the first comment, is it possible to send a HttpsState object instead of a string when calling trigger_mozbrowser_event? I haven't found a way to add HttpsState to constellation_msg.rs.
  • how to catch broken/deprecated https connections? Maybe this could be done in a followup PR.
@jdm
Copy link
Member

jdm commented Jan 11, 2016

  • We don't support SSL in our WPT harness yet due to #6919 . It would be nice to write a test for this, though, even if it's expected to fail in Servo until #6919 is fixed.
  • This will probably be easier after #9225.
  • Definitely followup.
@bors-servo
Copy link
Contributor

bors-servo commented Jan 13, 2016

The latest upstream changes (presumably #9271) made this pull request unmergeable. Please resolve the merge conflicts.

@paulrouget paulrouget force-pushed the paulrouget:securitychange branch from 4aaf250 to c90c4a4 Jan 22, 2016
@paulrouget
Copy link
Contributor Author

paulrouget commented Jan 22, 2016

Added a test. It fails, as expected (#6919). If I use my own http/https servers, it passes.

Now I can use HttpState to send a message. That looks a lot cleaner.

@paulrouget
Copy link
Contributor Author

paulrouget commented Jan 28, 2016

@frewsxcv / @jdm: review ping

@jdm jdm self-assigned this Jan 28, 2016
iframe.mozbrowser = "true";
iframe.src = urls[url_index++];

iframe.addEventListener("mozbrowsersecuritychange", t.step_func(e => {

This comment has been minimized.

Copy link
@jdm

jdm Feb 3, 2016

Member

Let's make a separate async_test for each iframe so we get better granularity for test failures.

This comment has been minimized.

Copy link
@paulrouget

paulrouget Feb 4, 2016

Author Contributor

I'm not sure to understand how that would help. There's only one iframe, and what matters is having the events to chain properly.

This comment has been minimized.

Copy link
@jdm

jdm Feb 4, 2016

Member

Whoops, I misread the test. You're right.

@jdm
Copy link
Member

jdm commented Feb 3, 2016

The code changes looks fine, but we can improve the test a bit more.

@@ -0,0 +1,49 @@
<head>

This comment has been minimized.

Copy link
@jdm

jdm Feb 4, 2016

Member

Let's give this a <title> and update the ini to use that instead of Untitled.

receivedEvents.push({ state: e.detail.state });

if (receivedEvents.length == expectedEvents.length) {
for (var i = 0; i < expectedEvents.length; i++) {

This comment has been minimized.

Copy link
@jdm

jdm Feb 4, 2016

Member

assert_array_equals

@jdm
Copy link
Member

jdm commented Feb 4, 2016

I will therefore reinstate two of my previous comments that I deleted after making the request to split the test.

@paulrouget paulrouget force-pushed the paulrouget:securitychange branch from c90c4a4 to b1170a1 Feb 5, 2016
@paulrouget
Copy link
Contributor Author

paulrouget commented Feb 5, 2016

I will therefore reinstate two of my previous comments

Addressed.

@@ -0,0 +1,46 @@
<head>
<title>mozbrowsersecuritychange</title>

This comment has been minimized.

Copy link
@jdm

jdm Feb 8, 2016

Member

How about "mozbrowsersecuritychange event is dispatched when content security state changes"

This comment has been minimized.

Copy link
@paulrouget

paulrouget Feb 9, 2016

Author Contributor

done.

var expectedEvents = [
"insecure",
"secure",
"insecure",

This comment has been minimized.

Copy link
@jdm

jdm Feb 8, 2016

Member

Let's load each page twice in a row to ensure that we don't get events when the state doesn't change. On the other hand, if that's not something we care about, the text at https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsersecuritychange should be updated to be more precise.

@paulrouget paulrouget force-pushed the paulrouget:securitychange branch from b1170a1 to 18b5d78 Feb 9, 2016
@paulrouget
Copy link
Contributor Author

paulrouget commented Feb 9, 2016

Let's load each page twice in a row to ensure that we don't get events when the state doesn't change. On the other hand, if that's not something we care about, the text at https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowsersecuritychange should be updated to be more precise.

Gecko fires this event even if the state doesn't actually change. I'll update MDN.

@paulrouget paulrouget force-pushed the paulrouget:securitychange branch from 18b5d78 to 63519c3 Feb 9, 2016
@jdm
Copy link
Member

jdm commented Feb 9, 2016

@bors-servo: r+
Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented Feb 9, 2016

📌 Commit 63519c3 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Feb 9, 2016

Testing commit 63519c3 with merge 3d63f09...

bors-servo added a commit that referenced this pull request Feb 9, 2016
mozbrowsersecuritychange event

Fixes #8544

No test yet. Is there a way to mock a https connection?

Also, I wish I could use the `HTTPSState` enum instead of a `String` when calling `trigger_mozbrowser_event` (https://github.com/servo/servo/compare/master...paulrouget:securitychange?expand=1#diff-30a18e04d7e0b66aafdf192e416cad44R306) but that would require `constellation_msg.rs` to know about `HTTPSState`, which is defined in `document.rs`, which would add a dependency to `components/msg`. I could define `HTTPSState` somewhere else maybe? Or maybe it's fine to use a `String`. But then, should I use the HTTPSState strings (`"modern/deprecated/none"`) or the mozbrowser strings (`"secure/insecure/broken"`) (as it is now)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9244)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 9, 2016

@bors-servo bors-servo merged commit 63519c3 into servo:master Feb 9, 2016
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.