Bug 1678813 - part2 : await all promises to ensure window is focus and loaded. r=mconley

On try server, sometime I noticed that we would get intermittent failure on waiting the window focus. From its description [1], that method won't resolve the promise for already focus window. So we should call that method earlier in order to prevent the intermittent failure where the method is called on a focused window.

[1] https://searchfox.org/mozilla-central/rev/168c45a7acc44e9904cfd4eebcb9eb080e05699c/testing/mochitest/tests/SimpleTest/SimpleTest.js#933-938

Differential Revision: https://phabricator.services.mozilla.com/D98283
This commit is contained in:
alwu 2020-12-03 22:43:13 +00:00
parent 7abb275b8f
commit cc933e516a

View File

@ -103,9 +103,11 @@ async function triggerPictureInPicture(browser, videoID) {
}, "Video is being cloned visually.");
});
let win = await domWindowOpened;
await win.promiseDocumentFlushed(() => {});
await videoReady;
await SimpleTest.promiseFocus(win);
await Promise.all([
SimpleTest.promiseFocus(win),
win.promiseDocumentFlushed(() => {}),
videoReady,
]);
return win;
}