4 https://bugzilla.mozilla.org/show_bug.cgi?id=1322273
8 <title>Test for Bug
1322273</title>
9 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css"/>
13 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=1322273">Mozilla Bug
1322273</a>
15 <iframe id=
"subframe"></iframe>
17 <script type=
"application/javascript">
20 function waitForWindowDestroyed(winID, callback) {
22 observe: function(subject, topic, data) {
23 let id = subject.QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
27 SpecialPowers.removeObserver(observer,
"outer-window-nuked");
28 SpecialPowers.executeSoon(callback);
31 SpecialPowers.addObserver(observer,
"outer-window-nuked");
34 add_task(async function() {
35 let frame = $('subframe');
37 await new Promise(resolve =
> frame.addEventListener(
"load", resolve, {once: true}));
39 let win = frame.contentWindow;
40 let winID = SpecialPowers.wrap(win).docShell.outerWindowID;
43 win.obj.foo = {bar:
"baz"};
47 let system = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal()
48 let sandbox = SpecialPowers.Cu.Sandbox(system);
52 let isWrapperDead = SpecialPowers.Cu.evalInSandbox(`(${
53 function isWrapperDead() {
54 return Cu.isDeadWrapper(obj);
59 is(isWrapperDead(), false,
"Sandbox wrapper for content window should not be dead");
60 is(obj.foo.bar,
"baz",
"Content wrappers into and out of content window should be alive");
62 // Remove the frame, which should nuke the content window.
63 info(
"Remove the content frame");
66 // Give the nuke wrappers task a chance to run.
67 await new Promise(resolve =
> waitForWindowDestroyed(winID, resolve));
69 is(isWrapperDead(), true,
"Sandbox wrapper for content window should be dead");
70 is(obj.foo.bar,
"baz",
"Content wrappers into and out of content window should be alive");