blob: 52c33cafb640fde20fcda6c71ce0bf18440203f8 [file] [log] [blame]
<html>
<body>
<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>
<div id="result"></div>
<script>
function log(msg) {
document.getElementById("result").innerHTML += msg + "<br>";
}
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
var count = 1;
var es = new EventSource("resources/es-eof.php");
es.onerror = function () {
if (count++ == 3) {
es.close();
if (window.testRunner)
testRunner.notifyDone();
}
};
es.onmessage = function (evt) {
if (evt.data == ("DATA" + count)) {
if (evt.lastEventId == count) {
if (evt.type == "message")
log("PASS: got event with expected data, lastEventId, and type");
else
log("FAIL: got expected data and lastEventId but type is wrong");
}
else if (evt.type == "message")
log("FAIL: got expected data but lastEventId is wrong");
else
log("FAIL: got expected data but lastEventId and type are wrong");
}
else if (count == 3 && evt.data == "DATA" && evt.lastEventId == "3.1" && evt.type == "msg")
log("DONE");
else
log("FAIL: got unexpected message event");
};
es.addEventListener("msg", es.onmessage);
</script>
</body>
</html>