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-eof.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-eof.js
diff --git a/LayoutTests/http/tests/eventsource/script-tests/eventsource-eof.js b/LayoutTests/http/tests/eventsource/script-tests/eventsource-eof.js
new file mode 100644
index 0000000000000000000000000000000000000000..8ce0b86b876d6fb934b347f6fe0376681ccc89be
--- /dev/null
+++ b/LayoutTests/http/tests/eventsource/script-tests/eventsource-eof.js
@@ -0,0 +1,33 @@
+if (self.importScripts)
+ importScripts("/js-test-resources/js-test.js");
+
+description("Test that EventSource discards event data if there is no newline before eof.");
+
+self.jsTestIsAsync = true;
+
+var count = 1;
+
+var es = new EventSource("/eventsource/resources/es-eof.php");
+
+es.onerror = function () {
+ if (count++ == 3) {
+ es.close();
+ finishJSTest();
+ }
+};
+
+var evt;
+
+es.onmessage = function (arg) {
+ evt = arg;
+ if (evt.data == ("DATA" + count)) {
+ shouldBeEqualToString("evt.type", "message");
+ shouldBeEqualToString("evt.data", "DATA" + count);
+ shouldBeEqualToString("evt.lastEventId", count.toString());
+ return;
+ }
+ shouldBeEqualToString("evt.type", "msg");
+ shouldBeEqualToString("evt.data", "DATA");
+ shouldBeEqualToString("evt.lastEventId", "3.1");
+};
+es.addEventListener("msg", es.onmessage);

Powered by Google App Engine
This is Rietveld 408576698