Bug 180383 - Add support for ServiceWorkerContainer.prototype.ready
Summary: Add support for ServiceWorkerContainer.prototype.ready
Alias: None
Product: WebKit
Classification: Unclassified
Component: Service Workers (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://w3c.github.io/ServiceWorker/#...
Keywords: InRadar
Depends on: 180360
  Show dependency treegraph
Reported: 2017-12-04 16:19 PST by Chris Dumez
Modified: 2017-12-06 16:48 PST (History)
5 users (show)

See Also:

WIP Patch (21.24 KB, patch)
2017-12-05 10:53 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (25.69 KB, patch)
2017-12-05 10:57 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (25.81 KB, patch)
2017-12-05 11:00 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (26.56 KB, patch)
2017-12-05 12:09 PST, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (26.56 KB, patch)
2017-12-05 12:24 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2017-12-04 16:19:45 PST
Add support for ServiceWorkerContainer.prototype.ready:
- https://w3c.github.io/ServiceWorker/#navigator-service-worker-ready
Comment 1 Chris Dumez 2017-12-05 10:53:54 PST
Created attachment 328468 [details]
WIP Patch
Comment 2 Chris Dumez 2017-12-05 10:57:15 PST
Created attachment 328469 [details]
Comment 3 Chris Dumez 2017-12-05 11:00:48 PST
Created attachment 328472 [details]
Comment 4 youenn fablet 2017-12-05 11:39:14 PST
Comment on attachment 328472 [details]

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

> Source/WebCore/workers/service/SWClientConnection.h:65
> +    using WhenRegistrationReadyCallback = WTF::Function<void(ServiceWorkerRegistrationData&&)>;

If this cannot be a CompletionHandler, probably the other callbacks cannot be either.

> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:93
> +                        return;

I wonder whether ScriptExecutionContext::postTaskTo would be able to prevent these kind of checks in the future.

> Source/WebCore/workers/service/server/SWServer.cpp:650
> +        connection->resolveRegistrationReadyRequests(registration);

Since we already expose Connection through getConnection, maybe it is fine to allow iterating in some ways inside SWServerRegistration directly.

> Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp:212
> +    m_registrationReadyRequests.append({ topOrigin, clientURL, WTFMove(callback) });

If we want to keep good WK2/WebCore layering, we should probably add this vector somewhere else, maybe at SWServerConnection level.
WebSWServerConnection::resolveRegistrationReadyRequests would also move up there.

In preexisting code, we should probably add an SWServerConnection::matchRegistration that would return an optional so that we would do less WebCore stuff in WebSWServerConnection::matchRegistration.
The same could apply there as well maybe.

> Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp:158
> +void WebSWClientConnection::whenRegistrationReady(Ref<SecurityOrigin>&& topOrigin, const URL& clientURL, WhenRegistrationReadyCallback&& callback)

Could probably take a const SecurityOrigin&.
Comment 5 Chris Dumez 2017-12-05 12:09:50 PST
Created attachment 328480 [details]
Comment 6 WebKit Commit Bot 2017-12-05 12:12:28 PST
Comment on attachment 328480 [details]

Rejecting attachment 328480 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-02', 'validate-changelog', '--check-oops', '--non-interactive', 328480, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

ChangeLog entry in LayoutTests/imported/w3c/ChangeLog contains OOPS!.

Full output: http://webkit-queues.webkit.org/results/5504306
Comment 7 Chris Dumez 2017-12-05 12:24:16 PST
Created attachment 328483 [details]
Comment 8 WebKit Commit Bot 2017-12-05 12:56:17 PST
Comment on attachment 328483 [details]

Clearing flags on attachment: 328483

Committed r225531: <https://trac.webkit.org/changeset/225531>
Comment 9 WebKit Commit Bot 2017-12-05 12:56:19 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Radar WebKit Bug Importer 2017-12-06 16:48:24 PST