4 https://bugzilla.mozilla.org/show_bug.cgi?id=1273687
8 <title>Test for Bug
1430164</title>
9 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://global/skin"/>
11 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"/>
12 <iframe id=
"t" src=
"https://example.com"></iframe>
13 <iframe id=
"i" src=
"http://example.com"></iframe>
14 <script type=
"application/javascript">
15 /** Test for Bug
1273687 **/
16 SimpleTest.waitForExplicitFinish();
18 window.onload = () =
> {
23 // Check we can inherit the system principal
24 var s = new Cu.Sandbox(window, { wantGlobalProperties: [
"isSecureContext"] } );
26 Cu.evalInSandbox('ok(isSecureContext)', s);
28 // Check options insecure works
29 let sb = new Cu.Sandbox('https://www.example.com',
30 { forceSecureContext: false,
34 ok(!Cu.evalInSandbox('isSecureContext', sb));
36 // Check options secure works
37 let sb2 = new Cu.Sandbox('https://www.example.com',
38 { forceSecureContext: true,
42 ok(Cu.evalInSandbox('isSecureContext', sb2));
46 // Check dom window inheritance works
47 function runTest(ifr, expectIsSecureContext) {
48 let frameWin = ifr.contentWindow;
49 let s = new Cu.Sandbox(frameWin, { wantGlobalProperties: [
"isSecureContext"] });
50 is(expectIsSecureContext, Cu.evalInSandbox('isSecureContext', s));
52 // Ensure the implementation of 'wantGlobalProperties' matches the DOM window prototype
53 let s2 = new Cu.Sandbox(frameWin, { sandboxPrototype: frameWin });
54 is(expectIsSecureContext, Cu.evalInSandbox('isSecureContext', s2));