blob: 9cc72fd8c3d443e24d1da20c476edd72edbaf214 [file] [log] [blame]
<html>
<body>
<p>Test EventSource attribute listener functionality. 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 es = new EventSource("eventsource");
if (es.onopen == null && es.onmessage == null && es.onerror == null)
log("PASS: attribute listeners are initially null");
else
log("FAIL: attribute listeners are not null initially");
var a = function () {};
es.onopen = a;
if (es.onopen == a)
log("PASS: setting and getting attribute listener works");
else
log("FAIL: setting/getting attribute listener does not work");
var b = function () {};
es.onopen = b;
if (es.onopen == b)
log("PASS: resetting attribute listener works");
else
log("FAIL: resetting attribute listener does not work");
var flag = false;
es.onmessage = function (e) { flag = (e.data == "hello"); };
var evt = document.createEvent("MessageEvent");
evt.initMessageEvent("message", false, false, "hello", null, null, null, null);
es.dispatchEvent(evt);
if (flag) {
log("PASS: dispatching event on an EventSource triggers attribute listener");
log("DONE");
}
else
log("FAIL: dispatching event on an EventSource does not trigger attribute listener");
if (window.testRunner)
testRunner.notifyDone();
</script>
</body>
</html>