format-field-retry.any.js (748B)
1 // META: title=EventSource: "retry" field 2 var test = async_test(); 3 test.step(function() { 4 var timeoutms = 3000, 5 timeoutstr = "03000", // 1536 in octal, but should be 3000 6 source = new EventSource("resources/message.py?message=retry%3A" + timeoutstr + "%0Adata%3Ax"), 7 opened = 0 8 source.onopen = function() { 9 test.step(function() { 10 if(opened == 0) 11 opened = new Date().getTime() 12 else { 13 var diff = (new Date().getTime()) - opened 14 assert_true(Math.abs(1 - diff / timeoutms) < 0.25) // allow 25% difference 15 this.close(); 16 test.done() 17 } 18 }, this) 19 } 20 })