OLD | NEW |
(Empty) | |
| 1 <canvas style="display: none"></canvas> |
| 2 <!-- The <img> background color should be visible behind the html5.png test imag
e: the |
| 3 image has an alpha channel, which should be preserved by the WEBP toDataURL en
coder. --> |
| 4 <img id="result" style="background-color: yellow"> |
| 5 <pre id="error"></pre> |
| 6 |
| 7 <script> |
| 8 if (window.testRunner) { |
| 9 window.testRunner.dumpAsTextWithPixelResults(); |
| 10 window.testRunner.waitUntilDone(); |
| 11 } |
| 12 |
| 13 var image = new Image(); |
| 14 |
| 15 image.onload = function() { |
| 16 var canvas = document.querySelector('canvas'); |
| 17 canvas.width = this.width * 2; |
| 18 canvas.height = this.height * 2; |
| 19 canvas.getContext('2d').drawImage(this, this.width / 2, this.height / 2); |
| 20 |
| 21 var dataURL = canvas.toDataURL('image/webp', 0.8); // good quality |
| 22 |
| 23 if (!dataURL.match(/^data:image\/webp[;,]/)) |
| 24 error.textContent += "FAIL: the dataURL should have 'image/webp' type."; |
| 25 else |
| 26 result.src = dataURL; |
| 27 |
| 28 if (window.testRunner) |
| 29 window.testRunner.notifyDone(); |
| 30 }; |
| 31 |
| 32 image.src = 'resources/html5.png'; |
| 33 </script> |
OLD | NEW |