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

Side by Side Diff: LayoutTests/http/tests/eventsource/eventsource-eof.html

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
1 <html> 1 <!DOCTYPE HTML>
2 <body> 2 <script src="/js-test-resources/js-test.js"></script>
3 <p>Test that EventSource discards event data if there is no newline before eof. Should print a series of PASS messages followed by DONE.</p> 3 <script src="script-tests/eventsource-eof.js">
4 <div id="result"></div>
5 <script>
6 function log(msg) {
7 document.getElementById("result").innerHTML += msg + "<br>";
8 }
9
10 if (window.testRunner) {
11 testRunner.dumpAsText();
12 testRunner.waitUntilDone();
13 }
14
15 var count = 1;
16
17 var es = new EventSource("resources/es-eof.php");
18
19 es.onerror = function () {
20 if (count++ == 3) {
21 es.close();
22 if (window.testRunner)
23 testRunner.notifyDone();
24 }
25 };
26
27 es.onmessage = function (evt) {
28 if (evt.data == ("DATA" + count)) {
29 if (evt.lastEventId == count) {
30 if (evt.type == "message")
31 log("PASS: got event with expected data, lastEventId, and type") ;
32 else
33 log("FAIL: got expected data and lastEventId but type is wrong") ;
34 }
35 else if (evt.type == "message")
36 log("FAIL: got expected data but lastEventId is wrong");
37 else
38 log("FAIL: got expected data but lastEventId and type are wrong");
39 }
40 else if (count == 3 && evt.data == "DATA" && evt.lastEventId == "3.1" && evt .type == "msg")
41 log("DONE");
42 else
43 log("FAIL: got unexpected message event");
44 };
45 es.addEventListener("msg", es.onmessage);
46 </script> 4 </script>
47 </body>
48 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698