importScripts() inside a service worker should ensure that the response has a JavaScr...
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Dec 2017 21:23:39 +0000 (21:23 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Dec 2017 21:23:39 +0000 (21:23 +0000)
commit1562daa4d4628a57276b955a3b920deb5d89a130
tree7504781029f5d4a8ab51abb909f0d38af50f252f
parentd2e43cdd9e55b4cffe4dd7ee6d5ae6d3985d303a
importScripts() inside a service worker should ensure that the response has a JavaScript MIME type
https://bugs.webkit.org/show_bug.cgi?id=181103

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

Rebaseline WPT test now that it fails later. The test expects that the registration promise be
rejected with a SecurityError. However, we reject it with a TypeError instead, which is the
result of the Network error from importScripts().

The spec does say that importScripts() should report a network error when the MIME type is
invalid:
- https://w3c.github.io/ServiceWorker/#importscripts (step 6)

Later on, the spec says that if "an uncaught runtime script error occurs" when running the script,
we should resolve the registration with a TypeError:
- https://w3c.github.io/ServiceWorker/#update (step 9.6)

Therefore, our behavior seems correct and I cannot find in the spec a reason why the test would
expect a SecurityError here.

* web-platform-tests/service-workers/service-worker/registration-mime-types.https-expected.txt:

Source/WebCore:

importScripts() inside a service worker should ensure that the response has a JavaScript
MIME type, as per:
- https://w3c.github.io/ServiceWorker/#importscripts (step 6)

No new tests, rebaselined existing test.

* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::importScripts):
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::didReceiveResponse):
* workers/WorkerScriptLoader.h:
(WebCore::WorkerScriptLoader::responseMIMEType const):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226275 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/registration-mime-types.https-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/workers/WorkerScriptLoader.h