diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/fullscreen/model | |
parent | Initial commit. (diff) | |
download | firefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fullscreen/model')
8 files changed, 342 insertions, 0 deletions
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> |