summaryrefslogtreecommitdiffstats
path: root/dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml')
-rw-r--r--dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml108
1 files changed, 108 insertions, 0 deletions
diff --git a/dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml b/dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml
new file mode 100644
index 0000000000..93f00311e7
--- /dev/null
+++ b/dom/base/test/fullscreen/MozDomFullscreen_chrome.xhtml
@@ -0,0 +1,108 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" type="text/css"?>
+<!--
+ Test that "MozDOMFullscreen:*" events are dispatched to chrome on documents that use DOM fullscreen.
+
+ Test Description:
+
+ This chrome window has a browser. The browser's contentDocument (the "outer document")
+ in turn has an iframe (the "inner document").
+
+ We request fullscreen in the outer document, and check that MozDOMFullscreen:Entered and
+ MozDOMFullscreen:NewOrigin are dispatched to chrome, targeted at the outer document.
+
+ Then we request fullscreen in the inner document, and check that MozDOMFullscreen:NewOrigin
+ is dispatched to chrome, targeted at the inner document.
+
+ Then we cancel fullscreen in the inner document, and check that MozDOMFullscreen:NewOrigin is
+ dispatched again to chrome, targeted at the outer document.
+-->
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onload="start();">
+
+<script src="chrome://mochikit/content/chrome-harness.js"></script>
+<script src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+<script type="application/javascript"><![CDATA[
+
+function ok(condition, msg) {
+ window.arguments[0].ok(condition, msg);
+}
+
+function is(a, b, msg) {
+ window.arguments[0].is(a, b, msg);
+}
+
+var gBrowser = null;
+var gOuterDoc = null;
+var gInnerDoc = null;
+
+var gReceivedFullscreenEnteredEvent = false;
+function firstEntry(event) {
+ if (event.type == "MozDOMFullscreen:NewOrigin") {
+ ok(false, "MozDOMFullscreen:NewOrigin shouldn't be triggered at first entry");
+ return;
+ }
+
+ if (event.type != "MozDOMFullscreen:Entered") {
+ ok(false, "Unknown event received");
+ return;
+ }
+
+ ok(gOuterDoc.fullscreenElement != null, "Outer doc should be in fullscreen");
+ is(event.target, gOuterDoc.body, "First MozDOMFullscreen:Entered should be targeted at outer body");
+ ok(!gReceivedFullscreenEnteredEvent, "MozDOMFullscreen:Entered shouldn't have been triggered twice");
+ gReceivedFullscreenEnteredEvent = true;
+ window.removeEventListener("MozDOMFullscreen:Entered", firstEntry);
+ window.removeEventListener("MozDOMFullscreen:NewOrigin", firstEntry);
+
+ window.addEventListener("MozDOMFullscreen:NewOrigin", secondEntry);
+ gInnerDoc = gOuterDoc.getElementById("innerFrame").contentDocument;
+ gInnerDoc.defaultView.focus();
+ gInnerDoc.body.requestFullscreen();
+}
+
+function secondEntry(event) {
+ is(event.target, gInnerDoc, "Second MozDOMFullscreen:NewOrigin should be targeted at inner doc");
+ ok(gInnerDoc.fullscreenElement != null, "Inner doc should be in fullscreen");
+ window.removeEventListener("MozDOMFullscreen:NewOrigin", secondEntry);
+ window.addEventListener("MozDOMFullscreen:NewOrigin", thirdEntry);
+ gInnerDoc.exitFullscreen();
+}
+
+function thirdEntry(event) {
+ is(event.target, gOuterDoc, "Third MozDOMFullscreen:NewOrigin should be targeted at outer doc");
+ ok(gOuterDoc.fullscreenElement != null, "Outer doc return to fullscreen after cancel fullscreen in inner doc");
+ window.removeEventListener("MozDOMFullscreen:NewOrigin", thirdEntry);
+ window.removeEventListener("MozDOMFullscreen:Exited", earlyExit);
+ window.addEventListener("MozDOMFullscreen:Exited", lastExit);
+ gOuterDoc.exitFullscreen();
+}
+
+function earlyExit(event) {
+ ok(false, "MozDOMFullscreen:Exited should only be triggered after cancel all fullscreen");
+}
+
+function lastExit(event) {
+ is(event.target, gOuterDoc, "MozDOMFullscreen:Exited should be targeted at the last exited doc");
+ ok(gOuterDoc.fullscreenElement == null, "Fullscreen should have been fully exited");
+ window.arguments[0].done();
+}
+
+function start() {
+ SimpleTest.waitForFocus(
+ function() {
+ gBrowser = document.getElementById("browser");
+ gOuterDoc = gBrowser.contentDocument;
+ gBrowser.contentWindow.focus();
+ window.addEventListener("MozDOMFullscreen:Entered", firstEntry);
+ window.addEventListener("MozDOMFullscreen:NewOrigin", firstEntry);
+ gOuterDoc.body.requestFullscreen();
+ });
+}
+
+]]>
+</script>
+<browser type="content" id="browser" width="400" height="400" src="file_MozDomFullscreen.html"/>
+
+</window>