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

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

Issue 1660993002: Revert of Simplify CanvasAsyncBlobCreator by removing ContextObserver and related tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/toBlob/canvas-toBlob-defaultpng.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/toBlob/canvas-toBlob-defaultpng.html b/third_party/WebKit/LayoutTests/fast/canvas/toBlob/canvas-toBlob-defaultpng.html
new file mode 100644
index 0000000000000000000000000000000000000000..c68d3ea45a39c74adb83b1b08040f04d65599015
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/toBlob/canvas-toBlob-defaultpng.html
@@ -0,0 +1,47 @@
+<script src = "../../../resources/js-test.js"></script>
+<script type = 'text/javascript'>
+jsTestIsAsync = true;
+description("Test that verifies whether the image data survives the toBlob process after async image encoding");
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+
+var canvas = document.createElement("canvas");
+var ctx = canvas.getContext("2d");
+ctx.fillStyle = "#FF0000";
+ctx.fillRect(0, 0, 150, 75);
+var canvas2 = document.createElement("canvas");
+var ctx2 = canvas2.getContext("2d");
+
+var newImg = new Image();
+newImg.onload = function() {
+ // 300x150 is the default size of the canvas, which is the source of the newImg.
+ ctx2.drawImage(newImg, 0, 0, 300, 150);
+
+ var imageData1 = ctx.getImageData(0, 0, 150, 75).data;
+ var imageData2 = ctx2.getImageData(0, 0, 150, 75).data;
+ var imageMatched = true;
+ for (var i = 1; i < imageData1.length; i++)
+ {
+ if (imageData1[i]!=imageData2[i])
+ {
+ imageMatched = false;
+ break;
+ }
+ }
+ if (imageMatched)
+ testPassed("image data survives through the toBlob and PNG Image encoder");
+ else
+ testFailed("image data does not survive through the toBlob and PNG Image encoder");
+
+ finishJSTest();
+}
+
+canvas.toBlob(function(blob) {
+ url = URL.createObjectURL(blob);
+ newImg.src = url;
+});
+
+</script>

Powered by Google App Engine
This is Rietveld 408576698