WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
238188
Only show notification permission prompt on transient activation
https://bugs.webkit.org/show_bug.cgi?id=238188
Summary
Only show notification permission prompt on transient activation
Ben Nham
Reported
2022-03-21 22:50:35 PDT
Only show notification permission prompt on transient activation
Attachments
Patch
(23.26 KB, patch)
2022-03-21 23:00 PDT
,
Ben Nham
no flags
Details
Formatted Diff
Diff
Patch
(30.33 KB, patch)
2022-03-22 17:51 PDT
,
Ben Nham
no flags
Details
Formatted Diff
Diff
Patch for landing
(30.32 KB, patch)
2022-03-22 17:53 PDT
,
Ben Nham
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Ben Nham
Comment 1
2022-03-21 23:00:15 PDT
Created
attachment 455337
[details]
Patch
Ben Nham
Comment 2
2022-03-21 23:01:46 PDT
<
rdar://90590937
>
youenn fablet
Comment 3
2022-03-21 23:57:03 PDT
Comment on
attachment 455337
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=455337&action=review
> Source/WebCore/Modules/push-api/PushManager.cpp:140 > + auto* window = document.frame()->window();
check frame is null?
> Source/WebCore/Modules/push-api/PushManager.cpp:141 > + if (!window || !window->consumeTransientActivation()) {
I would be tempted to do that check before enqueuing a task, but I guess this is more consistent the way you did it with the way the algorithm is done. The spec is a bit loose there, I filed
https://github.com/w3c/push-api/issues/346
to cover this. I guess the transient activation is implicitly done as part of step 8. This is potentially racy, for instance: - script checks subscribe permission (it is allowed). - before this event loop task is run, permission is changed to prompt - subscribe fails Is it fully consistent with Chrome and Firefox, aka is transient activation only checked when permission is neither granted nor denied?
> LayoutTests/ChangeLog:8 > + Add test cases to make sure that showing a permission prompt consumes a user gesture.
Can you add a test validating that calling subscribe out of user gesture 'works' if permission is denied or permission is granted?
Ben Nham
Comment 4
2022-03-22 17:51:16 PDT
Created
attachment 455461
[details]
Patch
Ben Nham
Comment 5
2022-03-22 17:51:26 PDT
(In reply to youenn fablet from
comment #3
)
> Comment on
attachment 455337
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=455337&action=review
> > > Source/WebCore/Modules/push-api/PushManager.cpp:140 > > + auto* window = document.frame()->window(); > > check frame is null?
Fixed in the patch to land.
> > Source/WebCore/Modules/push-api/PushManager.cpp:141 > > + if (!window || !window->consumeTransientActivation()) { > > I would be tempted to do that check before enqueuing a task, but I guess > this is more consistent the way you did it with the way the algorithm is > done. > The spec is a bit loose there, I filed >
https://github.com/w3c/push-api/issues/346
to cover this. > I guess the transient activation is implicitly done as part of step 8. > This is potentially racy, for instance: > - script checks subscribe permission (it is allowed). > - before this event loop task is run, permission is changed to prompt > - subscribe fails
Yeah, it's not clear which way is better, I just went with this way since it seemed clearer and closer to the algorithm the spec wants us to use.
> Is it fully consistent with Chrome and Firefox, aka is transient activation > only checked when permission is neither granted nor denied?
I checked Chromium, and as far as I can tell from inspection, they only check the transient activation flag in the case that they show a prompt.
> > LayoutTests/ChangeLog:8 > > + Add test cases to make sure that showing a permission prompt consumes a user gesture. > > Can you add a test validating that calling subscribe out of user gesture > 'works' if permission is denied or permission is granted?
I think these scenarios are already tested in subscribe-grant-permissions.html and subscribe-deny-permissions.html in the calls to testDocumentSubscribeWithoutUserGesture. I did update the logic in the test a bit to make sure that we are hitting the exact NotAllowedError we expect rather than any NotAllowedError.
Ben Nham
Comment 6
2022-03-22 17:53:07 PDT
Created
attachment 455463
[details]
Patch for landing
EWS
Comment 7
2022-03-22 23:48:55 PDT
Committed
r291737
(
248769@main
): <
https://commits.webkit.org/248769@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 455463
[details]
.
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