Title: [210385] branches/safari-603-branch

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (210384 => 210385)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-01-05 23:49:22 UTC (rev 210385)
@@ -1,5 +1,24 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210279. rdar://problem/29607569
+
+    2017-01-04  Joseph Pecoraro  <pecor...@apple.com>
+
+            Web Inspector: Cross Origin importScripts() scripts lack source URL, causes issues with Inspector showing Resource
+            https://bugs.webkit.org/show_bug.cgi?id=165569
+            <rdar://problem/29607569>
+
+            Reviewed by Youenn Fablet.
+
+            * http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts-expected.txt: Added.
+            * http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts.html: Added.
+            * http/tests/inspector/worker/resources/worker-blob-import-script.js: Added.
+            * http/tests/inspector/worker/resources/worker-blob-script.js: Added.
+            Ensure cross origin scripts imported by workers still get the correct Script URL.
+            Also this provides a test for worker started with a blob URL.
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210267. rdar://problem/29796608
 
     2017-01-03  Ryosuke Niwa  <rn...@webkit.org>

Added: branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts-expected.txt (0 => 210385)


--- branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts-expected.txt	2017-01-05 23:49:22 UTC (rev 210385)
@@ -0,0 +1,14 @@
+Test for Resources in a Worker started with a Blob URL that imports cross origin scripts.
+
+
+== Running test suite: Worker.Resources
+-- Running test case: Worker.Resource.Start
+PASS: Added Target should have Worker type.
+RESOURCES:
+http://localhost:8000/inspector/worker/resources/worker-blob-script.js
+http://localhost:8000/inspector/worker/resources/worker-blob-import-script.js
+SCRIPTS:
+blob:<sanitized>
+http://localhost:8000/inspector/worker/resources/worker-blob-script.js
+http://localhost:8000/inspector/worker/resources/worker-blob-import-script.js
+

Added: branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts.html (0 => 210385)


--- branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts.html	2017-01-05 23:49:22 UTC (rev 210385)
@@ -0,0 +1,91 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+let worker;
+
+function triggerWorkerStart() {
+    let blob = new Blob([`importScripts(["http://localhost:8000/inspector/worker/resources/worker-blob-script.js"]);`]);
+    let blobURL = URL.createObjectURL(blob);
+    worker = new Worker(blobURL);
+}
+
+function test()
+{
+    let workerTarget;
+    let mainTarget = WebInspector.mainTarget;
+
+    function sanitizeURL(url) {
+        if (!url)
+            return "<null>";
+        if (url.startsWith("blob:"))
+            return "blob:<sanitized>";
+        return url;
+    }
+
+    function dumpURLs(urls) {
+        if (!urls.length)
+            InspectorTest.log("-- None --");
+        else {
+            urls.sort((a, b) => a <= b)
+            for (let url of urls)
+                InspectorTest.log(url);
+        }
+    }
+
+    function dumpWorkerScripts() {
+        InspectorTest.log("SCRIPTS:");
+        let targetData = WebInspector.debuggerManager.dataForTarget(workerTarget);
+        let urls = [];
+        for (let script of targetData.scripts)
+            urls.push(sanitizeURL(script.url));
+        dumpURLs(urls);
+    }
+
+    function dumpWorkerResources() {
+        InspectorTest.log("RESOURCES:");
+        let urls = [];
+        for (let resource of workerTarget.resourceCollection.items)
+            urls.push(sanitizeURL(resource.url));
+        dumpURLs(urls);
+    }
+
+    let suite = InspectorTest.createAsyncSuite("Worker.Resources");
+
+    suite.addTestCase({
+        name: "Worker.Resource.Start",
+        description: "Start the worker and load multiple resources.",
+        test(resolve, reject) {
+            InspectorTest.evaluateInPage("triggerWorkerStart()");
+
+            WebInspector.targetManager.singleFireEventListener(WebInspector.TargetManager.Event.TargetAdded, (event) => {
+                workerTarget = event.data.target;
+                InspectorTest.assert(workerTarget instanceof WebInspector.Target);
+                InspectorTest.expectEqual(workerTarget.type, WebInspector.Target.Type.Worker, "Added Target should have Worker type.");
+            });
+
+            let seen = 0;
+            const expected = 3;
+            let listener = WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, (event) => {
+                if (event.data.script.target === workerTarget)
+                    seen++;
+                if (seen !== expected)
+                    return;
+
+                WebInspector.debuggerManager.removeEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, listener);
+                dumpWorkerResources();
+                dumpWorkerScripts();
+                resolve();
+            });
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for Resources in a Worker started with a Blob URL that imports cross origin scripts.</p>
+</body>
+</html>

Added: branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/resources/worker-blob-import-script.js (0 => 210385)


--- branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/resources/worker-blob-import-script.js	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/resources/worker-blob-import-script.js	2017-01-05 23:49:22 UTC (rev 210385)
@@ -0,0 +1,3 @@
+function workerBlobImportScript() {
+    console.trace("workerBlobImportScript");
+}

Added: branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/resources/worker-blob-script.js (0 => 210385)


--- branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/resources/worker-blob-script.js	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/http/tests/inspector/worker/resources/worker-blob-script.js	2017-01-05 23:49:22 UTC (rev 210385)
@@ -0,0 +1 @@
+importScripts(["http://localhost:8000/inspector/worker/resources/worker-blob-import-script.js"]);

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-01-05 23:49:22 UTC (rev 210385)
@@ -1,5 +1,36 @@
 2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r210279. rdar://problem/29607569
+
+    2017-01-04  Joseph Pecoraro  <pecor...@apple.com>
+
+            Web Inspector: Cross Origin importScripts() scripts lack source URL, causes issues with Inspector showing Resource
+            https://bugs.webkit.org/show_bug.cgi?id=165569
+            <rdar://problem/29607569>
+
+            Reviewed by Youenn Fablet.
+
+            Test: http/tests/inspector/worker/blob-script-with-cross-domain-imported-scripts.html
+
+            * Modules/fetch/FetchLoader.cpp:
+            (WebCore::FetchLoader::start):
+            * loader/DocumentThreadableLoader.cpp:
+            (WebCore::DocumentThreadableLoader::didReceiveResponse):
+            * loader/ThreadableLoader.cpp:
+            (WebCore::ThreadableLoaderOptions::ThreadableLoaderOptions):
+            * loader/ThreadableLoader.h:
+            * loader/WorkerThreadableLoader.cpp:
+            (WebCore::LoaderTaskOptions::LoaderTaskOptions):
+            Add a new ThreadableLoader option to avoid filtering the response.
+
+            * workers/WorkerScriptLoader.cpp:
+            (WebCore::WorkerScriptLoader::loadSynchronously):
+            (WebCore::WorkerScriptLoader::loadAsynchronously):
+            Disable filtering of the response. This is an internal load, we
+            don't want to filter data that would be valuable later.
+
+2017-01-05  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r210267. rdar://problem/29796608
 
     2017-01-03  Ryosuke Niwa  <rn...@webkit.org>

Modified: branches/safari-603-branch/Source/WebCore/Modules/fetch/FetchLoader.cpp (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/Modules/fetch/FetchLoader.cpp	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/Modules/fetch/FetchLoader.cpp	2017-01-05 23:49:22 UTC (rev 210385)
@@ -77,7 +77,7 @@
     ThreadableLoaderOptions options(request.fetchOptions(), ConsiderPreflight,
         context.shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective,
         String(cachedResourceRequestInitiators().fetch),
-        OpaqueResponseBodyPolicy::DoNotReceive);
+        OpaqueResponseBodyPolicy::DoNotReceive, ResponseFilteringPolicy::Enable);
     options.sendLoadCallbacks = SendCallbacks;
     options.dataBufferingPolicy = DoNotBufferData;
     options.sameOriginDataURLFlag = SameOriginDataURLFlag::Set;

Modified: branches/safari-603-branch/Source/WebCore/loader/DocumentThreadableLoader.cpp (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/loader/DocumentThreadableLoader.cpp	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/loader/DocumentThreadableLoader.cpp	2017-01-05 23:49:22 UTC (rev 210385)
@@ -286,7 +286,7 @@
 
     ASSERT(response.type() != ResourceResponse::Type::Error);
     if (response.type() == ResourceResponse::Type::Default) {
-        m_client->didReceiveResponse(identifier, ResourceResponse::filterResponse(response, tainting));
+        m_client->didReceiveResponse(identifier, options().filteringPolicy == ResponseFilteringPolicy::Enable ? ResourceResponse::filterResponse(response, tainting) : response);
         if (tainting == ResourceResponse::Tainting::Opaque && options().opaqueResponse == OpaqueResponseBodyPolicy::DoNotReceive) {
             clearResource();
             if (m_client)

Modified: branches/safari-603-branch/Source/WebCore/loader/ThreadableLoader.cpp (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/loader/ThreadableLoader.cpp	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/loader/ThreadableLoader.cpp	2017-01-05 23:49:22 UTC (rev 210385)
@@ -52,12 +52,13 @@
 {
 }
 
-ThreadableLoaderOptions::ThreadableLoaderOptions(const ResourceLoaderOptions& baseOptions, PreflightPolicy preflightPolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, String&& initiator, OpaqueResponseBodyPolicy opaqueResponse)
+ThreadableLoaderOptions::ThreadableLoaderOptions(const ResourceLoaderOptions& baseOptions, PreflightPolicy preflightPolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, String&& initiator, OpaqueResponseBodyPolicy opaqueResponse, ResponseFilteringPolicy filteringPolicy)
     : ResourceLoaderOptions(baseOptions)
     , preflightPolicy(preflightPolicy)
     , contentSecurityPolicyEnforcement(contentSecurityPolicyEnforcement)
     , initiator(WTFMove(initiator))
     , opaqueResponse(opaqueResponse)
+    , filteringPolicy(filteringPolicy)
 {
 }
 

Modified: branches/safari-603-branch/Source/WebCore/loader/ThreadableLoader.h (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/loader/ThreadableLoader.h	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/loader/ThreadableLoader.h	2017-01-05 23:49:22 UTC (rev 210385)
@@ -62,9 +62,14 @@
         DoNotReceive
     };
 
+    enum class ResponseFilteringPolicy {
+        Enable,
+        Disable,
+    };
+
     struct ThreadableLoaderOptions : ResourceLoaderOptions {
         ThreadableLoaderOptions();
-        ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, ContentSecurityPolicyEnforcement, String&& initiator, OpaqueResponseBodyPolicy);
+        ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, ContentSecurityPolicyEnforcement, String&& initiator, OpaqueResponseBodyPolicy, ResponseFilteringPolicy);
         ~ThreadableLoaderOptions();
 
         PreflightPolicy preflightPolicy { ConsiderPreflight };
@@ -71,6 +76,7 @@
         ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement { ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective };
         String initiator; // This cannot be an AtomicString, as isolatedCopy() wouldn't create an object that's safe for passing to another thread.
         OpaqueResponseBodyPolicy opaqueResponse { OpaqueResponseBodyPolicy::Receive };
+        ResponseFilteringPolicy filteringPolicy { ResponseFilteringPolicy::Enable };
     };
 
     // Useful for doing loader operations from any thread (not threadsafe,

Modified: branches/safari-603-branch/Source/WebCore/loader/WorkerThreadableLoader.cpp (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/loader/WorkerThreadableLoader.cpp	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/loader/WorkerThreadableLoader.cpp	2017-01-05 23:49:22 UTC (rev 210385)
@@ -92,7 +92,7 @@
 };
 
 LoaderTaskOptions::LoaderTaskOptions(const ThreadableLoaderOptions& options, const String& referrer, Ref<SecurityOrigin>&& origin)
-    : options(options, options.preflightPolicy, options.contentSecurityPolicyEnforcement, options.initiator.isolatedCopy(), options.opaqueResponse)
+    : options(options, options.preflightPolicy, options.contentSecurityPolicyEnforcement, options.initiator.isolatedCopy(), options.opaqueResponse, options.filteringPolicy)
     , referrer(referrer.isolatedCopy())
     , origin(WTFMove(origin))
 {

Modified: branches/safari-603-branch/Source/WebCore/workers/WorkerScriptLoader.cpp (210384 => 210385)


--- branches/safari-603-branch/Source/WebCore/workers/WorkerScriptLoader.cpp	2017-01-05 23:49:17 UTC (rev 210384)
+++ branches/safari-603-branch/Source/WebCore/workers/WorkerScriptLoader.cpp	2017-01-05 23:49:22 UTC (rev 210385)
@@ -66,6 +66,7 @@
     options.mode = mode;
     options.sendLoadCallbacks = SendCallbacks;
     options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
+    options.filteringPolicy = ResponseFilteringPolicy::Disable;
 
     WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(*scriptExecutionContext), WTFMove(*request), *this, options);
 }
@@ -91,6 +92,7 @@
     options.mode = mode;
     options.sendLoadCallbacks = SendCallbacks;
     options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
+    options.filteringPolicy = ResponseFilteringPolicy::Disable;
 
     // During create, callbacks may happen which remove the last reference to this object.
     Ref<WorkerScriptLoader> protectedThis(*this);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to