OLD | NEW |
1 <!-- The letters in the right image should be crisp like the letters in the left
image. --> | 1 <!-- The letters in the right image should be crisp like 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 testRunner.dumpAsTextWithPixelResults(); | 8 testRunner.dumpAsTextWithPixelResults(); |
9 testRunner.waitUntilDone(); | 9 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 result.onload = function() { | 20 result.onload = function() { |
21 if (window.testRunner) | 21 if (window.testRunner) |
22 window.testRunner.notifyDone(); | 22 window.testRunner.notifyDone(); |
23 }; | 23 }; |
24 | 24 |
25 canvas.toBlob(function(blob) { | 25 canvas.toBlob(function(blob) { |
26 var errorImage = "../../fast/images/resources/rgb-jpeg-red.jpg"; | 26 var errorImage = "../../images/resources/rgb-jpeg-red.jpg"; |
27 if (!(blob instanceof Blob)) { | 27 if (!(blob instanceof Blob)) { |
28 error.textContent += "FAIL: the blob is not valid."; | 28 error.textContent += "FAIL: the blob is not valid."; |
29 result.src = errorImage; | 29 result.src = errorImage; |
30 } else if (blob.type != 'image/webp') { | 30 } else if (blob.type != 'image/webp') { |
31 error.textContent += "FAIL: the blob should have 'image/webp' type."
; | 31 error.textContent += "FAIL: the blob should have 'image/webp' type."
; |
32 result.src = errorImage; | 32 result.src = errorImage; |
33 } else { | 33 } else { |
34 result.src = URL.createObjectURL(blob); | 34 result.src = URL.createObjectURL(blob); |
35 } | 35 } |
36 }, "image/webp", 1.0); // maximum quality | 36 }, "image/webp", 1.0); // maximum quality |
37 }; | 37 }; |
38 | 38 |
39 image.src = "resources/letters.png"; | 39 image.src = "resources/letters.png"; |
40 </script> | 40 </script> |
OLD | NEW |