summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/resources/focus-page-with-x-origin-iframe.sub.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/portals/resources/focus-page-with-x-origin-iframe.sub.html')
-rw-r--r--testing/web-platform/tests/portals/resources/focus-page-with-x-origin-iframe.sub.html28
1 files changed, 28 insertions, 0 deletions
diff --git a/testing/web-platform/tests/portals/resources/focus-page-with-x-origin-iframe.sub.html b/testing/web-platform/tests/portals/resources/focus-page-with-x-origin-iframe.sub.html
new file mode 100644
index 0000000000..df7974e75b
--- /dev/null
+++ b/testing/web-platform/tests/portals/resources/focus-page-with-x-origin-iframe.sub.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<body>
+ <script>
+ async function handleMessage(e) {
+ if (e.data == "focus" || e.data == "focus-update-active-element") {
+ let iframe = document.querySelector("iframe");
+ iframe.contentWindow.postMessage(e.data, "*");
+ }
+ }
+
+ if (window.portalHost)
+ window.portalHost.onmessage = handleMessage;
+
+ window.onportalactivate = e => {
+ var portal = e.adoptPredecessor();
+ document.body.appendChild(portal);
+ portal.onmessage = handleMessage;
+ }
+
+ window.onmessage = e => {
+ if (window.portalHost)
+ window.portalHost.postMessage(e.data);
+ else
+ document.querySelector("portal").postMessage(e.data);
+ }
+ </script>
+ <iframe src="http://{{hosts[alt][www]}}:{{ports[http][0]}}/portals/resources/focus-page-with-button.html"></iframe>
+</body>