Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / js / xpconnect / tests / chrome / test_sharedChromeCompartment.html
blobb653f197513dcc93aa0d2b43d1faeae9edf1a5f5
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=1517694
5 -->
6 <head>
7 <meta charset="utf-8">
8 <title>Test for Bug 1517694</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 <script type="application/javascript">
13 "use strict";
15 /** Test for Bug 1517694 **/
16 const { XPCOMUtils } = ChromeUtils.importESModule(
17 "resource://gre/modules/XPCOMUtils.sys.mjs"
20 SimpleTest.waitForExplicitFinish();
22 function go() {
23 var frame = $('subframe');
24 frame.onload = null;
26 var isSameCompartment = Cu.getJSTestingFunctions().isSameCompartment;
28 ok(isSameCompartment(window, frame.contentWindow),
29 "System window is in same compartment");
31 var sameCompSb = Cu.Sandbox(window);
32 ok(isSameCompartment(window, sameCompSb),
33 "System sandbox is in same compartment");
35 var ownCompSb = Cu.Sandbox(window, {freshCompartment: true});
36 ok(!isSameCompartment(window, ownCompSb),
37 "Sandbox created with freshCompartment is in separate compartment");
39 // Sandbox created in fresh-compartment sandbox must be in shared
40 // compartment.
41 var sb = Cu.evalInSandbox(`
42 let principal =
43 Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
44 Cu.Sandbox(principal)
45 `, ownCompSb);
46 ok(isSameCompartment(window, sb),
47 "System sandbox created in different compartment is in system compartment");
49 ok(isSameCompartment(window, XPCOMUtils),
50 "Object defined in JSM is in same compartment");
52 SimpleTest.finish();
55 </script>
56 </head>
57 <body>
58 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1517694">Mozilla Bug 1517694</a>
60 <iframe id="subframe" src="file_empty.html" onload="go()"></iframe>
62 </body>
63 </html>