forked from mykmelez/gecko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1771151 - Make modal dialog code more generic, and make it apply …
…to fullscreen too behind a pref. r=edgar For now, don't turn it on by default yet, because I want to wait for more discussion in w3c/csswg-drafts#6965 and so on. But I think the code is simple enough to land this. Differential Revision: https://phabricator.services.mozilla.com/D147295
- Loading branch information
Showing
11 changed files
with
179 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!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); | ||
|
||
await document.exitFullscreen(); | ||
clickButton(/* expectEvent = */ true); | ||
} | ||
|
||
add_task(async function() { | ||
await testFullscreenIsModal(true); | ||
}); | ||
|
||
add_task(async function() { | ||
await testFullscreenIsModal(false); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.