зеркало из https://github.com/mozilla/gecko-dev.git
Bug 996988 - use different method to wait for window closure, r=jaws
--HG-- extra : rebase_source : cfb78153229e5722609e10e9e4a417659590c28a
This commit is contained in:
Родитель
0078888ef0
Коммит
3c7a2873df
|
@ -85,7 +85,13 @@ add_task(function*() {
|
||||||
ok(otherTB.querySelector("#sync-button"), "Sync button is on other toolbar, too.");
|
ok(otherTB.querySelector("#sync-button"), "Sync button is on other toolbar, too.");
|
||||||
|
|
||||||
let wasInformedCorrectlyOfAreaDisappearing = false;
|
let wasInformedCorrectlyOfAreaDisappearing = false;
|
||||||
let windowClosed = null;
|
//XXXgijs So we could be using promiseWindowClosed here. However, after
|
||||||
|
// repeated random oranges, I'm instead relying on onWindowClosed below to
|
||||||
|
// fire appropriately - it is linked to an unload event as well, and so
|
||||||
|
// reusing it prevents a potential race between unload handlers where the
|
||||||
|
// one from promiseWindowClosed could fire before the onWindowClosed
|
||||||
|
// (and therefore onAreaNodeRegistered) one, causing the test to fail.
|
||||||
|
let windowCloseDeferred = Promise.defer();
|
||||||
listener = {
|
listener = {
|
||||||
onAreaNodeUnregistered: function(aArea, aNode, aReason) {
|
onAreaNodeUnregistered: function(aArea, aNode, aReason) {
|
||||||
if (aArea == TOOLBARID) {
|
if (aArea == TOOLBARID) {
|
||||||
|
@ -96,8 +102,7 @@ add_task(function*() {
|
||||||
},
|
},
|
||||||
onWindowClosed: function(aWindow) {
|
onWindowClosed: function(aWindow) {
|
||||||
if (aWindow == otherWin) {
|
if (aWindow == otherWin) {
|
||||||
info("Got window closed notification for correct window.");
|
windowCloseDeferred.resolve(aWindow);
|
||||||
windowClosed = aWindow;
|
|
||||||
} else {
|
} else {
|
||||||
info("Other window was closed!");
|
info("Other window was closed!");
|
||||||
info("Other window title: " + (aWindow.document && aWindow.document.title));
|
info("Other window title: " + (aWindow.document && aWindow.document.title));
|
||||||
|
@ -106,7 +111,8 @@ add_task(function*() {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
CustomizableUI.addListener(listener);
|
CustomizableUI.addListener(listener);
|
||||||
yield promiseWindowClosed(otherWin);
|
otherWin.close();
|
||||||
|
let windowClosed = yield windowCloseDeferred.promise;
|
||||||
|
|
||||||
is(windowClosed, otherWin, "Window should have sent onWindowClosed notification.");
|
is(windowClosed, otherWin, "Window should have sent onWindowClosed notification.");
|
||||||
ok(wasInformedCorrectlyOfAreaDisappearing, "Should be told about window closing.");
|
ok(wasInformedCorrectlyOfAreaDisappearing, "Should be told about window closing.");
|
||||||
|
|
|
@ -249,8 +249,13 @@ function openAndLoadWindow(aOptions, aWaitForDelayedStartup=false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function promiseWindowClosed(win) {
|
function promiseWindowClosed(win) {
|
||||||
|
let deferred = Promise.defer();
|
||||||
|
win.addEventListener("unload", function onunload() {
|
||||||
|
win.removeEventListener("unload", onunload);
|
||||||
|
deferred.resolve();
|
||||||
|
});
|
||||||
win.close();
|
win.close();
|
||||||
return waitForCondition(() => win.closed);
|
return deferred.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function promisePanelShown(win) {
|
function promisePanelShown(win) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче