75 lines
2.2 KiB
HTML
75 lines
2.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<!--
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=1322273
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Test for Bug 1322273</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
</head>
|
|
<body>
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1322273">Mozilla Bug 1322273</a>
|
|
|
|
<iframe id="subframe"></iframe>
|
|
|
|
<script type="application/javascript">
|
|
"use strict";
|
|
|
|
function waitForWindowDestroyed(winID, callback) {
|
|
let observer = {
|
|
observe: function(subject, topic, data) {
|
|
let id = subject.QueryInterface(SpecialPowers.Ci.nsISupportsPRUint64).data;
|
|
if (id != winID) {
|
|
return;
|
|
}
|
|
SpecialPowers.removeObserver(observer, "outer-window-nuked");
|
|
SpecialPowers.executeSoon(callback);
|
|
}
|
|
};
|
|
SpecialPowers.addObserver(observer, "outer-window-nuked");
|
|
}
|
|
|
|
add_task(async function() {
|
|
let frame = $('subframe');
|
|
frame.srcdoc = "foo";
|
|
await new Promise(resolve => frame.addEventListener("load", resolve, {once: true}));
|
|
|
|
let win = frame.contentWindow;
|
|
let winID = SpecialPowers.wrap(win).docShell.outerWindowID;
|
|
|
|
win.eval("obj = {}");
|
|
win.obj.foo = {bar: "baz"};
|
|
|
|
let obj = win.obj;
|
|
|
|
let system = SpecialPowers.Services.scriptSecurityManager.getSystemPrincipal()
|
|
let sandbox = SpecialPowers.Cu.Sandbox(system);
|
|
|
|
sandbox.obj = obj;
|
|
|
|
let isWrapperDead = SpecialPowers.Cu.evalInSandbox(`(${
|
|
function isWrapperDead() {
|
|
return Cu.isDeadWrapper(obj);
|
|
}
|
|
})`,
|
|
sandbox);
|
|
|
|
is(isWrapperDead(), false, "Sandbox wrapper for content window should not be dead");
|
|
is(obj.foo.bar, "baz", "Content wrappers into and out of content window should be alive");
|
|
|
|
// Remove the frame, which should nuke the content window.
|
|
info("Remove the content frame");
|
|
frame.remove();
|
|
|
|
// Give the nuke wrappers task a chance to run.
|
|
await new Promise(resolve => waitForWindowDestroyed(winID, resolve));
|
|
|
|
is(isWrapperDead(), true, "Sandbox wrapper for content window should be dead");
|
|
is(obj.foo.bar, "baz", "Content wrappers into and out of content window should be alive");
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|