Bug 231278 - Add PushSubscription stubs
Summary: Add PushSubscription stubs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ben Nham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-10-05 22:02 PDT by Ben Nham
Modified: 2021-10-06 21:15 PDT (History)
15 users (show)

See Also:


Attachments
Patch (77.39 KB, patch)
2021-10-05 22:13 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch (76.02 KB, patch)
2021-10-05 23:22 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch (75.36 KB, patch)
2021-10-06 11:07 PDT, Ben Nham
no flags Details | Formatted Diff | Diff
Patch (75.29 KB, patch)
2021-10-06 12:31 PDT, Ben Nham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ben Nham 2021-10-05 22:02:42 PDT
Add PushSubscription stubs
Comment 1 Ben Nham 2021-10-05 22:13:10 PDT
Created attachment 440330 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2021-10-05 22:15:11 PDT
<rdar://problem/83918867>
Comment 3 Alex Christensen 2021-10-05 22:48:48 PDT
Comment on attachment 440330 [details]
Patch

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

> Source/WebCore/Modules/push-api/PushEncryptionKeyName.h:32
> +enum class PushEncryptionKeyName {

: bool

> Source/WebCore/Modules/push-api/PushSubscription.cpp:103
> +            { "p256dh", base64URLEncodeToString(m_clientECDHPublicKey) },
> +            { "auth", base64URLEncodeToString(m_auth) }

_s

> Source/WebCore/Modules/push-api/PushSubscription.h:48
> +    WEBCORE_EXPORT static Ref<PushSubscription> create(String&& endpoint, std::optional<DOMTimeStamp> expirationTime, Ref<PushSubscriptionOptions>&&, Vector<uint8_t>&& clientECDHPublicKey, Vector<uint8_t>&& auth);

This might be a good candidate for something like this:
template<typename... Args> static Ref<PushSubscription> create(Args&&... args) { return adoptRef(*new PushSubscription(std::forward<Args>(args)...)); }

> Source/WebCore/Modules/push-api/PushSubscription.h:66
> +    Vector<uint8_t> m_auth;

Could you use a whole word to describe what this is instead of an abbreviation?

> Source/WebCore/Modules/push-api/PushSubscriptionOptions.cpp:40
> +

extra space.
Comment 4 Ben Nham 2021-10-05 23:22:31 PDT
Created attachment 440335 [details]
Patch
Comment 5 youenn fablet 2021-10-06 07:15:47 PDT
Comment on attachment 440335 [details]
Patch

Some nits below

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

> Source/WebCore/Modules/push-api/PushSubscription.cpp:65
> +Ref<PushSubscriptionOptions> PushSubscription::options() const

We can probably return a PushSubscriptionOptions&

> Source/WebCore/Modules/push-api/PushSubscription.h:37
> +#include <array>

Why do we need this one?

> Source/WebCore/Modules/push-api/PushSubscription.h:40
> +#include <wtf/RefCounted.h>

PushSubscriptionOptions.h probably has some of these.

> Source/WebCore/Modules/push-api/PushSubscriptionOptions.cpp:69
> +    return protectedApplicationServerKey;

return m_applicationServerKey.copyRef()?

> LayoutTests/ChangeLog:14
> +        * http/wpt/push-api/pushSubscription.https.any.html: Added.

Maybe not needed right now, but it will be good in the future to cover this in service worker context as well.
In case this is needed ServiceWorkerInternals can help.
Comment 6 Ben Nham 2021-10-06 11:07:34 PDT
Created attachment 440391 [details]
Patch
Comment 7 Ben Nham 2021-10-06 11:09:08 PDT
(In reply to youenn fablet from comment #5)
> > LayoutTests/ChangeLog:14
> > +        * http/wpt/push-api/pushSubscription.https.any.html: Added.
> 
> Maybe not needed right now, but it will be good in the future to cover this
> in service worker context as well.
> In case this is needed ServiceWorkerInternals can help.

For some reason I was having trouble with this--globalThis.internals was null in the service worker context in this test. I plan to change this test soon anyway to not use internals and just create a fake subscription via PushManager.subscribe. Once I do that I'll modify the test to run in the window and worker context.
Comment 8 Ben Nham 2021-10-06 12:31:19 PDT
Created attachment 440414 [details]
Patch
Comment 9 EWS 2021-10-06 21:15:12 PDT
Committed r283700 (242626@main): <https://commits.webkit.org/242626@main>

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