Improve inter-document focus handling (#36649)

*Describe the changes that this pull request makes here. This will be
the commit message.*
rewritten the PR #28571
Implement
[Window#focus](https://html.spec.whatwg.org/multipage/#dom-window-focus),
[Window#blur](https://html.spec.whatwg.org/multipage/#dom-window-blur)
Testing: WPT
Fixes: #8981 #9421

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
Co-authored-by: yvt <i@yvt.jp>
This commit is contained in:
Fuguo 2025-04-30 12:37:53 +08:00 committed by GitHub
parent 27570987fd
commit 0c0ee04b8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 1123 additions and 242 deletions

View file

@ -1,3 +0,0 @@
[activeelement-after-focusing-different-site-iframe-then-immediately-focusing-back.html]
[Check focus event and active element after focusing different site iframe then immediately focusing back]
expected: FAIL

View file

@ -1,3 +0,0 @@
[activeelement-after-focusing-different-site-iframe.html]
[Check trailing events]
expected: FAIL

View file

@ -1,2 +1,3 @@
[activeelement-after-focusing-same-site-iframe-contentwindow.html]
expected: TIMEOUT
[Check result]
expected: FAIL

View file

@ -1,3 +0,0 @@
[activeelement-after-focusing-same-site-iframe.html]
[Check trailing events]
expected: FAIL

View file

@ -1,2 +1,3 @@
[activeelement-after-immediately-focusing-different-site-iframe-contentwindow.html]
expected: TIMEOUT
[Check result]
expected: FAIL

View file

@ -1,2 +1,3 @@
[activeelement-after-immediately-focusing-same-site-iframe-contentwindow.html]
expected: TIMEOUT
[Check result]
expected: FAIL

View file

@ -1,2 +1,3 @@
[focus-restoration-in-different-site-iframes-window.html]
expected: TIMEOUT
[Check result]
expected: FAIL

View file

@ -1,2 +1,3 @@
[focus-restoration-in-same-site-iframes-window.html]
expected: TIMEOUT
[Check result]
expected: FAIL

View file

@ -1,2 +0,0 @@
[iframe-focuses-parent-same-site.html]
expected: TIMEOUT

View file

@ -1,7 +1,4 @@
[cross-origin-objects-function-caching.html]
[Cross-origin Window methods are cached]
expected: FAIL
[Cross-origin Location `replace` method is cached]
expected: FAIL

View file

@ -1,3 +0,0 @@
[focus.window.html]
[focus]
expected: FAIL

View file

@ -328,9 +328,3 @@
[A SecurityError exception must be thrown when window.stop is accessed from a different origin.]
expected: FAIL
[A SecurityError exception should not be thrown when window.blur is accessed from a different origin.]
expected: FAIL
[A SecurityError exception should not be thrown when window.focus is accessed from a different origin.]
expected: FAIL

View file

@ -1,9 +1,4 @@
[window-properties.https.html]
[Window method: focus]
expected: FAIL
[Window method: blur]
expected: FAIL
[Window method: print]
expected: FAIL

View file

@ -1738,9 +1738,6 @@
[Document interface: attribute all]
expected: FAIL
[Window interface: operation focus()]
expected: FAIL
[Window interface: attribute scrollbars]
expected: FAIL
@ -1870,9 +1867,6 @@
[Document interface: new Document() must inherit property "dir" with the proper type]
expected: FAIL
[Window interface: window must inherit property "blur()" with the proper type]
expected: FAIL
[Document interface: operation execCommand(DOMString, optional boolean, optional DOMString)]
expected: FAIL
@ -1897,9 +1891,6 @@
[Document interface: iframe.contentDocument must inherit property "queryCommandEnabled(DOMString)" with the proper type]
expected: FAIL
[Window interface: operation blur()]
expected: FAIL
[Document interface: iframe.contentDocument must inherit property "onslotchange" with the proper type]
expected: FAIL
@ -1924,9 +1915,6 @@
[Document interface: documentWithHandlers must inherit property "onauxclick" with the proper type]
expected: FAIL
[Window interface: window must inherit property "focus()" with the proper type]
expected: FAIL
[Document interface: documentWithHandlers must inherit property "onwebkitanimationend" with the proper type]
expected: FAIL

View file

@ -1,12 +1,6 @@
[event-listeners.window.html]
[Standard event listeners are to be removed from Window]
expected: FAIL
[Standard event listeners are to be removed from Window for an active but not fully active document]
expected: FAIL
[Standard event listeners are to be removed from Window for a non-active document that is the associated Document of a Window (frame is removed)]
expected: FAIL
[Custom event listeners are to be removed from Window for an active but not fully active document]
expected: FAIL

View file

@ -1,6 +1,3 @@
[global-object-implicit-this-value-cross-realm.html]
[Cross-realm global object's operation throws when called on incompatible object]
expected: FAIL
[Cross-realm global object's operation called on null / undefined]
expected: FAIL