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

Unified Diff: LayoutTests/http/tests/eventsource/script-tests/eventsource-parse-event-stream.js

Issue 347043002: Rework EventSource tests for better Worker test coverage. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move out CORS tests 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-parse-event-stream.js
diff --git a/LayoutTests/http/tests/eventsource/script-tests/eventsource-parse-event-stream.js b/LayoutTests/http/tests/eventsource/script-tests/eventsource-parse-event-stream.js
new file mode 100644
index 0000000000000000000000000000000000000000..eee0beed689ffba392632c535d9e77f263205174
--- /dev/null
+++ b/LayoutTests/http/tests/eventsource/script-tests/eventsource-parse-event-stream.js
@@ -0,0 +1,58 @@
+if (self.importScripts)
+ importScripts("/js-test-resources/js-test.js");
+
+description("Test EventSource text/event-stream parsing.");
+
+self.jsTestIsAsync = true;
+
+var count = -1;
+var es, evt;
+
+shouldNotThrow("es = new EventSource(\"resources/event-stream.php\");");
+es.onopen = function (evt) {
+ testPassed("got open event" + (!evt.data ? "" : " from server"));
+};
+
+es.onmessage = function (arg) {
+ evt = arg;
+ switch(count++) {
+ case -1:
+ shouldBeEqualToString("evt.data", "\n\n");
+ break;
+ case 0:
+ shouldBeEqualToString("evt.data", "simple");
+ break;
+ case 1:
+ shouldBeEqualToString("evt.data", "spanning\nmultiple\n\nlines\n");
+ break;
+ case 2:
+ shouldBeEqualToString("evt.data", "id is 1");
+ shouldBeEqualToString("evt.lastEventId", "1");
+ break
+ case 3:
+ shouldBeEqualToString("evt.data", "id is still 1");
+ shouldBeEqualToString("evt.lastEventId", "1");
+ break;
+ case 4:
+ shouldBeEqualToString("evt.data", "no id");
+ shouldBeEqualToString("evt.lastEventId", "");
+ break;
+ case 5:
+ shouldBeEqualToString("evt.data", "a message event with the name \"message\"");
+ break;
+ case 6:
+ shouldBeEqualToString("evt.data", "a line ending with crlf\na line with a : (colon)\na line ending with cr");
+ break;
+ default:
+ testFailed("got unexpected event");
+ es.close();
+ }
+};
+
+es.onerror = function () {
+ es.close();
+
+ shouldBe("count", "7");
+ debug("DONE");
+ finishJSTest();
+};

Powered by Google App Engine
This is Rietveld 408576698