Index: LayoutTests/http/tests/eventsource/script-tests/eventsource-cors-no-server.js |
diff --git a/LayoutTests/http/tests/eventsource/script-tests/eventsource-cors-no-server.js b/LayoutTests/http/tests/eventsource/script-tests/eventsource-cors-no-server.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..17b4e8aa4a3a559d3794da63ada268a20639d0ce |
--- /dev/null |
+++ b/LayoutTests/http/tests/eventsource/script-tests/eventsource-cors-no-server.js |
@@ -0,0 +1,28 @@ |
+if (self.importScripts) |
+ importScripts("/js-test-resources/js-test.js"); |
+ |
+description("Test that EventSource tries to reconnect if there's no server response when making cross-origin requests."); |
+ |
+self.jsTestIsAsync = true; |
+ |
+var count = 0; |
+var hosts = ["http://127.0.0.1:12345/event-stream", "http://localhost:54321/event-stream"]; |
+ |
+var es; |
+ |
+function runTest() { |
+ shouldNotThrow("es = new EventSource(\"" + hosts[count] + "\")"); |
+ es.onerror = function () { |
+ if (es.readyState == es.CONNECTING) { |
+ testPassed("got error event and readyState is CONNECTING"); |
+ es.close(); |
+ } else |
+ shouldBeTrue("es.readyState !== es.CLOSED"); |
+ if (++count == hosts.length) { |
+ finishJSTest(); |
+ return; |
+ } |
+ setTimeout(runTest); |
+ }; |
+} |
+runTest(); |