OLD | NEW |
---|---|
1 <!-- The letters in the right image should be blurry compared to the letters in the left image. --> | 1 <!-- The letters in the right image should be blurry compared to the letters in the left image. --> |
2 <canvas></canvas> | 2 <canvas></canvas> |
3 <img id="result"> | 3 <img id="result"> |
4 <pre id="error"></pre> | 4 <pre id="error"></pre> |
5 | 5 |
6 <script> | 6 <script> |
7 if (window.testRunner) { | 7 if (window.testRunner) { |
8 window.testRunner.dumpAsTextWithPixelResults(); | 8 window.testRunner.dumpAsTextWithPixelResults(); |
Justin Novosad
2017/02/15 20:02:28
You missed this test.
zakerinasab
2017/02/16 17:32:07
This is not a js-test.js based layout test. We hav
| |
9 window.testRunner.waitUntilDone(); | 9 window.testRunner.waitUntilDone(); |
10 } | 10 } |
11 | 11 |
12 var image = new Image(); | 12 var image = new Image(); |
13 | 13 |
14 image.onload = function() { | 14 image.onload = function() { |
15 var canvas = document.querySelector('canvas'); | 15 var canvas = document.querySelector('canvas'); |
16 canvas.width = this.width; | 16 canvas.width = this.width; |
17 canvas.height = this.height; | 17 canvas.height = this.height; |
18 canvas.getContext('2d').drawImage(this, 0, 0); | 18 canvas.getContext('2d').drawImage(this, 0, 0); |
19 | 19 |
20 var dataURL = canvas.toDataURL('image/webp', 0.3); // low quality | 20 var dataURL = canvas.toDataURL('image/webp', 0.3); // low quality |
21 | 21 |
22 if (!dataURL.match(/^data:image\/webp[;,]/)) | 22 if (!dataURL.match(/^data:image\/webp[;, ]/)) |
Justin Novosad
2017/02/15 20:02:28
why?
zakerinasab
2017/02/16 17:32:07
Because this is an image/webp data url?
| |
23 error.textContent += "FAIL: the dataURL should have 'image/webp' type."; | 23 error.textContent += "FAIL: the dataURL should have 'image/webp' type."; |
24 else | 24 else |
25 result.src = dataURL; | 25 result.src = dataURL; |
26 | 26 |
27 document.body.style.zoom = 1.3; // zoom in to see the low quality | 27 document.body.style.zoom = 1.3; // zoom in to see the low quality |
28 | 28 |
29 if (window.testRunner) | 29 if (window.testRunner) |
30 window.testRunner.notifyDone(); | 30 window.testRunner.notifyDone(); |
31 }; | 31 }; |
32 | 32 |
33 image.src = "resources/letters.png"; | 33 image.src = "resources/letters.png"; |
34 </script> | 34 </script> |
OLD | NEW |