4 https://bugzilla.mozilla.org/show_bug.cgi?id=1517694
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">
15 /** Test for Bug
1517694 **/
16 const { XPCOMUtils } = ChromeUtils.importESModule(
17 "resource://gre/modules/XPCOMUtils.sys.mjs"
20 SimpleTest.waitForExplicitFinish();
23 var frame = $('subframe');
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
41 var sb = Cu.evalInSandbox(`
43 Cc[
"@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal);
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");
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>