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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-longlived-context.js

Issue 2694703004: Use testharness.js instead of js-test.js in LayoutTests/fast/canvas tests. (Closed)
Patch Set: Created 3 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 description("This test ensures that Canvas and CanvasRenderingContext2D work cor rectly if the rendering context outlives the canvas element");
2
3 function dataToArray(data) {
4 var result = new Array(data.length)
5 for (var i = 0; i < data.length; i++)
6 result[i] = data[i];
7 return result;
8 }
9
10 function getPixel(x, y) {
11 var data = context.getImageData(x,y,1,1);
12 if (!data) // getImageData failed, which should never happen
13 return [-1,-1,-1,-1];
14 return dataToArray(data.data);
15 }
16
17 function pixelShouldBe(x, y, colour) {
18 shouldBe("getPixel(" + [x, y] +")", "["+colour+"]");
19 }
20
21 function prepareCanvas() {
22 var context = document.createElement("canvas").getContext("2d");
23 context.fillStyle = "green";
24 context.fillRect(0,0,100,100);
25 return context;
26 }
27
28 function clobberGC(count) {
29 for (var i = 0; i < 5000; ++i)
30 ({a: i*i*i*0.5+"str", b: i/Math.sqrt(i)});
31 if (count > 0)
32 clobberGC(count-1);
33 }
34
35 function test() {
36 context = prepareCanvas();
37 clobberGC(40);
38 pixelShouldBe(50, 50, [0, 128, 0, 255]);
39 }
40 test();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698