summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/script-tests/canvas-set-properties-with-non-invertible-ctm.js
blob: a1955b5045aa05f0b097d1bf10d0b0b16b7c520a (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
description("Tests to make sure we can assign to non-ctm effected properties with a non-invertible ctm set");
var canvas = document.createElement("canvas");
canvas.width = 100;
canvas.height = 100;
var ctx = canvas.getContext('2d');
document.body.appendChild(canvas);

function testPixel(x,y, r, g, b) {
    imageData = ctx.getImageData(x, y, 1, 1);
    shouldBe("imageData.data[0]", ""+r);
    shouldBe("imageData.data[1]", ""+g);
    shouldBe("imageData.data[2]", ""+b);
}

// Test our ability to set fillStyle
ctx.save();
ctx.scale(0, 0);
ctx.fillStyle = "green";
shouldBe('ctx.fillStyle', '"#008000"');
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.fillRect(0,0,100,100);
testPixel(50, 50, 0, 128, 0);
ctx.restore();

// Test our ability to set strokeStyle
ctx.save();
ctx.fillStyle = "red";
ctx.fillRect(0,0,100,100);
ctx.scale(0, 0);
ctx.strokeStyle = "green";
shouldBe('ctx.strokeStyle', '"#008000"');
ctx.lineWidth = 100;
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.strokeRect(0,0,100,100);
testPixel(50, 50, 0, 128, 0);
ctx.restore();


// test closePath
ctx.save();
ctx.fillStyle = "red";
ctx.fillRect(0,0,100,100);

ctx.beginPath();
ctx.strokeStyle = "green";
ctx.lineWidth = 100;
ctx.moveTo(-100,   50);
ctx.lineTo(-100, -100);
ctx.lineTo( 200, -100);
ctx.lineTo( 200,   50);
ctx.scale(0, 0);
ctx.closePath();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.stroke();
ctx.restore();
testPixel(50, 50, 0, 128, 0);

// Test beginPath behaviour
ctx.fillStyle = "green";
ctx.fillRect(0,0,100,100);
ctx.fillStyle = "red";
ctx.rect(0,0,100,100);
ctx.scale(0,0);
ctx.beginPath();
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.fill();

testPixel(50, 50, 0, 128, 0);