Bug 1443964: Follow-up: Another attempt at fixing intermittent timing issue after removal of sync messaging from shims. r=bustage

MozReview-Commit-ID: 2WUsb7DIqk7

--HG--
extra : rebase_source : 77fece9b202594887d6bfde8ae1c43c6caf15301
This commit is contained in:
Kris Maglione 2018-03-08 19:01:48 -08:00
parent 0e2f1f5ab8
commit 7a34beaa0f

View File

@ -31,13 +31,21 @@ function promiseNewTabSwitched() {
});
}
function promiseLoaded(browser) {
return ContentTask.spawn(browser, undefined, async () => {
if (!["interactive", "complete"].includes(content.document.readyState)) {
await new Promise(resolve => addEventListener(
"DOMContentLoaded", resolve, {once: true, capture: true}));
}
});
}
async function testURL(url, loadFunc, endFunc) {
let tabSwitchedPromise = promiseNewTabSwitched();
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, undefined,
{preferredRemoteType: "web"});
let tab = gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser);
let browser = gBrowser.selectedBrowser;
let pageshowPromise = BrowserTestUtils.waitForContentEvent(browser, "pageshow");
let pageshowPromise = promiseLoaded(browser);
await tabSwitchedPromise;
await pageshowPromise;