3 <meta http-equiv=
"Content-Security-Policy" content=
"connect-src http://invalid http://127.0.0.1">
6 <p>Test EventSource constructor functionality. Should print a series of PASS messages followed by DONE.
</p>
7 <div id=
"result"></div>
10 document
.getElementById("result").innerHTML
+= msg
+ "<br>";
13 if (window
.testRunner
) {
14 testRunner
.dumpAsText();
15 testRunner
.waitUntilDone();
20 log("FAIL: no exception when trying to construct an EventSource without argument");
22 log("PASS: missing argument to EventSource constructor resulted in an exception (" + e
+ ")");
27 log("FAIL: no exception when passing an empty string to the EventSource constructor");
29 log("PASS: passing an empty string to the EventSource constructor resulted in an exception (" + e
+ ")");
33 new EventSource("http://webserver:eighty/");
34 log("FAIL: no exception when passing an invalid URL to the EventSource constructor");
36 log("PASS: passing an invalid URL to the EventSource constructor resulted in an exception (" + e
+ ")");
40 new EventSource("http://disallowed.example.com/");
41 log("FAIL: no exception when passing an URL blocked by Content Security Policy to the EventSource constructor");
43 log("PASS: passing a Content-Security-Policy-blocked URL to the EventSource constructor resulted in an exception (" + e
+ ")");
47 var es
= new EventSource("http://127.0.0.1/", {"withCredentials": false});
49 if (!es
.withCredentials
) {
50 log("PASS: no exception when passing a second argument to the EventSource constructor");
53 log("FAIL: the 'withCredentials' property is unexpectedly true");
55 log("FAIL: passing a second argument to the EventSource constructor resulted in an exception (" + e
+ ")");
58 if (window
.testRunner
)
59 testRunner
.notifyDone();