| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="/resources/testharness.js"></script> |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame^] | 5 | <script src="/resources/testharnessreport.js"></script> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 6 | <title>XMLHttpRequest: The send() method: timeout is not 0 </title> |
| 7 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" /> |
| 8 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#infrastructure-for-the-send()-method" data-tested-assertations="following::dt[5] following::a[contains(@href,'#timeout-error')]/.." /> |
| 9 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#timeout-error" data-tested-assertations=".." /> |
| 10 | <link rel="help" href="http://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#request-error" data-tested-assertations="following::ol[1]/li[4] following::ol[1]/li[6] following::ol[1]/li[7]/ol/li[3] following::ol[1]/li[7]/ol/li[4] following::ol[1]/li[9] following::ol[1]/li[10]" /> |
| 11 | </head> |
| 12 | |
| 13 | <body> |
| 14 | <div id="log"></div> |
| 15 | |
| 16 | <script type="text/javascript"> |
| 17 | var test = async_test(); |
| 18 | |
| 19 | test.step(function() |
| 20 | { |
| 21 | var xhr = new XMLHttpRequest(); |
| 22 | var expect = [4, "", "upload.timeout", "upload.loadend", "timeout", "loadend"]; |
| 23 | var actual = []; |
| 24 | |
| 25 | xhr.onreadystatechange = function() |
| 26 | { |
| 27 | test.step(function() |
| 28 | { |
| 29 | if (xhr.readyState == 4) |
| 30 | { |
| 31 | actual.push(xhr.readyState, xhr.response); |
| 32 | } |
| 33 | }); |
| 34 | }; |
| 35 | |
| 36 | xhr.onloadend = function(e){ actual.push(e.type); VerifyResult()}; |
| 37 | xhr.ontimeout = function(e){ actual.push(e.type); }; |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame^] | 38 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 39 | xhr.upload.onloadend = function(e){ actual.push("upload." + e.type);}; |
| 40 | xhr.upload.ontimeout = function(e){ actual.push("upload." + e.type); }; |
| 41 | |
| 42 | function VerifyResult() |
| 43 | { |
| 44 | test.step(function() |
| 45 | { |
| 46 | assert_array_equals(actual, expect); |
| 47 | test.done(); |
| 48 | }); |
| 49 | }; |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame^] | 50 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 51 | var content = ""; |
| 52 | for (var i = 0; i < 121026; i++) |
| 53 | { |
| 54 | content += "[" + i + "]"; |
| 55 | } |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame^] | 56 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 57 | xhr.open("POST", "./resources/trickle.py", true); |
| 58 | xhr.timeout = 1; |
| 59 | xhr.send(content); |
| 60 | }); |
| 61 | </script> |
| 62 | </body> |
| 63 | </html> |