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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-ImageBitmap-transferable.html

Issue 2522693002: Color correct ImageBitmap(HTMLImageElement*) constructor (Closed)
Patch Set: Removing ImageDecoder::globalTargetColorSpace() calls for now Created 4 years 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <canvas id="canvas" width="3" height="2"></canvas> 4 <canvas id="canvas" width="3" height="2"></canvas>
5 <script src="../../resources/js-test.js"></script> 5 <script src="../../resources/js-test.js"></script>
6 <script> 6 <script>
7 jsTestIsAsync = true; 7 jsTestIsAsync = true;
8 var worker = new Worker('./resources/canvas-ImageBitmap-transferable.js'); 8 var worker = new Worker('./resources/canvas-ImageBitmap-transferable.js');
9 9
10 description("Tests that ImageBitmap is transferable and that the pixel data surv ives the trip, as well as createImageBitmap(ImageBitmap) works on worker thread" ); 10 description("Tests that ImageBitmap is transferable and that the pixel data surv ives the trip, as well as createImageBitmap(ImageBitmap) works on worker thread" );
11 11
12 var imageWidth = 3; 12 var imageWidth = 3;
13 var imageHeight = 2; 13 var imageHeight = 2;
14 var bitmapWidth; 14 var bitmapWidth;
15 var bitmapHeight; 15 var bitmapHeight;
16 var newImage; 16 var newImage;
17 var newImageBitmap; 17 var newImageBitmap;
18 var image = new ImageData(new Uint8ClampedArray( 18 var image = new ImageData(new Uint8ClampedArray(
19 [255, 0, 0, 255, 19 [255, 0, 0, 255,
20 0, 255, 0, 255, 20 0, 255, 0, 255,
21 255, 255, 255, 127, 21 255, 255, 255, 127,
22 0, 0, 0, 64, 22 0, 0, 0, 64,
23 12, 34, 56, 64, 23 12, 34, 56, 64,
24 12, 34, 56, 127]), 24 12, 34, 56, 127]),
25 imageWidth, imageHeight); 25 imageWidth, imageHeight);
26 var context = document.getElementById("canvas").getContext("2d"); 26 var context = document.getElementById("canvas").getContext("2d");
27 27
28 createImageBitmap(image).then(imageBitmap => { 28 createImageBitmap(image, {colorSpaceConversion: "none"}).then(imageBitmap => {
29 bitmapWidth = imageBitmap.width; 29 bitmapWidth = imageBitmap.width;
30 bitmapHeight = imageBitmap.height; 30 bitmapHeight = imageBitmap.height;
31 shouldBe("bitmapWidth", "imageWidth"); 31 shouldBe("bitmapWidth", "imageWidth");
32 shouldBe("bitmapHeight", "imageHeight"); 32 shouldBe("bitmapHeight", "imageHeight");
33 33
34 worker.postMessage({data: imageBitmap}, [imageBitmap]); 34 worker.postMessage({data: imageBitmap}, [imageBitmap]);
35 35
36 // ImageBitmap has been transferred to worker, main thread loses ownership 36 // ImageBitmap has been transferred to worker, main thread loses ownership
37 // of it, so the width and height should be 0 now. 37 // of it, so the width and height should be 0 now.
38 bitmapWidth = imageBitmap.width; 38 bitmapWidth = imageBitmap.width;
39 bitmapHeight = imageBitmap.height; 39 bitmapHeight = imageBitmap.height;
40 shouldBe("bitmapWidth", "0"); 40 shouldBe("bitmapWidth", "0");
41 shouldBe("bitmapHeight", "0"); 41 shouldBe("bitmapHeight", "0");
42 42
43 newImageBitmap = imageBitmap; 43 newImageBitmap = imageBitmap;
44 // Test createImageBitmap from neutered ImageBitmap 44 // Test createImageBitmap from neutered ImageBitmap
45 createImageBitmap(imageBitmap).then(function() { 45 createImageBitmap(imageBitmap, {colorSpaceConversion: "none"}).then(function() {
46 testFailed("Promise accepted, expected to be rejected"); 46 testFailed("Promise accepted, expected to be rejected");
47 finishJSTest(); 47 finishJSTest();
48 }, () => { 48 }, () => {
49 testPassed("createImageBitmap from a neutered ImageBitmap was rejected"); 49 testPassed("createImageBitmap from a neutered ImageBitmap was rejected");
50 }); 50 });
51 51
52 try { 52 try {
53 worker.postMessage({data:imageBitmap}); 53 worker.postMessage({data:imageBitmap});
54 testFailed("Apply structured cloning succeed, expected to fail"); 54 testFailed("Apply structured cloning succeed, expected to fail");
55 } catch(e) { 55 } catch(e) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 shouldBeCloseTo("newImage.data[20]", "image.data[20]", 5); 101 shouldBeCloseTo("newImage.data[20]", "image.data[20]", 5);
102 shouldBeCloseTo("newImage.data[21]", "image.data[21]", 5); 102 shouldBeCloseTo("newImage.data[21]", "image.data[21]", 5);
103 shouldBeCloseTo("newImage.data[22]", "image.data[22]", 5); 103 shouldBeCloseTo("newImage.data[22]", "image.data[22]", 5);
104 shouldBe("newImage.data[23]", "image.data[23]"); 104 shouldBe("newImage.data[23]", "image.data[23]");
105 finishJSTest(); 105 finishJSTest();
106 } 106 }
107 107
108 </script> 108 </script>
109 </body> 109 </body>
110 </html> 110 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698