Bug 1368275 - Make test_nukeContentWindow.html correctly wait for the window to be destroyed instead of relying on the scheduling of the corresponding event; r=kmag

This commit is contained in:
Ehsan Akhgari 2017-05-27 15:46:27 -04:00
Родитель 1f4d6b3ef6
Коммит a621e63109
1 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -18,12 +18,27 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1322273
<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-destroyed");
SpecialPowers.executeSoon(callback);
}
};
SpecialPowers.addObserver(observer, "outer-window-destroyed");
}
add_task(function* () {
let frame = $('subframe');
frame.src = "data:text/html,";
yield new Promise(resolve => frame.addEventListener("load", resolve, {once: true}));
let win = frame.contentWindow;
let winID = SpecialPowers.getDOMWindowUtils(win).outerWindowID;
win.eval("obj = {}");
win.obj.foo = {bar: "baz"};
@ -50,7 +65,7 @@ add_task(function* () {
frame.remove();
// Give the nuke wrappers task a chance to run.
yield new Promise(SimpleTest.executeSoon);
yield 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");