OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src='../../resources/testharness.js'></script> | 4 <script src='../../resources/testharness.js'></script> |
5 <script src='../../resources/testharnessreport.js'></script> | 5 <script src='../../resources/testharnessreport.js'></script> |
6 </head> | 6 </head> |
7 <body> | 7 <body> |
8 <div id='testElement'></div> | 8 <div id='testElement'></div> |
9 | 9 |
10 <script> | 10 <script> |
11 | 11 |
12 testElement.style.lineHeight = '10px'; | 12 testElement.style.lineHeight = '10px'; |
13 testElement.style.fontSize = '100px'; | 13 testElement.style.fontSize = '100px'; |
14 | 14 |
| 15 var computedStyleMap = getComputedStyleMap(testElement); |
15 | 16 |
16 var t1 = async_test("Getting a 10px lineHeight results in a CSSSimpleLength"); | 17 test(function() { |
17 function t1Callback(computedStyleMap) { | 18 var result = computedStyleMap.get('line-height'); |
18 t1.step(function() { | 19 assert_true(result instanceof CSSSimpleLength); |
19 var result = computedStyleMap.get('line-height'); | 20 assert_equals(result.cssText, '10px'); |
20 assert_equals(result.constructor.name, CSSSimpleLength.name); | 21 }, 'Getting a 10px lineHeight results in a CSSSimpleLength'); |
21 assert_equals(result.cssText, '10px'); | |
22 }); | |
23 t1.done(); | |
24 } | |
25 | 22 |
26 var t2 = async_test("getAll for lineHeight returns a single value"); | 23 test(function() { |
27 function t2Callback(computedStyleMap) { | 24 testElement.style.lineHeight = '20px'; |
28 t2.step(function() { | 25 var result = computedStyleMap.getAll('line-height'); |
29 testElement.style.lineHeight = '20px'; | 26 assert_equals(result.length, 1); |
30 var result = computedStyleMap.getAll('line-height'); | 27 assert_equals(result[0].cssText, '20px'); |
31 assert_equals(result.length, 1); | 28 }, 'getAll for lineHeight returns a single value'); |
32 assert_equals(result[0].cssText, '20px'); | |
33 }); | |
34 t2.done(); | |
35 } | |
36 | 29 |
37 var t3 = async_test("Getting a 10% lineHeight results in a CSSSimpleLength"); | 30 test(function() { |
38 function t3Callback(computedStyleMap) { | 31 testElement.style.lineHeight = '10%'; |
39 t3.step(function() { | 32 var result = computedStyleMap.get('line-height'); |
40 testElement.style.lineHeight = '10%'; | 33 assert_true(result instanceof CSSSimpleLength); |
41 var result = computedStyleMap.get('line-height'); | 34 assert_equals(result.cssText, '10px'); |
42 assert_equals(result.constructor.name, CSSSimpleLength.name); | 35 }, 'Getting a 10% lineHeight results in a CSSSimpleLength'); |
43 assert_equals(result.cssText, '10px'); | |
44 }); | |
45 t3.done(); | |
46 } | |
47 | 36 |
48 var t4 = async_test("Getting a number lineHeight results in a CSSNumberValue"); | 37 test(function() { |
49 function t4Callback(computedStyleMap) { | 38 testElement.style.lineHeight = '0.2'; |
50 t4.step(function() { | 39 var result = computedStyleMap.get('line-height'); |
51 testElement.style.lineHeight = '0.2'; | 40 assert_true(result instanceof CSSSimpleLength); |
52 var result = computedStyleMap.get('line-height'); | 41 assert_equals(result.cssText, '20px'); |
53 assert_equals(result.constructor.name, CSSNumberValue.name); | 42 }, 'Getting a number lineHeight results in a CSSSimpleLength'); |
54 assert_equals(result.cssText, '20'); | |
55 }); | |
56 t4.done(); | |
57 } | |
58 | 43 |
59 var t5 = async_test("Getting a calc lineHeight results in a CSSSimpleLength"); | 44 test(function() { |
60 function t5Callback(computedStyleMap) { | 45 testElement.style.lineHeight = 'calc(10px + 10%)'; |
61 t5.step(function() { | 46 var result = computedStyleMap.get('line-height'); |
62 testElement.style.lineHeight = 'calc(10px + 10%)'; | 47 assert_true(result instanceof CSSSimpleLength); |
63 var result = computedStyleMap.get('line-height'); | 48 assert_equals(result.cssText, '20px'); |
64 assert_equals(result.constructor.name, CSSSimpleLength.name); | 49 }, 'Getting a calc lineHeight results in a CSSSimpleLength'); |
65 assert_equals(result.cssText, '20px'); | |
66 }); | |
67 t5.done(); | |
68 } | |
69 | 50 |
70 var t6 = async_test("Getting a normal lineHeight results in a CSSKeywordValue"); | 51 test(function() { |
71 function t6Callback(computedStyleMap) { | 52 testElement.style.lineHeight = 'normal'; |
72 t6.step(function() { | 53 var result = computedStyleMap.get('line-height'); |
73 testElement.style.lineHeight = 'normal'; | 54 assert_true(result instanceof CSSKeywordValue); |
74 var result = computedStyleMap.get('line-height'); | 55 assert_equals(result.cssText, 'normal'); |
75 assert_equals(result.constructor.name, CSSKeywordValue.name); | 56 }, 'Getting a normal lineHeight results in a CSSKeywordValue'); |
76 assert_equals(result.cssText, 'normal'); | |
77 }); | |
78 t6.done(); | |
79 } | |
80 | |
81 document.onreadystatechange = function() { | |
82 if(document.readyState == 'complete') { | |
83 var computedStyleMap = getComputedStyleMap(testElement); | |
84 t1Callback(computedStyleMap); | |
85 t2Callback(computedStyleMap); | |
86 t3Callback(computedStyleMap); | |
87 t4Callback(computedStyleMap); | |
88 t5Callback(computedStyleMap); | |
89 t6Callback(computedStyleMap); | |
90 } | |
91 }; | |
92 | 57 |
93 </script> | 58 </script> |
94 </body> | 59 </body> |
95 </html> | 60 </html> |
OLD | NEW |