Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> | 2 <title>crbug.com/469678: We should fire an image load event even if the image is the last one we loaded successfully.</title> |
| 3 <script src="../../resources/testharness.js"></script> | |
| 4 <script src="../../resources/testharnessreport.js"></script> | |
| 3 <script> | 5 <script> |
| 4 if (window.testRunner) { | 6 async_test(function(t) { |
| 5 testRunner.waitUntilDone(); | 7 var img = new Image(); |
| 6 testRunner.dumpAsText(); | |
| 7 } | |
| 8 img = new Image(); | |
| 9 var onloadCounter = 0; | |
| 10 var testImage = 'resources/green.jpg'; | 8 var testImage = 'resources/green.jpg'; |
| 11 var resetImage = 'resources/green.jpg'; | 9 var resetImage = 'resources/green.jpg'; |
| 12 img.onload = function(){ | 10 // In this test we load an image then we immediately launch an other request |
|
fs
2016/08/18 10:44:26
Nit: s/an other/another/
sivag
2016/08/18 10:53:20
Done.
| |
| 13 onloadCounter++; | 11 // for the same image - only one load event should be fired. Then we do the |
| 14 debug("Image onload event fired for " + img.src.substring(img.src.lastIn dexOf('/') + 1)); | 12 // same again: another load event should be fired. |
| 15 if (onloadCounter == 2) { | 13 img.onload = t.step_func(function() { |
| 16 document.getElementById('result').textContent = "PASS"; | |
| 17 if (window.testRunner) | |
| 18 testRunner.notifyDone(); | |
| 19 return; | |
| 20 } | |
| 21 if (onloadCounter == 1) { | |
| 22 setTimeout(function() { | |
| 23 img.src= resetImage; | |
| 24 img.src = testImage; | |
| 25 }, 0); | |
| 26 return; | |
| 27 } | |
| 28 document.getElementById('result').textContent = "FAIL"; | |
| 29 }; | |
| 30 setTimeout(function() { | |
| 31 img.src= resetImage; | 14 img.src= resetImage; |
|
fs
2016/08/18 10:44:26
Nit: Space before =
sivag
2016/08/18 10:53:20
Done.
| |
| 32 img.src = testImage; | 15 img.src = testImage; |
| 33 }, 0); | 16 img.onload = t.step_func_done(); |
| 17 }); | |
| 18 img.src= resetImage; | |
|
fs
2016/08/18 10:44:26
Nit: Space before =
sivag
2016/08/18 10:53:20
Done.
| |
| 19 img.src = testImage; | |
| 20 }); | |
| 34 </script> | 21 </script> |
| 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> | |
| 37 In this test we load an image then we immediately launch an other request for th e same image - only one load event should be fired.<br> | |
| 38 Then we do the same again: another load event should be fired.<br> | |
| 39 </div> | |
| 40 <div id="result">FAIL</div> | |
| OLD | NEW |