Chromium Code Reviews| Index: LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html |
| diff --git a/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html b/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..84691be8a935cfc9cbfe6cf30b21d47eae9514cd |
| --- /dev/null |
| +++ b/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html |
| @@ -0,0 +1,46 @@ |
| +<!doctype html> |
| +<html> |
| +<head> |
| +<script src="../resources/testharness.js"></script> |
| +<script src="../resources/testharnessreport.js"></script> |
| +</head> |
| +<body> |
| +<p> Verify that a timeout ProgressEvent is dispatched and have the expected values.</p> |
| +<div id="log"></div> |
| +<script type="text/javascript"> |
| + |
| +function verifyProgressEvent(context, e) |
| +{ |
| + assert_true(e.loaded > 0, "Non-zero 'loaded' value for '" + context + " ' event."); |
|
tyoshino (SeeGerritForStatus)
2013/11/25 12:35:33
" ' event.");
->
"' event.");
tyoshino (SeeGerritForStatus)
2013/11/25 12:35:33
e.loaded == 0 is rare and hard to observe but poss
sof
2013/11/25 15:28:18
Done.
sof
2013/11/25 15:28:18
Let's do that.
|
| + assert_true(!e.lengthComputable || e.total > 0, "Non-zero 'total' value for '" + context + "' event."); |
| +} |
| + |
| +function logProgressEvent(e) { |
| + results += " " + e.type; |
| +} |
| + |
| +function unexpectedProgressEvent(e) { |
| + assert_unreached("Unexpected request error"); |
| +} |
| + |
| +function timeoutHandler(e) |
| +{ |
| + assert_true(e instanceof ProgressEvent); |
| + verifyProgressEvent("ontimeout", e); |
| + testOnTimeoutEvent.done(); |
| +} |
| + |
| +var testOnTimeoutEvent = async_test("Check that 'timeout' events are delivered and have expected values."); |
| +testOnTimeoutEvent.step(function () { |
| + var xhr = new XMLHttpRequest(); |
| + xhr.ontimeout = testOnTimeoutEvent.step_func(timeoutHandler); |
| + xhr.onabort = testOnTimeoutEvent.step_func(unexpectedProgressEvent); |
| + xhr.onerror = testOnTimeoutEvent.step_func(unexpectedProgressEvent); |
| + xhr.onload = testOnTimeoutEvent.step_func(unexpectedProgressEvent); |
| + xhr.timeout = 30; |
| + xhr.open("GET", "resources/big-response.php", true); |
|
tyoshino (SeeGerritForStatus)
2013/11/25 12:35:33
how about using load-and-stall.php? maybe it'll le
sof
2013/11/25 15:28:18
Ah, didn't know of its existence. Switched.
|
| + xhr.send(); |
| +}); |
| +</script> |
| +</body> |
| +</html> |