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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 if (self.importScripts)
2 importScripts("/js-test-resources/js-test.js");
3
4 description("Test EventSource text/event-stream parsing.");
5
6 self.jsTestIsAsync = true;
7
8 var count = -1;
9 var es, evt;
10
11 shouldNotThrow("es = new EventSource(\"resources/event-stream.php\");");
12 es.onopen = function (evt) {
13 testPassed("got open event" + (!evt.data ? "" : " from server"));
14 };
15
16 es.onmessage = function (arg) {
17 evt = arg;
18 switch(count++) {
19 case -1:
20 shouldBeEqualToString("evt.data", "\n\n");
21 break;
22 case 0:
23 shouldBeEqualToString("evt.data", "simple");
24 break;
25 case 1:
26 shouldBeEqualToString("evt.data", "spanning\nmultiple\n\nlines\n");
27 break;
28 case 2:
29 shouldBeEqualToString("evt.data", "id is 1");
30 shouldBeEqualToString("evt.lastEventId", "1");
31 break
32 case 3:
33 shouldBeEqualToString("evt.data", "id is still 1");
34 shouldBeEqualToString("evt.lastEventId", "1");
35 break;
36 case 4:
37 shouldBeEqualToString("evt.data", "no id");
38 shouldBeEqualToString("evt.lastEventId", "");
39 break;
40 case 5:
41 shouldBeEqualToString("evt.data", "a message event with the name \"messa ge\"");
42 break;
43 case 6:
44 shouldBeEqualToString("evt.data", "a line ending with crlf\na line with a : (colon)\na line ending with cr");
45 break;
46 default:
47 testFailed("got unexpected event");
48 es.close();
49 }
50 };
51
52 es.onerror = function () {
53 es.close();
54
55 shouldBe("count", "7");
56 debug("DONE");
57 finishJSTest();
58 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698