Bug 1464908 - Wait for MozAfterPaint on new windows before requesting fullscreen. r=xidorn

New windows cannot execute fullscreen requests until after the first
MozAfterPaint event has been fired on the window, because some of the
machinery in browser-fullScreenAndPointerLock.js isn't initialized until
that point. This test exercises that behaviour, and therefore should also
wait until the first MozAfterPaint before requesting fullscreen.

MozReview-Commit-ID: Igy7WfjslWA

--HG--
extra : rebase_source : 4b16293a107468bd53b8d1f54560b8acf326631f
This commit is contained in:
Kartikaya Gupta 2018-05-28 17:53:44 -04:00
Родитель b355943072
Коммит 967750873c
1 изменённых файлов: 18 добавлений и 8 удалений

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

@ -45,10 +45,18 @@ addLoadEvent(function () {
const OPEN_WINDOW_FUNCS = [
function openNewTab() {
return window.open("about:blank");
return new Promise(resolve => {
var win = window.open("about:blank");
resolve(win);
});
},
function openNewWindow() {
return window.open("about:blank", "", "width=300,height=200");
return new Promise(resolve => {
var win = window.open("about:blank", "", "width=300,height=200");
win.addEventListener("MozAfterPaint", () => {
resolve(win);
}, { once: true });
});
}
];
@ -105,10 +113,12 @@ function* testGenerator() {
}
function runTest(test) {
var win = test.openWinFunc();
return new Promise(resolve => {
SimpleTest.waitForFocus(resolve, win, true);
}).then(() => {
var winPromise = test.openWinFunc();
return winPromise.then((win) => {
return new Promise(resolve => {
SimpleTest.waitForFocus(() => resolve(win), win, true);
});
}).then((win) => {
return new Promise((resolve, reject) => {
var retried = false;
function listener(evt) {
@ -125,7 +135,7 @@ function runTest(test) {
is(evt.type, "fullscreenchange", "Should get fullscreenchange");
ok(win.document.fullscreenElement, "Should have entered fullscreen");
ok(win.fullScreen, "The window should be in fullscreen");
test.actionFunc(win).then(resolve);
test.actionFunc(win).then(() => resolve(win));
}
if (win.fullScreen) {
todo(false, "Should not open in fullscreen mode");
@ -138,7 +148,7 @@ function runTest(test) {
win.addEventListener("fullscreenerror", listener);
win.document.documentElement.requestFullscreen();
});
}).then(() => {
}).then((win) => {
ok(win.closed, "The window should have been closed");
});
}