| 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> |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 7 | </head> |
| 8 | |
| 9 | <body> |
| 10 | <div id="log"></div> |
| 11 | |
| 12 | <script type="text/javascript"> |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 13 | async_test(t => { |
| 14 | const xhr = new XMLHttpRequest(), |
| 15 | expect = [4, "", "upload.timeout", "upload.loadend", "timeout", "loadend"]; |
| 16 | let actual = []; |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 17 | |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 18 | xhr.onreadystatechange = t.step_func(() => { |
| 19 | if (xhr.readyState == 4) { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 20 | actual.push(xhr.readyState, xhr.response); |
| 21 | } |
| Hallvord R. M. Steen | 9ca5bae | 2015-03-20 14:24:24 | [diff] [blame] | 22 | }); |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 23 | |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 24 | xhr.onloadend = t.step_func_done(e => { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 25 | assert_equals(e.loaded, 0); |
| 26 | assert_equals(e.total, 0); |
| Hallvord R. M. Steen | 04766af | 2015-03-15 16:53:07 | [diff] [blame] | 27 | actual.push(e.type); |
| 28 | assert_array_equals(actual, expect); |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 29 | }); |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 30 | |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 31 | xhr.ontimeout = t.step_func(e => { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 32 | assert_equals(e.loaded, 0); |
| 33 | assert_equals(e.total, 0); |
| 34 | actual.push(e.type); |
| 35 | }); |
| 36 | |
| 37 | |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 38 | xhr.upload.onloadend = t.step_func(e => { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 39 | assert_equals(e.loaded, 0); |
| 40 | assert_equals(e.total, 0); |
| 41 | actual.push("upload." + e.type); |
| 42 | }); |
| 43 | |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 44 | xhr.upload.ontimeout = t.step_func(e => { |
| Hallvord R. M. Steen | 7603c6c | 2015-03-14 09:41:19 | [diff] [blame] | 45 | assert_equals(e.loaded, 0); |
| 46 | assert_equals(e.total, 0); |
| 47 | actual.push("upload." + e.type); |
| 48 | }); |
| 49 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 50 | |
| Anne van Kesteren | 89f9a29 | 2018-04-24 11:08:49 | [diff] [blame^] | 51 | let content = ""; |
| 52 | for (var i = 0; i < 121026; i++) { |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 53 | content += "[" + i + "]"; |
| 54 | } |
| James Graham | a3d9d8e | 2014-06-09 13:06:48 | [diff] [blame] | 55 | |
| Philip Jägenstedt | c053f40 | 2014-01-22 17:02:18 | [diff] [blame] | 56 | xhr.open("POST", "./resources/trickle.py", true); |
| 57 | xhr.timeout = 1; |
| 58 | xhr.send(content); |
| 59 | }); |
| 60 | </script> |
| 61 | </body> |
| 62 | </html> |