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

Side by Side Diff: LayoutTests/fast/canvas/script-tests/canvas-currentTransform2.js

Issue 24233004: Support currentTransform in 2D Canvas. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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 checks currentTransform in canvas v5");
2
3 var canvas = document.createElement('canvas');
4 document.body.appendChild(canvas);
5 canvas.setAttribute('width', '100');
6 canvas.setAttribute('height', '100');
7 var ctx = canvas.getContext('2d');
8 var matrix = ctx.currentTransform;
9
10 debug("Check initial currentTransform values");
11 shouldBe("matrix.a", "1");
12 shouldBe("matrix.b", "0");
13 shouldBe("matrix.c", "0");
14 shouldBe("matrix.d", "1");
15 shouldBe("matrix.e", "0");
16 shouldBe("matrix.f", "0");
17
18 matrix.a = 2;
19 matrix.b = 0;
20 matrix.c = 0;
21 matrix.d = 2;
22 matrix.e = 40;
23 matrix.f = 40;
24 ctx.currentTransform = matrix;
25 matrix = ctx.currentTransform;
Justin Novosad 2013/09/19 19:23:48 Should use a different variable here to test that
26
27 debug("Check assigning currentTransform");
28 shouldBe("matrix.a", "2");
29 shouldBe("matrix.b", "0");
30 shouldBe("matrix.c", "0");
31 shouldBe("matrix.d", "2");
32 shouldBe("matrix.e", "40");
33 shouldBe("matrix.f", "40");
34
35 ctx.save();
36 matrix.a = 3;
37 matrix.b = 0;
38 matrix.c = 0;
39 matrix.d = 3;
40 matrix.e = 60;
41 matrix.f = 60;
42 ctx.currentTransform = matrix;
43 matrix = ctx.currentTransform;
Justin Novosad 2013/09/19 19:23:48 Same here
44
45 debug("Check currentTransform after save of the context");
46 shouldBe("matrix.a", "3");
47 shouldBe("matrix.b", "0");
48 shouldBe("matrix.c", "0");
49 shouldBe("matrix.d", "3");
50 shouldBe("matrix.e", "60");
51 shouldBe("matrix.f", "60");
52
53 ctx.restore();
54 matrix = ctx.currentTransform;
55
56 debug("Check currentTransform after restore of the context");
57 shouldBe("matrix.a", "2");
58 shouldBe("matrix.b", "0");
59 shouldBe("matrix.c", "0");
60 shouldBe("matrix.d", "2");
61 shouldBe("matrix.e", "40");
62 shouldBe("matrix.f", "40");
63
64 debug("Check assigning an invalid object throws exception as expected");
65 shouldThrow("ctx.currentTransform = ctx", "'TypeError: Type error'")
66
67 matrix = ctx.currentTransform;
Justin Novosad 2013/09/19 19:23:48 Same here.
68
69 debug("Check currentTransform should preserve a value after exception");
70 shouldBe("matrix.a", "2");
71 shouldBe("matrix.b", "0");
72 shouldBe("matrix.c", "0");
73 shouldBe("matrix.d", "2");
74 shouldBe("matrix.e", "40");
75 shouldBe("matrix.f", "40");
76
77 ctx.scale(2, 2);
78 matrix = ctx.currentTransform;
79
80 debug("Check currentTransform after scale");
81 shouldBe("matrix.a", "4");
82 shouldBe("matrix.b", "0");
83 shouldBe("matrix.c", "0");
84 shouldBe("matrix.d", "4");
85 shouldBe("matrix.e", "40");
86 shouldBe("matrix.f", "40");
87
88 ctx.translate(10, 10);
89 matrix = ctx.currentTransform;
90
91 debug("Check currentTransform after translate");
92 shouldBe("matrix.a", "4");
93 shouldBe("matrix.b", "0");
94 shouldBe("matrix.c", "0");
95 shouldBe("matrix.d", "4");
96 shouldBe("matrix.e", "80");
97 shouldBe("matrix.f", "80");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698