Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-toBlob-webp-maximum-quality.html

Issue 1937433002: HTML <canvas>: add WEBP lossless encoding support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Patch for landing. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <canvas id="mycanvas"></canvas> 1 <!-- The letters in the right image should be crisp like the letters in the left image. -->
2 <img id="result" onload="testDone()"> 2 <canvas></canvas>
3 <script type = 'text/javascript'> 3 <img id="result">
4 <pre id="error"></pre>
5
6 <script>
4 if (window.testRunner) { 7 if (window.testRunner) {
5 testRunner.dumpAsTextWithPixelResults(); 8 testRunner.dumpAsTextWithPixelResults();
6 testRunner.waitUntilDone(); 9 testRunner.waitUntilDone();
7 } 10 }
8 11
9 function testDone() 12 var image = new Image();
10 {
11 if (window.testRunner)
12 testRunner.notifyDone();
13 }
14 13
15 var image = new Image();
16 image.onload = function() { 14 image.onload = function() {
17 var canvas = document.getElementById("mycanvas"); 15 var canvas = document.querySelector('canvas');
18 canvas.width = image.width; 16 canvas.width = this.width;
19 canvas.height = image.height; 17 canvas.height = this.height;
20 var ctx = canvas.getContext('2d'); 18 canvas.getContext('2d').drawImage(this, 0, 0);
21 ctx.drawImage(image, 0, 0);
22 19
23 canvas.toBlob(function(blob) { 20 result.onload = function() {
24 url = URL.createObjectURL(blob); 21 if (window.testRunner)
25 result.src = url; 22 window.testRunner.notifyDone();
26 }, "image/webp", 1.0); 23 };
27 } 24
25 canvas.toBlob(function(blob) {
26 var errorImage = "../../fast/images/resources/rgb-jpeg-red.jpg";
27 if (!(blob instanceof Blob)) {
28 error.textContent += "FAIL: the blob is not valid.";
29 result.src = errorImage;
30 } else if (blob.type != 'image/webp') {
31 error.textContent += "FAIL: the blob should have 'image/webp' type." ;
32 result.src = errorImage;
33 } else {
34 result.src = URL.createObjectURL(blob);
35 }
36 }, "image/webp", 1.0); // maximum quality
37 };
38
28 image.src = "resources/letters.png"; 39 image.src = "resources/letters.png";
29 </script> 40 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698