WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
229139
document.hasFocus() returns true for unfocused pages
https://bugs.webkit.org/show_bug.cgi?id=229139
Summary
document.hasFocus() returns true for unfocused pages
Carlos Garcia Campos
Reported
2021-08-16 07:33:20 PDT
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().
Attachments
Test
(225 bytes, text/html)
2021-08-16 07:33 PDT
,
Carlos Garcia Campos
no flags
Details
Patch
(4.44 KB, patch)
2021-08-16 07:36 PDT
,
Carlos Garcia Campos
aperez
: review+
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch
(4.68 KB, patch)
2021-08-17 00:27 PDT
,
Carlos Garcia Campos
no flags
Details
Formatted Diff
Diff
Patch for landing
(30.35 KB, patch)
2021-08-18 02:29 PDT
,
Carlos Garcia Campos
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch for landing
(29.61 KB, patch)
2021-08-18 03:31 PDT
,
Carlos Garcia Campos
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
Patch for landing
(29.61 KB, patch)
2021-08-18 23:37 PDT
,
Carlos Garcia Campos
no flags
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Carlos Garcia Campos
Comment 1
2021-08-16 07:36:20 PDT
Created
attachment 435600
[details]
Patch
Adrian Perez
Comment 2
2021-08-16 07:45:42 PDT
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 :)
Carlos Garcia Campos
Comment 3
2021-08-16 23:59:29 PDT
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?
Carlos Garcia Campos
Comment 4
2021-08-17 00:16:24 PDT
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.
Carlos Garcia Campos
Comment 5
2021-08-17 00:27:50 PDT
Created
attachment 435668
[details]
Patch
Carlos Garcia Campos
Comment 6
2021-08-18 02:28:55 PDT
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.
Carlos Garcia Campos
Comment 7
2021-08-18 02:29:24 PDT
Created
attachment 435755
[details]
Patch for landing
Carlos Garcia Campos
Comment 8
2021-08-18 03:31:27 PDT
Created
attachment 435758
[details]
Patch for landing
EWS
Comment 9
2021-08-18 23:31:22 PDT
ChangeLog entry in Tools/ChangeLog contains OOPS!.
Carlos Garcia Campos
Comment 10
2021-08-18 23:37:27 PDT
Created
attachment 435847
[details]
Patch for landing
EWS
Comment 11
2021-08-19 01:46:12 PDT
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]
.
Radar WebKit Bug Importer
Comment 12
2021-08-19 01:47:18 PDT
<
rdar://problem/82115580
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug