4 <script src=
"/js-test-resources/js-test.js"></script>
8 description("Tests if repeated loading of non-existent img.src resources doesn't deliver onload.");
10 window
.jsTestIsAsync
= true;
11 if (window
.testRunner
) {
12 testRunner
.dumpAsText();
13 testRunner
.waitUntilDone();
16 function finish(final
)
18 // Test handling for missing image resources and
19 // ones that load, but with status 404.
21 testImageOnError(true);
24 window
.finishJSTest();
27 function testImageOnError(broken
)
29 var img
= new Image();
30 img
.expectOnLoad
= broken
;
31 img
.onload = function() {
33 testPassed("Received onload for broken img.src");
35 testFailed("Received onload for non-existent img.src");
37 finish(img
.expectOnLoad
);
39 img
.onerror = function () {
40 if (img
.expectOnLoad
) {
42 testFailed("Received onload for boken img.src");
43 finish(img
.expectOnLoad
);
47 testPassed("Received onerror for non-existent img.src");
49 if (img
.haveFailedAlready
) {
51 testPassed("Received error event repeatedly.");
52 finish(img
.expectOnLoad
);
55 img
.haveFailedAlready
= true;
56 img
.src
= "invalidinvalid2.jpg";
58 img
.src
= broken
? "resources/404image.php" : "resources/non-existent.png";
60 testImageOnError(false);
62 <div id=
"console"></div>