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

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/content-security-policy/connect-src/connect-src-eventsource-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 es = new EventSource("http://{{domains[www]}}:{{ports[http][0]}}/commo n/text-plain.txt");
11 es.onerror = t.step_func(e => {
12 assert_equals(es.readyState, EventSource.CLOSED);
13
14 assert_false(errorEvent);
15 errorEvent = true;
16 if (cspEvent)
17 t.done();
18 });
19
20 document.addEventListener("securitypolicyviolation", t.step_func(e => {
21 if (e.blockedURI != "http://{{domains[www]}}:{{ports[http][0]}}/common/t ext-plain.txt")
22 return;
23
24 assert_equals(es.readyState, EventSource.CLOSED);
25 assert_equals(e.violatedDirective, "connect-src");
26
27 assert_false(cspEvent);
28 cspEvent = true;
29 if (errorEvent)
30 t.done();
31 }));
32 }, "EventSource should fire onerror.");
33
34 async_test(t => {
35 var errorEvent = false;
36 var cspEvent = false;
37
38 var es = new EventSource("/common/redirect-opt-in.py?status=307&location=h ttp://{{domains[www]}}:{{ports[http][0]}}/common/text-plain.txt");
39 es.onerror = t.step_func(e => {
40 assert_equals(es.readyState, EventSource.CLOSED);
41
42 assert_false(errorEvent);
43 errorEvent = true;
44 if (cspEvent)
45 t.done();
46 });
47
48 document.addEventListener("securitypolicyviolation", t.step_func(e => {
49 if (e.blockedURI != "http://{{domains[www]}}:{{ports[http][0]}}")
50 return;
51
52 assert_equals(es.readyState, EventSource.CLOSED);
53 assert_equals(e.violatedDirective, "connect-src");
54
55 assert_false(cspEvent);
56 cspEvent = true;
57 if (errorEvent)
58 t.done();
59 }));
60 }, "EventSource should fire onerror after a redirect.");
61 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698