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

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

Issue 2421473004: CSP: Fire 'SecurityPolicyViolation' on the offending element. (Closed)
Patch Set: Test. Created 4 years, 2 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
Index: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/securitypolicyviolation-helper.js
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/securitypolicyviolation-helper.js b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/securitypolicyviolation-helper.js
new file mode 100644
index 0000000000000000000000000000000000000000..a2b51948926f170882c1c273cf76b25611d0bdb3
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/securitypolicyviolation-helper.js
@@ -0,0 +1,25 @@
+function generateURL(type) {
+ return 'http://localhost:8000/security/contentSecurityPolicy/resources/loaded.js?' + type;
+}
+
+function assert_script_failed(t, url, line) {
+ window.addEventListener('message', t.step_func(e => {
+ if (e.data == url)
+ t.unreached_func("Script should not have loaded.");
+ }));
+ document.addEventListener('securitypolicyviolation', t.step_func(e => {
+ if (e.lineNumber == line)
+ t.done();
+ }));
+}
+
+function assert_script_loads(t, url, line) {
+ window.addEventListener('message', t.step_func(e => {
+ if (e.data == url)
+ t.done();
+ }));
+ document.addEventListener('securitypolicyviolation', t.step_func(e => {
+ if (e.lineNumber == line)
+ t.unreached_func("Script should not have failed.");
+ }));
+}

Powered by Google App Engine
This is Rietveld 408576698