| OLD | NEW |
| 1 <canvas id="canvas" width="64px" height="64px" style="display: none"></canvas> | 1 <canvas id="canvas" width="64px" height="64px" style="display: none"></canvas> |
| 2 <pre id="log"></pre> | 2 <pre id="log"></pre> |
| 3 <img id="result"> | 3 <!-- The <img> background color should be visible behind the html5.png test imag
e (the test |
| 4 image alpha channel should be preserved by the webp toDataURL encoder). --> |
| 5 <img id="result" style="background-color: green"> |
| 6 |
| 4 <script> | 7 <script> |
| 5 if (window.testRunner) { | 8 if (window.testRunner) { |
| 6 window.testRunner.dumpAsTextWithPixelResults(); | 9 window.testRunner.dumpAsTextWithPixelResults(); |
| 7 window.testRunner.waitUntilDone(); | 10 window.testRunner.waitUntilDone(); |
| 8 } | 11 } |
| 9 | 12 |
| 10 function webpDataURLTest() | 13 var image = new Image(); |
| 11 { | 14 image.onload = function() { |
| 12 var canvas = document.getElementById('canvas'); | 15 var canvas = document.getElementById('canvas'); |
| 13 var context = canvas.getContext('2d'); | 16 canvas.getContext('2d').drawImage(this, 0, 0, canvas.width, canvas.height); |
| 14 context.drawImage(window.image, 0, 0, canvas.width, canvas.height); | |
| 15 | 17 |
| 16 var dataURL = canvas.toDataURL('image/webp', 0.8); | 18 var dataURL = canvas.toDataURL('image/webp', 0.8); |
| 17 if (!dataURL.match(/^data:image\/webp[;,]/)) | 19 if (!dataURL.match(/^data:image\/webp[;,]/)) |
| 18 document.getElementById('log').textContent += "FAIL: canvas.toDataURL('i
mage/webp') not supported"; | 20 document.getElementById('log').textContent += "FAIL: canvas.toDataURL('i
mage/webp') expected"; |
| 19 else | 21 else |
| 20 document.getElementById('result').src = dataURL; | 22 document.getElementById('result').src = dataURL; |
| 21 | 23 |
| 22 if (window.testRunner) | 24 if (window.testRunner) |
| 23 window.testRunner.notifyDone(); | 25 window.testRunner.notifyDone(); |
| 24 } | 26 }; |
| 25 | 27 |
| 26 var image = new Image(); | |
| 27 image.onload = webpDataURLTest; | |
| 28 image.src = 'resources/html5.png'; | 28 image.src = 'resources/html5.png'; |
| 29 </script> | 29 </script> |
| OLD | NEW |