Support container.getRegistration() / getRegistrations() inside service workers
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2017 02:06:26 +0000 (02:06 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Dec 2017 02:06:26 +0000 (02:06 +0000)
commitb71cf8c0d493d1030dee03897f50c16f39198e6c
tree8a27573beefa27be629193cb1be40b838ef45990
parentd789ece61e227cc30eb436e2d615d6ebbd0f057c
Support container.getRegistration() / getRegistrations() inside service workers
https://bugs.webkit.org/show_bug.cgi?id=180360

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/service-workers/service-worker/activation.https-expected.txt:
Rebaseline test with slightly different output.

* web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt:
* web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html:
With my change, this test started running and passing a check before timing out. When investigating the time
out, I found out that this is caused by the test unregistering the worker while the test is still running
in the service worker, which causes the worker to terminate early. To address the issue, we no longer add
a cleanup step to unregister. The test now passes all checks.

Source/WebCore:

Support container.getRegistration() / getRegistrations() inside service workers
by making sure we hop to the right thread when needed.

Test: http/tests/workers/service/ServiceWorkerGlobalScope_getRegistration.html

* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::postTaskTo):
* dom/ScriptExecutionContext.h:
* workers/service/SWClientConnection.cpp:
(WebCore::SWClientConnection::jobRejectedInServer):
(WebCore::SWClientConnection::registrationJobResolvedInServer):
(WebCore::SWClientConnection::unregistrationJobResolvedInServer):
(WebCore::SWClientConnection::startScriptFetchForServer):
(WebCore::SWClientConnection::clearPendingJobs):
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::didFinishGetRegistrationRequest):
(WebCore::ServiceWorkerContainer::getRegistrations):
(WebCore::ServiceWorkerContainer::didFinishGetRegistrationsRequest):
(WebCore::ServiceWorkerContainer::stop):
* workers/service/ServiceWorkerContainer.h:

Source/WebKit:

* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::didMatchRegistration):
(WebKit::WebSWClientConnection::didGetRegistrations):
(WebKit::WebSWClientConnection::matchRegistration):
(WebKit::WebSWClientConnection::getRegistrations):

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/ServiceWorkerGlobalScope_getRegistration-expected.txt: Added.
* http/tests/workers/service/ServiceWorkerGlobalScope_getRegistration.html: Added.
* http/tests/workers/service/resources/ServiceWorkerGlobalScope_getRegistration-worker.js: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225513 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/workers/service/ServiceWorkerGlobalScope_getRegistration-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/ServiceWorkerGlobalScope_getRegistration.html [new file with mode: 0644]
LayoutTests/http/tests/workers/service/resources/ServiceWorkerGlobalScope_getRegistration-worker.js [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/activation.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-using-registration.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-using-registration.https.html
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting-without-using-registration.https.html
Source/WebCore/ChangeLog
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/dom/ScriptExecutionContext.h
Source/WebCore/workers/service/SWClientConnection.cpp
Source/WebCore/workers/service/SWClientConnection.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp