[Service Workers] Registration promise should be rejected when the service worker...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Nov 2017 05:15:15 +0000 (05:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 Nov 2017 05:15:15 +0000 (05:15 +0000)
commit34343c5f869302f535536e401ac47b94d6eca4df
tree2f74f8228e0adeac0a2e04b80409e0b01e81e803
parent611e16b2045b614e6667c7f4f1ac97e4b2574047
[Service Workers] Registration promise should be rejected when the service worker fails to start
https://bugs.webkit.org/show_bug.cgi?id=179566

Reviewed by Brady Eidson.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that we properly reject registration promises when the worker script
fails to evaluate.

* web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https-expected.txt:
* web-platform-tests/service-workers/service-worker/navigation-redirect.https-expected.txt:
* web-platform-tests/service-workers/service-worker/redirected-response.https-expected.txt:
* web-platform-tests/service-workers/service-worker/update.https-expected.txt:

Source/WebCore:

Registration promise should be rejected when the service worker fails to start.

Though our code intended to do this, there were several issues:
- Our code failed to properly detect when the script failed to evaluate. This is
  because it relied on the exception message being non-null but it was always
  null when same origin due to a bug.
- Our scriptContextFailedToStart() handler failed to rejected the promise
  and finish the job as per:
  - https://w3c.github.io/ServiceWorker/#update-algorithm (step 9.7)

Test: http/tests/workers/service/worker-fails-to-start.html

* bindings/js/WorkerScriptController.cpp:
(WebCore::WorkerScriptController::evaluate):
* workers/service/server/SWServerJobQueue.cpp:
(WebCore::SWServerJobQueue::scriptContextFailedToStart):

LayoutTests:

Add layout test coverage.

* TestExpectations: Mark test as flaky as the console lines sometimes change order.
* http/tests/workers/service/resources/worker-fails-to-start-worker.js: Added.
* http/tests/workers/service/worker-fails-to-start-expected.txt: Added.
* http/tests/workers/service/worker-fails-to-start.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224723 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/http/tests/workers/service/resources/worker-fails-to-start-worker.js [new file with mode: 0644]
LayoutTests/http/tests/workers/service/worker-fails-to-start-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/workers/service/worker-fails-to-start.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/ServiceWorkerGlobalScope/registration-attribute.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/navigation-redirect.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/redirected-response.https-expected.txt
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/update.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/WorkerScriptController.cpp
Source/WebCore/workers/service/server/SWServerJobQueue.cpp