Bug 1844582 - [remote] Stop using setTimeout for browser_NavigationManager_no_navigation.js r=webdriver-reviewers,Sasha

Differential Revision: https://phabricator.services.mozilla.com/D184175
This commit is contained in:
Julian Descottes 2023-07-21 09:43:02 +00:00
parent 0b166e6579
commit 1139066cb7

View File

@ -27,16 +27,19 @@ add_task(async function testDocumentOpenWriteClose() {
is(events.length, 0, "No event recorded");
info("Replace the document");
SpecialPowers.spawn(browser, [], () => {
await SpecialPowers.spawn(browser, [], async () => {
// Note: we need to use eval here to have reduced permissions and avoid
// security errors.
content.eval(`
document.open();
document.write("<h1>Replaced</h1>");
document.write("<h1 class='replaced'>Replaced</h1>");
document.close();
`);
await ContentTaskUtils.waitForCondition(() =>
content.document.querySelector(".replaced")
);
});
await wait(500);
// See Bug 1844517.
// document.open/write/close is identical to same-url + same-hash navigations.
@ -53,9 +56,3 @@ add_task(async function testDocumentOpenWriteClose() {
navigationManager.off("navigation-stopped", onEvent);
navigationManager.stopMonitoring();
});
function wait(ms) {
info(`Wait for ${ms} milliseconds`);
// eslint-disable-next-line mozilla/no-arbitrary-setTimeout
return new Promise(r => setTimeout(r, ms));
}