From 21507a80a10bce2260d6414b5161d141d0623abe Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 15 Nov 2021 21:09:30 +0000 Subject: [PATCH] Bug 1740043 - Add fullscreen test; r=smaug Differential Revision: https://phabricator.services.mozilla.com/D131007 --- dom/html/test/browser.ini | 2 + .../test/browser_fullscreen-navigation.js | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 dom/html/test/browser_fullscreen-navigation.js diff --git a/dom/html/test/browser.ini b/dom/html/test/browser.ini index 6ea7be9b653d..6fee8b1066e8 100644 --- a/dom/html/test/browser.ini +++ b/dom/html/test/browser.ini @@ -34,6 +34,8 @@ tags = fullscreen support-files = file_fullscreen-newtab.html skip-if = os == 'mac' (os == 'linux' && bits == 64 && os_version == '18.04') # Bug 1601460, Bug 1494843 +[browser_fullscreen-navigation.js] +tags = fullscreen [browser_submission_flush.js] [browser_refresh_after_document_write.js] support-files = diff --git a/dom/html/test/browser_fullscreen-navigation.js b/dom/html/test/browser_fullscreen-navigation.js new file mode 100644 index 000000000000..1e361c13d3cb --- /dev/null +++ b/dom/html/test/browser_fullscreen-navigation.js @@ -0,0 +1,64 @@ +"use strict"; + +// This test tends to trigger a race in the fullscreen time telemetry, +// where the fullscreen enter and fullscreen exit events (which use the +// same histogram ID) overlap. That causes TelemetryStopwatch to log an +// error. +SimpleTest.ignoreAllUncaughtExceptions(true); + +function waitFullscreenEvents(aDocument) { + return new Promise(resolve => { + function errorHandler() { + ok(false, "should not get fullscreenerror event"); + } + + let countFsChange = 0; + function changeHandler() { + ++countFsChange; + if (countFsChange == 2) { + aDocument.removeEventListener("fullscreenchange", changeHandler); + aDocument.removeEventListener("fullscreenerror", errorHandler); + resolve(); + } + } + + aDocument.addEventListener("fullscreenchange", changeHandler); + aDocument.addEventListener("fullscreenerror", errorHandler); + }); +} + +add_task(async function init() { + await pushPrefs( + ["full-screen-api.transition-duration.enter", "0 0"], + ["full-screen-api.transition-duration.leave", "0 0"] + ); +}); + +add_task(async function navigation() { + await BrowserTestUtils.withNewTab( + { + gBrowser, + url: `data:text/html, + + `, + }, + async function(browser) { + let promiseFsEvents = waitFullscreenEvents(document); + + await BrowserTestUtils.synthesizeMouseAtCenter("#button", {}, browser); + await promiseFsEvents; + + ok(!window.fullScreen, "The chrome window should not be in fullscreen"); + ok( + !document.documentElement.hasAttribute("inDOMFullscreen"), + "The chrome document should not be in fullscreen" + ); + } + ); +});