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

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

Issue 2711913003: Upstream Blink's 'securitypolicyviolation' tests. (Closed)
Patch Set: MANIFEST 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 document.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 document.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 waitUntilEvent(obj, name) { 22 function waitUntilEvent(obj, name) {
23 return new Promise((resolve, reject) => { 23 return new Promise((resolve, reject) => {
24 obj.addEventListener(name, resolve); 24 obj.addEventListener(name, resolve);
25 }); 25 });
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 waitUntilCSPEventForURL(t, reportedURL) 121 waitUntilCSPEventForURL(t, reportedURL)
122 .then(t.step_func_done(e => { 122 .then(t.step_func_done(e => {
123 assert_equals(e.blockedURI, reportedURL); 123 assert_equals(e.blockedURI, reportedURL);
124 assert_equals(e.violatedDirective, "worker-src"); 124 assert_equals(e.violatedDirective, "worker-src");
125 assert_equals(e.effectiveDirective, "worker-src"); 125 assert_equals(e.effectiveDirective, "worker-src");
126 })), 126 })),
127 promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url })) 127 promise_rejects(t, "SecurityError", navigator.serviceWorker.register(url, { scope: url }))
128 ]); 128 ]);
129 }, description); 129 }, description);
130 } 130 }
131
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698