OLD | NEW |
(Empty) | |
| 1 if (self.importScripts) |
| 2 importScripts("/js-test-resources/js-test.js"); |
| 3 |
| 4 description("Test that EventSource discards event data if there is no newline be
fore eof."); |
| 5 |
| 6 self.jsTestIsAsync = true; |
| 7 |
| 8 var count = 1; |
| 9 |
| 10 var es = new EventSource("/eventsource/resources/es-eof.php"); |
| 11 |
| 12 es.onerror = function () { |
| 13 if (count++ == 3) { |
| 14 es.close(); |
| 15 finishJSTest(); |
| 16 } |
| 17 }; |
| 18 |
| 19 var evt; |
| 20 |
| 21 es.onmessage = function (arg) { |
| 22 evt = arg; |
| 23 if (evt.data == ("DATA" + count)) { |
| 24 shouldBeEqualToString("evt.type", "message"); |
| 25 shouldBeEqualToString("evt.data", "DATA" + count); |
| 26 shouldBeEqualToString("evt.lastEventId", count.toString()); |
| 27 return; |
| 28 } |
| 29 shouldBeEqualToString("evt.type", "msg"); |
| 30 shouldBeEqualToString("evt.data", "DATA"); |
| 31 shouldBeEqualToString("evt.lastEventId", "3.1"); |
| 32 }; |
| 33 es.addEventListener("msg", es.onmessage); |
OLD | NEW |