Diff
Modified: trunk/LayoutTests/ChangeLog (224069 => 224070)
--- trunk/LayoutTests/ChangeLog 2017-10-26 23:44:27 UTC (rev 224069)
+++ trunk/LayoutTests/ChangeLog 2017-10-26 23:50:35 UTC (rev 224070)
@@ -1,5 +1,17 @@
2017-10-26 Youenn Fablet <[email protected]>
+ importScripts in service worker should use ServiceWorkersMode::None
+ https://bugs.webkit.org/show_bug.cgi?id=178888
+
+ Reviewed by Chris Dumez.
+
+ * http/tests/workers/service/resources/service-worker-importScript-worker.js: Added.
+ * http/tests/workers/service/resources/service-worker-importScript.js: Added.
+ * http/tests/workers/service/service-worker-importScript-expected.txt: Added.
+ * http/tests/workers/service/service-worker-importScript.html: Added.
+
+2017-10-26 Youenn Fablet <[email protected]>
+
Implement ServiceWorkerContainer getRegistration
https://bugs.webkit.org/show_bug.cgi?id=178882
Added: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-importScript-worker.js (0 => 224070)
--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-importScript-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-importScript-worker.js 2017-10-26 23:50:35 UTC (rev 224070)
@@ -0,0 +1 @@
+self.importScripts('/workers/service/resources/image-fetch-worker.js');
Added: trunk/LayoutTests/http/tests/workers/service/resources/service-worker-importScript.js (0 => 224070)
--- trunk/LayoutTests/http/tests/workers/service/resources/service-worker-importScript.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/service-worker-importScript.js 2017-10-26 23:50:35 UTC (rev 224070)
@@ -0,0 +1,22 @@
+async function logStatus()
+{
+ var response = await fetch("status");
+ log("Status is " + response.statusText);
+}
+
+async function test()
+{
+ try {
+ log("Registering service worker");
+ await navigator.serviceWorker.register("resources/service-worker-importScript-worker.js", { });
+ log("Registered service worker");
+
+ await logStatus();
+ log("PASS");
+ } catch(e) {
+ console.log("Got exception: " + e);
+ }
+ finishSWTest();
+}
+
+test();
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-importScript-expected.txt (0 => 224070)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-importScript-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-importScript-expected.txt 2017-10-26 23:50:35 UTC (rev 224070)
@@ -0,0 +1,5 @@
+Registering service worker
+Registered service worker
+Status is no status
+PASS
+
Added: trunk/LayoutTests/http/tests/workers/service/service-worker-importScript.html (0 => 224070)
--- trunk/LayoutTests/http/tests/workers/service/service-worker-importScript.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/service-worker-importScript.html 2017-10-26 23:50:35 UTC (rev 224070)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (224069 => 224070)
--- trunk/Source/WebCore/ChangeLog 2017-10-26 23:44:27 UTC (rev 224069)
+++ trunk/Source/WebCore/ChangeLog 2017-10-26 23:50:35 UTC (rev 224070)
@@ -1,3 +1,17 @@
+2017-10-26 Youenn Fablet <[email protected]>
+
+ importScripts in service worker should use ServiceWorkersMode::None
+ https://bugs.webkit.org/show_bug.cgi?id=178888
+
+ Reviewed by Chris Dumez.
+
+ Test: http/tests/workers/service/service-worker-importScript.html
+
+ Made sure ServiceWorkersMode::None is used for loading scripts in service workers as we do not support foreign fetch.
+
+ * workers/WorkerScriptLoader.cpp:
+ (WebCore::WorkerScriptLoader::loadSynchronously):
+
2017-10-26 Keith Miller <[email protected]>
Unreviewed, cleanup changelogs.
Modified: trunk/Source/WebCore/workers/WorkerScriptLoader.cpp (224069 => 224070)
--- trunk/Source/WebCore/workers/WorkerScriptLoader.cpp 2017-10-26 23:44:27 UTC (rev 224069)
+++ trunk/Source/WebCore/workers/WorkerScriptLoader.cpp 2017-10-26 23:50:35 UTC (rev 224070)
@@ -45,6 +45,7 @@
void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier)
{
ASSERT(scriptExecutionContext);
+ auto& workerGlobalScope = downcast<WorkerGlobalScope>(*scriptExecutionContext);
m_url = url;
@@ -62,8 +63,11 @@
options.mode = mode;
options.sendLoadCallbacks = SendCallbacks;
options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
-
- WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(*scriptExecutionContext), WTFMove(*request), *this, options);
+#if ENABLE(SERVICE_WORKER)
+ options.serviceWorkersMode = workerGlobalScope.isServiceWorkerGlobalScope() ? ServiceWorkersMode::None : ServiceWorkersMode::All;
+ options.serviceWorkerIdentifier = workerGlobalScope.selectedServiceWorkerIdentifier();
+#endif
+ WorkerThreadableLoader::loadResourceSynchronously(workerGlobalScope, WTFMove(*request), *this, options);
}
void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier, WorkerScriptLoaderClient* client)