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

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-extremely-large-dimensions.js

Issue 44253005: 2D Canvas: Refactor code re-attempting to allocate an imageBuffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@convertL
Patch Set: Use extremely instead of insanely. Amend test a bit. Created 7 years, 1 month 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 description("Series of tests to ensure correct behaviour when canvas size is ext remely large.");
2 var canvas = document.createElement('canvas')
3 var ctx = canvas.getContext('2d');
4
5 // IDL defines width and height as int. 2147483647 is int max.
6 var extremelyLargeNumber = 2147483647;
7 canvas.width = extremelyLargeNumber;
8 canvas.height = extremelyLargeNumber;
9
10 debug("check whether crash or not with extremely large size.");
Stephen White 2013/11/18 21:42:15 Nit: check for crash on extremely large canvas siz
11 useCanvasContext(ctx);
12 var imageData = ctx.getImageData(1, 1, 98, 98);
13 var imgdata = imageData.data;
14 // Blink returns zero color if the image buffer does not exist.
15 shouldBe("imgdata[4]", "0");
16 shouldBe("imgdata[5]", "0");
17 shouldBe("imgdata[6]", "0");
18
19 debug("check whether crash after reset to the same size.");
Stephen White 2013/11/18 21:42:15 Nit: check for crash after resetting to the same s
20 canvas.width = extremelyLargeNumber;
21 useCanvasContext(ctx);
22 imageData = ctx.getImageData(1, 1, 98, 98);
23 imgdata = imageData.data;
24 shouldBe("imgdata[4]", "0");
25 shouldBe("imgdata[5]", "0");
26 shouldBe("imgdata[6]", "0");
27
28 // googol is parsed to 0.
29 var googol = Math.pow(10, 100);
30 debug("check whether crash after resize to googol.");
Stephen White 2013/11/18 21:42:15 Nit: check for crash after resizing to googol. (h
31 canvas.width = googol;
32 canvas.height = googol;
33 useCanvasContext(ctx);
34 imageData = ctx.getImageData(1, 1, 98, 98);
35 imgdata = imageData.data;
36 shouldBe("imgdata[4]", "0");
37 shouldBe("imgdata[5]", "0");
38 shouldBe("imgdata[6]", "0");
39
40 debug("check whether crash after reset to the same size.");
Stephen White 2013/11/18 21:42:15 Nit: check for crash after resetting to the same s
41 canvas.width = googol;
42 useCanvasContext(ctx);
43 imageData = ctx.getImageData(1, 1, 98, 98);
44 imgdata = imageData.data;
45 shouldBe("imgdata[4]", "0");
46 shouldBe("imgdata[5]", "0");
47 shouldBe("imgdata[6]", "0");
48
49 debug("check again whether crash or not with extremely large size.");
Stephen White 2013/11/18 21:42:15 Nit: check again for crash with extremely large si
50 canvas.width = extremelyLargeNumber;
51 canvas.height = extremelyLargeNumber;
52 useCanvasContext(ctx);
53 imageData = ctx.getImageData(1, 1, 98, 98);
54 imgdata = imageData.data;
55 shouldBe("imgdata[4]", "0");
56 shouldBe("imgdata[5]", "0");
57 shouldBe("imgdata[6]", "0");
58
59 function useCanvasContext(ctx) {
60 ctx.fillStyle = 'green';
61 ctx.fillRect(0, 0, 100, 100);
62 for(var i = 0; i < 10000; i++) {
Stephen White 2013/11/18 21:42:15 I'm a little nervous about 10,000 calls to getImag
63 // This API tries to create an image buffer if the image buffer is not c reated.
64 ctx.getImageData(1, 1, 98, 98);
65 }
66 ctx.beginPath();
67 ctx.rect(0,0,100,100);
68 ctx.save();
69 ctx.fillStyle = 'red';
70 ctx.fillRect(0, 0, 100, 100);
71 ctx.restore();
72 ctx.fillStyle = 'green';
73 ctx.fill();
74 }
75
76 debug("after resize to normal size, canvas must be in valid state.");
Stephen White 2013/11/18 21:42:15 Nit: after resizing to normal size, the canvas mus
77 canvas.width = 100;
78 canvas.height = 100;
79 ctx.fillStyle = 'blue';
80 ctx.fillRect(0, 0, 100, 100);
81 imageData = ctx.getImageData(1, 1, 98, 98);
82 imgdata = imageData.data;
83 shouldBe("imgdata[4]", "0");
84 shouldBe("imgdata[5]", "0");
85 shouldBe("imgdata[6]", "255");
OLDNEW
« no previous file with comments | « LayoutTests/fast/canvas/canvas-extremely-large-dimensions-expected.txt ('k') | Source/core/html/HTMLCanvasElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698