OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="/js-test-resources/js-test.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <script> |
| 8 description("Tests if repeated loading of non-existent img.src resources doesn't
deliver onload."); |
| 9 |
| 10 window.jsTestIsAsync = true; |
| 11 if (window.testRunner) { |
| 12 testRunner.dumpAsText(); |
| 13 testRunner.waitUntilDone(); |
| 14 } |
| 15 |
| 16 function finish(final) |
| 17 { |
| 18 // Test handling for missing image resources and |
| 19 // ones that load, but with status 404. |
| 20 if (!final) { |
| 21 testImageOnError(true); |
| 22 return; |
| 23 } |
| 24 window.finishJSTest(); |
| 25 } |
| 26 |
| 27 function testImageOnError(broken) |
| 28 { |
| 29 var img = new Image(); |
| 30 img.expectOnLoad = broken; |
| 31 img.onload = function() { |
| 32 if (img.expectOnLoad) |
| 33 testPassed("Received onload for broken img.src"); |
| 34 else |
| 35 testFailed("Received onload for non-existent img.src"); |
| 36 |
| 37 finish(img.expectOnLoad); |
| 38 }; |
| 39 img.onerror = function () { |
| 40 if (img.expectOnLoad) { |
| 41 img.onerror = null; |
| 42 testFailed("Received onload for boken img.src"); |
| 43 finish(img.expectOnLoad); |
| 44 return; |
| 45 } |
| 46 else |
| 47 testPassed("Received onerror for non-existent img.src"); |
| 48 |
| 49 if (img.haveFailedAlready) { |
| 50 img.onerror = null; |
| 51 testPassed("Received error event repeatedly."); |
| 52 finish(img.expectOnLoad); |
| 53 return; |
| 54 } |
| 55 img.haveFailedAlready = true; |
| 56 img.src = "invalidinvalid2.jpg"; |
| 57 }; |
| 58 img.src = broken ? "resources/404image.php" : "resources/non-existent.png"; |
| 59 } |
| 60 testImageOnError(false); |
| 61 </script> |
| 62 <div id="console"></div> |
| 63 </body> |
| 64 </html> |
OLD | NEW |