RESOLVED FIXED 180360
Support container.getRegistration() / getRegistrations() inside service workers
https://bugs.webkit.org/show_bug.cgi?id=180360
Summary Support container.getRegistration() / getRegistrations() inside service workers
Chris Dumez
Reported 2017-12-04 09:15:37 PST
Support container.getRegistration() / getRegistrations() inside service workers.
Attachments
WIP Patch (17.32 KB, patch)
2017-12-04 11:45 PST, Chris Dumez
no flags
WIP Patch (20.94 KB, patch)
2017-12-04 12:09 PST, Chris Dumez
no flags
WIP Patch (20.78 KB, patch)
2017-12-04 12:18 PST, Chris Dumez
no flags
WIP Patch (20.83 KB, patch)
2017-12-04 12:57 PST, Chris Dumez
no flags
Archive of layout-test-results from ews105 for mac-elcapitan-wk2 (2.54 MB, application/zip)
2017-12-04 14:16 PST, EWS Watchlist
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.12 MB, application/zip)
2017-12-04 14:27 PST, EWS Watchlist
no flags
Patch (28.81 KB, patch)
2017-12-04 15:11 PST, Chris Dumez
no flags
Patch (29.02 KB, patch)
2017-12-04 15:35 PST, Chris Dumez
no flags
Patch (31.85 KB, patch)
2017-12-04 15:38 PST, Chris Dumez
no flags
Patch (31.05 KB, patch)
2017-12-04 16:40 PST, Chris Dumez
no flags
Patch (30.96 KB, patch)
2017-12-04 16:48 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2017-12-04 11:45:04 PST
Created attachment 328367 [details] WIP Patch
Chris Dumez
Comment 2 2017-12-04 12:09:25 PST
Created attachment 328373 [details] WIP Patch
Chris Dumez
Comment 3 2017-12-04 12:18:29 PST
Created attachment 328374 [details] WIP Patch
Chris Dumez
Comment 4 2017-12-04 12:57:54 PST
Created attachment 328379 [details] WIP Patch
EWS Watchlist
Comment 5 2017-12-04 14:16:07 PST
Comment on attachment 328379 [details] WIP Patch Attachment 328379 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/5491816 New failing tests: imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html imported/w3c/web-platform-tests/service-workers/service-worker/activation.https.html
EWS Watchlist
Comment 6 2017-12-04 14:16:09 PST
Created attachment 328389 [details] Archive of layout-test-results from ews105 for mac-elcapitan-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews105 Port: mac-elcapitan-wk2 Platform: Mac OS X 10.11.6
EWS Watchlist
Comment 7 2017-12-04 14:27:39 PST
Comment on attachment 328379 [details] WIP Patch Attachment 328379 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: http://webkit-queues.webkit.org/results/5491833 New failing tests: imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html imported/w3c/web-platform-tests/service-workers/service-worker/activation.https.html
EWS Watchlist
Comment 8 2017-12-04 14:27:40 PST
Created attachment 328391 [details] Archive of layout-test-results from ews126 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.12.6
Chris Dumez
Comment 9 2017-12-04 15:11:46 PST
Chris Dumez
Comment 10 2017-12-04 15:35:51 PST
Chris Dumez
Comment 11 2017-12-04 15:38:20 PST
Chris Dumez
Comment 12 2017-12-04 15:45:52 PST
Comment on attachment 328397 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=328397&action=review > LayoutTests/imported/w3c/ChangeLog:16 > + a cleanup step to unregister. The test now passes all checks. PR: https://github.com/w3c/web-platform-tests/pull/8559
youenn fablet
Comment 13 2017-12-04 16:16:08 PST
Comment on attachment 328397 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=328397&action=review > Source/WebCore/dom/ScriptExecutionContext.cpp:588 > +void ScriptExecutionContext::postTaskTo(const DocumentOrWorkerIdentifier& contextIdentifier, WTF::Function<void(ScriptExecutionContext&)>&& task) I am always wondering whether to use Identifier or const Identifier& in such cases. I have difficulties keeping it consistent. Since it is a Variant, it is better to pass it by ref? > Source/WebCore/dom/ScriptExecutionContext.cpp:592 > + switchOn(contextIdentifier, [&](DocumentIdentifier identifier) { space between ] and ( is apparently our style. > Source/WebCore/dom/ScriptExecutionContext.cpp:596 > + document->postTask([task = WTFMove(task)](ScriptExecutionContext& scope) { auto& here and in other various places below ? > Source/WebCore/workers/service/ServiceWorkerContainer.cpp:232 > + Ref<SecurityOrigin> topOrigin = context->topOrigin(); This may end up topOrigin to be destroyed on the main thread. Shouldn't we isolate it? Ditto below probably. > Source/WebCore/workers/service/ServiceWorkerContainer.cpp:320 > + } You can probably write it as: auto registrations = WTF::map(WTFMove(registrations), [this] (auto&& registrationData) { return ServiceWorkerRegistration::getOrCreate(*scriptExecutionContext(), *this, WTFMove(registrationData)); }); > Source/WebCore/workers/service/ServiceWorkerContainer.cpp:545 > + m_pendingGetRegistrationsRequests.clear(); I would try to use one map that keeps DeferredPromise instead of typed DOMPromiseDeferred. > Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp:140 > + ASSERT(isMainThread()); We do not do that often when receiving IPC messages. Should we try to do that more aggressively? Or should these assertions be moved to the lambdas instead?
Chris Dumez
Comment 14 2017-12-04 16:27:25 PST
Comment on attachment 328397 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=328397&action=review >> Source/WebCore/dom/ScriptExecutionContext.cpp:588 >> +void ScriptExecutionContext::postTaskTo(const DocumentOrWorkerIdentifier& contextIdentifier, WTF::Function<void(ScriptExecutionContext&)>&& task) > > I am always wondering whether to use Identifier or const Identifier& in such cases. > I have difficulties keeping it consistent. Since it is a Variant, it is better to pass it by ref? I am not sure in the case of a Variant so I figured better safe than sorry. >> Source/WebCore/dom/ScriptExecutionContext.cpp:592 >> + switchOn(contextIdentifier, [&](DocumentIdentifier identifier) { > > space between ] and ( is apparently our style. Uh? ok. >> Source/WebCore/dom/ScriptExecutionContext.cpp:596 >> + document->postTask([task = WTFMove(task)](ScriptExecutionContext& scope) { > > auto& here and in other various places below ? ok. >> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:232 >> + Ref<SecurityOrigin> topOrigin = context->topOrigin(); > > This may end up topOrigin to be destroyed on the main thread. Shouldn't we isolate it? > Ditto below probably. Will isolateCopy(). >> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:320 >> + } > > You can probably write it as: > auto registrations = WTF::map(WTFMove(registrations), [this] (auto&& registrationData) { > return ServiceWorkerRegistration::getOrCreate(*scriptExecutionContext(), *this, WTFMove(registrationData)); > }); Ok, wasn't familiar with WTF::map() >> Source/WebCore/workers/service/ServiceWorkerContainer.cpp:545 >> + m_pendingGetRegistrationsRequests.clear(); > > I would try to use one map that keeps DeferredPromise instead of typed DOMPromiseDeferred. Will look into this.
Chris Dumez
Comment 15 2017-12-04 16:40:43 PST
youenn fablet
Comment 16 2017-12-04 16:43:59 PST
Comment on attachment 328409 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=328409&action=review > Source/WebCore/workers/service/ServiceWorkerContainer.cpp:292 > + Ref<SecurityOrigin> topOrigin = context->topOrigin(); No need for this variable and refing topOrigin probably as well.
Chris Dumez
Comment 17 2017-12-04 16:48:24 PST
WebKit Commit Bot
Comment 18 2017-12-04 17:12:05 PST
Comment on attachment 328411 [details] Patch Rejecting attachment 328411 [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-03', 'land-attachment', '--force-clean', '--non-interactive', '--parent-command=commit-queue', 328411, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit Last 500 characters of output: ..99b2274 master -> origin/master Partial-rebuilding .git/svn/refs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc ... Currently at 225506 = 6dd634539ab447fd1507bbe274df2c73431ab7b7 r225507 = 99b227420d9a3b88cc44f866efee9ec3cb1c6da1 Done rebuilding .git/svn/refs/remotes/origin/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc First, rewinding head to replay your work on top of it... Fast-forwarded master to refs/remotes/origin/master. Total errors found: 0 in 0 files Full output: http://webkit-queues.webkit.org/results/5494450
Chris Dumez
Comment 19 2017-12-04 18:06:32 PST
Comment on attachment 328411 [details] Patch Clearing flags on attachment: 328411 Committed r225513: <https://trac.webkit.org/changeset/225513>
Chris Dumez
Comment 20 2017-12-04 18:06:34 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 21 2017-12-04 20:00:51 PST
Note You need to log in before you can comment on or make changes to this bug.