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

Side by Side Diff: third_party/WebKit/LayoutTests/virtual/threaded/fast/canvas-toBlob/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, 10 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <script>
8 jsTestIsAsync = true;
9 var worker = startWorker('../../../../fast/canvas/resources/canvas-createImageBi tmap-blob-in-workers.js');
10
11 description('Test createImageBitmap with blob in workers.');
12
13 var imgWidth = 20;
14 var imgHeight = 20;
15 var imageData2;
16 var numOfBitmaps = 5;
17 var bitmapArray = [];
18
19 var canvas1 = document.createElement("canvas");
20 var ctx1 = canvas1.getContext("2d");
21 ctx1.fillStyle = "#FF0000";
22 ctx1.fillRect(0, 0, imgWidth, imgHeight);
23
24 function compareImageData(data1, data2)
25 {
26 if (data1.length != data2.length) {
27 testFailed("The two image have different dimensions");
28 finishJSTest();
29 }
30 for (var i = 0; i < data1.length; i++) {
31 if (data1[i] != data2[i]) {
32 testFailed("The two image have different pixel data");
33 finishJSTest();
34 }
35 }
36 }
37
38 var newImg = new Image();
39 newImg.onload = function() {
40 var canvas2 = document.createElement("canvas");
41 var ctx2 = canvas2.getContext("2d");
42 ctx2.drawImage(newImg, 0, 0, imgWidth, imgHeight);
43 imageData2 = ctx2.getImageData(0, 0, imgWidth, imgHeight).data;
44
45 var canvas3 = document.createElement("canvas");
46 var ctx3 = canvas3.getContext("2d");
47 for (var i = 0; i < numOfBitmaps; i++) {
48 ctx3.clearRect(0, 0, imgWidth, imgHeight);
49 ctx3.drawImage(bitmapArray[i], 0, 0, imgWidth, imgHeight);
50 var imageData = ctx3.getImageData(0, 0, imgWidth, imgHeight).data;
51 compareImageData(imageData, imageData2);
52 }
53
54 worker.onmessage = function(e) {
55 var newImageBitmap = e.data.data;
56 ctx3.clearRect(0, 0, imgWidth, imgHeight);
57 ctx3.drawImage(newImageBitmap, 0, 0, imgWidth, imgHeight);
58 var imageData = ctx3.getImageData(0, 0, imgWidth, imgHeight).data;
59 compareImageData(imageData, imageData2);
60 testPassed("ImageBitmaps created from blob in worker and in main have th e same pixel data");
61 finishJSTest();
62 }
63 }
64
65 canvas1.toBlob(function(blob) {
66 worker.postMessage(blob);
67 for (var i = 0; i < numOfBitmaps; i++) {
68 createImageBitmap(blob).then(imageBitmap => {
69 bitmapArray.push(imageBitmap);
70 });
71 }
72 url = URL.createObjectURL(blob);
73 newImg.src = url;
74 });
75
76 </script>
77 </body>
78 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698