| Index: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html
|
| diff --git a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html
|
| index f642782a724d8e7b7f6659832115fdd90409e7b4..3c7aef01ae9d50a52c9b11e52b0e2a048ca448e0 100644
|
| --- a/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html
|
| +++ b/third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html
|
| @@ -1,52 +1,49 @@
|
| <!doctype html>
|
| <html>
|
| <body>
|
| -<pre id='console'></pre>
|
| +<pre id='consoleElement'></pre>
|
| <script type="text/javascript">
|
| -function log(message)
|
| -{
|
| - document.getElementById('console').appendChild(document.createTextNode(message + "\n"));
|
| +function log(message) {
|
| + consoleElement.appendChild(document.createTextNode(message + "\n"));
|
| }
|
|
|
| if (window.testRunner) {
|
| - testRunner.dumpAsText();
|
| - testRunner.waitUntilDone();
|
| + testRunner.dumpAsText();
|
| + testRunner.waitUntilDone();
|
| }
|
|
|
| (function() {
|
| - var xhr = new XMLHttpRequest;
|
| - var error = false;
|
| - var errorCalled = false;
|
| -
|
| - function testSuccess() {
|
| - if (!error)
|
| - log("PASS: Timeout override did not reactivate timer after failure");
|
| - }
|
| -
|
| - function performAssertions() {
|
| - if (!errorCalled)
|
| - log("FAIL: error event not dispatched");
|
| - else
|
| - testSuccess();
|
| - if (window.testRunner)
|
| - testRunner.notifyDone();
|
| - }
|
| -
|
| - xhr.onerror = function() {
|
| - xhr.timeout = 1;
|
| - errorCalled = true;
|
| - };
|
| -
|
| - xhr.ontimeout = function() {
|
| - error = true;
|
| - log("FAIL: Timeout override reactivated the timer");
|
| - }
|
| -
|
| - xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-denied.cgi");
|
| - xhr.timeout = 180;
|
| - xhr.send();
|
| -
|
| - setTimeout(performAssertions, 200);
|
| + var xhr = new XMLHttpRequest;
|
| + var errorCalled = false;
|
| +
|
| + xhr.onerror = function() {
|
| + errorCalled = true;
|
| + xhr.timeout = 1;
|
| +
|
| + // To ensure xhr.ontimeout is not called, we asynchronously record whether
|
| + // the test passes.
|
| + setTimeout(function() {
|
| + log("PASS: Timeout override did not reactivate timer after failure");
|
| + if (window.testRunner)
|
| + testRunner.notifyDone();
|
| + }, 50);
|
| + };
|
| +
|
| + xhr.ontimeout = function() {
|
| + // This test should never time out. There are two failure modes depending on
|
| + // whether xhr.onerror was called or not.
|
| + if (errorCalled)
|
| + log("FAIL: Timeout override reactivated the timer.");
|
| + else
|
| + log("FAIL: Request timed out but should have failed due to origin restrictions.");
|
| +
|
| + if (window.testRunner)
|
| + testRunner.notifyDone();
|
| + }
|
| +
|
| + xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control-basic-denied.cgi");
|
| + xhr.timeout = 500;
|
| + xhr.send();
|
| })();
|
| </script>
|
| </body>
|
|
|