summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/xfo
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 /testing/web-platform/tests/portals/xfo
parentInitial commit. (diff)
downloadthunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz
thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.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 'testing/web-platform/tests/portals/xfo')
-rw-r--r--testing/web-platform/tests/portals/xfo/portals-xfo-deny.sub.html43
-rw-r--r--testing/web-platform/tests/portals/xfo/portals-xfo-sameorigin.html18
-rw-r--r--testing/web-platform/tests/portals/xfo/resources/xfo-deny.asis8
-rw-r--r--testing/web-platform/tests/portals/xfo/resources/xfo-sameorigin.asis8
4 files changed, 77 insertions, 0 deletions
diff --git a/testing/web-platform/tests/portals/xfo/portals-xfo-deny.sub.html b/testing/web-platform/tests/portals/xfo/portals-xfo-deny.sub.html
new file mode 100644
index 0000000000..efc925276c
--- /dev/null
+++ b/testing/web-platform/tests/portals/xfo/portals-xfo-deny.sub.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+// TODO(jbroman): Ideally these would also check that the portal element gets a
+// completion event.
+
+async_test(t => {
+ assert_implements("HTMLPortalElement" in self);
+ var portal = document.createElement('portal');
+ portal.src = "/portals/xfo/resources/xfo-deny.asis";
+ portal.onmessage = t.unreached_func("should not have received a message");
+ document.body.appendChild(portal);
+ t.add_cleanup(() => portal.remove());
+ t.step_timeout(() => t.done(), 2000);
+}, "`XFO: DENY` blocks same-origin portals.");
+
+async_test(t => {
+ assert_implements("HTMLPortalElement" in self);
+ var portal = document.createElement('portal');
+ portal.src = "http://{{domains[www]}}:{{ports[http][0]}}/portals/xfo/resources/xfo-deny.asis";
+ portal.onmessage = t.unreached_func("should not have received a message");
+ document.body.appendChild(portal);
+ t.add_cleanup(() => portal.remove());
+ t.step_timeout(() => t.done(), 2000);
+}, "`XFO: DENY` blocks cross-origin portals.");
+
+async_test(t => {
+ assert_implements("HTMLPortalElement" in self);
+ var portal = document.createElement('portal');
+ portal.src = "/portals/xfo/resources/xfo-deny.asis";
+ portal.onmessage = t.unreached_func("should not have received a message");
+ document.body.appendChild(portal);
+ t.add_cleanup(() => portal.remove());
+ t.step_timeout(async () => {
+ await promise_rejects_dom(t, 'InvalidStateError', portal.activate());
+ t.done();
+ }, 2000);
+}, "Portals blocked by `XFO: DENY` cannot be activated.");
+</script>
+</body>
diff --git a/testing/web-platform/tests/portals/xfo/portals-xfo-sameorigin.html b/testing/web-platform/tests/portals/xfo/portals-xfo-sameorigin.html
new file mode 100644
index 0000000000..2482476782
--- /dev/null
+++ b/testing/web-platform/tests/portals/xfo/portals-xfo-sameorigin.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/get-host-info.sub.js"></script>
+<body>
+<script>
+async_test(t => {
+ assert_implements("HTMLPortalElement" in self);
+ var portal = document.createElement('portal');
+ portal.src = get_host_info().HTTP_REMOTE_HOST + "/portals/xfo/resources/xfo-sameorigin.asis";
+ portal.onmessage = t.unreached_func("should not have received a message");
+ document.body.appendChild(portal);
+ t.add_cleanup(() => portal.remove());
+ t.step_timeout(() => t.done(), 2000);
+}, "`XFO: SAMEORIGIN` blocks cross-origin portals.");
+</script>
+</body>
diff --git a/testing/web-platform/tests/portals/xfo/resources/xfo-deny.asis b/testing/web-platform/tests/portals/xfo/resources/xfo-deny.asis
new file mode 100644
index 0000000000..7779830852
--- /dev/null
+++ b/testing/web-platform/tests/portals/xfo/resources/xfo-deny.asis
@@ -0,0 +1,8 @@
+HTTP/1.1 200 OK
+Content-Type: text/html
+X-Frame-Options: DENY
+
+<!DOCTYPE html>
+<script>
+window.portalHost.postMessage('loaded', '*');
+</script>
diff --git a/testing/web-platform/tests/portals/xfo/resources/xfo-sameorigin.asis b/testing/web-platform/tests/portals/xfo/resources/xfo-sameorigin.asis
new file mode 100644
index 0000000000..8f3982bd84
--- /dev/null
+++ b/testing/web-platform/tests/portals/xfo/resources/xfo-sameorigin.asis
@@ -0,0 +1,8 @@
+HTTP/1.1 200 OK
+Content-Type: text/html
+X-Frame-Options: SAMEORIGIN
+
+<!DOCTYPE html>
+<script>
+window.portalHost.postMessage('loaded', '*');
+</script>