Auto merge of #9244 - paulrouget:securitychange, r=jdm

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 -->
This commit is contained in:
bors-servo 2016-02-09 13:00:29 +05:30
commit 3d63f09361
13 changed files with 135 additions and 4 deletions

View file

@ -5916,6 +5916,12 @@
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsericonchange_event.html"
}
],
"mozilla/mozbrowser/mozbrowsersecuritychange_event.html": [
{
"path": "mozilla/mozbrowser/mozbrowsersecuritychange_event.html",
"url": "/_mozilla/mozilla/mozbrowser/mozbrowsersecuritychange_event.html"
}
],
"mozilla/mozbrowser/mozbrowsershowmodalprompt_event.html": [
{
"path": "mozilla/mozbrowser/mozbrowsershowmodalprompt_event.html",

View file

@ -0,0 +1,5 @@
[mozbrowsersecuritychange_event.html]
type: testharness
[mozbrowsersecuritychange event is dispatched when content security state changes]
expected: FAIL

View file

@ -0,0 +1,46 @@
<head>
<title>mozbrowsersecuritychange event is dispatched when content security state changes</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function(t) {
const HTTP_URL = "http://web-platform.test:8000";
const HTTPS_URL = "https://web-platform.test:8443";
var urls = [ HTTP_URL, HTTPS_URL, HTTP_URL ];
var url_index = 0;
var expectedEvents = [
"insecure",
"secure",
"insecure",
];
var receivedEvents = [];
var iframe = document.createElement("iframe");
iframe.mozbrowser = "true";
iframe.src = urls[url_index++];
iframe.addEventListener("mozbrowsersecuritychange", t.step_func(e => {
receivedEvents.push(e.detail.state);
if (receivedEvents.length == expectedEvents.length) {
assert_array_equals(receivedEvents, expectedEvents);
t.done();
} else {
iframe.src = urls[url_index++];
}
}));
document.body.appendChild(iframe);
});
</script>
</body>