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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/resources/testharness-helper.js

Issue 2540983003: CSP: Dedicated workers always inherit policy. (Closed)
Patch Set: Rebase. 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/worker-connect-src-allowed.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 if (e.blockedURI == url) 16 if (e.blockedURI == url)
17 resolve(e); 17 resolve(e);
18 })); 18 }));
19 }); 19 });
20 } 20 }
21 21
22 function waitUntilCSPEventForEval(test, line) {
23 return new Promise((resolve, reject) => {
24 self.addEventListener("securitypolicyviolation", test.step_func(e => {
25 if (e.blockedURI == "eval" && e.lineNumber == line)
26 resolve(e);
27 }));
28 });
29 }
30
22 function waitUntilEvent(obj, name) { 31 function waitUntilEvent(obj, name) {
23 return new Promise((resolve, reject) => { 32 return new Promise((resolve, reject) => {
24 obj.addEventListener(name, resolve); 33 obj.addEventListener(name, resolve);
25 }); 34 });
26 } 35 }
27 36
28 // Given the URL of a worker that pings its opener upon load, this 37 // Given the URL of a worker that pings its opener upon load, this
29 // function builds a test that asserts that the ping is received, 38 // function builds a test that asserts that the ping is received,
30 // and that no CSP event fires. 39 // and that no CSP event fires.
31 function assert_worker_is_loaded(url, description) { 40 function assert_worker_is_loaded(url, description) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 waitUntilCSPEventForURL(t, reportedURL) 130 waitUntilCSPEventForURL(t, reportedURL)
122 .then(t.step_func_done(e => { 131 .then(t.step_func_done(e => {
123 assert_equals(e.blockedURI, reportedURL); 132 assert_equals(e.blockedURI, reportedURL);
124 assert_equals(e.violatedDirective, "worker-src"); 133 assert_equals(e.violatedDirective, "worker-src");
125 assert_equals(e.effectiveDirective, "worker-src"); 134 assert_equals(e.effectiveDirective, "worker-src");
126 })), 135 })),
127 promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url })) 136 promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url }))
128 ]); 137 ]);
129 }, description); 138 }, description);
130 } 139 }
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/worker-connect-src-allowed.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698