Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / chrome / test_secureContexts.html
blob956e609d5f2c2bc2ca01a5c44a2c9d927cb7e341
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1273687
5 -->
6 <head>
7 <meta charset="utf-8">
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 = () => {
19 /* globals t, i */
20 runTest(t, true);
21 runTest(i, false);
23 // Check we can inherit the system principal
24 var s = new Cu.Sandbox(window, { wantGlobalProperties: ["isSecureContext"] } );
25 s.ok = ok;
26 Cu.evalInSandbox('ok(isSecureContext)', s);
28 // Check options insecure works
29 let sb = new Cu.Sandbox('https://www.example.com',
30 { forceSecureContext: false,
31 wantGlobalProperties:
32 ["isSecureContext"]
33 });
34 ok(!Cu.evalInSandbox('isSecureContext', sb));
36 // Check options secure works
37 let sb2 = new Cu.Sandbox('https://www.example.com',
38 { forceSecureContext: true,
39 wantGlobalProperties:
40 ["isSecureContext"]
41 });
42 ok(Cu.evalInSandbox('isSecureContext', sb2));
43 SimpleTest.finish();
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));
56 </script>
57 </head>
58 </html>