Bug 1788204 - Fix frequent intermittent browser_ext_windows_create.js failures on macos. r=willdurand

I've been tried to bisect if this intermittent has been raising in intermittency due to some change on the
Firefox side, but I kept hitting this failure locally on macos artifiacts debug buils consistently when
using --verify even when I went month back in mozilla-central revisions, which seems to suggest that
this particular intermittent failure have been around for a while and increased in frequency either
for some small timing changes that increased the change of hitting it in a debug build (either on the
Firefox or macOS windows management side), which is not going to be easy to confirm or bisect precisely.

Interestingly when the same test file runs locally on macos using --headless along with --verify, the test
is passing consistently (which makes me thing that the issue may be hit because a browser window created
as fullscreen may be transitioning to fullscreen state asynchronously enough to not be always be in fullscreen
mode by the time browser.window.create resolves the new window details and we hit the intermittent assertion
failure).

As an alternative to skip the entire test file on macos debug builds, this patch includes
a small change to the test case that makes sure that if the test is running on macos and the
new window state is not fullscreen as requested, it wait until it gets to the fullscreen state.

This change was enough to pass --verify locally on macos, and so it also confirms that the newly created
window is getting to the fullscreen state at some point even when it wasn't yet in the fullscreen state
by the time browser.windows.create resolves.

Differential Revision: https://phabricator.services.mozilla.com/D169108
This commit is contained in:
Luca Greco 2023-02-08 12:09:31 +00:00
parent 36677e335e
commit 6811654c9d

View File

@ -27,6 +27,25 @@ add_task(async function testWindowCreate() {
// params is null when testing create without createData
params = params[0] || {};
// Prevent frequent intermittent failures on macos where the newly created window
// may have not always got into the fullscreen state before browser.window.create
// resolves the windows details.
if (
os === "mac" &&
params.state === "fullscreen" &&
window.state !== params.state
) {
browser.test.log(
"Wait for window.state for the newly create window to be set to fullscreen"
);
while (window.state !== params.state) {
window = await browser.windows.get(window.id, { populate: true });
}
browser.test.log(
"Newly created browser window got into fullscreen state"
);
}
for (let key of Object.keys(params)) {
if (key == "state" && os == "mac" && params.state == "normal") {
// OS-X doesn't have a hard distinction between "normal" and