diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/base/test/fullscreen/test_fullscreen_modal.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/fullscreen/test_fullscreen_modal.html')
-rw-r--r-- | dom/base/test/fullscreen/test_fullscreen_modal.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/dom/base/test/fullscreen/test_fullscreen_modal.html b/dom/base/test/fullscreen/test_fullscreen_modal.html new file mode 100644 index 0000000000..94b115f93e --- /dev/null +++ b/dom/base/test/fullscreen/test_fullscreen_modal.html @@ -0,0 +1,68 @@ +<!doctype html> +<title>Test for bug 1771150</title> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<link rel="stylesheet" href="/tests/SimpleTest/test.css"> +<style> + #fullscreen { + background-color: rgba(0, 255, 0, .5); + } + #fullscreen::backdrop { + background-color: transparent; + } + #fullscreen, #fullscreen::backdrop { + pointer-events: none; + } +</style> +<div id="fullscreen"></div> +<button>Go fullscreen</button> +<script> +const button = document.querySelector("button"); +let clickCount = 0; +let lastFullscreenPromise = null; +let shouldEnterFullscreen = false; +button.addEventListener("click", function(e) { + clickCount++; + if (shouldEnterFullscreen) { + lastFullscreenPromise = document.getElementById("fullscreen").requestFullscreen(); + } +}); + +function clickButton(expectEvent) { + let lastClickCount = clickCount; + synthesizeMouseAtCenter(button, {}); + (expectEvent ? isnot : is)(lastClickCount, clickCount, `Should've ${expectEvent ? "" : "not "}been able to click`); +} + +function enterFullscreen() { + lastFullscreenPromise = null; + shouldEnterFullscreen = true; + clickButton(true); + shouldEnterFullscreen = false; + isnot(lastFullscreenPromise, null, "Should be transitioning to fullscreen"); + return lastFullscreenPromise; +} + +async function testFullscreenIsModal(modal) { + info("testing modal: " + modal); + is(document.fullscreenElement, null, "Shouldn't be in fullscreen"); + await SpecialPowers.pushPrefEnv({ set: [["dom.fullscreen.modal", modal]] }); + await enterFullscreen(); + + clickButton(/* expectEvent = */ !modal); + + ok(document.fullscreenElement.matches(":fullscreen"), "Fullscreen element matches :fullscreen"); + is(document.fullscreenElement.matches(":modal"), modal, "Fullscreen element matches :modal"); + + await document.exitFullscreen(); + clickButton(/* expectEvent = */ true); +} + +add_task(async function() { + await testFullscreenIsModal(true); +}); + +add_task(async function() { + await testFullscreenIsModal(false); +}); +</script> |