summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/resources/focus-page-with-autofocus.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/portals/resources/focus-page-with-autofocus.html')
-rw-r--r--testing/web-platform/tests/portals/resources/focus-page-with-autofocus.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/testing/web-platform/tests/portals/resources/focus-page-with-autofocus.html b/testing/web-platform/tests/portals/resources/focus-page-with-autofocus.html
new file mode 100644
index 0000000000..d498ef6335
--- /dev/null
+++ b/testing/web-platform/tests/portals/resources/focus-page-with-autofocus.html
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<body>
+ <button id="one">one</button>
+ <button id="two" autofocus>two</button>
+ <button id="three">three</button>
+ <script>
+ function messageHandler(e) {
+ if (e.data === 'check-active-element') {
+ window.requestAnimationFrame(() => {
+ let autofocusedButton = document.querySelector('#two');
+ e.source.postMessage(document.activeElement === autofocusedButton);
+ });
+ }
+ }
+
+ window.portalHost.onmessage = messageHandler;
+ window.onportalactivate = e => {
+ let portal = e.adoptPredecessor();
+ portal.onmessage = messageHandler;
+ document.body.appendChild(portal);
+ }
+ </script>
+</body>