blob: 308e4d5d7ad430dda76d71c4a43930c70a828331 [file] [log] [blame]
Andrew Top61a84952019-04-30 15:07:33 -07001<!DOCTYPE html>
2<html>
3 <head>
4 <title>EventSource: request cancellation</title>
5 <script src="/resources/testharness.js"></script>
6 <script src="/resources/testharnessreport.js"></script>
7 </head>
8 <body>
9 <div id="log"></div>
10 <script>
11 var t = async_test();
12 onload = t.step_func(function() {
13 var url = "resources/message.py?sleep=1000&message=" + encodeURIComponent("retry:1000\ndata:abc\n\n");
14 var es = new EventSource(url);
15 es.onerror = t.step_func(function() {
16 assert_equals(es.readyState, EventSource.CLOSED)
17 setTimeout(t.step_func(function () {
18 assert_equals(es.readyState, EventSource.CLOSED,
19 "After stopping the eventsource readyState should be CLOSED")
20 t.done();
21 }), 1000);
22 });
23
24 setTimeout(t.step_func(function() {
25 window.stop()
26 es.onopen = t.unreached_func("Got open event");
27 es.onmessage = t.unreached_func("Got message after closing source");
28 }), 0);
29 });
30 </script>
31 </body>
32</html>