Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Unified Diff: third_party/WebKit/Source/modules/worklet/Worklet.cpp

Issue 2146633002: Enable checking for Content Security Policies before loading an external worklet script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/worklet-import-blocked-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/worklet/Worklet.cpp
diff --git a/third_party/WebKit/Source/modules/worklet/Worklet.cpp b/third_party/WebKit/Source/modules/worklet/Worklet.cpp
index 54993701b26d3318a46beafde5caadf43c95419a..b34b2ce30aff169a3e4a7d0dced9106809584d10 100644
--- a/third_party/WebKit/Source/modules/worklet/Worklet.cpp
+++ b/third_party/WebKit/Source/modules/worklet/Worklet.cpp
@@ -26,8 +26,9 @@ ScriptPromise Worklet::import(ScriptState* scriptState, const String& url)
return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(SyntaxError, "'" + url + "' is not a valid URL."));
}
- // TODO(ikilpatrick): Perform upfront CSP checks once we decide on a
- // CSP-policy for worklets.
+ if (!getExecutionContext()->securityContext().contentSecurityPolicy()->allowScriptFromSource(scriptURL, AtomicString())) {
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(NetworkError, "The script at '" + scriptURL.elidedString() + "' failed to load."));
ikilpatrick 2016/07/20 17:56:17 A better message is probably something like "Acces
+ }
ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
m_resolvers.append(resolver);
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/worklet-import-blocked-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698