зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1173801 - Correctly wait for both focus and the delayed startup to finish when opening a new window in private browsing tests; r=mconley
This commit is contained in:
Родитель
f22b71f788
Коммит
03b7410c5a
|
@ -7,34 +7,11 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
|
|||
|
||||
function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
let win = OpenBrowserWindow(aOptions);
|
||||
let gotLoad = false;
|
||||
let gotActivate = Services.focus.activeWindow == win;
|
||||
|
||||
function maybeRunCallback() {
|
||||
if (gotLoad && gotActivate) {
|
||||
executeSoon(function() { aCallback(win); });
|
||||
}
|
||||
}
|
||||
|
||||
if (!gotActivate) {
|
||||
win.addEventListener("activate", function onActivate() {
|
||||
info("Got activate.");
|
||||
win.removeEventListener("activate", onActivate, false);
|
||||
gotActivate = true;
|
||||
maybeRunCallback();
|
||||
}, false);
|
||||
} else {
|
||||
info("Was activated.");
|
||||
}
|
||||
|
||||
Services.obs.addObserver(function observer(aSubject, aTopic) {
|
||||
if (win == aSubject) {
|
||||
info("Delayed startup finished");
|
||||
Services.obs.removeObserver(observer, aTopic);
|
||||
gotLoad = true;
|
||||
maybeRunCallback();
|
||||
}
|
||||
}, "browser-delayed-startup-finished", false);
|
||||
let focused = SimpleTest.promiseFocus(win);
|
||||
let startupFinished = TestUtils.topicObserved("browser-delayed-startup-finished",
|
||||
subject => subject == win).then(() => win);
|
||||
Promise.all([focused, startupFinished])
|
||||
.then(results => executeSoon(() => aCallback(results[1])));
|
||||
|
||||
return win;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче