| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
| 3 <script> | 3 <script> |
| 4 if (window.testRunner) { | 4 if (window.testRunner) { |
| 5 testRunner.waitUntilDone(); | 5 testRunner.waitUntilDone(); |
| 6 testRunner.dumpAsText(); | 6 testRunner.dumpAsText(); |
| 7 } | 7 } |
| 8 img = new Image(); | 8 img = new Image(); |
| 9 var onloadCounter = 0; | 9 var onloadCounter = 0; |
| 10 var testImage = 'resources/green.jpg'; | 10 var testImage = 'resources/green.jpg'; |
| 11 var resetImage = 'resources/bad-png.png'; | 11 var resetImage = ''; |
| 12 img.onload = function(){ | 12 img.onload = function(){ |
| 13 onloadCounter++; | 13 onloadCounter++; |
| 14 debug("Image onload event fired for " + img.src.substring(img.src.lastIn
dexOf('/') + 1)); | 14 debug("Image onload event fired for " + img.src.substring(img.src.lastIn
dexOf('/') + 1)); |
| 15 if (onloadCounter == 2) { | 15 if (onloadCounter == 2) { |
| 16 document.getElementById('result').textContent = "PASS"; | 16 document.getElementById('result').textContent = "PASS"; |
| 17 if (window.testRunner) | 17 if (window.testRunner) |
| 18 testRunner.notifyDone(); | 18 testRunner.notifyDone(); |
| 19 return; | 19 return; |
| 20 } | 20 } |
| 21 if (onloadCounter == 1) { | 21 if (onloadCounter == 1) { |
| 22 setTimeout(function() { | 22 setTimeout(function() { |
| 23 img.src= resetImage; | 23 img.src= resetImage; |
| 24 img.src = testImage; | 24 img.src = testImage; |
| 25 }, 0); | 25 }, 0); |
| 26 return; | 26 return; |
| 27 } | 27 } |
| 28 document.getElementById('result').textContent = "FAIL"; | 28 document.getElementById('result').textContent = "FAIL"; |
| 29 }; | 29 }; |
| 30 setTimeout(function() { | 30 setTimeout(function() { |
| 31 img.src= resetImage; | 31 img.src= resetImage; |
| 32 img.src = testImage; | 32 img.src = testImage; |
| 33 }, 0); | 33 }, 0); |
| 34 </script> | 34 </script> |
| 35 <div id="console"> | 35 <div id="console"> |
| 36 crbug.com/469678: We should fire an image load event even if the image is the la
st one we loaded successfully.<br> | 36 crbug.com/469678: We should fire an image load event even if the image is the la
st one we loaded successfully.<br> |
| 37 In this test we load an image. Then we make a request for a broken image which d
oesn't get the chance to complete before we attempt to load the same image again
.<br> | 37 In this test we load an image. Then we make a null request (img.src='') which sh
ould clear down the image before we attempt to load the same image again.<br> |
| 38 </div> | 38 </div> |
| 39 <div id="result">FAIL</div> | 39 <div id="result">FAIL</div> |
| OLD | NEW |