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

Unified Diff: LayoutTests/http/tests/eventsource/script-tests/eventsource-cors-no-server.js

Issue 345813005: Rework EventSource CORS tests to be usable from Workers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Generalize redirect.php?cors_enabled to cors_allow_origin Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698