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

Unified Diff: LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror.html

Issue 1263743002: Upon load failure, remove sync script from execution queue. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: correctly remove in-order script loader from queue Created 5 years, 4 months 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 side-by-side diff with in-line comments
Download patch
Index: LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror.html
diff --git a/LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror.html b/LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror.html
new file mode 100644
index 0000000000000000000000000000000000000000..31138b6df7b4337eaa221b2988ff43d70e5a7e50
--- /dev/null
+++ b/LayoutTests/http/tests/misc/script-sync-slow-scripts-onerror.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="/js-test-resources/js-test.js"></script>
+<script>
+function loadScript(url, async, onload, onerror) {
+ var script = document.createElement("script");
+ script.async = async;
+ script.onload = onload;
+ if (onerror)
+ script.onerror = onerror;
+ script.src = url;
+ document.head.appendChild(script);
+}
+</script>
+</head>
+<body>
+<script>
+description("Slow scripts that fail to load should not dispatch multiple error events");
+
+window.jsTestIsAsync = true;
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+var firstOnErrorHandlerHasRun = false;
+function failedFirst() {
+ shouldBeFalse("firstOnErrorHandlerHasRun");
+ firstOnErrorHandlerHasRun = true;
+ // Issue another script load so as to have the script runner
+ // revisit its script queue. This should not result in this
+ // onerror handler running again.
+ loadScript("resources/success.js?1", true);
+}
+
+var secondOnErrorHandlerHasRun = false;
+function failedSecond() {
+ shouldBeTrue("firstOnErrorHandlerHasRun");
+ shouldBeFalse("secondOnErrorHandlerHasRun");
+ secondOnErrorHandlerHasRun = true;
+ loadScript("resources/success.js?2", true, finishJSTest);
+}
+
+function unexpectedLoad() {
+ testFailed("Script should not have loaded");
+ finishJSTest();
+}
+
+loadScript("resources/success.js?3", false);
+loadScript("resources/slow-nonexisting-script.php?sleep=1", false, unexpectedLoad, failedFirst);
+loadScript("resources/slow-nonexisting-script.php?sleep=2", false, unexpectedLoad, failedSecond);
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698