From 17087ede431e5ec7e4f5b706276a9cc7ba21cf1a Mon Sep 17 00:00:00 2001 From: Brad Werth Date: Thu, 2 Mar 2023 22:26:56 +0000 Subject: [PATCH] Bug 1631735 Part 2: Add a fullscreen test that checks event order, and a test of fs->minimize->fs. r=mstange,emilio The transition from fullscreen to minimize and back is not directly allowed in macOS, though our test harness can be forced to request it. The modified test forces this transition explicitly, so we can eliminate it as an accidental occurrence with other tests. The transition from minimize to fullscreen fails on Linux and Windows, so this change marks the entire test as failing on those platforms. New Bugs have been opened on this issue and those are noted in the fail-if. Depends on D166450 Differential Revision: https://phabricator.services.mozilla.com/D164248 --- .../base/content/test/fullscreen/browser.ini | 5 ++ .../browser_fullscreen_from_minimize.js | 72 +++++++++++++++++ browser/base/content/test/general/browser.ini | 2 +- .../fullscreen/file_fullscreen-single.html | 78 +++++++++++++++++++ dom/base/test/fullscreen/mochitest.ini | 10 +-- .../test/fullscreen/test_fullscreen-api.html | 2 + 6 files changed, 163 insertions(+), 6 deletions(-) create mode 100644 browser/base/content/test/fullscreen/browser_fullscreen_from_minimize.js create mode 100644 dom/base/test/fullscreen/file_fullscreen-single.html diff --git a/browser/base/content/test/fullscreen/browser.ini b/browser/base/content/test/fullscreen/browser.ini index eb73eaae6ed9..f23c453a6f74 100644 --- a/browser/base/content/test/fullscreen/browser.ini +++ b/browser/base/content/test/fullscreen/browser.ini @@ -14,6 +14,11 @@ support-files = fullscreen.html FullscreenFrame.sys.mjs support-files = fullscreen.html fullscreen_frame.html [browser_fullscreen_enterInUrlbar.js] skip-if = (os == 'mac') || (os == 'linux') # Bug 1648649 +[browser_fullscreen_from_minimize.js] +skip-if = + os == 'linux' # Bug 1818795 +fail-if = + os == 'win' # Bug 1818796 [browser_fullscreen_newtab.js] [browser_fullscreen_permissions_prompt.js] [browser_fullscreen_warning.js] diff --git a/browser/base/content/test/fullscreen/browser_fullscreen_from_minimize.js b/browser/base/content/test/fullscreen/browser_fullscreen_from_minimize.js new file mode 100644 index 000000000000..2282137c30d3 --- /dev/null +++ b/browser/base/content/test/fullscreen/browser_fullscreen_from_minimize.js @@ -0,0 +1,72 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// This test checks whether fullscreen windows can transition to minimized windows, +// and back again. This is sometimes not directly supported by the OS widgets. For +// example, in macOS, the minimize button is greyed-out in the title bar of +// fullscreen windows, making this transition impossible for users to initiate. +// Still, web APIs do allow arbitrary combinations of window calls, and this test +// exercises some of those combinations. + +add_task(async function() { + registerCleanupFunction(function() { + window.restore(); + }); + + // We reuse these variables to create new promises for each transition. + let promiseSizeModeChange; + let promiseFullscreen; + + ok(!window.fullScreen, "Window should be normal at start of test."); + + // Get to fullscreen. + info("Requesting fullscreen."); + promiseFullscreen = document.documentElement.requestFullscreen(); + await promiseFullscreen; + ok(window.fullScreen, "Window should be fullscreen before being minimized."); + + // Transition between fullscreen and minimize states. + info("Requesting minimize on a fullscreen window."); + promiseSizeModeChange = BrowserTestUtils.waitForEvent( + window, + "sizemodechange" + ); + window.minimize(); + await promiseSizeModeChange; + is( + window.windowState, + window.STATE_MINIMIZED, + "Window should be minimized after fullscreen." + ); + + // Whether or not the previous transition worked, restore the window + // and then minimize it. + if (window.windowState != window.STATE_NORMAL) { + info("Restoring window."); + promiseSizeModeChange = BrowserTestUtils.waitForEvent( + window, + "sizemodechange" + ); + window.restore(); + await promiseSizeModeChange; + is(window.windowState, window.STATE_NORMAL, "Window should be normal."); + } + + info("Requesting minimize on a normal window."); + promiseSizeModeChange = BrowserTestUtils.waitForEvent( + window, + "sizemodechange" + ); + window.minimize(); + await promiseSizeModeChange; + is( + window.windowState, + window.STATE_MINIMIZED, + "Window should be minimized before fullscreen." + ); + + info("Requesting fullscreen on a minimized window."); + promiseFullscreen = document.documentElement.requestFullscreen(); + await promiseFullscreen; + ok(window.fullScreen, "Window should be fullscreen after being minimized."); +}); diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index d5ecfce32edf..2e9438135aeb 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -404,7 +404,7 @@ skip-if = os == "win" && !debug # DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD. [browser_windowactivation.js] -skip-if = +skip-if = verify os == "linux" && debug # Bug 1678774 support-files = diff --git a/dom/base/test/fullscreen/file_fullscreen-single.html b/dom/base/test/fullscreen/file_fullscreen-single.html new file mode 100644 index 000000000000..2ebc58bdae82 --- /dev/null +++ b/dom/base/test/fullscreen/file_fullscreen-single.html @@ -0,0 +1,78 @@ + + + + + Simple Fullscreen Enter and Exit Test + + + + + + +

