Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <canvas id="mycanvas"></canvas> | |
| 2 <img id="result" onload="testDone()"> | |
|
Justin Novosad
2015/08/20 20:38:43
Test is more readable if you set the onload handle
| |
| 3 <script type = 'text/javascript'> | |
| 4 if (window.testRunner) { | |
| 5 testRunner.dumpAsTextWithPixelResults(); | |
| 6 testRunner.waitUntilDone(); | |
| 7 } | |
| 8 | |
| 9 function testDone() | |
| 10 { | |
| 11 if (window.testRunner) | |
| 12 testRunner.notifyDone(); | |
| 13 } | |
| 14 | |
| 15 var image = new Image(); | |
| 16 image.onload = function() { | |
| 17 var canvas = document.getElementById("mycanvas"); | |
|
Justin Novosad
2015/08/20 20:38:42
indentation
| |
| 18 canvas.width = image.width; | |
| 19 canvas.height = image.height; | |
| 20 var ctx = canvas.getContext('2d'); | |
| 21 ctx.drawImage(image, 0, 0); | |
| 22 | |
| 23 canvas.toBlob(function(blob) { | |
| 24 url = URL.createObjectURL(blob); | |
| 25 result.src = url; | |
|
Justin Novosad
2015/08/20 20:38:42
how come this works? Aren't we missing result = do
xlai (Olivia)
2015/08/20 21:36:28
Acknowledged and elsewhere.
I copied this from toD
| |
| 26 }, "image/jpeg", 1.0); | |
| 27 } | |
| 28 image.src = "resources/letters.png"; | |
| 29 </script> | |
| OLD | NEW |