summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fullscreen/model
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/fullscreen/model
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fullscreen/model')
-rw-r--r--testing/web-platform/tests/fullscreen/model/move-fullscreen-element.html29
-rw-r--r--testing/web-platform/tests/fullscreen/model/move-to-fullscreen-iframe.html65
-rw-r--r--testing/web-platform/tests/fullscreen/model/move-to-iframe.html44
-rw-r--r--testing/web-platform/tests/fullscreen/model/move-to-inactive-document.html40
-rw-r--r--testing/web-platform/tests/fullscreen/model/remove-child.html33
-rw-r--r--testing/web-platform/tests/fullscreen/model/remove-first.html45
-rw-r--r--testing/web-platform/tests/fullscreen/model/remove-last.html47
-rw-r--r--testing/web-platform/tests/fullscreen/model/remove-parent.html34
-rw-r--r--testing/web-platform/tests/fullscreen/model/remove-single.html34
9 files changed, 371 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fullscreen/model/move-fullscreen-element.html b/testing/web-platform/tests/fullscreen/model/move-fullscreen-element.html
new file mode 100644
index 0000000000..27f4c5dd82
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/move-fullscreen-element.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<title>Moving the fullscreen element should not leave the fullscreen flag</title>
+<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+
+<div id="fullscreen-element">Fullscreen element</div>
+
+<div id="new-parent"></div>
+
+<script>
+ promise_test(async () => {
+ const fullscreenElement = document.getElementById("fullscreen-element");
+ await trusted_request(fullscreenElement);
+ assert_true(fullscreenElement.matches(":fullscreen"), "Element has fullscreen flag");
+ assert_equals(document.fullscreenElement, fullscreenElement, "Element is fullscreen element");
+ document.getElementById("new-parent").appendChild(fullscreenElement);
+ assert_false(fullscreenElement.matches(":fullscreen"), "Element no longer has fullscreen flag after being moved");
+ assert_false(!!document.fullscreenElement, "There is no more fullscreen element, since fullscreen flag was removed");
+ await fullScreenChange();
+ assert_false(fullscreenElement.matches(":fullscreen"), "Element no longer has fullscreen flag after fullscreen change event");
+ assert_false(!!document.fullscreenElement, "There is no more fullscreen element, since fullscreen flag was removed");
+ });
+</script>
+</html>
diff --git a/testing/web-platform/tests/fullscreen/model/move-to-fullscreen-iframe.html b/testing/web-platform/tests/fullscreen/model/move-to-fullscreen-iframe.html
new file mode 100644
index 0000000000..0103b2979f
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/move-to-fullscreen-iframe.html
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<title>Moving fullscreen document's body into a fullscreen iframe</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<iframe allowfullscreen></iframe>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const iframe = document.querySelector("iframe");
+ await new Promise((resolve) => {
+ iframe.onload = resolve;
+ iframe.src = "about:blank";
+ });
+ const iframeDoc = iframe.contentDocument;
+
+ // Enter fullscreen for the iframe's body element.
+ await Promise.all([
+ trusted_request(iframeDoc.body, iframeDoc.body),
+ fullScreenChange(),
+ ]);
+
+ assert_equals(
+ document.fullscreenElement,
+ iframe,
+ "document's initial fullscreen element"
+ );
+ assert_equals(
+ iframeDoc.fullscreenElement,
+ iframeDoc.body,
+ "iframe's initial fullscreen element"
+ );
+
+ // Then, move the outer document's body into the iframe. This is an unusual
+ // thing to do, but means that the iframe is removed from its document and
+ // should trigger fullscreen exit.
+ iframeDoc.documentElement.appendChild(document.body);
+
+ // If we exit in an orderly fashion, that's all one can ask for.
+ await fullScreenChange();
+ assert_equals(
+ document.fullscreenElement,
+ null,
+ "document's final fullscreen element"
+ );
+
+ // Because the iframe was removed, its browsing context was discarded and
+ // its contentDocument has become null. Because that browsing context was
+ // neither a descendant browsing context nor had an active document,
+ // nothing at all was done with it in the exit fullscreen algorithm, so
+ // its fullscreenElement is unchanged.
+ assert_equals(iframe.contentDocument, null, "iframe's content document");
+ assert_equals(
+ iframeDoc.fullscreenElement,
+ iframeDoc.body,
+ "iframe's final fullscreen element"
+ );
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/move-to-iframe.html b/testing/web-platform/tests/fullscreen/model/move-to-iframe.html
new file mode 100644
index 0000000000..d3a7a67298
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/move-to-iframe.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<title>Move the fullscreen element to another document</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div></div>
+<iframe></iframe>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const div = document.querySelector("div");
+ const iframe = document.querySelector("iframe");
+ const [, event] = await Promise.all([
+ trusted_request(div),
+ fullScreenChange(),
+ ]);
+
+ assert_equals(document.fullscreenElement, div);
+ assert_equals(event.target, div);
+
+ assert_equals(div.ownerDocument, document);
+ iframe.contentDocument.body.appendChild(div);
+ assert_not_equals(div.ownerDocument, document);
+ // Moving /div/ removes it from the top layer and thus the fullscreen
+ // element synchronously becomes null.
+ assert_equals(document.fullscreenElement, null);
+
+ div.onfullscreenchange = t.unreached_func(
+ "fullscreenchange fired on element"
+ );
+ iframe.contentDocument.onfullscreenchange = t.unreached_func(
+ "fullscreenchange fired on other document"
+ );
+ const secondEvent = await fullScreenChange();
+ assert_equals(document.fullscreenElement, null);
+ assert_equals(secondEvent.target, document);
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/move-to-inactive-document.html b/testing/web-platform/tests/fullscreen/model/move-to-inactive-document.html
new file mode 100644
index 0000000000..b9a95f2954
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/move-to-inactive-document.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<title>Move the fullscreen element to an inactive document</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div></div>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const div = document.querySelector("div");
+
+ // Go fullscreen...
+ await Promise.all([trusted_request(div), fullScreenChange()]);
+
+ const inactiveDocument = document.implementation.createDocument(null, "");
+
+ div.onfullscreenchange = t.unreached_func(
+ "fullscreenchange fired on element"
+ );
+ inactiveDocument.onfullscreenchange = t.unreached_func(
+ "fullscreenchange fired on other document"
+ );
+
+ // Transplant element to inactive document...
+ inactiveDocument.appendChild(div);
+
+ // Fullscreen exits...
+ await fullScreenChange();
+ // Make sure no other events fire...
+ await new Promise((resolve) => {
+ requestAnimationFrame(resolve);
+ });
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/remove-child.html b/testing/web-platform/tests/fullscreen/model/remove-child.html
new file mode 100644
index 0000000000..42355dc2da
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/remove-child.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<title>Remove the child of the fullscreen element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div id="log"></div>
+<div id="parent">
+ <div></div>
+</div>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const parent = document.getElementById("parent");
+ await Promise.all([trusted_request(parent), fullScreenChange()]);
+
+ assert_equals(document.fullscreenElement, parent);
+ parent.textContent = ""; // removes all children
+ // The fullscreen element should not be affected.
+ assert_equals(document.fullscreenElement, parent);
+ document.onfullscreenchange = t.unreached_func("fullscreenchange event");
+ // A fullscreenchange event would be fired after an async section
+ // and an animation frame task, so wait until after that.
+ await new Promise((resolve) => {
+ requestAnimationFrame(resolve);
+ });
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/remove-first.html b/testing/web-platform/tests/fullscreen/model/remove-first.html
new file mode 100644
index 0000000000..b4058db320
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/remove-first.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<title>Remove the first element on the fullscreen element stack</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div id="log"></div>
+<div id="first">
+ <div id="last"></div>
+</div>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const first = document.getElementById("first");
+
+ const [, firstEvent] = await Promise.all([
+ trusted_request(first),
+ fullScreenChange(),
+ ]);
+ assert_equals(document.fullscreenElement, first);
+ assert_equals(firstEvent.target, first);
+
+ const last = document.getElementById("last");
+ const [, secondEvent] = await Promise.all([
+ trusted_request(last),
+ fullScreenChange(),
+ ]);
+ assert_equals(document.fullscreenElement, last);
+ assert_equals(event.target, last);
+ first.remove();
+
+ // Both /first/ and /last/ were removed from the top layer and
+ // thus the fullscreen element synchronously becomes null.
+ assert_equals(document.fullscreenElement, null);
+
+ const thirdEvent = await fullScreenChange();
+ assert_equals(document.fullscreenElement, null);
+ assert_equals(event.target, document);
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/remove-last.html b/testing/web-platform/tests/fullscreen/model/remove-last.html
new file mode 100644
index 0000000000..760ccaa0ba
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/remove-last.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<title>Remove the last element on the fullscreen element stack</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div id="log"></div>
+<div id="first">
+ <div id="last"></div>
+</div>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const first = document.getElementById("first");
+ const [, firstEvent] = await Promise.all([
+ trusted_request(first),
+ fullScreenChange(),
+ ]);
+
+ assert_equals(document.fullscreenElement, first);
+ assert_equals(firstEvent.target, first);
+
+ const last = document.getElementById("last");
+ const [, lastEvent] = await Promise.all([
+ trusted_request(last),
+ fullScreenChange(),
+ ]);
+
+ assert_equals(document.fullscreenElement, last);
+ assert_equals(event.target, last);
+ last.remove();
+ // Because /last/ was removed from the top layer, we exit
+ // fullscreen element synchronously.
+ assert_equals(document.fullscreenElement, first);
+
+ const finalEvent = await fullScreenChange();
+ // fullscreen change element should be queued against the
+ // document target.
+ assert_equals(document.fullscreenElement, null);
+ assert_equals(event.target, document);
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/remove-parent.html b/testing/web-platform/tests/fullscreen/model/remove-parent.html
new file mode 100644
index 0000000000..54ff5b8371
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/remove-parent.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<title>Remove the parent of the fullscreen element</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div id="log"></div>
+<div>
+ <div id="child"></div>
+</div>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const child = document.getElementById("child");
+ const [, event] = await Promise.all([
+ trusted_request(child),
+ fullScreenChange(),
+ ]);
+ assert_equals(document.fullscreenElement, child);
+ assert_equals(event.target, child);
+ child.parentNode.remove();
+ // Because /child/ was removed from the top layer, the fullscreen
+ // element becomes null synchronously.
+ assert_equals(document.fullscreenElement, null);
+ const secondEvent = await fullScreenChange();
+ assert_equals(document.fullscreenElement, null);
+ assert_equals(secondEvent.target, document);
+ });
+</script>
diff --git a/testing/web-platform/tests/fullscreen/model/remove-single.html b/testing/web-platform/tests/fullscreen/model/remove-single.html
new file mode 100644
index 0000000000..0401f77953
--- /dev/null
+++ b/testing/web-platform/tests/fullscreen/model/remove-single.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<title>Remove the single element on the fullscreen element stack</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/resources/testdriver.js"></script>
+<script src="/resources/testdriver-vendor.js"></script>
+<script src="../trusted-click.js"></script>
+<div id="log"></div>
+<div id="single"></div>
+<script>
+ promise_test(async (t) => {
+ t.add_cleanup(() => {
+ if (document.fullscreenElement) {
+ return document.exitFullscreen();
+ }
+ });
+ const single = document.getElementById("single");
+ const [, event] = await Promise.all([
+ trusted_request(single),
+ fullScreenChange(),
+ ]);
+
+ assert_equals(document.fullscreenElement, single);
+ assert_equals(event.target, single);
+ single.remove();
+ // Because /single/ was removed from the top layer, the fullscreen
+ // element becomes null synchronously.
+ assert_equals(document.fullscreenElement, null);
+
+ const secondEvent = await fullScreenChange();
+ assert_equals(document.fullscreenElement, null);
+ assert_equals(event.target, single);
+ });
+</script>