Chromium Code Reviews| Index: LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override.html |
| diff --git a/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html b/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override.html |
| similarity index 50% |
| copy from LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html |
| copy to LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override.html |
| index 23d1e0474ac3999b5604fc2af961b31f098d1761..23e17e8f9930b9958e2e87ff32cca7504af3fb67 100644 |
| --- a/LayoutTests/http/tests/xmlhttprequest/ontimeout-event.html |
| +++ b/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override.html |
| @@ -6,40 +6,36 @@ |
| </head> |
| <body> |
| <p> Verify that a timeout ProgressEvent is dispatched and have the expected values.</p> |
|
tyoshino (SeeGerritForStatus)
2014/05/21 04:59:49
remove
|
| -<div id="log"></div> |
| +<div id="logEvent"></div> |
|
tyoshino (SeeGerritForStatus)
2014/05/21 04:59:49
remove
|
| <script type="text/javascript"> |
| +var didTimeout = false; |
| -function verifyProgressEvent(context, e) |
| -{ |
| - assert_true(e.loaded >= 0, "Non-zero 'loaded' value for '" + context + "' event."); |
| - assert_true(!e.lengthComputable || e.total > 0, "Non-zero 'total' value for '" + context + "' event."); |
| -} |
| - |
| -function logProgressEvent(e) { |
| - results += " " + e.type; |
| +function timeoutEvent(e) { |
| + didTimeout = true; |
| } |
| function unexpectedProgressEvent(e) { |
| - assert_unreached("Unexpected request error"); |
| -} |
| - |
| -function timeoutHandler(e) |
| -{ |
| - assert_true(e instanceof ProgressEvent); |
| - verifyProgressEvent("ontimeout", e); |
| - testOnTimeoutEvent.done(); |
| + assert_unreached("'" + e.type + "' event should not be dispatched, expected 'timeout'"); |
| } |
| 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.ontimeout = testOnTimeoutEvent.step_func(timeoutEvent); |
| 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/load-and-stall.php?name=../resources/test.mp4&stallAt=100&stallFor=10000&mimeType=video/mp4", true); |
| + xhr.onloadend = testOnTimeoutEvent.step_func(function(e) { |
| + assert_true(didTimeout, "'timeout' event should be dispatched after 400ms"); |
| + testOnTimeoutEvent.done(); |
| + }); |
| + xhr.timeout = 100000; |
| + xhr.open("GET", "../resources/load-and-stall.php?name=test.mp4&stallAt=0&stallFor=1000&mimeType=video/mp4", true); |
| xhr.send(); |
| + // Defer overriding timeout |
| + setTimeout(function() { |
| + xhr.timeout = 400; |
| + }, 200); |
| }); |
| </script> |
| </body> |