| Andrea Marchesini | 1280be6 | 2017-02-15 19:50:38 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta charset="utf-8" /> |
| 5 | <title>XHR2 Timeout Property Tests</title> |
| 6 | <link rel="help" href="https://xhr.spec.whatwg.org/#timeout-error" /> |
| 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/#handler-xhr-ontimeout" data-tested-assertations="../.."/> |
| 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[9]"/> |
| 11 | <link rel="help" href="https://xhr.spec.whatwg.org/#infrastructure-for-the-send()-method" data-tested-assertations="following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/.. following-sibling::dl//code[contains(@title,'dom-XMLHttpRequest-timeout')]/../following-sibling::dd following::dt[1] following::dd[1]" /> |
| 12 | <meta name=timeout content=long> |
| 13 | <script src="/resources/testharness.js"></script> |
| 14 | <script src="/resources/testharnessreport.js"></script> |
| 15 | </head> |
| 16 | <body> |
| 17 | <div id="log"></div> |
| 18 | <script type="text/javascript"> |
| 19 | |
| 20 | function startRequest() { |
| 21 | xhr.open("GET", "./resources/content.py?content=Hi", true); |
| 22 | xhr.timeout = 2000; |
| 23 | setTimeout(function () { |
| 24 | xhr.send(); |
| 25 | }, 1000); |
| 26 | } |
| 27 | |
| 28 | var test = async_test(); |
| 29 | test.step(function() |
| 30 | { |
| 31 | var count = 0; |
| 32 | xhr = new XMLHttpRequest(); |
| 33 | xhr.onload = function () { |
| 34 | assert_equals(xhr.response, "Hi"); |
| 35 | if (++count == 2) { |
| 36 | test.done(); |
| 37 | } |
| 38 | } |
| 39 | xhr.ontimeout = function () { |
| 40 | assert_unreached("HTTP error should not timeout"); |
| 41 | } |
| 42 | startRequest(); |
| 43 | setTimeout(startRequest, 3500); |
| 44 | }); |
| 45 | |
| 46 | </script> |
| 47 | </body> |
| 48 | </html> |