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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/connect-src-eventsource-blocked.html

Issue 2456013002: CSP: 'connect-src' should not cause exceptions. (Closed)
Patch Set: Created 4 years, 1 month 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 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <meta http-equiv="Content-Security-Policy" content="connect-src 'self'">
3 <head> 3 <script src="/resources/testharness.js"></script>
4 <meta http-equiv="Content-Security-Policy" content="connect-src http://localhost :8000"> 4 <script src="/resources/testharnessreport.js"></script>
5 <script> 5 <script>
6 if (window.testRunner) 6 async_test(t => {
7 testRunner.dumpAsText(); 7 var eventsSeen = 0;
8
9 var es = new EventSource("http://example.test:8000/eventsource/resources/s imple-event-stream.asis");
10 es.onerror = t.step_func(e => {
11 assert_equals(es.readyState, EventSource.CLOSED);
12
13 eventsSeen++;
14 if (eventsSeen == 2)
15 t.done();
foolip 2016/10/27 13:59:50 With t.done() in two places, are there two valid w
Mike West 2016/10/27 14:18:24 I'll ping you about this.
16 });
17
18 document.addEventListener("securitypolicyviolation", t.step_func(e => {
19 if (e.blockedURI != "http://example.test:8000/eventsource/resources/simp le-event-stream.asis")
20 return;
21
22 assert_equals(es.readyState, EventSource.CLOSED);
23 assert_equals(e.violatedDirective, "connect-src");
24
25 eventsSeen++;
26 if (eventsSeen == 2)
27 t.done();
28 }));
29 }, "EventSource should fire onerror.");
30
31 async_test(t => {
32 var eventsSeen = 0;
33
34 var es = new EventSource("/resources/redirect.php?code=307&cors_allow_orig in=*&url=http://example.test:8080/eventsource/resources/simple-event-stream.asis ");
35 es.onerror = t.step_func(e => {
36 assert_equals(es.readyState, EventSource.CLOSED);
37
38 eventsSeen++;
39 if (eventsSeen == 2)
40 t.done();
41 });
42
43 document.addEventListener("securitypolicyviolation", t.step_func(e => {
44 if (e.blockedURI != "http://example.test:8080")
45 return;
46
47 assert_equals(es.readyState, EventSource.CLOSED);
48 assert_equals(e.violatedDirective, "connect-src");
49
50 eventsSeen++;
51 if (eventsSeen == 2)
52 t.done();
53 }));
54 }, "EventSource should fire onerror after a redirect.");
8 </script> 55 </script>
9 </head>
10 <body>
11 <pre id="console"></pre>
12 <script>
13 function log(msg)
14 {
15 document.getElementById("console").appendChild(document.createTextNode(msg + "\n"));
16 }
17
18 try {
19 var es = new EventSource("http://127.0.0.1:8000/eventsource/resources/simple -event-stream.asis");
20 log("Fail");
21 } catch(e) {
22 log("Pass");
23 }
24
25 </script>
26 </body>
27 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698