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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/support/testharness-helper.js

Issue 2456013002: CSP: 'connect-src' should not cause exceptions. (Closed)
Patch Set: Ugh. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 function assert_no_csp_event_for_url(test, url) { 1 function assert_no_csp_event_for_url(test, url) {
2 self.addEventListener("securitypolicyviolation", test.step_func(e => { 2 self.addEventListener("securitypolicyviolation", test.step_func(e => {
3 if (e.blockedURI !== url) 3 if (e.blockedURI !== url)
4 return; 4 return;
5 assert_unreached("SecurityPolicyViolation event fired for " + url); 5 assert_unreached("SecurityPolicyViolation event fired for " + url);
6 })); 6 }));
7 } 7 }
8 8
9 function assert_no_event(test, obj, name) { 9 function assert_no_event(test, obj, name) {
10 obj.addEventListener(name, test.unreached_func("The '" + name + "' event shoul d not have fired.")); 10 obj.addEventListener(name, test.unreached_func("The '" + name + "' event shoul d not have fired."));
11 } 11 }
12 12
13 function waitUntilCSPEventForURL(test, url) { 13 function waitUntilCSPEventForURL(test, url) {
14 return new Promise((resolve, reject) => { 14 return new Promise((resolve, reject) => {
15 self.addEventListener("securitypolicyviolation", test.step_func(e => { 15 self.addEventListener("securitypolicyviolation", test.step_func(e => {
16 console.log(e.blockedURI);
16 if (e.blockedURI == url) 17 if (e.blockedURI == url)
17 resolve(e); 18 resolve(e);
18 })); 19 }));
19 }); 20 });
20 } 21 }
21 22
22 function waitUntilCSPEventForEval(test, line) { 23 function waitUntilCSPEventForEval(test, line) {
23 return new Promise((resolve, reject) => { 24 return new Promise((resolve, reject) => {
24 self.addEventListener("securitypolicyviolation", test.step_func(e => { 25 self.addEventListener("securitypolicyviolation", test.step_func(e => {
25 if (e.blockedURI == "eval" && e.lineNumber == line) 26 if (e.blockedURI == "eval" && e.lineNumber == line)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 waitUntilCSPEventForURL(t, reportedURL) 131 waitUntilCSPEventForURL(t, reportedURL)
131 .then(t.step_func_done(e => { 132 .then(t.step_func_done(e => {
132 assert_equals(e.blockedURI, reportedURL); 133 assert_equals(e.blockedURI, reportedURL);
133 assert_equals(e.violatedDirective, "worker-src"); 134 assert_equals(e.violatedDirective, "worker-src");
134 assert_equals(e.effectiveDirective, "worker-src"); 135 assert_equals(e.effectiveDirective, "worker-src");
135 })), 136 })),
136 promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url })) 137 promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url }))
137 ]); 138 ]);
138 }, description); 139 }, description);
139 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698