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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-toDataURL-webp-alpha.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, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-toDataURL-webp-alpha.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-toDataURL-webp-alpha.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-toDataURL-webp-alpha.html
new file mode 100644
index 0000000000000000000000000000000000000000..2d4f393fc6020302e54a7a74421068c23039c103
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-toDataURL-webp-alpha.html
@@ -0,0 +1,33 @@
+<canvas style="display: none"></canvas>
+<!-- The <img> background color should be visible behind the html5.png test image: the
+ image has an alpha channel, which should be preserved by the WEBP toDataURL encoder. -->
+<img id="result" style="background-color: yellow">
+<pre id="error"></pre>
+
+<script>
+if (window.testRunner) {
+ window.testRunner.dumpAsTextWithPixelResults();
+ window.testRunner.waitUntilDone();
+}
+
+var image = new Image();
+
+image.onload = function() {
+ var canvas = document.querySelector('canvas');
+ canvas.width = this.width * 2;
+ canvas.height = this.height * 2;
+ canvas.getContext('2d').drawImage(this, this.width / 2, this.height / 2);
+
+ var dataURL = canvas.toDataURL('image/webp', 0.8); // good quality
+
+ if (!dataURL.match(/^data:image\/webp[;,]/))
+ error.textContent += "FAIL: the dataURL should have 'image/webp' type.";
+ else
+ result.src = dataURL;
+
+ if (window.testRunner)
+ window.testRunner.notifyDone();
+};
+
+image.src = 'resources/html5.png';
+</script>

Powered by Google App Engine
This is Rietveld 408576698