OLD | NEW |
1 <canvas id="canvas" width="64px" height="64px" style="display: none"></canvas> | 1 The letters in the right image should be blurry compared to the letters in the l
eft image.<p> |
2 <pre id="log"></pre> | 2 <canvas></canvas> |
3 <img id="result"> | 3 <img id="result"> |
| 4 |
4 <script> | 5 <script> |
5 if (window.testRunner) { | 6 if (window.testRunner) { |
6 window.testRunner.dumpAsTextWithPixelResults(); | 7 window.testRunner.dumpAsTextWithPixelResults(); |
7 window.testRunner.waitUntilDone(); | 8 window.testRunner.waitUntilDone(); |
8 } | 9 } |
9 | 10 |
10 function webpDataURLTest() | 11 var image = new Image(); |
11 { | 12 image.onload = function() { |
12 var canvas = document.getElementById('canvas'); | 13 var canvas = document.querySelector('canvas'); |
13 var context = canvas.getContext('2d'); | 14 canvas.width = this.width; |
14 context.drawImage(window.image, 0, 0, canvas.width, canvas.height); | 15 canvas.height = this.height; |
| 16 canvas.getContext('2d').drawImage(this, 0, 0); |
15 | 17 |
16 var dataURL = canvas.toDataURL('image/webp', 0.8); | 18 document.body.style.zoom = 1.3; |
17 if (!dataURL.match(/^data:image\/webp[;,]/)) | 19 |
18 document.getElementById('log').textContent += "FAIL: canvas.toDataURL('i
mage/webp') not supported"; | 20 document.getElementById('result').src = canvas.toDataURL('image/webp', 0.2); |
19 else | |
20 document.getElementById('result').src = dataURL; | |
21 | 21 |
22 if (window.testRunner) | 22 if (window.testRunner) |
23 window.testRunner.notifyDone(); | 23 window.testRunner.notifyDone(); |
24 } | 24 }; |
25 | 25 |
26 var image = new Image(); | 26 image.src = "resources/letters.png"; |
27 image.onload = webpDataURLTest; | |
28 image.src = 'resources/html5.png'; | |
29 </script> | 27 </script> |
OLD | NEW |