OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE HTML> |
2 <p> | 2 <script src="/js-test-resources/js-test.js"></script> |
3 Test that no more message events are fired after EventSource.close() is call
ed, even if it | 3 <script src="script-tests/eventsource-events-after-close.js"></script> |
4 means discarding events that were already processed. | |
5 Passes if only one message is received. | |
6 </p> | |
7 <pre id=log></pre> | |
8 <script> | |
9 if (window.testRunner) { | |
10 testRunner.dumpAsText(); | |
11 testRunner.waitUntilDone(); | |
12 } | |
13 | |
14 var log = document.getElementById("log"); | |
15 var es = new EventSource("resources/event-stream.php"); | |
16 var counter = 0; | |
17 es.addEventListener('message', function (e) { | |
18 log.innerHTML += "Got message #" + ++counter + "\n"; | |
19 | |
20 if (counter > 1) | |
21 log.innerHTML += "FAIL. Handler called after the source was closed e
xplicitely.\n"; | |
22 | |
23 es.close(); | |
24 | |
25 setTimeout(function () { | |
26 // Need to wait to see if we're called again. | |
27 // event-stream.php sends a bunch of events before flushing, so if c
lose() didn't take | |
28 // effect we'd get a second message practically instantaneously, wai
ting 100ms should be ok. | |
29 if (window.testRunner) | |
30 testRunner.notifyDone(); | |
31 }, 100); | |
32 }, false); | |
33 | |
34 </script> | |
OLD | NEW |