Bug 1167508 - Fix BrowserTestUtils.browserLoaded() and use it in sessionstore/head.js r=billm

This commit is contained in:
Tim Taubert 2015-06-09 22:11:43 +02:00
parent f7fafca965
commit 7389b135f9
2 changed files with 5 additions and 13 deletions

View File

@ -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) {

View File

@ -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();
}
});