From 84a44957233c13fb21f5d97b06db1d89076fb144 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 22 Feb 2019 11:01:20 +0100 Subject: [PATCH] HTML: window.focus() sans browsing context For https://github.com/whatwg/html/pull/4377. --- html/browsers/the-window-object/focus.window.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 html/browsers/the-window-object/focus.window.js diff --git a/html/browsers/the-window-object/focus.window.js b/html/browsers/the-window-object/focus.window.js new file mode 100644 index 00000000000000..6ec7feee281e75 --- /dev/null +++ b/html/browsers/the-window-object/focus.window.js @@ -0,0 +1,15 @@ +async_test(t => { + const input = document.body.appendChild(document.createElement("input")); + input.onfocus = t.step_func(() => { + const frame = document.body.appendChild(document.createElement("iframe")), + frameW = frame.contentWindow; + frameW.onfocus = t.unreached_func(); + frame.remove(); + frameW.focus(); + t.step_timeout(() => { + assert_equals(document.activeElement, input); + t.done(); + }, 100); + }); + input.focus(); +});