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

Side by Side Diff: third_party/WebKit/LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror.html

Issue 1449413002: Deflake http/tests/misc/script-sync-slow-scripts-onerror.html (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="/js-test-resources/js-test.js"></script> 4 <script src="/js-test-resources/js-test.js"></script>
5 <script> 5 <script>
6 function loadScript(url, async, onload, onerror) { 6 function loadScript(url, async, onload, onerror) {
7 var script = document.createElement("script"); 7 var script = document.createElement("script");
8 script.async = async; 8 script.async = async;
9 script.onload = onload; 9 script.onload = onload;
10 if (onerror) 10 if (onerror)
11 script.onerror = onerror; 11 script.onerror = onerror;
12 script.src = url; 12 script.src = url;
13 document.head.appendChild(script); 13 document.head.appendChild(script);
14 } 14 }
15 </script> 15 </script>
16 </head> 16 </head>
17 <body> 17 <body>
18 <script> 18 <script>
19 description("Slow scripts that fail to load should not dispatch multiple error e vents"); 19 description("Slow scripts that fail to load should not dispatch multiple error e vents");
20 20
21 window.jsTestIsAsync = true; 21 window.jsTestIsAsync = true;
22 22
23 if (window.testRunner) { 23 if (window.testRunner) {
24 testRunner.dumpAsText(); 24 testRunner.dumpAsText();
25 testRunner.waitUntilDone(); 25 testRunner.waitUntilDone();
26 } 26 }
27 27
28 var firstOnErrorHandlerHasRun = false; 28 var firstOnErrorHandlerCount = 0;
29 var secondOnErrorHandlerCount = 0;
30 function verifyAndFinish() {
31 shouldBe("firstOnErrorHandlerCount", "1");
32 shouldBe("secondOnErrorHandlerCount", "1");
33 finishJSTest();
34 };
35
29 function failedFirst() { 36 function failedFirst() {
30 shouldBeFalse("firstOnErrorHandlerHasRun"); 37 firstOnErrorHandlerCount++;
31 firstOnErrorHandlerHasRun = true;
32 // Issue another script load so as to have the script runner 38 // Issue another script load so as to have the script runner
33 // revisit its script queue. This should not result in this 39 // revisit its script queue. This should not result in this
34 // onerror handler running again. 40 // onerror handler running again.
35 loadScript("resources/success.js?1", true); 41 var continuation = secondOnErrorHandlerCount ? verifyAndFinish : undefined;
42 loadScript("resources/success.js?1", true, continuation);
36 } 43 }
37 44
38 var secondOnErrorHandlerHasRun = false;
39 function failedSecond() { 45 function failedSecond() {
40 shouldBeTrue("firstOnErrorHandlerHasRun"); 46 secondOnErrorHandlerCount++;
41 shouldBeFalse("secondOnErrorHandlerHasRun"); 47 var continuation = firstOnErrorHandlerCount ? verifyAndFinish : undefined;
42 secondOnErrorHandlerHasRun = true; 48 loadScript("resources/success.js?2", true, continuation);
43 loadScript("resources/success.js?2", true, finishJSTest);
44 } 49 }
45 50
46 function unexpectedLoad() { 51 function unexpectedLoad() {
47 testFailed("Script should not have loaded"); 52 testFailed("Script should not have loaded");
48 finishJSTest(); 53 finishJSTest();
49 } 54 }
50 55
51 loadScript("resources/success.js?3", false); 56 loadScript("resources/success.js?3", false);
52 loadScript("resources/slow-nonexisting-script.php?sleep=1", false, unexpectedLoa d, failedFirst); 57 loadScript("resources/slow-nonexisting-script.php?sleep=1", false, unexpectedLoa d, failedFirst);
53 loadScript("resources/slow-nonexisting-script.php?sleep=2", false, unexpectedLoa d, failedSecond); 58 loadScript("resources/slow-nonexisting-script.php?sleep=2", false, unexpectedLoa d, failedSecond);
54 </script> 59 </script>
55 </body> 60 </body>
56 </html> 61 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698