event-data.any.js (641B)
1 // META: title=EventSource: lines and data parsing 2 3 var test = async_test(); 4 test.step(function() { 5 var source = new EventSource("resources/message2.py"), 6 counter = 0; 7 source.onmessage = test.step_func(function(e) { 8 if(counter == 0) { 9 assert_equals(e.data,"msg\nmsg"); 10 } else if(counter == 1) { 11 assert_equals(e.data,""); 12 } else if(counter == 2) { 13 assert_equals(e.data,"end"); 14 source.close(); 15 test.done(); 16 } else { 17 assert_unreached(); 18 } 19 counter++; 20 }); 21 });