OLD | NEW |
| (Empty) |
1 description("Test rgba() color parsing results"); | |
2 | |
3 var ctx = document.createElement('canvas').getContext('2d'); | |
4 | |
5 function parse(rgba) { | |
6 ctx.globalCompositeOperation = 'copy'; | |
7 ctx.fillStyle = '#666'; | |
8 ctx.fillStyle = rgba; | |
9 ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); | |
10 var idata = ctx.getImageData(0, 0, 1, 1); | |
11 var data = idata.data; | |
12 return "RGBA[" + data[0] + ", " + data[1] + ", " + data[2] + ", " + data[3]
+ "]"; | |
13 } | |
14 | |
15 shouldBe("parse('rgba(0.9.9%, 0%, 0%, 1)')", "'RGBA[102, 102, 102, 255]'"); | |
16 shouldBe("parse('rgba(0, 0.., 0, 1)')", "'RGBA[102, 102, 102, 255]'"); | |
17 shouldBe("parse('rgba(10%, .%, 0%, 1)')", "'RGBA[102, 102, 102, 255]'"); | |
18 shouldBe("parse('rgba(13.37%1337%, 5%, 50.0%, 1)')", "'RGBA[102, 102, 102, 255]'
"); | |
19 shouldBe("parse('rgba(%, 50%, 50.0%, 1)')", "'RGBA[102, 102, 102, 255]'"); | |
20 shouldBe("parse('rgba(50.0%, 50%, a%, 1)')", "'RGBA[102, 102, 102, 255]'"); | |
21 shouldBe("parse('rgba(500%, 0%, 0%, 1)')", "'RGBA[255, 0, 0, 255]'"); | |
22 shouldBe("parse('rgba(100%, 100%, 100%, 1)')", "'RGBA[255, 255, 255, 255]'"); | |
23 shouldBe("parse('rgba(10.5%, 80%, 70%, 1)')", "'RGBA[26, 204, 179, 255]'"); | |
24 shouldBe("parse('rgba(0%, 0%, 0%, 1)')", "'RGBA[0, 0, 0, 255]'"); | |
25 shouldBe("parse('rgba(50.0%, 50.0%, 50.0%, 1)')", "'RGBA[128, 128, 128, 255]'"); | |
26 shouldBe("parse('rgba(100%, 100%, 100%, 1)')", "'RGBA[255, 255, 255, 255]'"); | |
27 shouldBe("parse('rgba(10.5%, 80%, 70%, 1)')", "'RGBA[26, 204, 179, 255]'"); | |
28 shouldBe("parse('rgba(55.5%, 0.5%, 110%, 1)')", "'RGBA[142, 1, 255, 255]'"); | |
29 shouldBe("parse('rgba(60.59998%, 0.59999%, 110.12345%, 1)')", "'RGBA[155, 1, 255
, 255]'"); | |
30 shouldBe("parse('rgba(10.999%, 0.999%, 0.000009%, 1)')", "'RGBA[28, 2, 0, 255]'"
); | |
31 shouldBe("parse('rgba(79.99999%, 99.99999%, 500%, 1)')", "'RGBA[204, 255, 255, 2
55]'"); | |
32 shouldBe("parse('rgba(0, 0, 0, -0.10)')", "'RGBA[0, 0, 0, 0]'"); | |
33 shouldBe("parse('rgba(0, 0, 0, -5.0)')", "'RGBA[0, 0, 0, 0]'"); | |
34 shouldBe("parse('rgba(0, 0, 0, 5.0)')", "'RGBA[0, 0, 0, 255]'"); | |
35 shouldBe("parse('rgba(0, 0, 0, -1)')", "'RGBA[0, 0, 0, 0]'"); | |
36 shouldBe("parse('rgba(0, 0, 0, 0)')", "'RGBA[0, 0, 0, 0]'"); | |
37 shouldBe("parse('rgba(0, 0, 0, 2)')", "'RGBA[0, 0, 0, 255]'"); | |
38 shouldBe("parse('rgba(0, 0, 0, 2.0)')", "'RGBA[0, 0, 0, 255]'"); | |
39 shouldBe("parse('rgba(0, 0, 0, 0.0)')", "'RGBA[0, 0, 0, 0]'"); | |
40 shouldBe("parse('rgba(0, 0, 0, 00.0)')", "'RGBA[0, 0, 0, 0]'"); | |
41 shouldBe("parse('rgba(0, 0, 0, 0.00)')", "'RGBA[0, 0, 0, 0]'"); | |
42 shouldBe("parse('rgba(0, 0, 0, .1)')", "'RGBA[0, 0, 0, 26]'"); | |
43 shouldBe("parse('rgba(0, 0, 0, .2)')", "'RGBA[0, 0, 0, 51]'"); | |
44 shouldBe("parse('rgba(0, 0, 0, .3)')", "'RGBA[0, 0, 0, 77]'"); | |
45 shouldBe("parse('rgba(0, 0, 0, .4)')", "'RGBA[0, 0, 0, 102]'"); | |
46 shouldBe("parse('rgba(0, 0, 0, .5)')", "'RGBA[0, 0, 0, 128]'"); | |
47 shouldBe("parse('rgba(0, 0, 0, .6)')", "'RGBA[0, 0, 0, 153]'"); | |
48 shouldBe("parse('rgba(0, 0, 0, .7)')", "'RGBA[0, 0, 0, 179]'"); | |
49 shouldBe("parse('rgba(0, 0, 0, .8)')", "'RGBA[0, 0, 0, 204]'"); | |
50 shouldBe("parse('rgba(0, 0, 0, .9)')", "'RGBA[0, 0, 0, 230]'"); | |
51 shouldBe("parse('rgba(0, 0, 0, 0.1)')", "'RGBA[0, 0, 0, 26]'"); | |
52 shouldBe("parse('rgba(0, 0, 0, 0.2)')", "'RGBA[0, 0, 0, 51]'"); | |
53 shouldBe("parse('rgba(0, 0, 0, 0.3)')", "'RGBA[0, 0, 0, 77]'"); | |
54 shouldBe("parse('rgba(0, 0, 0, 0.4)')", "'RGBA[0, 0, 0, 102]'"); | |
55 shouldBe("parse('rgba(0, 0, 0, 0.5)')", "'RGBA[0, 0, 0, 128]'"); | |
56 shouldBe("parse('rgba(0, 0, 0, 0.6)')", "'RGBA[0, 0, 0, 153]'"); | |
57 shouldBe("parse('rgba(0, 0, 0, 0.7)')", "'RGBA[0, 0, 0, 179]'"); | |
58 shouldBe("parse('rgba(0, 0, 0, 0.8)')", "'RGBA[0, 0, 0, 204]'"); | |
59 shouldBe("parse('rgba(0, 0, 0, 0.9)')", "'RGBA[0, 0, 0, 230]'"); | |
60 shouldBe("parse('rgba(0, 0, 0, 1.0)')", "'RGBA[0, 0, 0, 255]'"); | |
61 shouldBe("parse('rgba(0, 0, 0, 0.10)')", "'RGBA[0, 0, 0, 26]'"); | |
62 shouldBe("parse('rgba(0, 0, 0, 0.20)')", "'RGBA[0, 0, 0, 51]'"); | |
63 shouldBe("parse('rgba(0, 0, 0, 0.30)')", "'RGBA[0, 0, 0, 77]'"); | |
64 shouldBe("parse('rgba(0, 0, 0, 0.40)')", "'RGBA[0, 0, 0, 102]'"); | |
65 shouldBe("parse('rgba(0, 0, 0, 0.50)')", "'RGBA[0, 0, 0, 128]'"); | |
66 shouldBe("parse('rgba(0, 0, 0, 0.60)')", "'RGBA[0, 0, 0, 153]'"); | |
67 shouldBe("parse('rgba(0, 0, 0, 0.70)')", "'RGBA[0, 0, 0, 179]'"); | |
68 shouldBe("parse('rgba(0, 0, 0, 0.80)')", "'RGBA[0, 0, 0, 204]'"); | |
69 shouldBe("parse('rgba(0, 0, 0, 0.90)')", "'RGBA[0, 0, 0, 230]'"); | |
70 shouldBe("parse('rgba(0, 0, 0, 1.00)')", "'RGBA[0, 0, 0, 255]'"); | |
71 shouldBe("parse('rgba(0, 0, 0, .10)')", "'RGBA[0, 0, 0, 26]'"); | |
72 shouldBe("parse('rgba(0, 0, 0, .20)')", "'RGBA[0, 0, 0, 51]'"); | |
73 shouldBe("parse('rgba(0, 0, 0, .30)')", "'RGBA[0, 0, 0, 77]'"); | |
74 shouldBe("parse('rgba(0, 0, 0, .40)')", "'RGBA[0, 0, 0, 102]'"); | |
75 shouldBe("parse('rgba(0, 0, 0, .50)')", "'RGBA[0, 0, 0, 128]'"); | |
76 shouldBe("parse('rgba(0, 0, 0, .60)')", "'RGBA[0, 0, 0, 153]'"); | |
77 shouldBe("parse('rgba(0, 0, 0, .70)')", "'RGBA[0, 0, 0, 179]'"); | |
78 shouldBe("parse('rgba(0, 0, 0, .80)')", "'RGBA[0, 0, 0, 204]'"); | |
79 shouldBe("parse('rgba(0, 0, 0, .90)')", "'RGBA[0, 0, 0, 230]'"); | |
80 shouldBe("parse('rgba(0, 0, 0, 0.10000000000000000000000)')", "'RGBA[0, 0, 0, 26
]'"); | |
81 shouldBe("parse('rgba(0, 0, 0, 0.20000000000000000000000)')", "'RGBA[0, 0, 0, 51
]'"); | |
82 shouldBe("parse('rgba(0, 0, 0, 0.30000000000000000000000)')", "'RGBA[0, 0, 0, 77
]'"); | |
83 shouldBe("parse('rgba(0, 0, 0, 0.40000000000000000000000)')", "'RGBA[0, 0, 0, 10
2]'"); | |
84 shouldBe("parse('rgba(0, 0, 0, 0.50000000000000000000000)')", "'RGBA[0, 0, 0, 12
8]'"); | |
85 shouldBe("parse('rgba(0, 0, 0, 0.60000000000000000000000)')", "'RGBA[0, 0, 0, 15
3]'"); | |
86 shouldBe("parse('rgba(0, 0, 0, 0.70000000000000000000000)')", "'RGBA[0, 0, 0, 17
9]'"); | |
87 shouldBe("parse('rgba(0, 0, 0, 0.80000000000000000000000)')", "'RGBA[0, 0, 0, 20
4]'"); | |
88 shouldBe("parse('rgba(0, 0, 0, 0.90000000000000000000000)')", "'RGBA[0, 0, 0, 23
0]'"); | |
89 shouldBe("parse('rgba(0, 0, 0, 1.00000000000000000000000)')", "'RGBA[0, 0, 0, 25
5]'"); | |
90 shouldBe("parse('rgba(0, 0, 0, 0.990)')", "'RGBA[0, 0, 0, 252]'"); | |
91 shouldBe("parse('rgba(0, 0, 0, 0.991)')", "'RGBA[0, 0, 0, 253]'"); | |
92 shouldBe("parse('rgba(0, 0, 0, 0.992)')", "'RGBA[0, 0, 0, 253]'"); | |
93 shouldBe("parse('rgba(0, 0, 0, 0.993)')", "'RGBA[0, 0, 0, 253]'"); | |
94 shouldBe("parse('rgba(0, 0, 0, 0.994)')", "'RGBA[0, 0, 0, 253]'"); | |
95 shouldBe("parse('rgba(0, 0, 0, 0.995)')", "'RGBA[0, 0, 0, 254]'"); | |
96 shouldBe("parse('rgba(0, 0, 0, 0.996)')", "'RGBA[0, 0, 0, 254]'"); | |
97 shouldBe("parse('rgba(0, 0, 0, 0.997)')", "'RGBA[0, 0, 0, 254]'"); | |
98 shouldBe("parse('rgba(0, 0, 0, 0.998)')", "'RGBA[0, 0, 0, 254]'"); | |
99 shouldBe("parse('rgba(0, 0, 0, 0.999)')", "'RGBA[0, 0, 0, 255]'"); | |
OLD | NEW |