Bug 1827202: Make a fullscreen test await focus before requesting fullscreen. r=edgar

This ensures that the browsing context is active before the fullscreen
request, which prevents a common reason for promise rejection.

It also changes the parameter order for the click count check function.
This makes the failure message make sense, since the "expected" value is
the second parameter.

Differential Revision: https://phabricator.services.mozilla.com/D182379
This commit is contained in:
Brad Werth 2023-06-29 16:17:11 +00:00
parent b0541db065
commit 9e6f0307fb

View file

@ -25,15 +25,17 @@ button.addEventListener("click", function(e) {
clickCount++;
if (shouldEnterFullscreen) {
const fullscreenElement = document.getElementById("fullscreen");
fullscreenElement.focus();
lastFullscreenPromise = fullscreenElement.requestFullscreen();
lastFullscreenPromise = SimpleTest.promiseFocus().then(() => {
fullscreenElement.focus();
return fullscreenElement.requestFullscreen();
});
}
});
function clickButton(expectEvent) {
let lastClickCount = clickCount;
synthesizeMouseAtCenter(button, {});
(expectEvent ? isnot : is)(lastClickCount, clickCount, `Should've ${expectEvent ? "" : "not "}been able to click`);
(expectEvent ? isnot : is)(clickCount, lastClickCount, `Should've ${expectEvent ? "" : "not "}been able to click`);
}
function enterFullscreen() {