Implement ServiceWorkerRegistration.update()
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Nov 2017 20:18:17 +0000 (20:18 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 5 Nov 2017 20:18:17 +0000 (20:18 +0000)
commit33d300db424f6b0ca4210cb8df2b259dc67ded12
treeb3634add9710bf1eca7604bb6f5a9199f886af52
parent568785318126ae9b55e44bea3bd989da923a049d
Implement ServiceWorkerRegistration.update()
https://bugs.webkit.org/show_bug.cgi?id=179270

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more are passing or at least failing later.

* web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt:
* web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt:
* web-platform-tests/service-workers/service-worker/import-scripts-redirect.https-expected.txt:
* web-platform-tests/service-workers/service-worker/multiple-register.https-expected.txt:
* web-platform-tests/service-workers/service-worker/multiple-update.https-expected.txt:
* web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt:
* web-platform-tests/service-workers/service-worker/ready.https-expected.txt:
* web-platform-tests/service-workers/service-worker/registration-script.https-expected.txt:
* web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt:
* web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt:

* web-platform-tests/service-workers/service-worker/update.https-expected.txt:
I investigated this test and it is still failing later on because we clear registrations too
aggressively on the StorageProcess side we are supposed to make sure the registration does
not have a newestWorker before clearing it when a script fetch fails or a script syntax error
occurs. We properly have those if (!newestWorker) checks in the code but service workers
are not yet populated on the SWServerRegistration object so SWServerRegistration::getNewestWorker()
alwasy returns null.

Source/WebCore:

Implement ServiceWorkerRegistration.update():
- https://w3c.github.io/ServiceWorker/#service-worker-registration-update

We already had support for the Update algorithm in SWServerJobQueue but
this patch enhances our support a bit to get us closer to the specification:
- https://w3c.github.io/ServiceWorker/#update-algorithm

No new tests, rebaselined existing tests.

* workers/service/ServiceWorker.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::updateRegistration):
(WebCore::ServiceWorkerContainer::getRegistration):
(WebCore::ServiceWorkerContainer::jobResolvedWithRegistration):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerJobData.h:
(WebCore::ServiceWorkerJobData::encode const):
(WebCore::ServiceWorkerJobData::decode):
* workers/service/ServiceWorkerJobType.h:
* workers/service/ServiceWorkerRegistration.cpp:
(WebCore::ServiceWorkerRegistration::ServiceWorkerRegistration):
(WebCore::ServiceWorkerRegistration::installing):
(WebCore::ServiceWorkerRegistration::waiting):
(WebCore::ServiceWorkerRegistration::active):
(WebCore::ServiceWorkerRegistration::setInstallingWorker):
(WebCore::ServiceWorkerRegistration::setWaitingWorker):
(WebCore::ServiceWorkerRegistration::setActiveWorker):
(WebCore::ServiceWorkerRegistration::getNewestWorker):
(WebCore::ServiceWorkerRegistration::update):
* workers/service/ServiceWorkerRegistration.h:
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptFetchFinished):
(WebCore::SWServerJobQueue::scriptContextFailedToStart):
(WebCore::SWServerJobQueue::runNextJobSynchronously):
(WebCore::SWServerJobQueue::runUpdateJob):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224469 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-affect-other-registration.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/claim-with-redirect.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/import-scripts-redirect.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multiple-register.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/multiple-update.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/postmessage-from-waiting-serviceworker.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ready.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-script.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/skip-waiting.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/unregister-then-register.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/service/ServiceWorker.h
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebCore/workers/service/ServiceWorkerJob.cpp
Source/WebCore/workers/service/ServiceWorkerJobClient.h
Source/WebCore/workers/service/ServiceWorkerJobData.h
Source/WebCore/workers/service/ServiceWorkerJobType.h
Source/WebCore/workers/service/ServiceWorkerRegistration.cpp
Source/WebCore/workers/service/ServiceWorkerRegistration.h
Source/WebCore/workers/service/server/SWServerJobQueue.cpp