summaryrefslogtreecommitdiffstats
path: root/dom/base/test/fullscreen/file_fullscreen-featurePolicy.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/base/test/fullscreen/file_fullscreen-featurePolicy.html
parentInitial commit. (diff)
downloadfirefox-esr-upstream.tar.xz
firefox-esr-upstream.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/base/test/fullscreen/file_fullscreen-featurePolicy.html')
-rw-r--r--dom/base/test/fullscreen/file_fullscreen-featurePolicy.html90
1 files changed, 90 insertions, 0 deletions
diff --git a/dom/base/test/fullscreen/file_fullscreen-featurePolicy.html b/dom/base/test/fullscreen/file_fullscreen-featurePolicy.html
new file mode 100644
index 0000000000..c8b943c612
--- /dev/null
+++ b/dom/base/test/fullscreen/file_fullscreen-featurePolicy.html
@@ -0,0 +1,90 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>Test for FeaturePolicy + fullscreen</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
+ <script type="application/javascript" src="file_fullscreen-utils.js"></script>
+ <style>
+ body {
+ background-color: black;
+ }
+ </style>
+</head>
+<body>
+
+<script type="application/javascript">
+function ok(condition, msg) {
+ opener.ok(condition, "[featurePolicy] " + msg);
+}
+
+function is(a, b, msg) {
+ opener.is(a, b, "[featurePolicy] " + msg);
+}
+
+const INNER_FILE = "file_fullscreen-featurePolicy-inner.html";
+
+function begin() {
+ nextTest();
+}
+
+var tests = [
+ ["fullscreen 'none'", "fullscreenerror"],
+ ["fullscreen", "fullscreenchange"],
+ ["fullscreen 'src'", "fullscreenchange"],
+ ["fullscreen 'self'", "fullscreenchange"],
+ ["fullscreen *", "fullscreenchange"],
+ ["fullscreen http://random.net", "fullscreenerror"],
+ [null, "fullscreenchange"],
+];
+
+async function nextTest() {
+ if (!tests.length) {
+ opener.nextTest();
+ return;
+ }
+
+ let [value, expectedEvent] = tests.shift();
+
+ for (const isChrome of [false, true]) {
+ opener.info(`Running ${value} ${isChrome ? "w/" : "wo/"} chrome privileges`);
+
+ // Create an iframe with an allowfullscreen and with an allow attribute.
+ // The request should be denied or allowed, based on the current test.
+ const iframe = document.createElement("iframe");
+ iframe.setAttribute("allowfullscreen", "true");
+ if (value) {
+ iframe.setAttribute("allow", value);
+ }
+ iframe.src = INNER_FILE + (isChrome ? "?chrome" : "");
+
+ const setupForInnerTest = targetName => {
+ window.testTargetName = targetName;
+ return new Promise(resolve => {
+ window.continueTest = (event, enabled) => {
+ delete window.testTargetName;
+ delete window.continueTest;
+ resolve({ event, enabled });
+ };
+ document.body.appendChild(iframe);
+ });
+ };
+
+ const { event, enabled } = await setupForInnerTest(
+ `an iframe+allowfullscreen+allow:${value}+isChrome:${isChrome}`
+ );
+
+ if (isChrome) {
+ is(event, "fullscreenchange", "Expected a fullscreenchange event");
+ ok(enabled, "Should be enabled in chrome");
+ } else {
+ is(event, expectedEvent, "Expected a " + expectedEvent + " event");
+ is(enabled, expectedEvent == "fullscreenchange", "Should be appropriately enabled");
+ }
+ iframe.remove();
+ }
+ SimpleTest.executeSoon(nextTest);
+}
+</script>
+</body>
+</html>