blob: eae25681077edeffe8671ef56f4c61ca8ed0b18b [file] [log] [blame]
Philip Jägenstedtc053f402014-01-22 17:02:181<!DOCTYPE html>
2<html>
3<head>
4 <script src="/resources/testharness.js"></script>
James Grahama3d9d8e2014-06-09 13:06:485 <script src="/resources/testharnessreport.js"></script>
Philip Jägenstedtc053f402014-01-22 17:02:186 <title>XMLHttpRequest: The send() method: timeout is not 0 </title>
Philip Jägenstedtc053f402014-01-22 17:02:187</head>
8
9<body>
10 <div id="log"></div>
11
12 <script type="text/javascript">
Anne van Kesteren89f9a292018-04-24 11:08:4913 async_test(t => {
14 const xhr = new XMLHttpRequest(),
15 expect = [4, "", "upload.timeout", "upload.loadend", "timeout", "loadend"];
16 let actual = [];
Philip Jägenstedtc053f402014-01-22 17:02:1817
Anne van Kesteren89f9a292018-04-24 11:08:4918 xhr.onreadystatechange = t.step_func(() => {
19 if (xhr.readyState == 4) {
Hallvord R. M. Steen7603c6c2015-03-14 09:41:1920 actual.push(xhr.readyState, xhr.response);
21 }
Hallvord R. M. Steen9ca5bae2015-03-20 14:24:2422 });
Philip Jägenstedtc053f402014-01-22 17:02:1823
Anne van Kesteren89f9a292018-04-24 11:08:4924 xhr.onloadend = t.step_func_done(e => {
Hallvord R. M. Steen7603c6c2015-03-14 09:41:1925 assert_equals(e.loaded, 0);
26 assert_equals(e.total, 0);
Hallvord R. M. Steen04766af2015-03-15 16:53:0727 actual.push(e.type);
28 assert_array_equals(actual, expect);
Hallvord R. M. Steen7603c6c2015-03-14 09:41:1929 });
James Grahama3d9d8e2014-06-09 13:06:4830
Anne van Kesteren89f9a292018-04-24 11:08:4931 xhr.ontimeout = t.step_func(e => {
Hallvord R. M. Steen7603c6c2015-03-14 09:41:1932 assert_equals(e.loaded, 0);
33 assert_equals(e.total, 0);
34 actual.push(e.type);
35 });
36
37
Anne van Kesteren89f9a292018-04-24 11:08:4938 xhr.upload.onloadend = t.step_func(e => {
Hallvord R. M. Steen7603c6c2015-03-14 09:41:1939 assert_equals(e.loaded, 0);
40 assert_equals(e.total, 0);
41 actual.push("upload." + e.type);
42 });
43
Anne van Kesteren89f9a292018-04-24 11:08:4944 xhr.upload.ontimeout = t.step_func(e => {
Hallvord R. M. Steen7603c6c2015-03-14 09:41:1945 assert_equals(e.loaded, 0);
46 assert_equals(e.total, 0);
47 actual.push("upload." + e.type);
48 });
49
Philip Jägenstedtc053f402014-01-22 17:02:1850
Anne van Kesteren89f9a292018-04-24 11:08:4951 let content = "";
52 for (var i = 0; i < 121026; i++) {
Philip Jägenstedtc053f402014-01-22 17:02:1853 content += "[" + i + "]";
54 }
James Grahama3d9d8e2014-06-09 13:06:4855
Philip Jägenstedtc053f402014-01-22 17:02:1856 xhr.open("POST", "./resources/trickle.py", true);
57 xhr.timeout = 1;
58 xhr.send(content);
59 });
60 </script>
61</body>
62</html>