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

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/cascade-helper.js

Issue 2472333003: CSP: "local schemes" should inherit policy when embedded. (Closed)
Patch Set: dcheng@ Created 4 years, 1 month 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
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/cascade-helper.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/cascade-helper.js b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/cascade-helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..1a3168b373d3dc64e9db19337419f7b00c94d44e
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/cascade-helper.js
@@ -0,0 +1,34 @@
+function assert_allowed_image_in_document(test, doc, url) {
+ doc.addEventListener('securitypolicyviolation', test.step_func(e => {
+ if (e.blockedURI == url)
+ assert_unreached("No violation expected for " + url);
+ }));
+
+ var i = doc.createElement('img');
+ i.onerror = test.unreached_func("onerror fired for " + url);
+ i.onload = test.step_func_done();
+ i.src = url;
+}
+
+
+function assert_blocked_image_in_document(test, doc, url) {
+ var cspEvent = false;
+ var errorEvent = false;
+ doc.addEventListener('securitypolicyviolation', test.step_func(e => {
+ if (e.blockedURI != url)
+ return;
+
+ cspEvent = true;
+ if (errorEvent)
+ test.done();
+ }));
+
+ var i = doc.createElement('img');
+ i.onload = test.unreached_func("onload fired for " + url);
+ i.onerror = test.step_func(e => {
+ errorEvent = true;
+ if (cspEvent)
+ test.done();
+ });
+ i.src = url;
+}

Powered by Google App Engine
This is Rietveld 408576698