1 description("This test ensures that legacy color attributes are parsed properly.");
3 shouldBe("document.body.bgColor='';getComputedStyle(document.body).backgroundColor;", "'rgba(0, 0, 0, 0)'");
4 shouldBe("document.body.bgColor='transparent';getComputedStyle(document.body).backgroundColor;", "'rgba(0, 0, 0, 0)'");
5 shouldBe("document.body.bgColor=' transparent ';getComputedStyle(document.body).backgroundColor;", "'rgba(0, 0, 0, 0)'");
8 {'test':'red', 'expected':[255, 0, 0]},
9 {'test':' red ', 'expected':[255, 0, 0]},
10 {'test':'#f00', 'expected':[255, 0, 0]},
11 {'test':' #f00 ', 'expected':[255, 0, 0]},
12 {'test':'#ff0000', 'expected':[255, 0, 0]},
13 {'test':' #ff0000 ', 'expected':[255, 0, 0]},
14 {'test':'#fzz', 'expected':[15, 0, 0]},
15 {'test':'#ffzzzz', 'expected':[255, 0, 0]},
16 {'test':'f00', 'expected':[15, 0, 0]},
17 {'test':'ff0000', 'expected':[255, 0, 0]},
18 {'test':'#00000000', 'expected':[0, 0, 0]},
19 {'test':'foo', 'expected':[15, 0, 0]},
20 {'test':'cheese', 'expected':[192, 238, 14]},
21 {'test':'ffff', 'expected':[255, 0, 255]},
22 {'test':'ff', 'expected':[240, 15, 0]},
23 {'test':'rgb(255, 0, 0)', 'expected':[0, 85, 0]},
24 {'test':'rgba(255,255,255,50%)', 'expected':[0,80,85]},
25 {'test':'hsl(180,100%,50%)', 'expected':[0,1,80]},
26 {'test':'hsla(180,100%,50%,50%)', 'expected':[0,16,5]},
27 {'test':'currentColor', 'expected':[192,224,0]},
28 {'test':'550000001155000000115500000011', 'expected':[17, 17, 17]},
29 {'test':'550000000155000000015500000001', 'expected':[1, 1, 1]},
30 {'test':'550000000055000000005500000000', 'expected':[0, 0, 0]},
31 {'test':'550020001155000000115500000011', 'expected':[32, 0, 0]},
32 {'test':'55201155001155000011', 'expected':[32, 0, 0]},
33 {'test':'#', 'expected':[0, 0, 0]},
34 {'test':'#5', 'expected':[5, 0, 0]},
35 {'test':'#55', 'expected':[5, 5, 0]},
36 {'test':'#555', 'expected':[85, 85, 85]},
37 {'test':'#5555', 'expected':[85, 85, 0]},
38 {'test':'#55555', 'expected':[85, 85, 80]},
39 {'test':'#555555', 'expected':[85, 85, 85]},
40 {'test':'#5555555', 'expected':[85, 85, 80]},
41 {'test':'#55555555', 'expected':[85, 85, 85]},
42 {'test':'5', 'expected':[5, 0, 0]},
43 {'test':'55', 'expected':[5, 5, 0]},
44 {'test':'555', 'expected':[5, 5, 5]},
45 {'test':'5555', 'expected':[85, 85, 0]},
46 {'test':'55555', 'expected':[85, 85, 80]},
47 {'test':'555555', 'expected':[85, 85, 85]},
48 {'test':'5555555', 'expected':[85, 85, 80]},
49 {'test':'55555555', 'expected':[85, 85, 85]},
50 {'test':'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000', 'expected':[255, 255, 255]},
51 {'test':'ffffff', 'expected':[0, 0, 0]},
52 {'test':' ', 'expected':[0, 0, 0]},
53 {'test':' ffffff ', 'expected':[255, 255, 255]}
56 for(var i = 0; i < tests.length; i++) {
57 var t = tests[i].test;
58 var e = tests[i].expected;
59 shouldBe("document.body.bgColor='" + t + "';getComputedStyle(document.body).backgroundColor;", "'rgb(" + e[0] + ", " + e[1] + ", " + e[2] + ")'");