Bug 1306696 part 4 - Add test for this bug. r=smaug

MozReview-Commit-ID: 1Pzt6DPif00

--HG--
extra : source : 8e4d810704a278ea8130d8dc3c38c3173ca92a55
This commit is contained in:
Xidorn Quan 2018-09-28 14:28:54 +10:00
Родитель 4407187413
Коммит 48a77c4938
3 изменённых файлов: 89 добавлений и 1 удалений

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

@ -29,7 +29,11 @@ support-files =
tags = fullscreen
[browser_fullscreen-contextmenu-esc.js]
tags = fullscreen
[browser_fullscreen-newtab.js]
tags = fullscreen
support-files = file_fullscreen-newtab.html
skip-if = os == 'mac' # bug 1494843
[browser_submission_flush.js]
[browser_refresh_wyciwyg_url.js]
support-files =
file_refresh_wyciwyg_url.html
file_refresh_wyciwyg_url.html

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

@ -0,0 +1,80 @@
"use strict";
const kPage = "http://example.org/browser/" +
"dom/html/test/file_fullscreen-newtab.html";
function getSizeMode() {
return document.documentElement.getAttribute("sizemode");
}
async function runTest() {
await BrowserTestUtils.withNewTab({
gBrowser,
url: kPage
}, async function (browser) {
await ContentTask.spawn(browser, null, function() {
content.document.addEventListener("fullscreenchange", () => {
sendAsyncMessage("Test:FullscreenChange");
});
content.document.addEventListener("fullscreenerror", () => {
sendAsyncMessage("Test:FullscreenError");
});
});
let promiseFsEvents = new Promise(resolve => {
let countFsChange = 0;
let countFsError = 0;
function checkAndResolve() {
if (countFsChange > 0 && countFsError > 0) {
ok(false, "Got both fullscreenchange and fullscreenerror events");
} else if (countFsChange > 2) {
ok(false, "Got too many fullscreenchange events");
} else if (countFsError > 1) {
ok(false, "Got too many fullscreenerror events");
} else if (countFsChange == 2 || countFsError == 1) {
resolve();
}
}
let mm = browser.messageManager;
mm.addMessageListener("Test:FullscreenChange", () => {
info("Got fullscreenchange event");
++countFsChange;
checkAndResolve();
});
mm.addMessageListener("Test:FullscreenError", () => {
info("Got fullscreenerror event");
++countFsError;
checkAndResolve();
});
});
let promiseNewTab =
BrowserTestUtils.waitForNewTab(gBrowser, "about:blank");
await BrowserTestUtils.synthesizeMouseAtCenter("#link", {}, browser);
let [newtab] = await Promise.all([promiseNewTab, promiseFsEvents]);
await BrowserTestUtils.removeTab(newtab);
// Ensure the browser exits fullscreen state in reasonable time.
await Promise.race([
BrowserTestUtils.waitForCondition(() => getSizeMode() == "normal"),
new Promise(resolve => setTimeout(resolve, 2000))
]);
ok(!window.fullScreen, "The chrome window should not be in fullscreen");
ok(!document.fullscreen, "The chrome document should not be in fullscreen");
});
}
add_task(async function () {
await pushPrefs(
["full-screen-api.unprefix.enabled", true],
["full-screen-api.transition-duration.enter", "0 0"],
["full-screen-api.transition-duration.leave", "0 0"]);
await runTest();
});
add_task(async function () {
await pushPrefs(
["full-screen-api.unprefix.enabled", true],
["full-screen-api.transition-duration.enter", "200 200"],
["full-screen-api.transition-duration.leave", "200 200"]);
await runTest();
});

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

@ -0,0 +1,4 @@
<!DOCTYPE html>
<meta charset="UTF-8">
<a id="link" href="about:blank" target="_blank"
onclick="document.body.requestFullscreen()">Click here</a>