send-timeout-events.htm (1836B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <title>XMLHttpRequest: The send() method: timeout is not 0 </title> 7 </head> 8 9 <body> 10 <div id="log"></div> 11 12 <script type="text/javascript"> 13 async_test(t => { 14 const xhr = new XMLHttpRequest(), 15 expect = [4, "", "upload.timeout", "upload.loadend", "timeout", "loadend"]; 16 let actual = []; 17 18 xhr.onreadystatechange = t.step_func(() => { 19 if (xhr.readyState == 4) { 20 actual.push(xhr.readyState, xhr.response); 21 } 22 }); 23 24 xhr.onloadend = t.step_func_done(e => { 25 assert_equals(e.loaded, 0); 26 assert_equals(e.total, 0); 27 actual.push(e.type); 28 assert_array_equals(actual, expect); 29 }); 30 31 xhr.ontimeout = t.step_func(e => { 32 assert_equals(e.loaded, 0); 33 assert_equals(e.total, 0); 34 actual.push(e.type); 35 }); 36 37 38 xhr.upload.onloadend = t.step_func(e => { 39 assert_equals(e.loaded, 0); 40 assert_equals(e.total, 0); 41 actual.push("upload." + e.type); 42 }); 43 44 xhr.upload.ontimeout = t.step_func(e => { 45 assert_equals(e.loaded, 0); 46 assert_equals(e.total, 0); 47 actual.push("upload." + e.type); 48 }); 49 50 51 let content = ""; 52 for (var i = 0; i < 121026; i++) { 53 content += "[" + i + "]"; 54 } 55 56 xhr.open("POST", "./resources/trickle.py", true); 57 xhr.timeout = 1; 58 xhr.send(content); 59 }); 60 </script> 61 </body> 62 </html>