| 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> |
| Ms2ger | 91fef14 | 2014-11-01 09:24:37 | [diff] [blame] | 7 | <link rel="help" href="https://xhr.spec.whatwg.org/#the-timeout-attribute" data-tested-assertations="following::ol[1]/li[2]" /> |
| 8 | <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following::dt[5] following::a[contains(@href,'#timeout-error')]/.." /> |
| 9 | <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" data-tested-assertations=".." /> |
| 10 | <link rel="help" href="https://xhr.spec.whatwg.org/#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]" /> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 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(); |
| Hallvord R. M. Steen | 04766af | 2015-03-15 16:53:07 | [diff] [blame] | 22 | var expect = [4, "", "upload.timeout", "upload.loadend", "timeout", "loadend"]; |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 23 | var actual = []; |
| 24 | |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame^] | 25 | xhr.onreadystatechange = test.step_func(function() |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 26 | { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 27 | if (xhr.readyState == 4) |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 28 | { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 29 | actual.push(xhr.readyState, xhr.response); |
| 30 | } |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame^] | 31 | }); |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 32 | |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame^] | 33 | xhr.onloadend = test.step_func_done(function(e) |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 34 | { |
| 35 | assert_equals(e.loaded, 0); |
| 36 | assert_equals(e.total, 0); |
| Hallvord R. M. Steen | 04766af | 2015-03-15 16:53:07 | [diff] [blame] | 37 | actual.push(e.type); |
| 38 | assert_array_equals(actual, expect); |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 39 | }); |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 40 | |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame^] | 41 | xhr.ontimeout = test.step_func(function(e) |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 42 | { |
| 43 | assert_equals(e.loaded, 0); |
| 44 | assert_equals(e.total, 0); |
| 45 | actual.push(e.type); |
| 46 | }); |
| 47 | |
| 48 | |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame^] | 49 | xhr.upload.onloadend = test.step_func(function(e) |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 50 | { |
| 51 | assert_equals(e.loaded, 0); |
| 52 | assert_equals(e.total, 0); |
| 53 | actual.push("upload." + e.type); |
| 54 | }); |
| 55 | |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame^] | 56 | xhr.upload.ontimeout = test.step_func(function(e) |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 57 | { |
| 58 | assert_equals(e.loaded, 0); |
| 59 | assert_equals(e.total, 0); |
| 60 | actual.push("upload." + e.type); |
| 61 | }); |
| 62 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 63 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 64 | var content = ""; |
| 65 | for (var i = 0; i < 121026; i++) |
| 66 | { |
| 67 | content += "[" + i + "]"; |
| 68 | } |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 69 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 70 | xhr.open("POST", "./resources/trickle.py", true); |
| 71 | xhr.timeout = 1; |
| 72 | xhr.send(content); |
| 73 | }); |
| 74 | </script> |
| 75 | </body> |
| 76 | </html> |