blob: 5b96a3e0a5a6be2c4f28d994721a57a70814887e [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>
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 Grahama3d9d8e2014-06-09 13:06:4838
Philip Jägenstedtc053f402014-01-22 17:02:1839 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 Grahama3d9d8e2014-06-09 13:06:4850
Philip Jägenstedtc053f402014-01-22 17:02:1851 var content = "";
52 for (var i = 0; i < 121026; i++)
53 {
54 content += "[" + i + "]";
55 }
James Grahama3d9d8e2014-06-09 13:06:4856
Philip Jägenstedtc053f402014-01-22 17:02:1857 xhr.open("POST", "./resources/trickle.py", true);
58 xhr.timeout = 1;
59 xhr.send(content);
60 });
61 </script>
62</body>
63</html>