diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/fullscreen/api/resources | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/fullscreen/api/resources')
4 files changed, 156 insertions, 0 deletions
diff --git a/testing/web-platform/tests/fullscreen/api/resources/attempt-fullscreen.html b/testing/web-platform/tests/fullscreen/api/resources/attempt-fullscreen.html new file mode 100644 index 0000000000..98cca04516 --- /dev/null +++ b/testing/web-platform/tests/fullscreen/api/resources/attempt-fullscreen.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>IFrame Fullscreen API success reporter</title> +<body></body> +<script> + window.addEventListener("message", async (e) => { + switch (e.data.action) { + case "report": + await sendReport(); + break; + default: + parent.postMessage( + { + report: { + api: "fullscreen", + result: `Unknown action ${e.data.action}`, + frame: window.name, + }, + }, + "*" + ); + } + }); + + async function sendReport() { + let didSucceed = true; + let error; + let errorMessage; + try { + await document.body.requestFullscreen(); + } catch (e) { + didSucceed = false; + error = e.name; + errorMessage = e.message; + } finally { + const data = { + report: { + api: "fullscreen", + result: didSucceed, + frame: window.name, + error, + errorMessage, + }, + }; + parent.postMessage(data, "*"); + } + } +</script> diff --git a/testing/web-platform/tests/fullscreen/api/resources/echo-fullscreenEnabled.html b/testing/web-platform/tests/fullscreen/api/resources/echo-fullscreenEnabled.html new file mode 100644 index 0000000000..ad5edf7986 --- /dev/null +++ b/testing/web-platform/tests/fullscreen/api/resources/echo-fullscreenEnabled.html @@ -0,0 +1,11 @@ +<!doctype html> +<script> +window.onmessage = (e) => { + if (e.data === 'What is document.fullscreenEnabled?') { + e.source.postMessage(document.fullscreenEnabled, '*'); + } else { + e.source.postMessage('Incorrect message', '*'); + } +} +</script> +<p>This page echos document.fullscreenEnabled.</p> diff --git a/testing/web-platform/tests/fullscreen/api/resources/recursive-iframe-fullscreen.html b/testing/web-platform/tests/fullscreen/api/resources/recursive-iframe-fullscreen.html new file mode 100644 index 0000000000..d242a3b3e6 --- /dev/null +++ b/testing/web-platform/tests/fullscreen/api/resources/recursive-iframe-fullscreen.html @@ -0,0 +1,86 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<title>Recursive IFrame Fullscreen API success reporter</title> +<body> + <script src="/resources/testdriver.js"></script> + <script src="/resources/testdriver-vendor.js"></script> + <script src="../../trusted-click.js"></script> + <script> + let child_frame = null; + const events = []; + + document.onfullscreenchange = () => { + events.push("fullscreenchange"); + }; + + document.onfullscreenerror = () => { + events.push("fullscreenerror"); + }; + + function send_report() { + window.top.postMessage( + { + name: window.name, + action: "report", + report: { + api: "fullscreen", + frame: window.name, + fullscreenElementIsNull: document.fullscreenElement === null, + events, + }, + }, + "*" + ); + } + + async function create_child_frame({ src, name, allow_fullscreen }) { + child_frame = document.createElement("iframe"); + child_frame.allow = allow_fullscreen ? "fullscreen" : ""; + child_frame.name = name; + child_frame.style.width = "100%"; + child_frame.style.height = "100%"; + document.body.appendChild(child_frame); + await new Promise((resolve) => { + child_frame.addEventListener("load", resolve, { once: true }); + child_frame.src = src; + }); + window.top.postMessage({ action: "load", name }, "*"); + } + + async function go_fullscreen() { + await trusted_click(document.body); + let error; + try { + await document.body.requestFullscreen(); + } catch (err) { + error = err.name; + } finally { + window.top.postMessage( + { action: "requestFullscreen", name: window.name, error }, + "*" + ); + } + } + + window.addEventListener("message", async (e) => { + // Massage is not for us, try to pass it on... + if (e.data.name !== window.name) { + child_frame?.contentWindow.postMessage(e.data, "*"); + return; + } + switch (e.data.action) { + case "requestReport": + send_report(); + break; + case "requestFullscreen": + await go_fullscreen(); + break; + case "addIframe": + await create_child_frame(e.data.iframe); + break; + default: + window.top.postMessage(e.data, "*"); + } + }); + </script> +</body> diff --git a/testing/web-platform/tests/fullscreen/api/resources/report-fullscreen-enabled.html b/testing/web-platform/tests/fullscreen/api/resources/report-fullscreen-enabled.html new file mode 100644 index 0000000000..ee8d4cfab7 --- /dev/null +++ b/testing/web-platform/tests/fullscreen/api/resources/report-fullscreen-enabled.html @@ -0,0 +1,11 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>IFrame fullscreenEnabled attribute reporter</title> +<body> +<script> +parent.postMessage({"report": { + "api": "fullscreen", + "enabled": document.fullscreenEnabled, + "frame": window.name +}}, "*"); +</script> |