summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-clearRect.js
blob: 61f4633587c0f0700e8c77b47aaba1aae03543f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
description("Series of tests to ensure correct behavior of canvas.clearRect().");
var ctx = document.createElement('canvas').getContext('2d');

// Clear rect with height = width = 0.
debug("Test canvas.clearRect() with height = width = 0.");
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
ctx.clearRect(0, 0, 0, 0);

var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
shouldBe("imgdata[0]", "255");
shouldBe("imgdata[1]", "0");
shouldBe("imgdata[2]", "0");

ctx.clearRect(0, 0, 1, 1);

// Clear rect with height = 0, width = 1.
debug("Test canvas.clearRect() with height = 0, width = 1.");
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
ctx.clearRect(0, 0, 1, 0);

var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
shouldBe("imgdata[0]", "255");
shouldBe("imgdata[1]", "0");
shouldBe("imgdata[2]", "0");

ctx.clearRect(0, 0, 1, 1);

// Clear rect with height = 1, width = 0.
debug("Test canvas.clearRect() with height = 1, width = 0.");
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 1, 1);
ctx.clearRect(0, 0, 0, 1);

var imageData = ctx.getImageData(0, 0, 1, 1);
var imgdata = imageData.data;
shouldBe("imgdata[0]", "255");
shouldBe("imgdata[1]", "0");
shouldBe("imgdata[2]", "0");

ctx.clearRect(0, 0, 1, 1);