Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/xmlhttprequest/ontimeout-event-override-after-failure.html

Issue 2518383003: Rewrite ontimeout-event-override-after-failure for less flakes and better errors (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!doctype html> 1 <!doctype html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <pre id='console'></pre> 4 <pre id='consoleElement'></pre>
5 <script type="text/javascript"> 5 <script type="text/javascript">
6 function log(message) 6 function log(message) {
7 { 7 consoleElement.appendChild(document.createTextNode(message + "\n"));
8 document.getElementById('console').appendChild(document.createTextNode(messa ge + "\n"));
9 } 8 }
10 9
11 if (window.testRunner) { 10 if (window.testRunner) {
12 testRunner.dumpAsText(); 11 testRunner.dumpAsText();
13 testRunner.waitUntilDone(); 12 testRunner.waitUntilDone();
14 } 13 }
15 14
16 (function() { 15 (function() {
17 var xhr = new XMLHttpRequest; 16 var xhr = new XMLHttpRequest;
18 var error = false; 17 var errorCalled = false;
19 var errorCalled = false;
20 18
21 function testSuccess() { 19 xhr.onerror = function() {
22 if (!error) 20 errorCalled = true;
23 log("PASS: Timeout override did not reactivate timer after failure") ; 21 xhr.timeout = 1;
24 }
25 22
26 function performAssertions() { 23 // To ensure xhr.ontimeout is not called, we asynchronously record whether
27 if (!errorCalled) 24 // the test passes.
28 log("FAIL: error event not dispatched"); 25 setTimeout(function() {
29 else 26 log("PASS: Timeout override did not reactivate timer after failure");
30 testSuccess(); 27 if (window.testRunner)
31 if (window.testRunner) 28 testRunner.notifyDone();
32 testRunner.notifyDone(); 29 }, 50);
33 } 30 };
34 31
35 xhr.onerror = function() { 32 xhr.ontimeout = function() {
36 xhr.timeout = 1; 33 // This test should never time out. There are two failure modes depending on
37 errorCalled = true; 34 // whether xhr.onerror was called or not.
38 }; 35 if (errorCalled)
36 log("FAIL: Timeout override reactivated the timer.");
37 else
38 log("FAIL: Request timed out but should have failed due to origin restrict ions.");
39 39
40 xhr.ontimeout = function() { 40 if (window.testRunner)
41 error = true; 41 testRunner.notifyDone();
42 log("FAIL: Timeout override reactivated the timer"); 42 }
43 }
44 43
45 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-contr ol-basic-denied.cgi"); 44 xhr.open("GET", "http://localhost:8000/xmlhttprequest/resources/access-control -basic-denied.cgi");
46 xhr.timeout = 180; 45 xhr.timeout = 500;
47 xhr.send(); 46 xhr.send();
48
49 setTimeout(performAssertions, 200);
50 })(); 47 })();
51 </script> 48 </script>
52 </body> 49 </body>
53 </html> 50 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698