WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-164425-20170701194116.patch (text/plain), 107.34 KB, created by
Yusuke Suzuki
on 2017-07-01 03:41:17 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2017-07-01 03:41:17 PDT
Size:
107.34 KB
patch
obsolete
>Subversion Revision: 219047 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 35e2d782d7a2bce83069bcd915fc67cb7f83ee27..029d0088d91d7655a660e0b2c716500086e13d09 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,186 @@ >+2017-07-01 Joseph Pecoraro <pecoraro@apple.com> >+ >+ Worker Script Loads (new Worker(...), importScripts(...)) should be classified as Scripts not Raw requests >+ https://bugs.webkit.org/show_bug.cgi?id=164425 >+ <rdar://problem/29117281> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests. This is a refactoring covered by existing tests. >+ >+ This change moves `new Worker(...)` and `importScripts(...)` Script loading >+ off of WorkerThreadableLoader / DocumentThreadableLoader to a regular >+ CachedScript CachedResourceLoader request. This allows the loads to be treated >+ more like regular script loading. >+ >+ A new CachedResource::WorkerScript type is added for `new Worker(...)` resources. >+ It is a CachedScript just like CachedResource::Script. The only difference is >+ the type of the resource. This is necessary so that CachedResourceLoader can >+ know to use the proper CSP directive during loading. Normal Scripts use "script-src" >+ but Worker scripts use "child-src" in CSP 2.0. This will change again in CSP 3.0 >+ and having the new type should still be useful there. >+ >+ Finally, `importScripts(...)` moves off of the ThreadableLoader path to its >+ own much smaller bridge to load normal scripts through CachedResourceLoader. >+ In order to properly handle CSP during loading of these scripts loading needs >+ to have the loading content information from the Worker scope instead of from >+ the Document's scope. WorkerThreadableLoader already did something similiar. >+ >+ This introduces ResourceLoaderContext to encapsulate the necessary scripting >+ environment context information necessary for loading. This can be set on >+ a CachedResourceRequest and will be consulted by the CachedResourceLoader >+ if available. >+ >+ * CMakeLists.txt: >+ * WebCore.xcodeproj/project.pbxproj: >+ * html/parser/HTMLScriptRunner.cpp: >+ (WebCore::HTMLScriptRunner::runScript): >+ * inspector/InspectorInstrumentation.cpp: >+ (WebCore::InspectorInstrumentation::scriptImportedImpl): Deleted. >+ (WebCore::InspectorInstrumentation::didReceiveScriptResponseImpl): Deleted. >+ * inspector/InspectorInstrumentation.h: >+ (WebCore::InspectorInstrumentation::scriptExecutionBlockedByCSP): >+ (WebCore::InspectorInstrumentation::scriptImported): Deleted. >+ (WebCore::InspectorInstrumentation::didReceiveScriptResponse): Deleted. >+ * inspector/InspectorNetworkAgent.cpp: >+ (WebCore::InspectorNetworkAgent::setInitialScriptContent): Deleted. >+ (WebCore::InspectorNetworkAgent::didReceiveScriptResponse): Deleted. >+ * inspector/InspectorNetworkAgent.h: >+ Remove now unnecessary inspector hooks for worker script loading. From Inspector's >+ point of view the loading is now identical to <script> loading. >+ >+ * inspector/InspectorPageAgent.cpp: >+ (WebCore::InspectorPageAgent::cachedResourceContent): >+ (WebCore::InspectorPageAgent::cachedResourceType): >+ Treat CachedResource::WorkerScript the same as CachedResource::Script. >+ >+ * loader/DocumentThreadableLoader.cpp: >+ (WebCore::DocumentThreadableLoader::redirectReceived): >+ Update comment. WorkerScriptLoader no longer uses DocumentThreadableLoader. >+ >+ (WebCore::DocumentThreadableLoader::isAllowedByContentSecurityPolicy): >+ * loader/LinkLoader.cpp: >+ (WebCore::createLinkPreloadResourceClient): >+ * loader/ResourceLoadInfo.cpp: >+ (WebCore::toResourceType): >+ Handle new CachedResource::WorkerScript type. >+ >+ * loader/ResourceLoaderContext.h: Added. >+ (WebCore::ResourceLoaderContext::create): >+ (WebCore::ResourceLoaderContext::referrer): >+ (WebCore::ResourceLoaderContext::securityOrigin): >+ (WebCore::ResourceLoaderContext::contentSecurityPolicy): >+ Helpers for getting LoaderContext objects or falling back to the Document. >+ >+ (WebCore::ResourceLoaderContext::isolatedCopy): >+ (WebCore::ResourceLoaderContext::ResourceLoaderContext): >+ (WebCore::ResourceLoaderContext::isolatedContentSecurityPolicy): >+ LoaderContext information that can be associated with a CachedResourceRequest. >+ This is everything CachedResourceLoader needs to make the appropriate CORS >+ and CSP decisions while loading the request. >+ >+ * loader/SubresourceLoader.cpp: >+ (WebCore::SubresourceLoader::willSendRequestInternal): >+ (WebCore::logResourceLoaded): >+ * loader/ThreadableLoader.h: >+ * loader/cache/CachedResource.cpp: >+ (WebCore::CachedResource::defaultPriorityForResourceType): >+ (WebCore::deadDecodedDataDeletionIntervalForResourceType): >+ (WebCore::CachedResource::CachedResource): >+ * loader/cache/CachedResource.h: >+ (WebCore::CachedResource::loaderContext): >+ * loader/cache/CachedResourceLoader.cpp: >+ (WebCore::createResource): >+ (WebCore::CachedResourceLoader::requestWorkerScript): >+ (WebCore::contentTypeFromResourceType): >+ Handle new CachedResource::WorkerScript type. >+ >+ (WebCore::CachedResourceLoader::checkInsecureContent): >+ (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy): >+ (WebCore::CachedResourceLoader::canRequest): >+ (WebCore::CachedResourceLoader::canRequestAfterRedirection): >+ (WebCore::CachedResourceLoader::updateRequestAfterRedirection): >+ Use the SecurityOrigin / ContentSecurityPolicy associated with the Resource/Request's >+ LoaderContext. Otherwise fallback with the Document's (normal). >+ >+ (WebCore::CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest): >+ (WebCore::isResourceSuitableForDirectReuse): >+ Match old behavior by disallowing reuse for Worker script loads. >+ It looks like this would be fine if there is an empty CSP associated with it. >+ >+ (WebCore::CachedResourceLoader::prepareFetch): >+ Set the origin based on the LoaderContext's origin. >+ >+ (WebCore::CachedResourceLoader::securityOrigin): >+ (WebCore::CachedResourceLoader::contentSecurityPolicy): >+ * loader/cache/CachedResourceLoader.h: >+ * loader/cache/CachedResourceRequest.h: >+ (WebCore::CachedResourceRequest::loaderContext): >+ (WebCore::CachedResourceRequest::setLoaderContext): >+ Setting a LoaderContext on a request will ensure it gets used during loading. >+ >+ * loader/cache/CachedScript.cpp: >+ (WebCore::CachedScript::CachedScript): >+ * loader/cache/CachedScript.h: >+ (isType): >+ CachedScript may have now have two types (Script or WorkerScript). >+ >+ * loader/cache/MemoryCache.cpp: >+ (WebCore::MemoryCache::getStatistics): >+ Handle new CachedResource::WorkerScript type. >+ >+ * workers/Worker.cpp: >+ * workers/Worker.cpp: >+ (WebCore::Worker::Worker): >+ (WebCore::Worker::create): >+ (WebCore::Worker::~Worker): >+ (WebCore::Worker::requestClassicWorkerScript): >+ (WebCore::Worker::notifyFinished): >+ (WebCore::Worker::dispatchErrorEvent): >+ (WebCore::Worker::didReceiveResponse): Deleted. >+ `new Worker` loads are already on the Main Thread / Document. Just make a >+ CachedResourceRequest for a WorkerScript. >+ >+ * workers/Worker.h: >+ * workers/WorkerGlobalScope.cpp: >+ (WebCore::WorkerGlobalScope::importScripts): >+ `importScripts` loads happen on the Worker Thread. Setup a request but >+ ultimately bridge to the Main Thread to make the CachedResourceRequest. >+ This setups up the ResourceRequest, ResourceLoaderOptions, and ResourceLoaderContext >+ needed and the loader does the rest. >+ >+ * workers/WorkerImportScriptLoader.cpp: Added. >+ (WebCore::WorkerImportScriptLoader::importScriptSynchronously): >+ (WebCore::WorkerImportScriptLoader::importFinished): >+ (WebCore::WorkerImportScriptLoader::MainThreadImportScriptLoader::~MainThreadImportScriptLoader): >+ (WebCore::WorkerImportScriptLoader::MainThreadImportScriptLoader::requestClassicScript): >+ (WebCore::WorkerImportScriptLoader::MainThreadImportScriptLoader::cancel): >+ (WebCore::WorkerImportScriptLoader::MainThreadImportScriptLoader::notifyFinished): >+ (WebCore::WorkerImportScriptLoader::MainThreadImportScriptLoader::importFailed): >+ (WebCore::WorkerImportScriptLoader::MainThreadImportScriptLoader::cleanup): >+ (WebCore::WorkerImportScriptLoader::MainThreadBridge::MainThreadBridge): >+ (WebCore::WorkerImportScriptLoader::MainThreadBridge::requestClassicScript): >+ (WebCore::WorkerImportScriptLoader::MainThreadBridge::cancel): >+ (WebCore::WorkerImportScriptLoader::MainThreadBridge::importFinished): >+ * workers/WorkerImportScriptLoader.h: Added. >+ (WebCore::ImportScriptLoaderClient::~ImportScriptLoaderClient): >+ (WebCore::WorkerImportScriptLoader::create): >+ (WebCore::WorkerImportScriptLoader::responseURL): >+ (WebCore::WorkerImportScriptLoader::script): >+ (WebCore::WorkerImportScriptLoader::failed): >+ (WebCore::WorkerImportScriptLoader::ImportScriptLoaderClientWrapper::create): >+ (WebCore::WorkerImportScriptLoader::ImportScriptLoaderClientWrapper::ImportScriptLoaderClientWrapper): >+ (WebCore::WorkerImportScriptLoader::ImportScriptLoaderClientWrapper::clearClient): >+ Like WorkerThreadableLoader or WorkerThreadableWebSocketChannel this uses >+ a bridge over to the Main Thread to do the load. Unlike other cases this >+ can be simplified because it is always a synchronous load, only loads a single >+ CachedScript, and it can only be canceled from the Worker side. >+ >+ * workers/WorkerScriptLoader.cpp: Removed. >+ * workers/WorkerScriptLoader.h: Removed. >+ * workers/WorkerScriptLoaderClient.h: Removed. >+ Remove old loading implementation that used ThreadableLoader. >+ > 2017-06-30 Said Abou-Hallawa <sabouhallawa@apple.com> > > If an image appears more than once on a page, decoding for painting one instance repaints them all >diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog >index 6508101cde5dee1790cddcf8d1621ca3e629a85a..11f804b32dc4a2c8f21c6764b06b60ed4d87dda7 100644 >--- a/Source/WebKit2/ChangeLog >+++ b/Source/WebKit2/ChangeLog >@@ -1,3 +1,14 @@ >+2017-07-01 Joseph Pecoraro <pecoraro@apple.com> >+ >+ Worker Script Loads (new Worker(...), importScripts(...)) should be classified as Scripts not Raw requests >+ https://bugs.webkit.org/show_bug.cgi?id=164425 >+ <rdar://problem/29117281> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebProcess/Network/WebLoaderStrategy.cpp: >+ (WebKit::maximumBufferingTime): >+ > 2017-06-30 Megan Gardner <megan_gardner@apple.com> > > Unreviewed mac build fix. >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index ce7b168efb4736c60ec1a7690910f4e9e0cd4e0c..f6f88e4a6ded03a00f490f759648f3d7ebb3a3c4 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -2933,11 +2933,11 @@ set(WebCore_SOURCES > workers/WorkerConsoleClient.cpp > workers/WorkerEventQueue.cpp > workers/WorkerGlobalScope.cpp >+ workers/WorkerImportScriptLoader.cpp > workers/WorkerInspectorProxy.cpp > workers/WorkerLocation.cpp > workers/WorkerMessagingProxy.cpp > workers/WorkerRunLoop.cpp >- workers/WorkerScriptLoader.cpp > workers/WorkerThread.cpp > > xml/DOMParser.cpp >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 3e1331aeba3bb3d38b40b6cac9f0e445594bb739..bea9035e878d4e393951945d234a6054ff5375ba 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1314,7 +1314,6 @@ > 2E94F43B119207DA00B7F75D /* JSFileReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E94F439119207DA00B7F75D /* JSFileReader.cpp */; }; > 2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94F43A119207DA00B7F75D /* JSFileReader.h */; }; > 2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */; }; > 2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */; }; > 2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */; }; > 2EB767561DA19B99003E23B5 /* InputEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EB767551DA19B99003E23B5 /* InputEvent.cpp */; }; >@@ -4422,6 +4421,9 @@ > A578F43C1DE01423003DFC6A /* JSPromiseRejectionEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A578F43A1DE013FB003DFC6A /* JSPromiseRejectionEvent.h */; }; > A578F43F1DE0B630003DFC6A /* RejectedPromiseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = A578F43E1DE0B62B003DFC6A /* RejectedPromiseTracker.h */; settings = {ATTRIBUTES = (Private, ); }; }; > A578F4401DE0B634003DFC6A /* RejectedPromiseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A578F43D1DE0B62B003DFC6A /* RejectedPromiseTracker.cpp */; }; >+ A575CFE81E025E2C000ED98F /* WorkerImportScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A575CFE71E025E18000ED98F /* WorkerImportScriptLoader.h */; }; >+ A575CFE91E025E30000ED98F /* WorkerImportScriptLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A575CFE61E025E18000ED98F /* WorkerImportScriptLoader.cpp */; }; >+ A575CFEB1E035323000ED98F /* ResourceLoaderContext.h in Headers */ = {isa = PBXBuildFile; fileRef = A575CFEA1E03531E000ED98F /* ResourceLoaderContext.h */; settings = {ATTRIBUTES = (Private, ); }; }; > A57FD71B1DB9423E006AE24B /* WorkerRuntimeAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A57FD7191DB94236006AE24B /* WorkerRuntimeAgent.cpp */; }; > A57FD71C1DB9423E006AE24B /* WorkerRuntimeAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A57FD71A1DB94236006AE24B /* WorkerRuntimeAgent.h */; }; > A5840E1C187B74D500843B10 /* InspectorInstrumentationCookie.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5840E1A187B74D500843B10 /* InspectorInstrumentationCookie.cpp */; }; >@@ -4536,8 +4538,6 @@ > A7D20F62107F406900A80392 /* JSWebGLActiveInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D20F60107F406900A80392 /* JSWebGLActiveInfo.cpp */; }; > A7D20F63107F406900A80392 /* JSWebGLActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F61107F406900A80392 /* JSWebGLActiveInfo.h */; }; > A7D20F6D107F438B00A80392 /* WebGLActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F6B107F438B00A80392 /* WebGLActiveInfo.h */; }; >- A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */; }; >- A7D6B34A0F61104500B79FD1 /* WorkerScriptLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D6B3480F61104500B79FD1 /* WorkerScriptLoader.cpp */; }; > A7DBF8DD1276919C006B6008 /* TextCheckingHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7DBF8DB1276919C006B6008 /* TextCheckingHelper.cpp */; }; > A7DBF8DE1276919C006B6008 /* TextCheckingHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = A7DBF8DC1276919C006B6008 /* TextCheckingHelper.h */; }; > A80A38FE0E50CC8200A25EBC /* PatternCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A80A38FD0E50CC8200A25EBC /* PatternCG.cpp */; }; >@@ -8929,7 +8929,6 @@ > 2E94F439119207DA00B7F75D /* JSFileReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFileReader.cpp; sourceTree = "<group>"; }; > 2E94F43A119207DA00B7F75D /* JSFileReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFileReader.h; sourceTree = "<group>"; }; > 2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WheelEventDeltaFilterMac.h; sourceTree = "<group>"; }; >- 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptLoaderClient.h; sourceTree = "<group>"; }; > 2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BlobResourceHandle.cpp; sourceTree = "<group>"; }; > 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlobResourceHandle.h; sourceTree = "<group>"; }; > 2EB767531DA19313003E23B5 /* InputEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = InputEvent.idl; sourceTree = "<group>"; }; >@@ -12715,6 +12714,9 @@ > A578F43A1DE013FB003DFC6A /* JSPromiseRejectionEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPromiseRejectionEvent.h; sourceTree = "<group>"; }; > A578F43D1DE0B62B003DFC6A /* RejectedPromiseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RejectedPromiseTracker.cpp; sourceTree = "<group>"; }; > A578F43E1DE0B62B003DFC6A /* RejectedPromiseTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RejectedPromiseTracker.h; sourceTree = "<group>"; }; >+ A575CFE61E025E18000ED98F /* WorkerImportScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerImportScriptLoader.cpp; sourceTree = "<group>"; }; >+ A575CFE71E025E18000ED98F /* WorkerImportScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerImportScriptLoader.h; sourceTree = "<group>"; }; >+ A575CFEA1E03531E000ED98F /* ResourceLoaderContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoaderContext.h; sourceTree = "<group>"; }; > A57FD7191DB94236006AE24B /* WorkerRuntimeAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerRuntimeAgent.cpp; sourceTree = "<group>"; }; > A57FD71A1DB94236006AE24B /* WorkerRuntimeAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerRuntimeAgent.h; sourceTree = "<group>"; }; > A5840E1A187B74D500843B10 /* InspectorInstrumentationCookie.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentationCookie.cpp; sourceTree = "<group>"; }; >@@ -12844,8 +12846,6 @@ > A7D20F60107F406900A80392 /* JSWebGLActiveInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebGLActiveInfo.cpp; sourceTree = "<group>"; }; > A7D20F61107F406900A80392 /* JSWebGLActiveInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebGLActiveInfo.h; sourceTree = "<group>"; }; > A7D20F6B107F438B00A80392 /* WebGLActiveInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGLActiveInfo.h; sourceTree = "<group>"; }; >- A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerScriptLoader.h; sourceTree = "<group>"; }; >- A7D6B3480F61104500B79FD1 /* WorkerScriptLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerScriptLoader.cpp; sourceTree = "<group>"; }; > A7DBF8DB1276919C006B6008 /* TextCheckingHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextCheckingHelper.cpp; sourceTree = "<group>"; }; > A7DBF8DC1276919C006B6008 /* TextCheckingHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextCheckingHelper.h; sourceTree = "<group>"; }; > A7F1F4BA17148BDB00CD4852 /* DOMWindowQuota.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = DOMWindowQuota.idl; sourceTree = "<group>"; }; >@@ -17594,6 +17594,8 @@ > 2E4346370F546A8200B0F1BA /* WorkerGlobalScope.h */, > 2E4346380F546A8200B0F1BA /* WorkerGlobalScope.idl */, > 2E4346390F546A8200B0F1BA /* WorkerGlobalScopeProxy.h */, >+ A575CFE61E025E18000ED98F /* WorkerImportScriptLoader.cpp */, >+ A575CFE71E025E18000ED98F /* WorkerImportScriptLoader.h */, > A54A0C691DB831F10017A90B /* WorkerInspectorProxy.cpp */, > A54A0C6A1DB831F20017A90B /* WorkerInspectorProxy.h */, > 18F831B70FD48C7800D8C56B /* WorkerLoaderProxy.h */, >@@ -17606,9 +17608,6 @@ > 416E29A5102FA962007FC14E /* WorkerReportingProxy.h */, > 2E4346400F546A8200B0F1BA /* WorkerRunLoop.cpp */, > 2E4346410F546A8200B0F1BA /* WorkerRunLoop.h */, >- A7D6B3480F61104500B79FD1 /* WorkerScriptLoader.cpp */, >- A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */, >- 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */, > 2E4346420F546A8200B0F1BA /* WorkerThread.cpp */, > 2E4346430F546A8200B0F1BA /* WorkerThread.h */, > ); >@@ -23990,6 +23989,7 @@ > 7C2FA6101EA95A3200A03108 /* ResourceCryptographicDigest.h */, > 93E227DE0AF589AD00D48324 /* ResourceLoader.cpp */, > 656D37270ADBA5DE00A4554D /* ResourceLoader.h */, >+ A575CFEA1E03531E000ED98F /* ResourceLoaderContext.h */, > D0A3A7301405A39800FB8ED3 /* ResourceLoaderOptions.h */, > 51AF503516F100F60095B2E8 /* ResourceLoaderTypes.h */, > 51EE7B391AA5123100F92B21 /* ResourceLoadInfo.cpp */, >@@ -29328,6 +29328,7 @@ > 514C767B0CE923A1007EF3CD /* ResourceHandleInternal.h in Headers */, > 51E4143416A6596300C633C7 /* ResourceHandleTypes.h in Headers */, > 656D373F0ADBA5DE00A4554D /* ResourceLoader.h in Headers */, >+ A575CFEB1E035323000ED98F /* ResourceLoaderContext.h in Headers */, > D0A3A7311405A39800FB8ED3 /* ResourceLoaderOptions.h in Headers */, > 51AF503616F100F60095B2E8 /* ResourceLoaderTypes.h in Headers */, > 51EE7B381AA50B0500F92B21 /* ResourceLoadInfo.h in Headers */, >@@ -30297,6 +30298,7 @@ > 2E4346490F546A8200B0F1BA /* WorkerGlobalScope.h in Headers */, > 5185FCB41BB4C4E80012898F /* WorkerGlobalScopeIndexedDatabase.h in Headers */, > 2E43464B0F546A8200B0F1BA /* WorkerGlobalScopeProxy.h in Headers */, >+ A575CFE81E025E2C000ED98F /* WorkerImportScriptLoader.h in Headers */, > A54A0C621DB7F8C10017A90B /* WorkerInspectorController.h in Headers */, > A54A0C6C1DB831F90017A90B /* WorkerInspectorProxy.h in Headers */, > 18F831B80FD48C7800D8C56B /* WorkerLoaderProxy.h in Headers */, >@@ -30310,8 +30312,6 @@ > A57FD71C1DB9423E006AE24B /* WorkerRuntimeAgent.h in Headers */, > E1A643F20EC0972500779668 /* WorkerScriptController.h in Headers */, > A54A0C661DB805360017A90B /* WorkerScriptDebugServer.h in Headers */, >- A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */, >- 2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */, > 2E4346550F546A8200B0F1BA /* WorkerThread.h in Headers */, > 0B9056F90F2685F30095FF6A /* WorkerThreadableLoader.h in Headers */, > 97AABD2D14FA09D5007457AE /* WorkerThreadableWebSocketChannel.h in Headers */, >@@ -34019,6 +34019,7 @@ > 2E4346480F546A8200B0F1BA /* WorkerGlobalScope.cpp in Sources */, > 418C395A1C8DD6990051C8A3 /* WorkerGlobalScopeFetch.cpp in Sources */, > 5185FCB31BB4C4E80012898F /* WorkerGlobalScopeIndexedDatabase.cpp in Sources */, >+ A575CFE91E025E30000ED98F /* WorkerImportScriptLoader.cpp in Sources */, > A54A0C611DB7F8C10017A90B /* WorkerInspectorController.cpp in Sources */, > A54A0C6B1DB831F90017A90B /* WorkerInspectorProxy.cpp in Sources */, > 2E43464C0F546A8200B0F1BA /* WorkerLocation.cpp in Sources */, >@@ -34028,7 +34029,6 @@ > A57FD71B1DB9423E006AE24B /* WorkerRuntimeAgent.cpp in Sources */, > E1A643FD0EC097A000779668 /* WorkerScriptController.cpp in Sources */, > A54A0C651DB805360017A90B /* WorkerScriptDebugServer.cpp in Sources */, >- A7D6B34A0F61104500B79FD1 /* WorkerScriptLoader.cpp in Sources */, > 2E4346540F546A8200B0F1BA /* WorkerThread.cpp in Sources */, > 0B9056F80F2685F30095FF6A /* WorkerThreadableLoader.cpp in Sources */, > 97AABD2C14FA09D5007457AE /* WorkerThreadableWebSocketChannel.cpp in Sources */, >diff --git a/Source/WebCore/html/parser/HTMLScriptRunner.cpp b/Source/WebCore/html/parser/HTMLScriptRunner.cpp >index 1a38b1323451649ef0a184f0b1557eff819aaee1..414a83761363674f2807de93ded93f2b857661b0 100644 >--- a/Source/WebCore/html/parser/HTMLScriptRunner.cpp >+++ b/Source/WebCore/html/parser/HTMLScriptRunner.cpp >@@ -237,7 +237,7 @@ void HTMLScriptRunner::runScript(ScriptElement& scriptElement, const TextPositio > ASSERT(m_document); > ASSERT(!hasParserBlockingScript()); > >- // FIXME: This may be too agressive as we always deliver mutations at >+ // FIXME: This may be too aggressive as we always deliver mutations at > // every script element, even if it's not ready to execute yet. There's > // unfortunately no obvious way to tell if prepareScript is going to > // execute the script before calling it. >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.cpp b/Source/WebCore/inspector/InspectorInstrumentation.cpp >index 7236442807305d8bd486c2d7062098d175366554..9fa60cadbf83a06964f70492436d0ef01c477f4d 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.cpp >+++ b/Source/WebCore/inspector/InspectorInstrumentation.cpp >@@ -655,24 +655,12 @@ void InspectorInstrumentation::didLoadXHRSynchronouslyImpl(InstrumentingAgents& > networkAgent->didLoadXHRSynchronously(); > } > >-void InspectorInstrumentation::scriptImportedImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier, const String& sourceString) >-{ >- if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent()) >- networkAgent->setInitialScriptContent(identifier, sourceString); >-} >- > void InspectorInstrumentation::scriptExecutionBlockedByCSPImpl(InstrumentingAgents& instrumentingAgents, const String& directiveText) > { > if (InspectorDebuggerAgent* debuggerAgent = instrumentingAgents.inspectorDebuggerAgent()) > debuggerAgent->scriptExecutionBlockedByCSP(directiveText); > } > >-void InspectorInstrumentation::didReceiveScriptResponseImpl(InstrumentingAgents& instrumentingAgents, unsigned long identifier) >-{ >- if (InspectorNetworkAgent* networkAgent = instrumentingAgents.inspectorNetworkAgent()) >- networkAgent->didReceiveScriptResponse(identifier); >-} >- > void InspectorInstrumentation::domContentLoadedEventFiredImpl(InstrumentingAgents& instrumentingAgents, Frame& frame) > { > if (!frame.isMainFrame()) >diff --git a/Source/WebCore/inspector/InspectorInstrumentation.h b/Source/WebCore/inspector/InspectorInstrumentation.h >index 9e7cc2386a25fac551d0a6840dba0a3b4ae32cc6..a26a95ee858f1d2ddbc44d1b7c0150f6cdc28166 100644 >--- a/Source/WebCore/inspector/InspectorInstrumentation.h >+++ b/Source/WebCore/inspector/InspectorInstrumentation.h >@@ -170,9 +170,7 @@ class InspectorInstrumentation { > static void didFinishXHRLoading(ScriptExecutionContext*, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber); > static void willLoadXHRSynchronously(ScriptExecutionContext*); > static void didLoadXHRSynchronously(ScriptExecutionContext*); >- static void scriptImported(ScriptExecutionContext&, unsigned long identifier, const String& sourceString); > static void scriptExecutionBlockedByCSP(ScriptExecutionContext*, const String& directiveText); >- static void didReceiveScriptResponse(ScriptExecutionContext*, unsigned long identifier); > static void domContentLoadedEventFired(Frame&); > static void loadEventFired(Frame*); > static void frameDetachedFromParent(Frame&); >@@ -344,9 +342,7 @@ class InspectorInstrumentation { > static void didFinishXHRLoadingImpl(InstrumentingAgents&, unsigned long identifier, std::optional<String> decodedText, const String& url, const String& sendURL, unsigned sendLineNumber, unsigned sendColumnNumber); > static void willLoadXHRSynchronouslyImpl(InstrumentingAgents&); > static void didLoadXHRSynchronouslyImpl(InstrumentingAgents&); >- static void scriptImportedImpl(InstrumentingAgents&, unsigned long identifier, const String& sourceString); > static void scriptExecutionBlockedByCSPImpl(InstrumentingAgents&, const String& directiveText); >- static void didReceiveScriptResponseImpl(InstrumentingAgents&, unsigned long identifier); > static void domContentLoadedEventFiredImpl(InstrumentingAgents&, Frame&); > static void loadEventFiredImpl(InstrumentingAgents&, Frame*); > static void frameDetachedFromParentImpl(InstrumentingAgents&, Frame&); >@@ -925,24 +921,12 @@ inline void InspectorInstrumentation::didLoadXHRSynchronously(ScriptExecutionCon > didLoadXHRSynchronouslyImpl(*instrumentingAgents); > } > >-inline void InspectorInstrumentation::scriptImported(ScriptExecutionContext& context, unsigned long identifier, const String& sourceString) >-{ >- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) >- scriptImportedImpl(*instrumentingAgents, identifier, sourceString); >-} >- > inline void InspectorInstrumentation::scriptExecutionBlockedByCSP(ScriptExecutionContext* context, const String& directiveText) > { > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) > scriptExecutionBlockedByCSPImpl(*instrumentingAgents, directiveText); > } > >-inline void InspectorInstrumentation::didReceiveScriptResponse(ScriptExecutionContext* context, unsigned long identifier) >-{ >- if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context)) >- didReceiveScriptResponseImpl(*instrumentingAgents, identifier); >-} >- > inline void InspectorInstrumentation::domContentLoadedEventFired(Frame& frame) > { > if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame)) >diff --git a/Source/WebCore/inspector/InspectorNetworkAgent.cpp b/Source/WebCore/inspector/InspectorNetworkAgent.cpp >index 077b633987d924add643fad1bb293b8535bab982..58ca7fe3334d79a9a583cf1ad704b41caa4eede4 100644 >--- a/Source/WebCore/inspector/InspectorNetworkAgent.cpp >+++ b/Source/WebCore/inspector/InspectorNetworkAgent.cpp >@@ -503,16 +503,6 @@ void InspectorNetworkAgent::didLoadResourceFromMemoryCache(DocumentLoader& loade > m_frontendDispatcher->requestServedFromMemoryCache(requestId, frameId, loaderId, loader.url().string(), timestamp(), initiatorObject, buildObjectForCachedResource(&resource)); > } > >-void InspectorNetworkAgent::setInitialScriptContent(unsigned long identifier, const String& sourceString) >-{ >- m_resourcesData->setResourceContent(IdentifiersFactory::requestId(identifier), sourceString); >-} >- >-void InspectorNetworkAgent::didReceiveScriptResponse(unsigned long identifier) >-{ >- m_resourcesData->setResourceType(IdentifiersFactory::requestId(identifier), InspectorPageAgent::ScriptResource); >-} >- > void InspectorNetworkAgent::didReceiveThreadableLoaderResponse(unsigned long identifier, DocumentThreadableLoader& documentThreadableLoader) > { > String initiator = documentThreadableLoader.options().initiator; >diff --git a/Source/WebCore/inspector/InspectorNetworkAgent.h b/Source/WebCore/inspector/InspectorNetworkAgent.h >index 9bb818f96eefc36712f888e3c9ec618209c1d803..a32d0edd83f311d10f5fa0b0ffcb92fcd136942a 100644 >--- a/Source/WebCore/inspector/InspectorNetworkAgent.h >+++ b/Source/WebCore/inspector/InspectorNetworkAgent.h >@@ -87,7 +87,6 @@ class InspectorNetworkAgent final : public InspectorAgentBase, public Inspector: > void didFinishXHRLoading(unsigned long identifier, const String& decodedText); > void willLoadXHRSynchronously(); > void didLoadXHRSynchronously(); >- void didReceiveScriptResponse(unsigned long identifier); > void willDestroyCachedResource(CachedResource&); > #if ENABLE(WEB_SOCKETS) > void didCreateWebSocket(unsigned long identifier, const URL& requestURL); >@@ -99,7 +98,6 @@ class InspectorNetworkAgent final : public InspectorAgentBase, public Inspector: > void didReceiveWebSocketFrameError(unsigned long identifier, const String&); > #endif > void mainFrameNavigated(DocumentLoader&); >- void setInitialScriptContent(unsigned long identifier, const String& sourceString); > void didScheduleStyleRecalculation(Document&); > > void searchOtherRequests(const JSC::Yarr::RegularExpression&, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Page::SearchResult>>&); >diff --git a/Source/WebCore/inspector/InspectorPageAgent.cpp b/Source/WebCore/inspector/InspectorPageAgent.cpp >index f9b25ed9dae1609fa3411db9e59d42fd16331dec..c857ba7c09277710501fc234407f65bfb8c0c5c2 100644 >--- a/Source/WebCore/inspector/InspectorPageAgent.cpp >+++ b/Source/WebCore/inspector/InspectorPageAgent.cpp >@@ -137,6 +137,7 @@ bool InspectorPageAgent::cachedResourceContent(CachedResource* cachedResource, S > *result = downcast<CachedCSSStyleSheet>(*cachedResource).sheetText(); > return !result->isNull(); > case CachedResource::Script: >+ case CachedResource::WorkerScript: > *result = downcast<CachedScript>(*cachedResource).script().toString(); > return true; > case CachedResource::MediaResource: >@@ -288,6 +289,7 @@ InspectorPageAgent::ResourceType InspectorPageAgent::cachedResourceType(const Ca > case CachedResource::CSSStyleSheet: > return InspectorPageAgent::StylesheetResource; > case CachedResource::Script: >+ case CachedResource::WorkerScript: > return InspectorPageAgent::ScriptResource; > case CachedResource::MainResource: > return InspectorPageAgent::DocumentResource; >diff --git a/Source/WebCore/loader/DocumentThreadableLoader.cpp b/Source/WebCore/loader/DocumentThreadableLoader.cpp >index 494999cc67b646a90f6b7514887be93d6a6148d3..b1b74fb7c2aae31b2f5c6e121e99f345b34d453e 100644 >--- a/Source/WebCore/loader/DocumentThreadableLoader.cpp >+++ b/Source/WebCore/loader/DocumentThreadableLoader.cpp >@@ -231,7 +231,7 @@ void DocumentThreadableLoader::redirectReceived(CachedResource& resource, Resour > Ref<DocumentThreadableLoader> protectedThis(*this); > --m_options.maxRedirectCount; > >- // FIXME: We restrict this check to Fetch API for the moment, as this might disrupt WorkerScriptLoader. >+ // FIXME: We restrict this check to Fetch API for the moment. > // Reassess this check based on https://github.com/whatwg/fetch/issues/393 discussions. > // We should also disable that check in navigation mode. > if (!request.url().protocolIsInHTTPFamily() && m_options.initiator == cachedResourceRequestInitiators().fetch) { >@@ -557,8 +557,6 @@ bool DocumentThreadableLoader::isAllowedByContentSecurityPolicy(const URL& url, > switch (m_options.contentSecurityPolicyEnforcement) { > case ContentSecurityPolicyEnforcement::DoNotEnforce: > return true; >- case ContentSecurityPolicyEnforcement::EnforceChildSrcDirective: >- return contentSecurityPolicy().allowChildContextFromSource(url, redirectResponseReceived); > case ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective: > return contentSecurityPolicy().allowConnectToSource(url, redirectResponseReceived); > case ContentSecurityPolicyEnforcement::EnforceScriptSrcDirective: >diff --git a/Source/WebCore/loader/LinkLoader.cpp b/Source/WebCore/loader/LinkLoader.cpp >index 36fe97bc5ce1975053b8705fb72e3d5ddc807e0f..8d1b25692bc585bed4a5d9ed08940b5b438c2c27 100644 >--- a/Source/WebCore/loader/LinkLoader.cpp >+++ b/Source/WebCore/loader/LinkLoader.cpp >@@ -153,6 +153,7 @@ static std::unique_ptr<LinkPreloadResourceClient> createLinkPreloadResourceClien > case CachedResource::RawResource: > return LinkPreloadRawResourceClient::create(loader, static_cast<CachedRawResource&>(resource)); > case CachedResource::MainResource: >+ case CachedResource::WorkerScript: > case CachedResource::Icon: > #if ENABLE(SVG_FONTS) > case CachedResource::SVGFontResource: >diff --git a/Source/WebCore/loader/ResourceLoadInfo.cpp b/Source/WebCore/loader/ResourceLoadInfo.cpp >index 027b3f7dc665db3f9a612efecab7626313b73428..6c0ff87ce3879dc78c54d7818d58f923c8fca0d1 100644 >--- a/Source/WebCore/loader/ResourceLoadInfo.cpp >+++ b/Source/WebCore/loader/ResourceLoadInfo.cpp >@@ -47,6 +47,7 @@ ResourceType toResourceType(CachedResource::Type type) > return ResourceType::StyleSheet; > > case CachedResource::Script: >+ case CachedResource::WorkerScript: > return ResourceType::Script; > > case CachedResource::FontResource: >diff --git a/Source/WebCore/loader/ResourceLoaderContext.h b/Source/WebCore/loader/ResourceLoaderContext.h >new file mode 100644 >index 0000000000000000000000000000000000000000..7835428ac5d508e24a3758910ec0b0333db5f3cc >--- /dev/null >+++ b/Source/WebCore/loader/ResourceLoaderContext.h >@@ -0,0 +1,80 @@ >+/* >+ * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' >+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, >+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS >+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF >+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS >+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN >+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) >+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF >+ * THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "ContentSecurityPolicy.h" >+#include "SecurityOrigin.h" >+#include <wtf/ThreadSafeRefCounted.h> >+ >+namespace WebCore { >+ >+class ResourceLoaderContext : public ThreadSafeRefCounted<ResourceLoaderContext> { >+ WTF_MAKE_NONCOPYABLE(ResourceLoaderContext); WTF_MAKE_FAST_ALLOCATED; >+public: >+ static Ref<ResourceLoaderContext> create(const String& referrer, SecurityOrigin& securityOrigin, ContentSecurityPolicy& contentSecurityPolicy) >+ { >+ return adoptRef(*new ResourceLoaderContext(referrer, securityOrigin, contentSecurityPolicy)); >+ } >+ >+ String referrer() const { return m_referrer; } >+ SecurityOrigin& securityOrigin() { return m_securityOrigin.get(); } >+ ContentSecurityPolicy& contentSecurityPolicy() const { return *m_contentSecurityPolicy.get(); } >+ >+ Ref<ResourceLoaderContext> isolatedCopy() const >+ { >+ auto referrerCopy = m_referrer.isolatedCopy(); >+ auto securityOriginCopy = m_securityOrigin->isolatedCopy(); >+ auto contentSecurityPolicyCopy = ResourceLoaderContext::isolatedContentSecurityPolicy(securityOriginCopy.get(), *m_contentSecurityPolicy.get()); >+ return adoptRef(*new ResourceLoaderContext(referrerCopy, securityOriginCopy.get(), WTFMove(contentSecurityPolicyCopy))); >+ } >+ >+private: >+ ResourceLoaderContext(const String& referrer, SecurityOrigin& securityOrigin, std::unique_ptr<ContentSecurityPolicy> contentSecurityPolicy) >+ : m_referrer(referrer) >+ , m_securityOrigin(securityOrigin) >+ , m_contentSecurityPolicy(WTFMove(contentSecurityPolicy)) >+ { } >+ >+ ResourceLoaderContext(const String& referrer, SecurityOrigin& securityOrigin, ContentSecurityPolicy& contentSecurityPolicy) >+ : m_referrer(referrer) >+ , m_securityOrigin(securityOrigin) >+ , m_contentSecurityPolicy(ResourceLoaderContext::isolatedContentSecurityPolicy(securityOrigin, contentSecurityPolicy)) >+ { } >+ >+ static std::unique_ptr<ContentSecurityPolicy> isolatedContentSecurityPolicy(const SecurityOrigin& securityOrigin, ContentSecurityPolicy& contentSecurityPolicy) >+ { >+ auto contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(securityOrigin); >+ contentSecurityPolicyCopy->copyStateFrom(&contentSecurityPolicy); >+ contentSecurityPolicyCopy->copyUpgradeInsecureRequestStateFrom(contentSecurityPolicy); >+ return contentSecurityPolicyCopy; >+ } >+ >+ String m_referrer; >+ Ref<SecurityOrigin> m_securityOrigin; >+ std::unique_ptr<ContentSecurityPolicy> m_contentSecurityPolicy; >+}; >+ >+} >diff --git a/Source/WebCore/loader/SubresourceLoader.cpp b/Source/WebCore/loader/SubresourceLoader.cpp >index 5c85b52f1ba609c1eff62d77b25a43ea5d54bea7..9576fafcfef97cf330eb5709a870e81fe5211b19 100644 >--- a/Source/WebCore/loader/SubresourceLoader.cpp >+++ b/Source/WebCore/loader/SubresourceLoader.cpp >@@ -210,7 +210,7 @@ void SubresourceLoader::willSendRequestInternal(ResourceRequest& newRequest, con > m_frame->page()->diagnosticLoggingClient().logDiagnosticMessageWithResult(DiagnosticLoggingKeys::cachedResourceRevalidationKey(), emptyString(), DiagnosticLoggingResultFail, ShouldSample::Yes); > } > >- if (!m_documentLoader->cachedResourceLoader().updateRequestAfterRedirection(m_resource->type(), newRequest, options())) { >+ if (!m_documentLoader->cachedResourceLoader().updateRequestAfterRedirection(*m_resource, newRequest, options())) { > cancel(); > return; > } >@@ -439,6 +439,7 @@ static void logResourceLoaded(Frame* frame, CachedResource::Type type) > resourceType = DiagnosticLoggingKeys::styleSheetKey(); > break; > case CachedResource::Script: >+ case CachedResource::WorkerScript: > resourceType = DiagnosticLoggingKeys::scriptKey(); > break; > case CachedResource::FontResource: >diff --git a/Source/WebCore/loader/ThreadableLoader.h b/Source/WebCore/loader/ThreadableLoader.h >index 630dca05f99dcf3bb482bcaa931cb83fb33600e6..41d7c8b865ed7b6f3c7ef14e025f716499a10d38 100644 >--- a/Source/WebCore/loader/ThreadableLoader.h >+++ b/Source/WebCore/loader/ThreadableLoader.h >@@ -51,7 +51,6 @@ namespace WebCore { > > enum class ContentSecurityPolicyEnforcement { > DoNotEnforce, >- EnforceChildSrcDirective, > EnforceConnectSrcDirective, > EnforceScriptSrcDirective, > }; >diff --git a/Source/WebCore/loader/cache/CachedResource.cpp b/Source/WebCore/loader/cache/CachedResource.cpp >index d8d68fa6b5ec36353887f6006df867801be12ac7..22f78436f1b0dc515dc94fee77fb99d5bae80fef 100644 >--- a/Source/WebCore/loader/cache/CachedResource.cpp >+++ b/Source/WebCore/loader/cache/CachedResource.cpp >@@ -71,6 +71,7 @@ ResourceLoadPriority CachedResource::defaultPriorityForResourceType(Type type) > return ResourceLoadPriority::VeryHigh; > case CachedResource::CSSStyleSheet: > case CachedResource::Script: >+ case CachedResource::WorkerScript: > return ResourceLoadPriority::High; > #if ENABLE(SVG_FONTS) > case CachedResource::SVGFontResource: >@@ -105,7 +106,7 @@ ResourceLoadPriority CachedResource::defaultPriorityForResourceType(Type type) > > static Seconds deadDecodedDataDeletionIntervalForResourceType(CachedResource::Type type) > { >- if (type == CachedResource::Script) >+ if (type == CachedResource::Script || type == CachedResource::WorkerScript) > return 0_s; > > return MemoryCache::singleton().deadDecodedDataDeletionInterval(); >@@ -116,6 +117,7 @@ DEFINE_DEBUG_ONLY_GLOBAL(RefCountedLeakCounter, cachedResourceLeakCounter, ("Cac > CachedResource::CachedResource(CachedResourceRequest&& request, Type type, SessionID sessionID) > : m_resourceRequest(request.releaseResourceRequest()) > , m_options(request.options()) >+ , m_loaderContext(request.loaderContext()) > , m_decodedDataDeletionTimer(*this, &CachedResource::destroyDecodedData, deadDecodedDataDeletionIntervalForResourceType(type)) > , m_sessionID(sessionID) > , m_loadPriority(defaultPriorityForResourceType(type)) >diff --git a/Source/WebCore/loader/cache/CachedResource.h b/Source/WebCore/loader/cache/CachedResource.h >index 242ffaca27dbb52192ffa701ce23c39a9e2cd74b..aec4f326d1feb6694ab49de5c74f520823fb3788 100644 >--- a/Source/WebCore/loader/cache/CachedResource.h >+++ b/Source/WebCore/loader/cache/CachedResource.h >@@ -27,6 +27,7 @@ > #include "FrameLoaderTypes.h" > #include "ResourceError.h" > #include "ResourceLoadPriority.h" >+#include "ResourceLoaderContext.h" > #include "ResourceLoaderOptions.h" > #include "ResourceRequest.h" > #include "ResourceResponse.h" >@@ -65,6 +66,7 @@ class CachedResource { > ImageResource, > CSSStyleSheet, > Script, >+ WorkerScript, > FontResource, > #if ENABLE(SVG_FONTS) > SVGFontResource, >@@ -72,16 +74,16 @@ class CachedResource { > MediaResource, > RawResource, > Icon, >- SVGDocumentResource >+ SVGDocumentResource, > #if ENABLE(XSLT) >- , XSLStyleSheet >+ XSLStyleSheet, > #endif > #if ENABLE(LINK_PREFETCH) >- , LinkPrefetch >- , LinkSubresource >+ LinkPrefetch, >+ LinkSubresource, > #endif > #if ENABLE(VIDEO_TRACK) >- , TextTrackResource >+ TextTrackResource, > #endif > }; > >@@ -90,7 +92,7 @@ class CachedResource { > Pending, // only partially loaded > Cached, // regular case > LoadError, >- DecodeError >+ DecodeError, > }; > > CachedResource(CachedResourceRequest&&, Type, SessionID); >@@ -225,6 +227,8 @@ class CachedResource { > bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; } > const FetchOptions& options() const { return m_options; } > >+ ResourceLoaderContext* loaderContext() const { return m_loaderContext.get(); } >+ > virtual void destroyDecodedData() { } > > void setOwningCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) { m_owningCachedResourceLoader = cachedResourceLoader; } >@@ -292,6 +296,7 @@ class CachedResource { > ResourceRequest m_resourceRequest; > RefPtr<SubresourceLoader> m_loader; > ResourceLoaderOptions m_options; >+ RefPtr<ResourceLoaderContext> m_loaderContext; > ResourceResponse m_response; > ResourceResponse::Tainting m_responseTainting { ResourceResponse::Tainting::Basic }; > RefPtr<SharedBuffer> m_data; >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.cpp b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >index dea7bc91c9bdd1f7e0edb32f079bf99df4b4cf5d..c20f5256b042dbe965471a77ac3b232e27e5b1aa 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.cpp >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.cpp >@@ -94,7 +94,9 @@ static CachedResource* createResource(CachedResource::Type type, CachedResourceR > case CachedResource::CSSStyleSheet: > return new CachedCSSStyleSheet(WTFMove(request), sessionID); > case CachedResource::Script: >- return new CachedScript(WTFMove(request), sessionID); >+ return new CachedScript(WTFMove(request), CachedResource::Script, sessionID); >+ case CachedResource::WorkerScript: >+ return new CachedScript(WTFMove(request), CachedResource::WorkerScript, sessionID); > case CachedResource::SVGDocumentResource: > return new CachedSVGDocument(WTFMove(request), sessionID); > #if ENABLE(SVG_FONTS) >@@ -251,6 +253,11 @@ CachedResourceHandle<CachedScript> CachedResourceLoader::requestScript(CachedRes > return downcast<CachedScript>(requestResource(CachedResource::Script, WTFMove(request)).get()); > } > >+CachedResourceHandle<CachedScript> CachedResourceLoader::requestWorkerScript(CachedResourceRequest&& request) >+{ >+ return downcast<CachedScript>(requestResource(CachedResource::WorkerScript, WTFMove(request)).get()); >+} >+ > #if ENABLE(XSLT) > CachedResourceHandle<CachedXSLStyleSheet> CachedResourceLoader::requestXSLStyleSheet(CachedResourceRequest&& request) > { >@@ -304,6 +311,7 @@ static MixedContentChecker::ContentType contentTypeFromResourceType(CachedResour > > case CachedResource::CSSStyleSheet: > case CachedResource::Script: >+ case CachedResource::WorkerScript: > case CachedResource::FontResource: > return MixedContentChecker::ContentType::Active; > >@@ -344,6 +352,7 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const > > switch (type) { > case CachedResource::Script: >+ case CachedResource::WorkerScript: > #if ENABLE(XSLT) > case CachedResource::XSLStyleSheet: > #endif >@@ -391,44 +400,47 @@ bool CachedResourceLoader::checkInsecureContent(CachedResource::Type type, const > return true; > } > >-bool CachedResourceLoader::allowedByContentSecurityPolicy(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived) const >+bool CachedResourceLoader::allowedByContentSecurityPolicy(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options, ContentSecurityPolicy* contentSecurityPolicy, ContentSecurityPolicy::RedirectResponseReceived redirectResponseReceived) const > { > if (options.contentSecurityPolicyImposition == ContentSecurityPolicyImposition::SkipPolicyCheck) > return true; > >- ASSERT(m_document); >- ASSERT(m_document->contentSecurityPolicy()); >+ ASSERT(contentSecurityPolicy); > > switch (type) { > #if ENABLE(XSLT) > case CachedResource::XSLStyleSheet: > #endif > case CachedResource::Script: >- if (!m_document->contentSecurityPolicy()->allowScriptFromSource(url, redirectResponseReceived)) >+ if (!contentSecurityPolicy->allowScriptFromSource(url, redirectResponseReceived)) > return false; > break; >+ case CachedResource::WorkerScript: >+ if (!contentSecurityPolicy->allowChildContextFromSource(url, redirectResponseReceived)) >+ return false; >+ break; > case CachedResource::CSSStyleSheet: >- if (!m_document->contentSecurityPolicy()->allowStyleFromSource(url, redirectResponseReceived)) >+ if (!contentSecurityPolicy->allowStyleFromSource(url, redirectResponseReceived)) > return false; > break; > case CachedResource::SVGDocumentResource: > case CachedResource::Icon: > case CachedResource::ImageResource: >- if (!m_document->contentSecurityPolicy()->allowImageFromSource(url, redirectResponseReceived)) >+ if (!contentSecurityPolicy->allowImageFromSource(url, redirectResponseReceived)) > return false; > break; > #if ENABLE(SVG_FONTS) > case CachedResource::SVGFontResource: > #endif > case CachedResource::FontResource: >- if (!m_document->contentSecurityPolicy()->allowFontFromSource(url, redirectResponseReceived)) >+ if (!contentSecurityPolicy->allowFontFromSource(url, redirectResponseReceived)) > return false; > break; > case CachedResource::MediaResource: > #if ENABLE(VIDEO_TRACK) > case CachedResource::TextTrackResource: > #endif >- if (!m_document->contentSecurityPolicy()->allowMediaFromSource(url, redirectResponseReceived)) >+ if (!contentSecurityPolicy->allowMediaFromSource(url, redirectResponseReceived)) > return false; > break; > case CachedResource::RawResource: >@@ -450,6 +462,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, > { > auto& options = request.options(); > >+ // FIXME: Should this canDisplay apply for workers? > if (document() && !document()->securityOrigin().canDisplay(url)) { > if (forPreload == ForPreload::No) > FrameLoader::reportLocalLoadFailed(frame(), url.stringCenterEllipsizedToLength()); >@@ -457,12 +470,12 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, > return false; > } > >- if (options.mode == FetchOptions::Mode::SameOrigin && !m_document->securityOrigin().canRequest(url) && !isSameOriginDataURL(url, options)) { >+ if (options.mode == FetchOptions::Mode::SameOrigin && !securityOrigin(request)->canRequest(url) && !isSameOriginDataURL(url, options)) { > printAccessDeniedMessage(url); > return false; > } > >- if (!allowedByContentSecurityPolicy(type, url, options, ContentSecurityPolicy::RedirectResponseReceived::No)) >+ if (!allowedByContentSecurityPolicy(type, url, options, contentSecurityPolicy(request), ContentSecurityPolicy::RedirectResponseReceived::No)) > return false; > > // SVG Images have unique security rules that prevent all subresource requests except for data urls. >@@ -482,8 +495,9 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const URL& url, > } > > // FIXME: Should we find a way to know whether the redirection is for a preload request like we do for CachedResourceLoader::canRequest? >-bool CachedResourceLoader::canRequestAfterRedirection(CachedResource::Type type, const URL& url, const ResourceLoaderOptions& options) const >+bool CachedResourceLoader::canRequestAfterRedirection(const CachedResource& resource, const URL& url, const ResourceLoaderOptions& options) const > { >+ // FIXME: Should this canDisplay apply for workers? > if (document() && !document()->securityOrigin().canDisplay(url)) { > FrameLoader::reportLocalLoadFailed(frame(), url.stringCenterEllipsizedToLength()); > LOG(ResourceLoading, "CachedResourceLoader::requestResource URL was not allowed by SecurityOrigin::canDisplay"); >@@ -493,23 +507,23 @@ bool CachedResourceLoader::canRequestAfterRedirection(CachedResource::Type type, > // FIXME: According to https://fetch.spec.whatwg.org/#http-redirect-fetch, we should check that the URL is HTTP(s) except if in navigation mode. > // But we currently allow at least data URLs to be loaded. > >- if (options.mode == FetchOptions::Mode::SameOrigin && !m_document->securityOrigin().canRequest(url)) { >+ if (options.mode == FetchOptions::Mode::SameOrigin && !securityOrigin(resource)->canRequest(url)) { > printAccessDeniedMessage(url); > return false; > } > >- if (!allowedByContentSecurityPolicy(type, url, options, ContentSecurityPolicy::RedirectResponseReceived::Yes)) >+ if (!allowedByContentSecurityPolicy(resource.type(), url, options, contentSecurityPolicy(resource), ContentSecurityPolicy::RedirectResponseReceived::Yes)) > return false; > > // Last of all, check for insecure content. We do this last so that when folks block insecure content with a CSP policy, they don't get a warning. > // They'll still get a warning in the console about CSP blocking the load. >- if (!checkInsecureContent(type, url)) >+ if (!checkInsecureContent(resource.type(), url)) > return false; > > return true; > } > >-bool CachedResourceLoader::updateRequestAfterRedirection(CachedResource::Type type, ResourceRequest& request, const ResourceLoaderOptions& options) >+bool CachedResourceLoader::updateRequestAfterRedirection(const CachedResource& resource, ResourceRequest& request, const ResourceLoaderOptions& options) > { > ASSERT(m_documentLoader); > if (auto* document = m_documentLoader->cachedResourceLoader().document()) >@@ -517,7 +531,7 @@ bool CachedResourceLoader::updateRequestAfterRedirection(CachedResource::Type ty > > // FIXME: We might want to align the checks done here with the ones done in CachedResourceLoader::requestResource, content extensions blocking in particular. > >- return canRequestAfterRedirection(type, request.url(), options); >+ return canRequestAfterRedirection(resource, request.url(), options); > } > > bool CachedResourceLoader::canRequestInContentDispositionAttachmentSandbox(CachedResource::Type type, const URL& url) const >@@ -602,6 +616,10 @@ bool CachedResourceLoader::shouldUpdateCachedResourceWithCurrentRequest(const Ca > if (resource.options().redirect != request.options().redirect && resource.hasRedirections()) > return true; > >+ // FIXME: Worker cached resource loads may have a different CSP to enforce. >+ if (request.loaderContext()) >+ return true; >+ > return false; > } > >@@ -626,6 +644,10 @@ static inline bool isResourceSuitableForDirectReuse(const CachedResource& resour > if (resource.type() == CachedResource::Type::RawResource || resource.type() == CachedResource::Type::MediaResource) > return false; > >+ // FIXME: Implement reuse of Worker cached resource loads. >+ if (request.loaderContext()) >+ return false; >+ > return true; > } > >@@ -652,8 +674,12 @@ void CachedResourceLoader::prepareFetch(CachedResource::Type type, CachedResourc > { > // Implementing step 1 to 7 of https://fetch.spec.whatwg.org/#fetching > >- if (!request.origin() && document()) >- request.setOrigin(document()->securityOrigin()); >+ if (!request.origin()) { >+ if (request.loaderContext()) >+ request.setOrigin(request.loaderContext()->securityOrigin()); >+ else if (document()) >+ request.setOrigin(document()->securityOrigin()); >+ } > > request.setAcceptHeaderIfNone(type); > >@@ -1307,4 +1333,32 @@ bool CachedResourceLoader::isAlwaysOnLoggingAllowed() const > return m_documentLoader ? m_documentLoader->isAlwaysOnLoggingAllowed() : true; > } > >+SecurityOrigin* CachedResourceLoader::securityOrigin(const CachedResource& resource) const >+{ >+ if (resource.loaderContext()) >+ return &resource.loaderContext()->securityOrigin(); >+ return m_document ? &m_document->securityOrigin() : nullptr; >+} >+ >+ContentSecurityPolicy* CachedResourceLoader::contentSecurityPolicy(const CachedResource& resource) const >+{ >+ if (resource.loaderContext()) >+ return &resource.loaderContext()->contentSecurityPolicy(); >+ return m_document ? m_document->contentSecurityPolicy() : nullptr; >+} >+ >+SecurityOrigin* CachedResourceLoader::securityOrigin(const CachedResourceRequest& request) const >+{ >+ if (request.loaderContext()) >+ return &request.loaderContext()->securityOrigin(); >+ return m_document ? &m_document->securityOrigin() : nullptr; >+} >+ >+ContentSecurityPolicy* CachedResourceLoader::contentSecurityPolicy(const CachedResourceRequest& request) const >+{ >+ if (request.loaderContext()) >+ return &request.loaderContext()->contentSecurityPolicy(); >+ return m_document ? m_document->contentSecurityPolicy() : nullptr; >+} >+ > } >diff --git a/Source/WebCore/loader/cache/CachedResourceLoader.h b/Source/WebCore/loader/cache/CachedResourceLoader.h >index c206def1e26ea6268a2a5fcbfdac859a17b27360..9b031be37cb4b43d59606d02e3cb70632c130bde 100644 >--- a/Source/WebCore/loader/cache/CachedResourceLoader.h >+++ b/Source/WebCore/loader/cache/CachedResourceLoader.h >@@ -40,17 +40,19 @@ > namespace WebCore { > > class CachedCSSStyleSheet; >-class CachedSVGDocument; > class CachedFont; > class CachedImage; > class CachedRawResource; >+class CachedSVGDocument; > class CachedScript; > class CachedTextTrack; > class CachedXSLStyleSheet; >+class ContentSecurityPolicy; > class Document; > class DocumentLoader; > class Frame; > class ImageLoader; >+class SecurityOrigin; > class Settings; > class URL; > >@@ -75,6 +77,7 @@ friend class ResourceCacheValidationSuppressor; > CachedResourceHandle<CachedCSSStyleSheet> requestCSSStyleSheet(CachedResourceRequest&&); > CachedResourceHandle<CachedCSSStyleSheet> requestUserCSSStyleSheet(CachedResourceRequest&&); > CachedResourceHandle<CachedScript> requestScript(CachedResourceRequest&&); >+ CachedResourceHandle<CachedScript> requestWorkerScript(CachedResourceRequest&&); > CachedResourceHandle<CachedFont> requestFont(CachedResourceRequest&&, bool isSVG); > CachedResourceHandle<CachedRawResource> requestMedia(CachedResourceRequest&&); > CachedResourceHandle<CachedRawResource> requestIcon(CachedResourceRequest&&); >@@ -135,7 +138,7 @@ friend class ResourceCacheValidationSuppressor; > void warnUnusedPreloads(); > void stopUnusedPreloadsTimer(); > >- bool updateRequestAfterRedirection(CachedResource::Type, ResourceRequest&, const ResourceLoaderOptions&); >+ bool updateRequestAfterRedirection(const CachedResource&, ResourceRequest&, const ResourceLoaderOptions&); > > static const ResourceLoaderOptions& defaultCachedResourceOptions(); > >@@ -171,16 +174,21 @@ friend class ResourceCacheValidationSuppressor; > > bool shouldContinueAfterNotifyingLoadedFromMemoryCache(const CachedResourceRequest&, CachedResource*); > bool checkInsecureContent(CachedResource::Type, const URL&) const; >- bool allowedByContentSecurityPolicy(CachedResource::Type, const URL&, const ResourceLoaderOptions&, ContentSecurityPolicy::RedirectResponseReceived) const; >+ bool allowedByContentSecurityPolicy(CachedResource::Type, const URL&, const ResourceLoaderOptions&, ContentSecurityPolicy*, ContentSecurityPolicy::RedirectResponseReceived) const; > > void performPostLoadActions(); > > bool clientDefersImage(const URL&) const; > void reloadImagesIfNotDeferred(); > >- bool canRequestAfterRedirection(CachedResource::Type, const URL&, const ResourceLoaderOptions&) const; >+ bool canRequestAfterRedirection(const CachedResource&, const URL&, const ResourceLoaderOptions&) const; > bool canRequestInContentDispositionAttachmentSandbox(CachedResource::Type, const URL&) const; > >+ SecurityOrigin* securityOrigin(const CachedResource&) const; >+ ContentSecurityPolicy* contentSecurityPolicy(const CachedResource&) const; >+ SecurityOrigin* securityOrigin(const CachedResourceRequest&) const; >+ ContentSecurityPolicy* contentSecurityPolicy(const CachedResourceRequest&) const; >+ > HashSet<String> m_validatedURLs; > mutable DocumentResourceMap m_documentResources; > Document* m_document; >diff --git a/Source/WebCore/loader/cache/CachedResourceRequest.h b/Source/WebCore/loader/cache/CachedResourceRequest.h >index 262ea519809e3db419ea202f76fc3705349260f3..d6976bc0b17e1e745d39e940394d4f6aa0502722 100644 >--- a/Source/WebCore/loader/cache/CachedResourceRequest.h >+++ b/Source/WebCore/loader/cache/CachedResourceRequest.h >@@ -28,6 +28,7 @@ > #include "CachedResource.h" > #include "Element.h" > #include "ResourceLoadPriority.h" >+#include "ResourceLoaderContext.h" > #include "ResourceLoaderOptions.h" > #include "ResourceRequest.h" > #include "SecurityOrigin.h" >@@ -63,6 +64,9 @@ class CachedResourceRequest { > bool allowsCaching() const { return m_options.cachingPolicy == CachingPolicy::AllowCaching; } > void setCachingPolicy(CachingPolicy policy) { m_options.cachingPolicy = policy; } > >+ ResourceLoaderContext* loaderContext() const { return m_loaderContext.get(); } >+ void setLoaderContext(RefPtr<ResourceLoaderContext>&& context) { m_loaderContext = WTFMove(context); } >+ > void setAsPotentiallyCrossOrigin(const String&, Document&); > void updateForAccessControl(Document&); > >@@ -93,6 +97,7 @@ class CachedResourceRequest { > String m_charset; > ResourceLoaderOptions m_options; > std::optional<ResourceLoadPriority> m_priority; >+ RefPtr<ResourceLoaderContext> m_loaderContext; > RefPtr<Element> m_initiatorElement; > AtomicString m_initiatorName; > RefPtr<SecurityOrigin> m_origin; >diff --git a/Source/WebCore/loader/cache/CachedScript.cpp b/Source/WebCore/loader/cache/CachedScript.cpp >index 986b07911c77d9a8f8fe4aa49abff9b942d72e52..d0775c682ff434d1f032d598a47374a51b5567cb 100644 >--- a/Source/WebCore/loader/cache/CachedScript.cpp >+++ b/Source/WebCore/loader/cache/CachedScript.cpp >@@ -36,8 +36,8 @@ > > namespace WebCore { > >-CachedScript::CachedScript(CachedResourceRequest&& request, SessionID sessionID) >- : CachedResource(WTFMove(request), Script, sessionID) >+CachedScript::CachedScript(CachedResourceRequest&& request, CachedResource::Type type, SessionID sessionID) >+ : CachedResource(WTFMove(request), type, sessionID) > , m_decoder(TextResourceDecoder::create(ASCIILiteral("application/javascript"), request.charset())) > { > } >diff --git a/Source/WebCore/loader/cache/CachedScript.h b/Source/WebCore/loader/cache/CachedScript.h >index 6bb0f312f3c679ee69dc380f2106a098d87f226d..9574c295c211f007e1d0f3a984e0fc3abe433d38 100644 >--- a/Source/WebCore/loader/cache/CachedScript.h >+++ b/Source/WebCore/loader/cache/CachedScript.h >@@ -33,7 +33,7 @@ class TextResourceDecoder; > > class CachedScript final : public CachedResource { > public: >- CachedScript(CachedResourceRequest&&, SessionID); >+ CachedScript(CachedResourceRequest&&, CachedResource::Type, SessionID); > virtual ~CachedScript(); > > StringView script(); >@@ -64,4 +64,6 @@ class CachedScript final : public CachedResource { > > } // namespace WebCore > >-SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedScript, CachedResource::Script) >+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::CachedScript) >+ static bool isType(const WebCore::CachedResource& resource) { return resource.type() == WebCore::CachedResource::Script || resource.type() == WebCore::CachedResource::WorkerScript; } >+SPECIALIZE_TYPE_TRAITS_END() >diff --git a/Source/WebCore/loader/cache/MemoryCache.cpp b/Source/WebCore/loader/cache/MemoryCache.cpp >index 62df190ffa1e439d0c15b55678ec61eb33506654..61a14190ff6b17671af0f350d703f718e694ed53 100644 >--- a/Source/WebCore/loader/cache/MemoryCache.cpp >+++ b/Source/WebCore/loader/cache/MemoryCache.cpp >@@ -665,6 +665,7 @@ MemoryCache::Statistics MemoryCache::getStatistics() > stats.cssStyleSheets.addResource(*resource); > break; > case CachedResource::Script: >+ case CachedResource::WorkerScript: > stats.scripts.addResource(*resource); > break; > #if ENABLE(XSLT) >diff --git a/Source/WebCore/workers/Worker.cpp b/Source/WebCore/workers/Worker.cpp >index f7053d6495c421b258d6cc3ea057dc43c045da0c..f2d82eba1eea7a6f4b61846d08e6fea4dc4f7090 100644 >--- a/Source/WebCore/workers/Worker.cpp >+++ b/Source/WebCore/workers/Worker.cpp >@@ -27,7 +27,8 @@ > #include "config.h" > #include "Worker.h" > >-#include "ContentSecurityPolicy.h" >+#include "CachedResourceLoader.h" >+#include "ContentSecurityPolicyResponseHeaders.h" > #include "Event.h" > #include "EventNames.h" > #include "InspectorInstrumentation.h" >@@ -35,7 +36,6 @@ > #include "ResourceResponse.h" > #include "SecurityOrigin.h" > #include "WorkerGlobalScopeProxy.h" >-#include "WorkerScriptLoader.h" > #include "WorkerThread.h" > #include <inspector/IdentifiersFactory.h> > #include <wtf/HashSet.h> >@@ -55,6 +55,7 @@ inline Worker::Worker(ScriptExecutionContext& context, JSC::RuntimeFlags runtime > : ActiveDOMObject(&context) > , m_identifier("worker:" + Inspector::IdentifiersFactory::createIdentifier()) > , m_contextProxy(WorkerGlobalScopeProxy::create(*this)) >+ , m_shouldBypassMainWorldContentSecurityPolicy(context.shouldBypassMainWorldContentSecurityPolicy()) > , m_runtimeFlags(runtimeFlags) > { > if (!allWorkers) { >@@ -77,22 +78,19 @@ ExceptionOr<Ref<Worker>> Worker::create(ScriptExecutionContext& context, JSC::Ru > > worker->suspendIfNeeded(); > >- bool shouldBypassMainWorldContentSecurityPolicy = context.shouldBypassMainWorldContentSecurityPolicy(); >- auto scriptURL = worker->resolveURL(url, shouldBypassMainWorldContentSecurityPolicy); >+ auto scriptURL = worker->resolveURL(url, context.shouldBypassMainWorldContentSecurityPolicy()); > if (scriptURL.hasException()) > return scriptURL.releaseException(); > >- worker->m_shouldBypassMainWorldContentSecurityPolicy = shouldBypassMainWorldContentSecurityPolicy; >- > // The worker context does not exist while loading, so we must ensure that the worker object is not collected, nor are its event listeners. > worker->setPendingActivity(worker.ptr()); > > // https://html.spec.whatwg.org/multipage/workers.html#official-moment-of-creation > worker->m_workerCreationTime = MonotonicTime::now(); > >- worker->m_scriptLoader = WorkerScriptLoader::create(); >- auto contentSecurityPolicyEnforcement = shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceChildSrcDirective; >- worker->m_scriptLoader->loadAsynchronously(&context, scriptURL.releaseReturnValue(), FetchOptions::Mode::SameOrigin, contentSecurityPolicyEnforcement, worker->m_identifier, worker.ptr()); >+ // FIXME: Allow creating Workers with options dictionary to allow loading class or module Worker scripts. >+ worker->requestClassicWorkerScript(scriptURL.releaseReturnValue()); >+ > return WTFMove(worker); > } > >@@ -100,6 +98,7 @@ Worker::~Worker() > { > ASSERT(isMainThread()); > ASSERT(scriptExecutionContext()); // The context is protected by worker context proxy, so it cannot be destroyed while a Worker exists. >+ ASSERT(!m_cachedScript); > allWorkers->remove(this); > m_contextProxy.workerObjectDestroyed(); > } >@@ -124,6 +123,71 @@ void Worker::terminate() > m_contextProxy.terminateWorkerGlobalScope(); > } > >+// https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-script >+void Worker::requestClassicWorkerScript(const URL& url) >+{ >+ ASSERT(!m_cachedScript); >+ >+ ASSERT_WITH_SECURITY_IMPLICATION(m_shouldBypassMainWorldContentSecurityPolicy || scriptExecutionContext()->contentSecurityPolicy()->allowChildContextFromSource(url, ContentSecurityPolicy::RedirectResponseReceived::No)); >+ >+ ResourceRequest request(url); >+ request.setHTTPMethod(ASCIILiteral("GET")); >+ request.setInitiatorIdentifier(m_identifier); >+ >+ ResourceLoaderOptions options; >+ options.credentials = FetchOptions::Credentials::SameOrigin; >+ options.mode = FetchOptions::Mode::SameOrigin; >+ options.sendLoadCallbacks = SendCallbacks; >+ options.contentSecurityPolicyImposition = m_shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck; >+ >+ CachedResourceRequest cachedResourceRequest(WTFMove(request), options); >+ cachedResourceRequest.setCharset(ASCIILiteral("UTF-8")); >+ >+ Document& document = downcast<Document>(*scriptExecutionContext()); >+ m_cachedScript = document.cachedResourceLoader().requestWorkerScript(WTFMove(cachedResourceRequest)); >+ >+ if (!m_cachedScript) { >+ dispatchErrorEvent(); >+ unsetPendingActivity(this); >+ return; >+ } >+ >+ m_cachedScript->addClient(*this); >+} >+ >+void Worker::notifyFinished(CachedResource& resource) >+{ >+ ASSERT(m_cachedScript.get() == &resource); >+ >+ auto response = resource.response(); >+ >+ if (resource.loadFailedOrCanceled()) >+ dispatchErrorEvent(); >+ else if (response.httpStatusCode() && !response.isSuccessful()) >+ dispatchErrorEvent(); >+ else { >+ auto url = response.url(); >+ auto userAgent = scriptExecutionContext()->userAgent(url); >+ auto script = m_cachedScript.get()->script().toString(); >+ >+ auto contentSecurityPolicyResponseHeaders = scriptExecutionContext()->contentSecurityPolicy()->responseHeaders(); >+ if (!url.protocolIsBlob() && !url.protocolIs("file") && !SecurityOrigin::create(url)->isUnique()) >+ contentSecurityPolicyResponseHeaders = ContentSecurityPolicyResponseHeaders(response); >+ >+ m_contextProxy.startWorkerGlobalScope(url, userAgent, script, contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags); >+ } >+ >+ m_cachedScript->removeClient(*this); >+ m_cachedScript = nullptr; >+ >+ unsetPendingActivity(this); >+} >+ >+void Worker::dispatchErrorEvent() >+{ >+ dispatchEvent(Event::create(eventNames().errorEvent, false, true)); >+} >+ > bool Worker::canSuspendForDocumentSuspension() const > { > // FIXME: It is not currently possible to suspend a worker, so pages with workers can not go into page cache. >@@ -150,26 +214,4 @@ void Worker::notifyNetworkStateChange(bool isOnLine) > m_contextProxy.notifyNetworkStateChange(isOnLine); > } > >-void Worker::didReceiveResponse(unsigned long identifier, const ResourceResponse& response) >-{ >- const URL& responseURL = response.url(); >- if (!responseURL.protocolIsBlob() && !responseURL.protocolIs("file") && !SecurityOrigin::create(responseURL)->isUnique()) >- m_contentSecurityPolicyResponseHeaders = ContentSecurityPolicyResponseHeaders(response); >- InspectorInstrumentation::didReceiveScriptResponse(scriptExecutionContext(), identifier); >-} >- >-void Worker::notifyFinished() >-{ >- if (m_scriptLoader->failed()) >- dispatchEvent(Event::create(eventNames().errorEvent, false, true)); >- else { >- const ContentSecurityPolicyResponseHeaders& contentSecurityPolicyResponseHeaders = m_contentSecurityPolicyResponseHeaders ? m_contentSecurityPolicyResponseHeaders.value() : scriptExecutionContext()->contentSecurityPolicy()->responseHeaders(); >- m_contextProxy.startWorkerGlobalScope(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script(), contentSecurityPolicyResponseHeaders, m_shouldBypassMainWorldContentSecurityPolicy, m_workerCreationTime, m_runtimeFlags); >- InspectorInstrumentation::scriptImported(*scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script()); >- } >- m_scriptLoader = nullptr; >- >- unsetPendingActivity(this); >-} >- > } // namespace WebCore >diff --git a/Source/WebCore/workers/Worker.h b/Source/WebCore/workers/Worker.h >index 855c7e6feaf12f9cea7af812d79ee0e1e203809d..ba09414ff13879f93b8c701b7c621b155ca57ccf 100644 >--- a/Source/WebCore/workers/Worker.h >+++ b/Source/WebCore/workers/Worker.h >@@ -27,12 +27,13 @@ > > #include "AbstractWorker.h" > #include "ActiveDOMObject.h" >-#include "ContentSecurityPolicyResponseHeaders.h" >+#include "CachedResourceClient.h" >+#include "CachedResourceHandle.h" >+#include "CachedScript.h" >+#include "ContentSecurityPolicy.h" > #include "EventTarget.h" > #include "MessagePort.h" >-#include "WorkerScriptLoaderClient.h" > #include <runtime/RuntimeFlags.h> >-#include <wtf/Optional.h> > #include <wtf/text/AtomicStringHash.h> > > namespace JSC { >@@ -45,9 +46,8 @@ namespace WebCore { > > class ScriptExecutionContext; > class WorkerGlobalScopeProxy; >-class WorkerScriptLoader; > >-class Worker final : public AbstractWorker, public ActiveDOMObject, private WorkerScriptLoaderClient { >+class Worker final : public AbstractWorker, public ActiveDOMObject, private CachedResourceClient { > public: > static ExceptionOr<Ref<Worker>> create(ScriptExecutionContext&, JSC::RuntimeFlags, const String& url); > virtual ~Worker(); >@@ -68,9 +68,10 @@ class Worker final : public AbstractWorker, public ActiveDOMObject, private Work > EventTargetInterface eventTargetInterface() const final { return WorkerEventTargetInterfaceType; } > > void notifyNetworkStateChange(bool isOnline); >+ void requestClassicWorkerScript(const URL&); > >- void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final; >- void notifyFinished() final; >+ void dispatchErrorEvent(); >+ void notifyFinished(CachedResource&) final; > > bool canSuspendForDocumentSuspension() const final; > void stop() final; >@@ -78,10 +79,9 @@ class Worker final : public AbstractWorker, public ActiveDOMObject, private Work > > friend void networkStateChanged(bool isOnLine); > >- RefPtr<WorkerScriptLoader> m_scriptLoader; >+ CachedResourceHandle<CachedScript> m_cachedScript; > String m_identifier; > WorkerGlobalScopeProxy& m_contextProxy; // The proxy outlives the worker to perform thread shutdown. >- std::optional<ContentSecurityPolicyResponseHeaders> m_contentSecurityPolicyResponseHeaders; > MonotonicTime m_workerCreationTime; > bool m_shouldBypassMainWorldContentSecurityPolicy { false }; > JSC::RuntimeFlags m_runtimeFlags; >diff --git a/Source/WebCore/workers/WorkerGlobalScope.cpp b/Source/WebCore/workers/WorkerGlobalScope.cpp >index f40929e1207ea675b343be9547ac1b48deb59c8b..cd8d249d78d400499b286674d02938c81171bacb 100644 >--- a/Source/WebCore/workers/WorkerGlobalScope.cpp >+++ b/Source/WebCore/workers/WorkerGlobalScope.cpp >@@ -34,17 +34,19 @@ > #include "IDBConnectionProxy.h" > #include "InspectorInstrumentation.h" > #include "Performance.h" >+#include "ResourceLoaderOptions.h" >+#include "ResourceRequest.h" > #include "ScheduledAction.h" > #include "ScriptSourceCode.h" > #include "SecurityOrigin.h" > #include "SecurityOriginPolicy.h" > #include "SocketProvider.h" >+#include "WorkerImportScriptLoader.h" > #include "WorkerInspectorController.h" > #include "WorkerLoaderProxy.h" > #include "WorkerLocation.h" > #include "WorkerNavigator.h" > #include "WorkerReportingProxy.h" >-#include "WorkerScriptLoader.h" > #include "WorkerThread.h" > #include <inspector/ScriptArguments.h> > #include <inspector/ScriptCallStack.h> >@@ -256,23 +258,33 @@ ExceptionOr<void> WorkerGlobalScope::importScripts(const Vector<String>& urls) > completedURLs.uncheckedAppend(WTFMove(url)); > } > >+ // https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-classic-worker-imported-script >+ >+ auto loaderContext = ResourceLoaderContext::create(String(), *securityOrigin(), *contentSecurityPolicy()); >+ > for (auto& url : completedURLs) { >- // FIXME: Convert this to check the isolated world's Content Security Policy once webkit.org/b/104520 is solved. > bool shouldBypassMainWorldContentSecurityPolicy = this->shouldBypassMainWorldContentSecurityPolicy(); > if (!shouldBypassMainWorldContentSecurityPolicy && !contentSecurityPolicy()->allowScriptFromSource(url)) > return Exception { NETWORK_ERR }; > >- auto scriptLoader = WorkerScriptLoader::create(); >- scriptLoader->loadSynchronously(this, url, FetchOptions::Mode::NoCors, shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceScriptSrcDirective, resourceRequestIdentifier()); >+ ResourceRequest request(url); >+ request.setHTTPMethod(ASCIILiteral("GET")); >+ request.setInitiatorIdentifier(resourceRequestIdentifier()); > >- // If the fetching attempt failed, throw a NETWORK_ERR exception and abort all these steps. >- if (scriptLoader->failed()) >- return Exception { NETWORK_ERR }; >+ ResourceLoaderOptions options; >+ options.credentials = FetchOptions::Credentials::Include; >+ options.mode = FetchOptions::Mode::NoCors; >+ options.sendLoadCallbacks = SendCallbacks; >+ options.contentSecurityPolicyImposition = shouldBypassMainWorldContentSecurityPolicy ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck; > >- InspectorInstrumentation::scriptImported(*this, scriptLoader->identifier(), scriptLoader->script()); >+ auto importLoader = WorkerImportScriptLoader::create(); >+ importLoader->importScriptSynchronously(*this, WTFMove(request), options, loaderContext.get()); >+ >+ if (importLoader->failed()) >+ return Exception { NETWORK_ERR }; > > NakedPtr<JSC::Exception> exception; >- m_script->evaluate(ScriptSourceCode(scriptLoader->script(), scriptLoader->responseURL()), exception); >+ m_script->evaluate(ScriptSourceCode(importLoader->script(), importLoader->responseURL()), exception); > if (exception) { > m_script->setException(exception); > return { }; >diff --git a/Source/WebCore/workers/WorkerImportScriptLoader.cpp b/Source/WebCore/workers/WorkerImportScriptLoader.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..ea5ab9ebe8254bb0b1f45506083ce9015b84846e >--- /dev/null >+++ b/Source/WebCore/workers/WorkerImportScriptLoader.cpp >@@ -0,0 +1,185 @@ >+/* >+ * Copyright (C) 2016 Apple Inc. All Rights Reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "WorkerImportScriptLoader.h" >+ >+#include "CachedResourceLoader.h" >+#include "Document.h" >+#include "ResourceLoaderContext.h" >+#include "ResourceLoaderOptions.h" >+#include "ResourceRequest.h" >+#include "ResourceResponse.h" >+#include "WorkerGlobalScope.h" >+#include "WorkerLoaderProxy.h" >+#include "WorkerRunLoop.h" >+#include "WorkerThread.h" >+ >+namespace WebCore { >+ >+void WorkerImportScriptLoader::importScriptSynchronously(WorkerGlobalScope& workerGlobalScope, ResourceRequest&& request, const ResourceLoaderOptions& options, ResourceLoaderContext& loaderContext) >+{ >+ // Create a unique run loop mode just for this synchronous resource load. >+ WorkerRunLoop& runLoop = workerGlobalScope.thread().runLoop(); >+ String taskMode = makeString("synchronous", String::number(runLoop.createUniqueId())); >+ >+ auto wrapper = WorkerImportScriptLoader::ImportScriptLoaderClientWrapper::create(*this); >+ auto bridge = std::make_unique<MainThreadBridge>(wrapper.get(), workerGlobalScope.thread().workerLoaderProxy(), taskMode); >+ bridge->requestClassicScript(WTFMove(request), options, loaderContext); >+ >+ MessageQueueWaitResult result = MessageQueueMessageReceived; >+ while (!m_done && result != MessageQueueTerminated) >+ result = runLoop.runInMode(&workerGlobalScope, taskMode); >+ >+ if (!m_done && result == MessageQueueTerminated) { >+ m_failed = true; >+ bridge->cancel(); >+ } >+} >+ >+void WorkerImportScriptLoader::importFinished(const ImportScriptResult& result) >+{ >+ m_failed = result.failed; >+ m_responseURL = result.responseURL; >+ m_script = result.script; >+ >+ m_done = true; >+} >+ >+// MainThreadImportScriptLoader >+ >+WorkerImportScriptLoader::MainThreadImportScriptLoader::~MainThreadImportScriptLoader() >+{ >+ cleanup(); >+} >+ >+void WorkerImportScriptLoader::MainThreadImportScriptLoader::requestClassicScript(Document& document, ResourceRequest&& request, const ResourceLoaderOptions& options, ResourceLoaderContext& loaderContext) >+{ >+ ASSERT(!m_cachedScript); >+ >+ CachedResourceRequest cachedResourceRequest(WTFMove(request), options); >+ cachedResourceRequest.setCharset(ASCIILiteral("UTF-8")); >+ cachedResourceRequest.setLoaderContext(&loaderContext); >+ >+ m_cachedScript = document.cachedResourceLoader().requestScript(WTFMove(cachedResourceRequest)); >+ >+ if (!m_cachedScript) { >+ importFailed(); >+ return; >+ } >+ >+ m_cachedScript->addClient(*this); >+} >+ >+void WorkerImportScriptLoader::MainThreadImportScriptLoader::cancel() >+{ >+ cleanup(); >+} >+ >+void WorkerImportScriptLoader::MainThreadImportScriptLoader::notifyFinished(CachedResource& resource) >+{ >+ ASSERT(m_cachedScript); >+ ASSERT(m_cachedScript.get() == &resource); >+ >+ auto response = resource.response(); >+ >+ if (resource.loadFailedOrCanceled()) >+ importFailed(); >+ else if (response.httpStatusCode() && !response.isSuccessful()) >+ importFailed(); >+ else { >+ auto url = response.url(); >+ auto script = m_cachedScript.get()->script().toString(); >+ m_client.importFinished({false, url, script}); >+ } >+ >+ cleanup(); >+} >+ >+void WorkerImportScriptLoader::MainThreadImportScriptLoader::importFailed() >+{ >+ m_client.importFinished({true, URL(), String()}); >+} >+ >+void WorkerImportScriptLoader::MainThreadImportScriptLoader::cleanup() >+{ >+ if (m_cachedScript) { >+ m_cachedScript->removeClient(*this); >+ m_cachedScript = nullptr; >+ } >+} >+ >+// MainThreadBridge >+ >+WorkerImportScriptLoader::MainThreadBridge::MainThreadBridge(ImportScriptLoaderClientWrapper& clientWrapper, WorkerLoaderProxy& loaderProxy, const String& taskMode) >+ : m_clientWrapper(clientWrapper) >+ , m_loaderProxy(loaderProxy) >+ , m_taskMode(taskMode.isolatedCopy()) >+{ >+} >+ >+void WorkerImportScriptLoader::MainThreadBridge::requestClassicScript(ResourceRequest&& request, const ResourceLoaderOptions& options, ResourceLoaderContext& loaderContext) >+{ >+ // FIXME: <https://webkit.org/b/164732> Web Inspector: Workers cannot step over importScripts line if Page is paused >+ // postTaskToLoader uses Document::postTask which uses callOnMainThread which would not run if >+ // Web Inspector is trying to step over an importScripts call. >+ >+ m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options, loaderContext = loaderContext.isolatedCopy()] (ScriptExecutionContext& context) mutable { >+ ASSERT(isMainThread()); >+ Document& document = downcast<Document>(context); >+ m_mainThreadLoader = WorkerImportScriptLoader::MainThreadImportScriptLoader::create(*this); >+ m_mainThreadLoader->requestClassicScript(document, WTFMove(request), options, loaderContext); >+ }); >+} >+ >+void WorkerImportScriptLoader::MainThreadBridge::cancel() >+{ >+ m_clientWrapper->clearClient(); >+ >+ // Cancel m_mainThreadLoader on the main thread and then "delete this". >+ m_loaderProxy.postTaskToLoader([self = std::unique_ptr<MainThreadBridge>(this)] (ScriptExecutionContext& context) { >+ ASSERT(isMainThread()); >+ ASSERT_UNUSED(context, context.isDocument()); >+ if (self->m_mainThreadLoader) { >+ self->m_mainThreadLoader->cancel(); >+ self->m_mainThreadLoader = nullptr; >+ } >+ }); >+} >+ >+void WorkerImportScriptLoader::MainThreadBridge::importFinished(const ImportScriptResult& result) >+{ >+ ASSERT(isMainThread()); >+ >+ m_mainThreadLoader = nullptr; >+ >+ Ref<ImportScriptLoaderClientWrapper> protectedClientWrapper = m_clientWrapper.copyRef(); >+ m_loaderProxy.postTaskForModeToWorkerGlobalScope([protectedClientWrapper = WTFMove(protectedClientWrapper), failed = result.failed, url = result.responseURL.isolatedCopy(), script = result.script.isolatedCopy()] (ScriptExecutionContext& context) mutable { >+ ASSERT_UNUSED(context, is<WorkerGlobalScope>(context)); >+ protectedClientWrapper->importFinished({failed, url, script}); >+ }, m_taskMode); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/workers/WorkerImportScriptLoader.h b/Source/WebCore/workers/WorkerImportScriptLoader.h >new file mode 100644 >index 0000000000000000000000000000000000000000..464e272dbf8ee36b74e36d238dddfa9217fd5fa9 >--- /dev/null >+++ b/Source/WebCore/workers/WorkerImportScriptLoader.h >@@ -0,0 +1,169 @@ >+/* >+ * Copyright (C) 2016 Apple Inc. All Rights Reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#pragma once >+ >+#include "CachedResourceClient.h" >+#include "CachedResourceHandle.h" >+#include "CachedScript.h" >+#include "URL.h" >+#include <wtf/FastMalloc.h> >+#include <wtf/RefCounted.h> >+#include <wtf/RefPtr.h> >+#include <wtf/ThreadSafeRefCounted.h> >+ >+namespace WebCore { >+ >+class Document; >+class ResourceLoaderContext; >+class ResourceRequest; >+class WorkerGlobalScope; >+class WorkerLoaderProxy; >+struct ResourceLoaderOptions; >+ >+struct ImportScriptResult { >+ bool failed; >+ URL responseURL; >+ String script; >+}; >+ >+class ImportScriptLoaderClient { >+public: >+ virtual void importFinished(const ImportScriptResult&) = 0; >+protected: >+ virtual ~ImportScriptLoaderClient() { } >+}; >+ >+class WorkerImportScriptLoader : public RefCounted<WorkerImportScriptLoader>, private ImportScriptLoaderClient { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ static Ref<WorkerImportScriptLoader> create() { return adoptRef(*new WorkerImportScriptLoader); } >+ >+ void importScriptSynchronously(WorkerGlobalScope&, ResourceRequest&&, const ResourceLoaderOptions&, ResourceLoaderContext&); >+ >+ URL responseURL() const { return m_responseURL; } >+ String script() const { return m_script; } >+ bool failed() const { return m_failed; } >+ >+private: >+ void importFinished(const ImportScriptResult&) final; >+ >+ URL m_responseURL; >+ String m_script; >+ bool m_failed { false }; >+ bool m_done { false }; >+ >+private: >+ >+ // ImportScriptLoaderWrapper wraps an ImportScriptLoaderClient so that >+ // the client can be cleared before the load completes. >+ >+ class ImportScriptLoaderClientWrapper : public ThreadSafeRefCounted<ImportScriptLoaderClientWrapper>, private ImportScriptLoaderClient { >+ public: >+ static Ref<ImportScriptLoaderClientWrapper> create(ImportScriptLoaderClient& client) >+ { >+ return adoptRef(*new ImportScriptLoaderClientWrapper(client)); >+ } >+ >+ explicit ImportScriptLoaderClientWrapper(ImportScriptLoaderClient& client) >+ : m_client(&client) >+ { >+ } >+ >+ void clearClient() >+ { >+ m_client = nullptr; >+ } >+ >+ void importFinished(const ImportScriptResult& result) final >+ { >+ if (m_client) >+ m_client->importFinished(result); >+ } >+ >+ private: >+ ImportScriptLoaderClient* m_client; >+ }; >+ >+ // MainThreadImportScriptLoader is what performs the load on the Main thread. >+ // This is just for importing a script so it just decodes and sends the resulting >+ // failure or success + url + script back. Its client will be the bridge. >+ >+ class MainThreadImportScriptLoader final : public RefCounted<MainThreadImportScriptLoader>, private CachedResourceClient { >+ public: >+ static Ref<MainThreadImportScriptLoader> create(ImportScriptLoaderClient& client) >+ { >+ return adoptRef(*new MainThreadImportScriptLoader(client)); >+ } >+ >+ explicit MainThreadImportScriptLoader(ImportScriptLoaderClient& client) >+ : m_client(client) >+ { >+ } >+ >+ virtual ~MainThreadImportScriptLoader(); >+ >+ void requestClassicScript(Document&, ResourceRequest&&, const ResourceLoaderOptions&, ResourceLoaderContext&); >+ void cancel(); >+ >+ private: >+ void notifyFinished(CachedResource&) final; >+ >+ void importFailed(); >+ void cleanup(); >+ >+ CachedResourceHandle<CachedScript> m_cachedScript; >+ ImportScriptLoaderClient& m_client; // Bridge. >+ }; >+ >+ // MainThreadBridge is created on the Worker thread. It then creates and >+ // completes the load via a MainThreadImportScriptLoader on the Main thread >+ // and eventually communicates the results back to the client. It may be >+ // cancelled from the Worker thread. >+ >+ class MainThreadBridge final : private ImportScriptLoaderClient { >+ public: >+ MainThreadBridge(ImportScriptLoaderClientWrapper&, WorkerLoaderProxy&, const String& taskMode); >+ >+ void requestClassicScript(ResourceRequest&&, const ResourceLoaderOptions&, ResourceLoaderContext&); >+ void cancel(); >+ >+ private: >+ // ImportScriptLoaderClient >+ void importFinished(const ImportScriptResult&) final; >+ >+ // Only to be used on the worker thread. >+ Ref<ImportScriptLoaderClientWrapper> m_clientWrapper; >+ >+ // Only to be used on the main thread. >+ RefPtr<MainThreadImportScriptLoader> m_mainThreadLoader; >+ >+ // May be used on either thread. >+ WorkerLoaderProxy& m_loaderProxy; >+ String m_taskMode; >+ }; >+}; >+ >+} // namespace WebCore >diff --git a/Source/WebCore/workers/WorkerScriptLoader.cpp b/Source/WebCore/workers/WorkerScriptLoader.cpp >deleted file mode 100644 >index 0bb317078f8b487b65f98298bc263e5d445afa75..0000000000000000000000000000000000000000 >--- a/Source/WebCore/workers/WorkerScriptLoader.cpp >+++ /dev/null >@@ -1,194 +0,0 @@ >-/* >- * Copyright (C) 2009-2017 Apple Inc. All Rights Reserved. >- * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "WorkerScriptLoader.h" >- >-#include "ContentSecurityPolicy.h" >-#include "ResourceResponse.h" >-#include "ScriptExecutionContext.h" >-#include "TextResourceDecoder.h" >-#include "WorkerGlobalScope.h" >-#include "WorkerScriptLoaderClient.h" >-#include "WorkerThreadableLoader.h" >-#include <wtf/Ref.h> >- >-namespace WebCore { >- >-WorkerScriptLoader::WorkerScriptLoader() >-{ >-} >- >-WorkerScriptLoader::~WorkerScriptLoader() >-{ >-} >- >-void WorkerScriptLoader::loadSynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier) >-{ >- ASSERT(scriptExecutionContext); >- >- m_url = url; >- >- std::unique_ptr<ResourceRequest> request(createResourceRequest(initiatorIdentifier)); >- if (!request) >- return; >- >- ASSERT_WITH_SECURITY_IMPLICATION(is<WorkerGlobalScope>(scriptExecutionContext)); >- >- // Only used for importScripts that prescribes NoCors mode. >- ASSERT(mode == FetchOptions::Mode::NoCors); >- >- ThreadableLoaderOptions options; >- options.credentials = FetchOptions::Credentials::Include; >- options.mode = mode; >- options.sendLoadCallbacks = SendCallbacks; >- options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement; >- >- WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(*scriptExecutionContext), WTFMove(*request), *this, options); >-} >- >-void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, FetchOptions::Mode mode, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, const String& initiatorIdentifier, WorkerScriptLoaderClient* client) >-{ >- ASSERT(client); >- ASSERT(scriptExecutionContext); >- >- m_client = client; >- m_url = url; >- >- std::unique_ptr<ResourceRequest> request(createResourceRequest(initiatorIdentifier)); >- if (!request) >- return; >- >- // Only used for loading worker scripts in classic mode. >- // FIXME: We should add an option to set credential mode. >- ASSERT(mode == FetchOptions::Mode::SameOrigin); >- >- ThreadableLoaderOptions options; >- options.credentials = FetchOptions::Credentials::SameOrigin; >- options.mode = mode; >- options.sendLoadCallbacks = SendCallbacks; >- options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement; >- >- // During create, callbacks may happen which remove the last reference to this object. >- Ref<WorkerScriptLoader> protectedThis(*this); >- m_threadableLoader = ThreadableLoader::create(*scriptExecutionContext, *this, WTFMove(*request), options); >-} >- >-const URL& WorkerScriptLoader::responseURL() const >-{ >- ASSERT(!failed()); >- return m_responseURL; >-} >- >-std::unique_ptr<ResourceRequest> WorkerScriptLoader::createResourceRequest(const String& initiatorIdentifier) >-{ >- auto request = std::make_unique<ResourceRequest>(m_url); >- request->setHTTPMethod(ASCIILiteral("GET")); >- request->setInitiatorIdentifier(initiatorIdentifier); >- return request; >-} >- >-void WorkerScriptLoader::didReceiveResponse(unsigned long identifier, const ResourceResponse& response) >-{ >- if (response.httpStatusCode() / 100 != 2 && response.httpStatusCode()) { >- m_failed = true; >- return; >- } >- >-#if ENABLE(NOSNIFF) >- if (!isScriptAllowedByNosniff(response)) { >- m_failed = true; >- return; >- } >-#endif >- >- m_responseURL = response.url(); >- m_responseEncoding = response.textEncodingName(); >- if (m_client) >- m_client->didReceiveResponse(identifier, response); >-} >- >-void WorkerScriptLoader::didReceiveData(const char* data, int len) >-{ >- if (m_failed) >- return; >- >- if (!m_decoder) { >- if (!m_responseEncoding.isEmpty()) >- m_decoder = TextResourceDecoder::create(ASCIILiteral("text/javascript"), m_responseEncoding); >- else >- m_decoder = TextResourceDecoder::create(ASCIILiteral("text/javascript"), "UTF-8"); >- } >- >- if (!len) >- return; >- >- if (len == -1) >- len = strlen(data); >- >- m_script.append(m_decoder->decode(data, len)); >-} >- >-void WorkerScriptLoader::didFinishLoading(unsigned long identifier) >-{ >- if (m_failed) { >- notifyError(); >- return; >- } >- >- if (m_decoder) >- m_script.append(m_decoder->flush()); >- >- m_identifier = identifier; >- notifyFinished(); >-} >- >-void WorkerScriptLoader::didFail(const ResourceError&) >-{ >- notifyError(); >-} >- >-void WorkerScriptLoader::notifyError() >-{ >- m_failed = true; >- notifyFinished(); >-} >- >-String WorkerScriptLoader::script() >-{ >- return m_script.toString(); >-} >- >-void WorkerScriptLoader::notifyFinished() >-{ >- if (!m_client || m_finishing) >- return; >- >- m_finishing = true; >- m_client->notifyFinished(); >-} >- >-} // namespace WebCore >diff --git a/Source/WebCore/workers/WorkerScriptLoader.h b/Source/WebCore/workers/WorkerScriptLoader.h >deleted file mode 100644 >index c80798ac6c925a15b8c2dd07b7f34bd1e623447b..0000000000000000000000000000000000000000 >--- a/Source/WebCore/workers/WorkerScriptLoader.h >+++ /dev/null >@@ -1,91 +0,0 @@ >-/* >- * Copyright (C) 2009 Apple Inc. All Rights Reserved. >- * Copyright (C) 2009, 2011 Google Inc. All Rights Reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#include "URL.h" >-#include "ResourceRequest.h" >-#include "ThreadableLoader.h" >-#include "ThreadableLoaderClient.h" >-#include <memory> >-#include <wtf/FastMalloc.h> >-#include <wtf/RefCounted.h> >-#include <wtf/RefPtr.h> >-#include <wtf/text/StringBuilder.h> >- >-namespace WebCore { >- >- class ResourceResponse; >- class ScriptExecutionContext; >- class TextResourceDecoder; >- class WorkerScriptLoaderClient; >- >- class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public ThreadableLoaderClient { >- WTF_MAKE_FAST_ALLOCATED; >- public: >- static Ref<WorkerScriptLoader> create() >- { >- return adoptRef(*new WorkerScriptLoader); >- } >- >- void loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier); >- void loadAsynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier, WorkerScriptLoaderClient*); >- >- void notifyError(); >- >- String script(); >- const URL& url() const { return m_url; } >- const URL& responseURL() const; >- bool failed() const { return m_failed; } >- unsigned long identifier() const { return m_identifier; } >- >- void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override; >- void didReceiveData(const char* data, int dataLength) override; >- void didFinishLoading(unsigned long identifier) override; >- void didFail(const ResourceError&) override; >- >- private: >- friend class WTF::RefCounted<WorkerScriptLoader>; >- >- WorkerScriptLoader(); >- ~WorkerScriptLoader(); >- >- std::unique_ptr<ResourceRequest> createResourceRequest(const String& initiatorIdentifier); >- void notifyFinished(); >- >- WorkerScriptLoaderClient* m_client { nullptr }; >- RefPtr<ThreadableLoader> m_threadableLoader; >- String m_responseEncoding; >- RefPtr<TextResourceDecoder> m_decoder; >- StringBuilder m_script; >- URL m_url; >- URL m_responseURL; >- unsigned long m_identifier { 0 }; >- bool m_failed { false }; >- bool m_finishing { false }; >- }; >- >-} // namespace WebCore >diff --git a/Source/WebCore/workers/WorkerScriptLoaderClient.h b/Source/WebCore/workers/WorkerScriptLoaderClient.h >deleted file mode 100644 >index 10d06c762261dcec1823338f9c0783231f085989..0000000000000000000000000000000000000000 >--- a/Source/WebCore/workers/WorkerScriptLoaderClient.h >+++ /dev/null >@@ -1,45 +0,0 @@ >-/* >- * Copyright (C) 2009 Apple Inc. All Rights Reserved. >- * Copyright (C) 2009 Google Inc. All Rights Reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-namespace WebCore { >- >- class ResourceResponse; >- >- class WorkerScriptLoaderClient { >- public: >- virtual void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse&) { } >- >- // FIXME: notifyFinished() is not currently guaranteed to be invoked if used from worker context and the worker shuts down in the middle of an operation. >- // This will cause leaks when we support nested workers. >- virtual void notifyFinished() { } >- >- protected: >- virtual ~WorkerScriptLoaderClient() { } >- }; >- >-} // namespace WebCore >diff --git a/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp b/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp >index 667bdd1934066030186e861846ed6ed68b55a3db..526b63b30eee2c36e9287669218981766b4353e8 100644 >--- a/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp >+++ b/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp >@@ -107,6 +107,7 @@ static Seconds maximumBufferingTime(CachedResource* resource) > switch (resource->type()) { > case CachedResource::CSSStyleSheet: > case CachedResource::Script: >+ case CachedResource::WorkerScript: > #if ENABLE(SVG_FONTS) > case CachedResource::SVGFontResource: > #endif >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 79797270e8f7b410f422e5331e4d8a8e6642e238..b6d3c9e58b25540a9c10db965d5121db7a5b93b8 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,12 @@ >+2017-07-01 Yusuke Suzuki <utatane.tea@gmail.com> >+ >+ Worker Script Loads (new Worker(...), importScripts(...)) should be classified as Scripts not Raw requests >+ https://bugs.webkit.org/show_bug.cgi?id=164425 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * inspector/page/searchInResources-expected.txt: >+ > 2017-06-30 Said Abou-Hallawa <sabouhallawa@apple.com> > > If an image appears more than once on a page, decoding for painting one instance repaints them all >diff --git a/LayoutTests/inspector/page/searchInResources-expected.txt b/LayoutTests/inspector/page/searchInResources-expected.txt >index 5c5c9d454d62b886757199cac5bd024d72914c73..49016f7f287dac6c8abb25a85f9eec66b06ccea9 100644 >--- a/LayoutTests/inspector/page/searchInResources-expected.txt >+++ b/LayoutTests/inspector/page/searchInResources-expected.txt >@@ -6,7 +6,6 @@ Tests for the Page.searchInResources and Page.searchInResource commands. > PASS: Should find results in multiple resources. > FOUND: inspector/page/resources/search-script.js (1) > FOUND: inspector/page/resources/search-stylesheet.css (1) >-FOUND: inspector/page/resources/search-worker.js (1) > FOUND: inspector/page/resources/search-xhr.txt (2) > FOUND: inspector/page/searchInResources.html (1) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 164425
:
297336
|
297340
|
297347
|
297348
|
297349
|
314380
|
314381
|
314382
|
314383
|
314522
|
314827
|
314832
|
314833
|
314835
|
314836
|
315415
|
316720
|
316724
|
316725