Fullscreen div

+ + + + + diff --git a/dom/base/test/fullscreen/mochitest.ini b/dom/base/test/fullscreen/mochitest.ini index ee2da299b0ae..6beac184d343 100644 --- a/dom/base/test/fullscreen/mochitest.ini +++ b/dom/base/test/fullscreen/mochitest.ini @@ -1,8 +1,8 @@ [DEFAULT] tags = fullscreen support-files = - file_fullscreen-api.html file_fullscreen-api-race.html + file_fullscreen-api.html file_fullscreen-async.html file_fullscreen-backdrop.html file_fullscreen-denied-inner.html @@ -27,6 +27,7 @@ support-files = file_fullscreen-scrollbar.html file_fullscreen-selector.html file_fullscreen-shadowdom.html + file_fullscreen-single.html file_fullscreen-sub-iframe.html file_fullscreen-svg-element.html file_fullscreen-table.html @@ -34,14 +35,13 @@ support-files = file_fullscreen-utils.js file_fullscreen-with-full-zoom.html +[test_fullscreen-api-race.html] +skip-if = toolkit == 'android' # same as test_fullscreen-api.html, 1356570 + os == "mac" && debug [test_fullscreen-api.html] allow_xul_xbl = true # XUL is used in file_fullscreen-api.html skip-if = toolkit == 'android' os == 'mac' && bits == 64 && debug # Bug 1579623 -[test_fullscreen-api-race.html] -skip-if = toolkit == 'android' # same as test_fullscreen-api.html, 1356570 - verify && debug && os == 'mac' - os == "mac" && debug [test_fullscreen_meta_viewport.html] [test_fullscreen_modal.html] diff --git a/dom/base/test/fullscreen/test_fullscreen-api.html b/dom/base/test/fullscreen/test_fullscreen-api.html index b2d98628b54a..2a59d6eeb079 100644 --- a/dom/base/test/fullscreen/test_fullscreen-api.html +++ b/dom/base/test/fullscreen/test_fullscreen-api.html @@ -28,6 +28,7 @@ SimpleTest.requestFlakyTimeout("untriaged"); // run in an iframe, which by default will not have the allowfullscreen // attribute set, so full-screen won't work. var gTestWindows = [ + { test: "file_fullscreen-single.html" }, { test: "file_fullscreen-multiple.html", prefs: [["full-screen-api.exit-on.windowRaise", false], ["full-screen-api.exit-on.windowOpen", false]] }, @@ -72,6 +73,7 @@ function nextTest() { info("main window focused, starting next test"); SimpleTest.executeSoon(runNextTest); }, {once: true}); + info("testWindow.close()"); testWindow.close(); } else { SimpleTest.executeSoon(runNextTest);