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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/connect-src/connect-src-websocket-blocked.sub.html

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
(Empty)
1 <!DOCTYPE html>
2 <meta http-equiv="Content-Security-Policy" content="connect-src 'self'">
3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script>
5 <script>
6 async_test(t => {
7 var errorEvent = false;
8 var cspEvent = false;
9
10 var ws = new WebSocket("ws://{{domains[www]}}:{{ports[ws][0]}}/echo");
11 ws.onopen = t.unreached_func("open should not fire.");
12 ws.onerror = t.step_func(e => {
13 assert_equals(ws.readyState, WebSocket.CLOSED);
14
15 assert_false(errorEvent);
16 errorEvent = true;
17 if (cspEvent)
18 t.done();
19 });
20
21 document.addEventListener("securitypolicyviolation", t.step_func(e => {
22 if (e.blockedURI != "ws://{{domains[www]}}:{{ports[ws][0]}}")
23 return;
24
25 assert_equals(ws.readyState, WebSocket.CLOSED);
26 assert_equals(e.violatedDirective, "connect-src");
27
28 assert_false(cspEvent);
29 cspEvent = true;
30 if (errorEvent)
31 t.done();
32 }));
33 }, "WebSocket should fire error event.");
34 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698