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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-from-canvas-toBlob.html

Issue 1589923002: Add more layout test cases to createImageBitmap (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update layout test result Created 4 years, 11 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-createImageBitmap-from-canvas-toBlob.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-from-canvas-toBlob.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-from-canvas-toBlob.html
new file mode 100644
index 0000000000000000000000000000000000000000..99da913b175c5b493ab9beeae821a4a051129c44
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-from-canvas-toBlob.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<script src="../../resources/js-test.js"></script>
+<script>
+jsTestIsAsync = true;
+
+description("Tests that createImageBitmap from a canvas.toBlob object should have the same pixel data as the blob.");
+
+var imageData2;
+var imageData3;
+
+var canvas1 = document.createElement("canvas");
+var ctx1 = canvas1.getContext("2d");
+ctx1.fillStyle = "#FF0000";
+ctx1.fillRect(0, 0, 150, 75);
+
+var newImg = new Image();
+newImg.onload = function() {
+ var canvas3 = document.createElement("canvas");
+ var ctx3 = canvas3.getContext("2d");
+ ctx3.drawImage(newImg, 0, 0, 150, 75);
+
+ imageData3 = ctx3.getImageData(0, 0, 150, 75).data;
+ var imageMatched = true;
+ for (var i = 1; i < imageData2.length; i++) {
+ if (imageData2[i] != imageData3[i]) {
+ imageMatched = false;
+ break;
+ }
+ }
+ if (imageMatched)
+ testPassed("image data from the created ImageBitmap and the originated blob is the same");
+ else
+ testFailed("image data from the created ImageBitmap and the originated blob is NOT the same");
+ finishJSTest();
+}
+
+canvas1.toBlob(function(blob) {
+ createImageBitmap(blob).then(imageBitmap => {
+ var canvas2 = document.createElement("canvas");
+ var ctx2 = canvas2.getContext("2d");
+ ctx2.drawImage(imageBitmap, 0, 0, 150, 75);
+ imageData2 = ctx2.getImageData(0, 0, 150, 75).data;
+ url = URL.createObjectURL(blob);
+ newImg.src = url;
+ });
+});
+</script>

Powered by Google App Engine
This is Rietveld 408576698