Bug 236739

Summary: Hook up PushManager to notification permission state
Product: WebKit Reporter: Ben Nham <nham>
Component: New BugsAssignee: Ben Nham <nham>
Status: RESOLVED FIXED    
Severity: Normal CC: beidson, cdumez, nham, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch for landing
none
Patch for landing none

Description Ben Nham 2022-02-16 15:12:03 PST
Hook up PushManager to notification permission state
Comment 1 Ben Nham 2022-02-16 15:24:28 PST
Created attachment 452257 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2022-02-16 16:52:50 PST
<rdar://problem/89056721>
Comment 3 Ben Nham 2022-02-16 20:40:56 PST
Created attachment 452302 [details]
Patch
Comment 4 Brady Eidson 2022-02-16 22:52:16 PST
Comment on attachment 452302 [details]
Patch

This seems fine. Ping me when the bots are green and I'll give it the nit-pick look, but it'll be r+
Comment 5 Ben Nham 2022-02-17 00:56:19 PST
Created attachment 452334 [details]
Patch
Comment 6 Ben Nham 2022-02-17 00:58:30 PST
Created attachment 452335 [details]
Patch
Comment 7 Ben Nham 2022-02-17 01:00:06 PST
Created attachment 452336 [details]
Patch
Comment 8 Ben Nham 2022-02-17 07:57:51 PST
Created attachment 452366 [details]
Patch
Comment 9 Ben Nham 2022-02-17 23:02:31 PST
Created attachment 452486 [details]
Patch
Comment 10 Chris Dumez 2022-02-18 09:08:25 PST
Comment on attachment 452486 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=452486&action=review

> Source/WebCore/Modules/push-api/PushManager.cpp:134
> +                promise.reject(Exception { NotAllowedError, "User denied push permission"_s });

We may want to provide a clearer explanation here of WHY this is failing.

> Source/WebCore/Modules/push-api/PushManager.cpp:139
> +            // Ref { *this } triggers a compiler bug on wincairo where it tries to ref the lambda instead of PushManager.

MSVC has trouble with nested lambdas. I think the trick to get this building in MSVC is to capture `protectedThis = WTFMove(protectedThis)` below instead of `protectedThis = Ref { *this }`.

> Source/WebCore/Modules/push-api/PushManager.cpp:170
> +        if (permission == NotificationPermission::Default)

This screams for a switch statement IMO.
Comment 11 Brady Eidson 2022-02-18 13:33:20 PST
Comment on attachment 452486 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=452486&action=review

R+ with review feedback addressed

>> Source/WebCore/Modules/push-api/PushManager.cpp:139
>> +            // Ref { *this } triggers a compiler bug on wincairo where it tries to ref the lambda instead of PushManager.
> 
> MSVC has trouble with nested lambdas. I think the trick to get this building in MSVC is to capture `protectedThis = WTFMove(protectedThis)` below instead of `protectedThis = Ref { *this }`.

I think the bot bubbles are all green, which is good.

>> Source/WebCore/Modules/push-api/PushManager.cpp:170
>> +        if (permission == NotificationPermission::Default)
> 
> This screams for a switch statement IMO.

Agreed: Switch plz
Comment 12 Chris Dumez 2022-02-18 13:34:02 PST
Comment on attachment 452486 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=452486&action=review

>>> Source/WebCore/Modules/push-api/PushManager.cpp:139
>>> +            // Ref { *this } triggers a compiler bug on wincairo where it tries to ref the lambda instead of PushManager.
>> 
>> MSVC has trouble with nested lambdas. I think the trick to get this building in MSVC is to capture `protectedThis = WTFMove(protectedThis)` below instead of `protectedThis = Ref { *this }`.
> 
> I think the bot bubbles are all green, which is good.

Well, they are all green because of an ugly #if !PLATFORM(WIN_CAIRO)
Comment 13 Ben Nham 2022-02-18 15:48:44 PST
Created attachment 452590 [details]
Patch for landing
Comment 14 EWS 2022-02-18 19:25:13 PST
Found 1 new test failure: http/wpt/push-api/onpush-disabled.html
Comment 15 Ben Nham 2022-02-18 19:44:36 PST
Created attachment 452617 [details]
Patch for landing
Comment 16 EWS 2022-02-18 21:27:58 PST
Committed r290198 (247526@main): <https://commits.webkit.org/247526@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 452617 [details].