Bug 1705532 wait for pagehide instead of polling on location.href r=annyG

waitForCondition() waits only 3 seconds, which can sometimes not be long
enough for slow builds such as TSan builds.
https://searchfox.org/mozilla-central/rev/468a65168dd0bc3c7d602211a566c16e66416cce/testing/mochitest/tests/SimpleTest/SimpleTest.js#1266,1269

Differential Revision: https://phabricator.services.mozilla.com/D134581
This commit is contained in:
Karl Tomlinson 2021-12-25 22:47:11 +00:00
Родитель 5ec86389c8
Коммит d4229451f9
1 изменённых файлов: 8 добавлений и 3 удалений

Просмотреть файл

@ -64,9 +64,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=386782
is(gTest.window.document.body.innerHTML, gTest.expectedBodyAfterEdit, "Editing failed.");
gTest.window.location = "about:blank";
let cond = () => gTest.window.location.href == "about:blank";
await SimpleTest.promiseWaitForCondition(cond,
"about:blank never loaded");
await new Promise(r => gTest.window.onpagehide = r);
// The active document is updated synchronously after "pagehide" (and
// its associated microtasks), so, after waiting for the next global
// task, gTest.window will be proxying the realm associated with the
// "about:blank" document.
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#update-the-session-history-with-the-new-page
await new Promise(r => setTimeout(r));
is(gTest.window.location.href, "about:blank", "location.href");
await SimpleTest.promiseFocus(gTest.window, true);
gTest.window.history.back();