mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 06:11:37 +00:00
Bug 1167508 - Fix BrowserTestUtils.browserLoaded() and use it in sessionstore/head.js r=billm
This commit is contained in:
parent
f7fafca965
commit
7389b135f9
@ -282,14 +282,7 @@ let promiseForEachSessionRestoreFile = Task.async(function*(cb) {
|
||||
});
|
||||
|
||||
function promiseBrowserLoaded(aBrowser, ignoreSubFrames = true) {
|
||||
return new Promise(resolve => {
|
||||
aBrowser.messageManager.addMessageListener("ss-test:loadEvent", function onLoad(msg) {
|
||||
if (!ignoreSubFrames || !msg.data.subframe) {
|
||||
aBrowser.messageManager.removeMessageListener("ss-test:loadEvent", onLoad);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
return BrowserTestUtils.browserLoaded(aBrowser, !ignoreSubFrames);
|
||||
}
|
||||
|
||||
function whenWindowLoaded(aWindow, aCallback = next) {
|
||||
|
@ -140,11 +140,10 @@ this.BrowserTestUtils = {
|
||||
*/
|
||||
browserLoaded(browser, includeSubFrames=false) {
|
||||
return new Promise(resolve => {
|
||||
browser.messageManager.addMessageListener("browser-test-utils:loadEvent",
|
||||
function onLoad(msg) {
|
||||
if (!msg.data.subframe || includeSubFrames) {
|
||||
browser.messageManager.removeMessageListener(
|
||||
"browser-test-utils:loadEvent", onLoad);
|
||||
let mm = browser.ownerDocument.defaultView.messageManager;
|
||||
mm.addMessageListener("browser-test-utils:loadEvent", function onLoad(msg) {
|
||||
if (msg.target == browser && (!msg.data.subframe || includeSubFrames)) {
|
||||
mm.removeMessageListener("browser-test-utils:loadEvent", onLoad);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user