Bug 1589102 - Part 5: Fix tests that relied on about:blank loads happening instantenously, r=mattwoodrow

Differential Revision: https://phabricator.services.mozilla.com/D85083
This commit is contained in:
Anny Gakhokidze 2020-08-28 17:20:45 +00:00
parent 46b53bc947
commit aa5ab9056f
3 changed files with 9 additions and 6 deletions

View File

@ -23,10 +23,9 @@ add_task(async function() {
info("Test tabs added in first window");
info("Open a second window");
const windowOpenedPromise = BrowserTestUtils.waitForNewWindow();
const win2 = OpenBrowserWindow();
await new Promise(r => {
win2.addEventListener("load", r, { capture: true, once: true });
});
await windowOpenedPromise;
info("Add test tabs in second window");
const tab3 = await addTab(TEST_URI, { window: win2 });

View File

@ -55,8 +55,9 @@
case 5: {
opener.isnot(Math.round(window.scrollY), 0, "Should have scrolled to #hash.");
opener.is(history.scrollRestoration, "manual", "Should have the same scrollRestoration mode as before fragment navigation.");
window.onunload = function() {}; // Disable bfcache.
opener.setTimeout("is(SpecialPowers.wrap(testWindow).history.scrollRestoration, 'auto'); SpecialPowers.wrap(testWindow).history.back();", 250);
window.onunload = function() {
opener.setTimeout("is(SpecialPowers.wrap(testWindow).history.scrollRestoration, 'auto'); SpecialPowers.wrap(testWindow).history.back();", 250);
}; // Disable bfcache.
window.location.href = "about:blank";
break;
}

View File

@ -70,7 +70,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Editing failed.");
gTest.window.location = "about:blank";
SimpleTest.waitForFocus(goBack, gTest.window);
let cond = () => gTest.window.location.href == "about:blank";
SimpleTest.waitForCondition(cond, () => {
SimpleTest.waitForFocus(goBack, gTest.window, true);
}, "about:blank never loaded");
}
function goBack() {