Index: LayoutTests/http/tests/misc/image-onerror-no-load-event.html |
diff --git a/LayoutTests/http/tests/misc/image-onerror-no-load-event.html b/LayoutTests/http/tests/misc/image-onerror-no-load-event.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a7861cb5a86c00155c72d4a4a344d48d70af16e4 |
--- /dev/null |
+++ b/LayoutTests/http/tests/misc/image-onerror-no-load-event.html |
@@ -0,0 +1,64 @@ |
+<!doctype html> |
+<html> |
+<head> |
+<script src="/js-test-resources/js-test.js"></script> |
+</head> |
+<body> |
+<script> |
+description("Tests if repeated loading of non-existent img.src resources doesn't deliver onload."); |
+ |
+window.jsTestIsAsync = true; |
+if (window.testRunner) { |
+ testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+} |
+ |
+function finish(final) |
+{ |
+ // Test handling for missing image resources and |
+ // ones that load, but with status 404. |
+ if (!final) { |
+ testImageOnError(true); |
+ return; |
+ } |
+ window.finishJSTest(); |
+} |
+ |
+function testImageOnError(broken) |
+{ |
+ var img = new Image(); |
+ img.expectOnLoad = broken; |
+ img.onload = function() { |
+ if (img.expectOnLoad) |
+ testPassed("Received onload for broken img.src"); |
+ else |
+ testFailed("Received onload for non-existent img.src"); |
+ |
+ finish(img.expectOnLoad); |
+ }; |
+ img.onerror = function () { |
+ if (img.expectOnLoad) { |
+ img.onerror = null; |
+ testFailed("Received onload for boken img.src"); |
+ finish(img.expectOnLoad); |
+ return; |
+ } |
+ else |
+ testPassed("Received onerror for non-existent img.src"); |
+ |
+ if (img.haveFailedAlready) { |
+ img.onerror = null; |
+ testPassed("Received error event repeatedly."); |
+ finish(img.expectOnLoad); |
+ return; |
+ } |
+ img.haveFailedAlready = true; |
+ img.src = "invalidinvalid2.jpg"; |
+ }; |
+ img.src = broken ? "resources/404image.php" : "resources/non-existent.png"; |
+} |
+testImageOnError(false); |
+</script> |
+<div id="console"></div> |
+</body> |
+</html> |