dom/browser-element/mochitest/browserElement_SecurityChange.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:20507e3c6cef
1 /* Any copyright is dedicated to the public domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 // Bug 763694 - Test that <iframe mozbrowser> delivers proper
5 // mozbrowsersecuritychange events.
6
7 "use strict";
8 SimpleTest.waitForExplicitFinish();
9 browserElementTestHelpers.setEnabledPref(true);
10 browserElementTestHelpers.addPermission();
11
12 function runTest() {
13 var iframe = document.createElement('iframe');
14 SpecialPowers.wrap(iframe).mozbrowser = true;
15
16 var lastSecurityState;
17 iframe.addEventListener('mozbrowsersecuritychange', function(e) {
18 lastSecurityState = e.detail;
19 });
20
21 var filepath = 'tests/dom/browser-element/mochitest/file_browserElement_SecurityChange.html';
22
23 var count = 0;
24 iframe.addEventListener('mozbrowserloadend', function(e) {
25 count++;
26 var nextURL;
27 switch (count) {
28 case 1:
29 is(lastSecurityState.state, 'secure');
30 is(lastSecurityState.extendedValidation, false);
31 iframe.src = "http://example.com/" + filepath;
32 break;
33 case 2:
34 is(lastSecurityState.state, 'insecure');
35 is(lastSecurityState.extendedValidation, false);
36 iframe.src = 'https://example.com:443/' + filepath + '?broken';
37 break;
38 case 3:
39 is(lastSecurityState.state, 'broken');
40 is(lastSecurityState.extendedValidation, false);
41 SimpleTest.finish();
42 }
43 });
44
45 iframe.src = "https://example.com/" + filepath;
46 document.body.appendChild(iframe);
47 }
48
49 addEventListener('testready', runTest);

mercurial