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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-blob-in-workers.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/canvas-createImageBitmap-blob-in-workers.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-blob-in-workers.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-blob-in-workers.html
new file mode 100644
index 0000000000000000000000000000000000000000..ea845ef241c5b77a454a0d7bbc570013ca319658
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-createImageBitmap-blob-in-workers.html
@@ -0,0 +1,78 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test.js"></script>
+</head>
+<body>
+<script>
+jsTestIsAsync = true;
+var worker = startWorker('./resources/canvas-createImageBitmap-blob-in-workers.js');
+
+description('Test createImageBitmap with blob in workers.');
+
+var imgWidth = 20;
+var imgHeight = 20;
+var imageData2;
+var numOfBitmaps = 5;
+var bitmapArray = [];
+
+var canvas1 = document.createElement("canvas");
+var ctx1 = canvas1.getContext("2d");
+ctx1.fillStyle = "#FF0000";
+ctx1.fillRect(0, 0, imgWidth, imgHeight);
+
+function compareImageData(data1, data2)
+{
+ if (data1.length != data2.length) {
+ testFailed("The two image have different dimensions");
+ finishJSTest();
+ }
+ for (var i = 0; i < data1.length; i++) {
+ if (data1[i] != data2[i]) {
+ testFailed("The two image have different pixel data");
+ finishJSTest();
+ }
+ }
+}
+
+var newImg = new Image();
+newImg.onload = function() {
+ var canvas2 = document.createElement("canvas");
+ var ctx2 = canvas2.getContext("2d");
+ ctx2.drawImage(newImg, 0, 0, imgWidth, imgHeight);
+ imageData2 = ctx2.getImageData(0, 0, imgWidth, imgHeight).data;
+
+ var canvas3 = document.createElement("canvas");
+ var ctx3 = canvas3.getContext("2d");
+ for (var i = 0; i < numOfBitmaps; i++) {
+ ctx3.clearRect(0, 0, imgWidth, imgHeight);
+ ctx3.drawImage(bitmapArray[i], 0, 0, imgWidth, imgHeight);
+ var imageData = ctx3.getImageData(0, 0, imgWidth, imgHeight).data;
+ compareImageData(imageData, imageData2);
+ }
+
+ worker.onmessage = function(e) {
+ var newImageBitmap = e.data.data;
+ ctx3.clearRect(0, 0, imgWidth, imgHeight);
+ ctx3.drawImage(newImageBitmap, 0, 0, imgWidth, imgHeight);
+ var imageData = ctx3.getImageData(0, 0, imgWidth, imgHeight).data;
+ compareImageData(imageData, imageData2);
+ testPassed("ImageBitmaps created from blob in worker and in main have the same pixel data");
+ finishJSTest();
+ }
+}
+
+canvas1.toBlob(function(blob) {
+ worker.postMessage(blob);
+ for (var i = 0; i < numOfBitmaps; i++) {
+ createImageBitmap(blob).then(imageBitmap => {
+ bitmapArray.push(imageBitmap);
+ });
+ }
+ url = URL.createObjectURL(blob);
+ newImg.src = url;
+});
+
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698