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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-transferToImageBitmap.html

Issue 1775153002: Make OffscreenCanvasRenderingContext2D renderable on a worker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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 <script src="../../resources/js-test.js"></script>
3 <script>
4 var aCanvas = new OffscreenCanvas(60, 40);
5
6 // TransferToImageBitmap on an OffscreenCanvas with no context
7 shouldThrow("aCanvas.transferToImageBitmap()");
8 ctx = aCanvas.getContext('2d');
9
10 // Verify ImageBitmap is correctly sized
11 var image = aCanvas.transferToImageBitmap();
12 shouldBe("image.width", "60");
13 shouldBe("image.height", "40");
14
15 // Verify state is preserved through transferToImageBitmap()
16 ctx.lineWidth = 5;
17 aCanvas.transferToImageBitmap();
18 shouldBe("ctx.lineWidth", "5");
19
20 // Verify backing is reset through transferToImageBitmap()
21 ctx.fillStyle = '#f00';
22 ctx.fillRect(0, 0, aCanvas.width, aCanvas.height);
23 var firstImage = aCanvas.transferToImageBitmap();
24 var secondImage = aCanvas.transferToImageBitmap();
25 var testCanvas = document.createElement('canvas');
26 var testCtx = testCanvas.getContext('2d');
27 testCtx.drawImage(firstImage, 0, 0);
28 var imgData = testCtx.getImageData(0, 0, 1, 1).data;
29 shouldBe("imgData[0]", "255");
30 shouldBe("imgData[1]", "0");
31 shouldBe("imgData[2]", "0");
32 shouldBe("imgData[3]", "255");
33 testCtx.clearRect(0, 0, testCanvas.width, testCanvas.height);
34 testCtx.drawImage(secondImage, 0, 0);
35 imgData = testCtx.getImageData(0, 0, 1, 1).data;
36 shouldBe("imgData[0]", "0");
37 shouldBe("imgData[1]", "0");
38 shouldBe("imgData[2]", "0");
39 shouldBe("imgData[3]", "0");
40
41 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698