eventsource-request-cancellation.window.js (838B)
1 // META: title=EventSource: request cancellation 2 3 var t = async_test(); 4 onload = t.step_func(function() { 5 var url = "resources/message.py?sleep=1000&message=" + encodeURIComponent("retry:1000\ndata:abc\n\n"); 6 var es = new EventSource(url); 7 es.onerror = t.step_func(function() { 8 assert_equals(es.readyState, EventSource.CLOSED) 9 t.step_timeout(function () { 10 assert_equals(es.readyState, EventSource.CLOSED, 11 "After stopping the eventsource readyState should be CLOSED") 12 t.done(); 13 }, 1000); 14 }); 15 16 t.step_timeout(function() { 17 window.stop() 18 es.onopen = t.unreached_func("Got open event"); 19 es.onmessage = t.unreached_func("Got message after closing source"); 20 }, 0); 21 });