Created attachment 435599 [details] Test This can be reproduced with the attached test, the web view title shows whether the document has the focus or not at any time. Move the focus to a new tab in MiniBrowser to see that it remains true for the hidden tab. The problem is that we are always claiming to have the focus when the web view is in the active window. This is not happening in safari, but I don't understand why. I noticed this because ikea.com website stores the active widget in localstorage using document.hasFocus(). When opening multiple tabs it starts writing local storage like crazy making the network and web processes consume 100% cpu. It doesn't happen when using multiple windows instead of tabs, because in that case only the tab in the active window returns true for document.hasFocus().
Created attachment 435600 [details] Patch
Comment on attachment 435600 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=435600&action=review > Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebView.cpp:801 > +static void testWebViewDocumentFocus(WebViewTest* test, gconstpointer) Nice test, by the way :)
The gtk unit test is failing under xvfb, I'll fix it. But I need help with the cocoa unit tests. WebAuthenticationPanel test looks unrelated, but maybe the test assumes the view has the focus while the panel is open or something like that?
In the case of gtk I think the problem is that the toplevel window focus is given to the window by the window manager, so under xvfb we never set the WindowIsActive flag because there's no a window manager.
Created attachment 435668 [details] Patch
The cocoa tests failures are because the credential container requires the document to be focused and the page isn't actually focused, now caught by document.hasFocus(). We just need to focus the view in all the tests.
Created attachment 435755 [details] Patch for landing
Created attachment 435758 [details] Patch for landing
ChangeLog entry in Tools/ChangeLog contains OOPS!.
Created attachment 435847 [details] Patch for landing
Committed r281228 (240665@main): <https://commits.webkit.org/240665@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 435847 [details].
<rdar://problem/82115580>