Changeset 289672 in webkit
- Timestamp:
- Feb 11, 2022 2:57:33 PM (5 months ago)
- Location:
- trunk
- Files:
-
- 2 added
- 24 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/resourceLoadStatistics/resources/script-revealing-cookies.py (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-importScript-redirect-cross-origin-allowed.py (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-importScript-redirect-cross-origin-blocked.py (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-xhr-allowed.py (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-xhr-redirect-cross-origin-allowed.py (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-xhr-redirect-cross-origin-blocked.py (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker.py (modified) (1 diff)
-
LayoutTests/http/tests/workers/resources/subworker-encoded.py (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/workers/Worker_script_mimetype-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/workers/constructors/SharedWorker/Infinity.headers (added)
-
LayoutTests/imported/w3c/web-platform-tests/workers/constructors/SharedWorker/NaN.headers (added)
-
LayoutTests/imported/w3c/web-platform-tests/workers/importscripts_mime.any.sharedworker-expected.txt (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/workers/importscripts_mime.any.worker-expected.txt (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp (modified) (1 diff)
-
Source/WebCore/loader/FetchOptions.h (modified) (1 diff)
-
Source/WebCore/workers/Worker.cpp (modified) (1 diff)
-
Source/WebCore/workers/WorkerGlobalScope.cpp (modified) (1 diff)
-
Source/WebCore/workers/WorkerScriptLoader.cpp (modified) (6 diffs)
-
Source/WebCore/workers/WorkerScriptLoader.h (modified) (3 diffs)
-
Source/WebCore/workers/service/ServiceWorkerJob.cpp (modified) (1 diff)
-
Source/WebCore/workers/shared/SharedWorkerScriptLoader.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r289668 r289672 1 2022-02-11 Chris Dumez <cdumez@apple.com> 2 3 Fix MIME type check for classic worker script fetches 4 https://bugs.webkit.org/show_bug.cgi?id=236411 5 6 Reviewed by Alex Christensen. 7 8 Fix existing layout tests to make sure that worker scripts are served with a JavaScript mime type. 9 10 * http/tests/resourceLoadStatistics/resources/script-revealing-cookies.py: 11 * http/tests/security/contentSecurityPolicy/resources/worker-importScript-redirect-cross-origin-allowed.py: 12 * http/tests/security/contentSecurityPolicy/resources/worker-importScript-redirect-cross-origin-blocked.py: 13 * http/tests/security/contentSecurityPolicy/resources/worker-xhr-allowed.py: 14 * http/tests/security/contentSecurityPolicy/resources/worker-xhr-redirect-cross-origin-allowed.py: 15 * http/tests/security/contentSecurityPolicy/resources/worker-xhr-redirect-cross-origin-blocked.py: 16 * http/tests/security/contentSecurityPolicy/resources/worker.py: 17 * http/tests/workers/resources/subworker-encoded.py: 18 1 19 2022-02-11 Antoine Quint <graouts@webkit.org> 2 20 -
trunk/LayoutTests/http/tests/resourceLoadStatistics/resources/script-revealing-cookies.py
r274975 r289672 19 19 first_party_cookie = cookies.get('firstPartyCookie', None) 20 20 21 sys.stdout.write('Content-Type: text/ html\r\n\r\n')21 sys.stdout.write('Content-Type: text/javascript\r\n\r\n') 22 22 23 23 if first_party_cookie: -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-importScript-redirect-cross-origin-allowed.py
r274671 r289672 6 6 determine_content_security_policy_header() 7 7 sys.stdout.write( 8 'Content-Type: text/ html\r\n\r\n'8 'Content-Type: text/javascript\r\n\r\n' 9 9 'self.result = false;\n' 10 10 'var exception;\n' -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-importScript-redirect-cross-origin-blocked.py
r274671 r289672 6 6 determine_content_security_policy_header() 7 7 sys.stdout.write( 8 'Content-Type: text/ html\r\n\r\n'8 'Content-Type: text/javascript\r\n\r\n' 9 9 'var exception;\n' 10 10 'try {\n' -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-xhr-allowed.py
r274671 r289672 6 6 determine_content_security_policy_header() 7 7 sys.stdout.write( 8 'Content-Type: text/ html\r\n\r\n'8 'Content-Type: text/javascript\r\n\r\n' 9 9 'var isAsynchronous = false;\n' 10 10 'var xhr = new XMLHttpRequest;\n' -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-xhr-redirect-cross-origin-allowed.py
r274671 r289672 5 5 6 6 sys.stdout.write( 7 'Content-Type: text/ html\r\n\r\n'7 'Content-Type: text/javascript\r\n\r\n' 8 8 'var isAsynchronous = false;\n' 9 9 'var xhr = new XMLHttpRequest;\n' -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker-xhr-redirect-cross-origin-blocked.py
r274671 r289672 6 6 determine_content_security_policy_header() 7 7 sys.stdout.write( 8 'Content-Type: text/ html\r\n\r\n'8 'Content-Type: text/javascript\r\n\r\n' 9 9 'var expectedExceptionCode = 19; // DOMException.NETWORK_ERR\n' 10 10 'var isAsynchronous = false;\n' -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/resources/worker.py
r277964 r289672 13 13 'Cache-Control: no-cache, must-revalidate\r\n' 14 14 'Pragma: no-cache\r\n' 15 'Content-Type: text/ html\r\n'15 'Content-Type: text/javascript\r\n' 16 16 ) 17 17 -
trunk/LayoutTests/http/tests/workers/resources/subworker-encoded.py
r274768 r289672 11 11 'Cache-Control: no-cache, must-revalidate\r\n' 12 12 'Pragma: no-cache\r\n' 13 'Content-Type: text/ html\r\n\r\n'13 'Content-Type: text/javascript\r\n\r\n' 14 14 'postMessage(\'Sub: Original test string: \' + String.fromCharCode(0x41F, 0x440, 0x438, 0x432, 0x435, 0x442));' 15 15 'postMessage(\'Sub: Test string encoded using koi8-r: {}.\');' -
trunk/LayoutTests/imported/w3c/ChangeLog
r289631 r289672 1 2022-02-11 Chris Dumez <cdumez@apple.com> 2 3 Fix MIME type check for classic worker script fetches 4 https://bugs.webkit.org/show_bug.cgi?id=236411 5 6 Reviewed by Alex Christensen. 7 8 * web-platform-tests/workers/Worker_script_mimetype-expected.txt: 9 * web-platform-tests/workers/importscripts_mime.any.sharedworker-expected.txt: 10 * web-platform-tests/workers/importscripts_mime.any.worker-expected.txt: 11 Rebaseline WPT tests now that more checks are passing. 12 13 * web-platform-tests/workers/constructors/SharedWorker/Infinity.headers: Added. 14 * web-platform-tests/workers/constructors/SharedWorker/NaN.headers: Added. 15 Merge upstream fix from https://github.com/web-platform-tests/wpt/pull/32782. 16 1 17 2022-02-11 Jon Lee <jonlee@apple.com> 2 18 -
trunk/LayoutTests/imported/w3c/web-platform-tests/workers/Worker_script_mimetype-expected.txt
r279602 r289672 1 1 2 FAIL HTTP(S) URLs which respond with text/plain MIME type must not work assert_unreached: Worker should not recieve messages Reached unreachable code 2 PASS HTTP(S) URLs which respond with text/plain MIME type must not work 3 3 PASS blob: URLs should load, despite no MIME type for the backing Blob 4 4 PASS blob: URLs should load, despite the wrong MIME type for the backing Blob -
trunk/LayoutTests/imported/w3c/web-platform-tests/workers/importscripts_mime.any.sharedworker-expected.txt
r289116 r289672 6 6 PASS importScripts() requires scripty MIME types: text/csv is blocked. 7 7 PASS importScripts() requires scripty MIME types: video/mpeg is blocked. 8 FAIL importScripts() requires scripty MIME types: text/html is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 9 FAIL importScripts() requires scripty MIME types: text/plain is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 10 FAIL importScripts() requires scripty MIME types: application/xml is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 11 FAIL importScripts() requires scripty MIME types: application/octet-stream is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 12 FAIL importScripts() requires scripty MIME types: text/potato is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 13 FAIL importScripts() requires scripty MIME types: potato/text is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 14 FAIL importScripts() requires scripty MIME types: aaa/aaa is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 15 FAIL importScripts() requires scripty MIME types: zzz/zzz is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 8 PASS importScripts() requires scripty MIME types: text/html is blocked. 9 PASS importScripts() requires scripty MIME types: text/plain is blocked. 10 PASS importScripts() requires scripty MIME types: application/xml is blocked. 11 PASS importScripts() requires scripty MIME types: application/octet-stream is blocked. 12 PASS importScripts() requires scripty MIME types: text/potato is blocked. 13 PASS importScripts() requires scripty MIME types: potato/text is blocked. 14 PASS importScripts() requires scripty MIME types: aaa/aaa is blocked. 15 PASS importScripts() requires scripty MIME types: zzz/zzz is blocked. 16 16 PASS importScripts() requires scripty MIME types: text/javascript; charset=utf-8 is allowed. 17 17 PASS importScripts() requires scripty MIME types: text/javascript;charset=utf-8 is allowed. … … 20 20 PASS importScripts() requires scripty MIME types: text/csv;charset=utf-8 is blocked. 21 21 PASS importScripts() requires scripty MIME types: text/csv;bla;bla is blocked. 22 FAIL importScripts() requires scripty MIME types: Text/html is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 23 FAIL importScripts() requires scripty MIME types: text/Html is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 24 FAIL importScripts() requires scripty MIME types: TeXt/HtMl is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 25 FAIL importScripts() requires scripty MIME types: TEXT/HTML is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 22 PASS importScripts() requires scripty MIME types: Text/html is blocked. 23 PASS importScripts() requires scripty MIME types: text/Html is blocked. 24 PASS importScripts() requires scripty MIME types: TeXt/HtMl is blocked. 25 PASS importScripts() requires scripty MIME types: TEXT/HTML is blocked. 26 26 -
trunk/LayoutTests/imported/w3c/web-platform-tests/workers/importscripts_mime.any.worker-expected.txt
r267649 r289672 6 6 PASS importScripts() requires scripty MIME types: text/csv is blocked. 7 7 PASS importScripts() requires scripty MIME types: video/mpeg is blocked. 8 FAIL importScripts() requires scripty MIME types: text/html is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 9 FAIL importScripts() requires scripty MIME types: text/plain is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 10 FAIL importScripts() requires scripty MIME types: application/xml is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 11 FAIL importScripts() requires scripty MIME types: application/octet-stream is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 12 FAIL importScripts() requires scripty MIME types: text/potato is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 13 FAIL importScripts() requires scripty MIME types: potato/text is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 14 FAIL importScripts() requires scripty MIME types: aaa/aaa is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 15 FAIL importScripts() requires scripty MIME types: zzz/zzz is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 8 PASS importScripts() requires scripty MIME types: text/html is blocked. 9 PASS importScripts() requires scripty MIME types: text/plain is blocked. 10 PASS importScripts() requires scripty MIME types: application/xml is blocked. 11 PASS importScripts() requires scripty MIME types: application/octet-stream is blocked. 12 PASS importScripts() requires scripty MIME types: text/potato is blocked. 13 PASS importScripts() requires scripty MIME types: potato/text is blocked. 14 PASS importScripts() requires scripty MIME types: aaa/aaa is blocked. 15 PASS importScripts() requires scripty MIME types: zzz/zzz is blocked. 16 16 PASS importScripts() requires scripty MIME types: text/javascript; charset=utf-8 is allowed. 17 17 PASS importScripts() requires scripty MIME types: text/javascript;charset=utf-8 is allowed. … … 20 20 PASS importScripts() requires scripty MIME types: text/csv;charset=utf-8 is blocked. 21 21 PASS importScripts() requires scripty MIME types: text/csv;bla;bla is blocked. 22 FAIL importScripts() requires scripty MIME types: Text/html is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 23 FAIL importScripts() requires scripty MIME types: text/Html is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 24 FAIL importScripts() requires scripty MIME types: TeXt/HtMl is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 25 FAIL importScripts() requires scripty MIME types: TEXT/HTML is blocked. assert_throws_dom: function "_ => { importScripts(import_url) }" did not throw 22 PASS importScripts() requires scripty MIME types: Text/html is blocked. 23 PASS importScripts() requires scripty MIME types: text/Html is blocked. 24 PASS importScripts() requires scripty MIME types: TeXt/HtMl is blocked. 25 PASS importScripts() requires scripty MIME types: TEXT/HTML is blocked. 26 26 -
trunk/Source/WebCore/ChangeLog
r289666 r289672 1 2022-02-11 Chris Dumez <cdumez@apple.com> 2 3 Fix MIME type check for classic worker script fetches 4 https://bugs.webkit.org/show_bug.cgi?id=236411 5 6 Reviewed by Alex Christensen. 7 8 Fix MIME type check for classic worker script fetches and classic worker script imports, so that we are 9 now aligned with the specification: 10 - https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script (Step 5) 11 - https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-imported-script (Step 5) 12 13 This was causing us to fail some Web Platform Tests. 14 15 No new tests, rebaselined existing tests. 16 17 * bindings/js/WorkerModuleScriptLoader.cpp: 18 (WebCore::WorkerModuleScriptLoader::load): 19 * loader/FetchOptions.h: 20 (WebCore::isScriptLikeDestination): 21 * workers/Worker.cpp: 22 (WebCore::Worker::create): 23 * workers/WorkerGlobalScope.cpp: 24 (WebCore::WorkerGlobalScope::importScripts): 25 * workers/WorkerScriptLoader.cpp: 26 (WebCore::WorkerScriptLoader::loadSynchronously): 27 (WebCore::WorkerScriptLoader::loadAsynchronously): 28 (WebCore::constructJavaScriptMIMETypeError): 29 (WebCore::WorkerScriptLoader::validateWorkerResponse): 30 (WebCore::WorkerScriptLoader::didReceiveResponse): 31 * workers/WorkerScriptLoader.h: 32 * workers/service/ServiceWorkerJob.cpp: 33 (WebCore::ServiceWorkerJob::fetchScriptWithContext): 34 * workers/shared/SharedWorkerScriptLoader.cpp: 35 (WebCore::SharedWorkerScriptLoader::load): 36 1 37 2022-02-11 Antoine Quint <graouts@webkit.org> 2 38 -
trunk/Source/WebCore/bindings/js/WorkerModuleScriptLoader.cpp
r288701 r289672 94 94 } 95 95 96 m_scriptLoader->loadAsynchronously(context, WTFMove(request), W TFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, *this, taskMode());96 m_scriptLoader->loadAsynchronously(context, WTFMove(request), WorkerScriptLoader::Source::ModuleScript, WTFMove(fetchOptions), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, *this, taskMode()); 97 97 return true; 98 98 } -
trunk/Source/WebCore/loader/FetchOptions.h
r286288 r289672 108 108 || destination == FetchOptions::Destination::Script 109 109 || destination == FetchOptions::Destination::Serviceworker 110 || destination == FetchOptions::Destination::Sharedworker 110 111 || destination == FetchOptions::Destination::Worker; 111 112 } -
trunk/Source/WebCore/workers/Worker.cpp
r289483 r289672 114 114 request.setInitiatorIdentifier(worker->m_identifier); 115 115 116 worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), workerFetchOptions(worker->m_options, FetchOptions::Destination::Worker), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker.get(), WorkerRunLoop::defaultMode()); 116 auto source = options.type == WorkerType::Module ? WorkerScriptLoader::Source::ModuleScript : WorkerScriptLoader::Source::ClassicWorkerScript; 117 worker->m_scriptLoader->loadAsynchronously(context, WTFMove(request), source, workerFetchOptions(worker->m_options, FetchOptions::Destination::Worker), contentSecurityPolicyEnforcement, ServiceWorkersMode::All, worker.get(), WorkerRunLoop::defaultMode()); 117 118 118 119 return worker; -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r289236 r289672 383 383 auto scriptLoader = WorkerScriptLoader::create(); 384 384 auto cspEnforcement = shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceScriptSrcDirective; 385 if (auto exception = scriptLoader->loadSynchronously(this, url, FetchOptions::Mode::NoCors, cachePolicy, cspEnforcement, resourceRequestIdentifier()))385 if (auto exception = scriptLoader->loadSynchronously(this, url, WorkerScriptLoader::Source::ClassicWorkerImport, FetchOptions::Mode::NoCors, cachePolicy, cspEnforcement, resourceRequestIdentifier())) 386 386 return WTFMove(*exception); 387 387 -
trunk/Source/WebCore/workers/WorkerScriptLoader.cpp
r289489 r289672 53 53 WorkerScriptLoader::~WorkerScriptLoader() = default; 54 54 55 std::optional<Exception> WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, FetchOptions::Cache cachePolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier)55 std::optional<Exception> WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, Source source, FetchOptions::Mode mode, FetchOptions::Cache cachePolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier) 56 56 { 57 57 ASSERT(scriptExecutionContext); … … 60 60 m_url = url; 61 61 m_lastRequestURL = url; 62 m_source = source; 62 63 m_destination = FetchOptions::Destination::Script; 63 64 m_isCOEPEnabled = scriptExecutionContext->settingsValues().crossOriginEmbedderPolicyEnabled; … … 115 116 } 116 117 117 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext& scriptExecutionContext, ResourceRequest&& scriptRequest, FetchOptions&& fetchOptions, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, ServiceWorkersMode serviceWorkerMode, WorkerScriptLoaderClient& client, String&& taskMode)118 void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext& scriptExecutionContext, ResourceRequest&& scriptRequest, Source source, FetchOptions&& fetchOptions, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, ServiceWorkersMode serviceWorkerMode, WorkerScriptLoaderClient& client, String&& taskMode) 118 119 { 119 120 m_client = &client; 120 121 m_url = scriptRequest.url(); 121 122 m_lastRequestURL = scriptRequest.url(); 123 m_source = source; 122 124 m_destination = fetchOptions.destination; 123 125 m_isCOEPEnabled = scriptExecutionContext.settingsValues().crossOriginEmbedderPolicyEnabled; … … 164 166 } 165 167 166 ResourceError WorkerScriptLoader::validateWorkerResponse(const ResourceResponse& response, FetchOptions::Destination destination) 168 static ResourceError constructJavaScriptMIMETypeError(const ResourceResponse& response) 169 { 170 auto message = makeString("Refused to execute ", response.url().stringCenterEllipsizedToLength(), " as script because ", response.mimeType(), " is not a script MIME type."); 171 return { errorDomainWebKitInternal, 0, response.url(), WTFMove(message), ResourceError::Type::AccessControl }; 172 } 173 174 ResourceError WorkerScriptLoader::validateWorkerResponse(const ResourceResponse& response, Source source, FetchOptions::Destination destination) 167 175 { 168 176 if (response.httpStatusCode() / 100 != 2 && response.httpStatusCode()) … … 174 182 } 175 183 176 if (shouldBlockResponseDueToMIMEType(response, destination)) { 177 auto message = makeString("Refused to execute ", response.url().stringCenterEllipsizedToLength(), " as script because ", response.mimeType(), " is not a script MIME type."); 178 return { errorDomainWebKitInternal, 0, response.url(), WTFMove(message), ResourceError::Type::General }; 184 switch (source) { 185 case Source::ClassicWorkerScript: 186 // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script (Step 5) 187 // This is the result a dedicated / shared / service worker script fetch. 188 if (response.url().protocolIsInHTTPFamily() && !MIMETypeRegistry::isSupportedJavaScriptMIMEType(response.mimeType())) 189 return constructJavaScriptMIMETypeError(response); 190 break; 191 case Source::ClassicWorkerImport: 192 // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-imported-script (Step 5). 193 // This is the result of an importScripts() call. 194 if (!MIMETypeRegistry::isSupportedJavaScriptMIMEType(response.mimeType())) 195 return constructJavaScriptMIMETypeError(response); 196 break; 197 case Source::ModuleScript: 198 if (shouldBlockResponseDueToMIMEType(response, destination)) 199 return constructJavaScriptMIMETypeError(response); 200 break; 179 201 } 180 202 … … 189 211 void WorkerScriptLoader::didReceiveResponse(ResourceLoaderIdentifier identifier, const ResourceResponse& response) 190 212 { 191 m_error = validateWorkerResponse(response, m_ destination);213 m_error = validateWorkerResponse(response, m_source, m_destination); 192 214 if (!m_error.isNull()) { 193 215 m_failed = true; -
trunk/Source/WebCore/workers/WorkerScriptLoader.h
r289489 r289672 61 61 } 62 62 63 std::optional<Exception> loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, FetchOptions::Cache, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier); 64 void loadAsynchronously(ScriptExecutionContext&, ResourceRequest&&, FetchOptions&&, ContentSecurityPolicyEnforcement, ServiceWorkersMode, WorkerScriptLoaderClient&, String&& taskMode); 63 enum class Source : uint8_t { ClassicWorkerScript, ClassicWorkerImport, ModuleScript }; 64 65 std::optional<Exception> loadSynchronously(ScriptExecutionContext*, const URL&, Source, FetchOptions::Mode, FetchOptions::Cache, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier); 66 void loadAsynchronously(ScriptExecutionContext&, ResourceRequest&&, Source, FetchOptions&&, ContentSecurityPolicyEnforcement, ServiceWorkersMode, WorkerScriptLoaderClient&, String&& taskMode); 65 67 66 68 void notifyError(); … … 91 93 void cancel(); 92 94 93 WEBCORE_EXPORT static ResourceError validateWorkerResponse(const ResourceResponse&, FetchOptions::Destination);95 WEBCORE_EXPORT static ResourceError validateWorkerResponse(const ResourceResponse&, Source, FetchOptions::Destination); 94 96 95 97 private: … … 112 114 CertificateInfo m_certificateInfo; 113 115 String m_responseMIMEType; 116 Source m_source; 114 117 FetchOptions::Destination m_destination; 115 118 ContentSecurityPolicyResponseHeaders m_contentSecurityPolicy; -
trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp
r289483 r289672 114 114 options.destination = FetchOptions::Destination::Serviceworker; 115 115 options.credentials = FetchOptions::Credentials::SameOrigin; 116 m_scriptLoader->loadAsynchronously(context, WTFMove(request), WTFMove(options), ContentSecurityPolicyEnforcement::DoNotEnforce, ServiceWorkersMode::None, *this, WorkerRunLoop::defaultMode()); 116 117 auto source = m_jobData.workerType == WorkerType::Module ? WorkerScriptLoader::Source::ModuleScript : WorkerScriptLoader::Source::ClassicWorkerScript; 118 m_scriptLoader->loadAsynchronously(context, WTFMove(request), source, WTFMove(options), ContentSecurityPolicyEnforcement::DoNotEnforce, ServiceWorkersMode::None, *this, WorkerRunLoop::defaultMode()); 117 119 } 118 120 -
trunk/Source/WebCore/workers/shared/SharedWorkerScriptLoader.cpp
r289483 r289672 49 49 m_completionHandler = WTFMove(completionHandler); 50 50 51 m_loader->loadAsynchronously(*m_worker->scriptExecutionContext(), ResourceRequest(m_url), m_worker->workerFetchOptions(m_options, FetchOptions::Destination::Sharedworker), ContentSecurityPolicyEnforcement::EnforceWorkerSrcDirective, ServiceWorkersMode::All, *this, WorkerRunLoop::defaultMode()); 51 auto source = m_options.type == WorkerType::Module ? WorkerScriptLoader::Source::ModuleScript : WorkerScriptLoader::Source::ClassicWorkerScript; 52 m_loader->loadAsynchronously(*m_worker->scriptExecutionContext(), ResourceRequest(m_url), source, m_worker->workerFetchOptions(m_options, FetchOptions::Destination::Sharedworker), ContentSecurityPolicyEnforcement::EnforceWorkerSrcDirective, ServiceWorkersMode::All, *this, WorkerRunLoop::defaultMode()); 52 53 } 53 54 -
trunk/Source/WebKit/ChangeLog
r289665 r289672 1 2022-02-11 Chris Dumez <cdumez@apple.com> 2 3 Fix MIME type check for classic worker script fetches 4 https://bugs.webkit.org/show_bug.cgi?id=236411 5 6 Reviewed by Alex Christensen. 7 8 * NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp: 9 (WebKit::ServiceWorkerSoftUpdateLoader::processResponse): 10 1 11 2022-02-11 Wenson Hsieh <wenson_hsieh@apple.com> 2 12 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/ServiceWorkerSoftUpdateLoader.cpp
r289483 r289672 161 161 ResourceError ServiceWorkerSoftUpdateLoader::processResponse(const ResourceResponse& response) 162 162 { 163 auto error = WorkerScriptLoader::validateWorkerResponse(response, FetchOptions::Destination::Serviceworker); 163 auto source = m_jobData.workerType == WorkerType::Module ? WorkerScriptLoader::Source::ModuleScript : WorkerScriptLoader::Source::ClassicWorkerScript; 164 auto error = WorkerScriptLoader::validateWorkerResponse(response, source, FetchOptions::Destination::Serviceworker); 164 165 if (!error.isNull()) 165 166 return error;
Note: See TracChangeset
for help on using the changeset viewer.