OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <div id="test-div" style="font-size: 10pt; transform: rotate(100grad); -webkit-a
nimation-delay: 0.2s;"></div> | |
8 <script> | |
9 if (window.testRunner) | |
10 testRunner.dumpAsText(); | |
11 | |
12 description("Testing whether CSSPrimitiveValue.getFloatValue() converts units co
rrectly."); | |
13 | |
14 function getFloatValue(nestLevel, propertyName, unit) | |
15 { | |
16 var value = document.getElementById("test-div").style.getPropertyCSSValue(pr
opertyName); | |
17 while (nestLevel--) | |
18 value = value[0]; | |
19 return Number(value.getFloatValue(unit).toFixed(6)); | |
20 } | |
21 | |
22 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_PT)", "10"); | |
23 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_MM)", "3.527778"); | |
24 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_CM)", "0.352778"); | |
25 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_IN)", "0.138889"); | |
26 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_PC)", "0.833333"); | |
27 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_PX)", "13.333333")
; | |
28 shouldBe("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_NUMBER)", "13.3333
33"); | |
29 shouldBe("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_DEG)", "90"); | |
30 shouldBe("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_RAD)", "1.570796")
; | |
31 shouldBe("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_GRAD)", "100"); | |
32 shouldBe("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_NUMBER)", "90"); | |
33 shouldBe("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_MS)"
, "200"); | |
34 shouldBe("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_S)",
"0.2"); | |
35 shouldBe("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_NUMB
ER)", "200"); | |
36 | |
37 shouldThrow("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_PERCENTAGE)"); | |
38 shouldThrow("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_MS)"); | |
39 shouldThrow("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_HZ)"); | |
40 shouldThrow("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_DEG)"); | |
41 shouldThrow("getFloatValue(0, 'font-size', CSSPrimitiveValue.CSS_RGBCOLOR)"); | |
42 | |
43 shouldThrow("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_PERCENTAGE)"); | |
44 shouldThrow("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_PX)"); | |
45 shouldThrow("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_MS)"); | |
46 shouldThrow("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_HZ)"); | |
47 shouldThrow("getFloatValue(2, 'transform', CSSPrimitiveValue.CSS_RGBCOLOR)"); | |
48 | |
49 shouldThrow("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_P
ERCENTAGE)"); | |
50 shouldThrow("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_P
X)"); | |
51 shouldThrow("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_D
EG)"); | |
52 shouldThrow("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_H
Z)"); | |
53 shouldThrow("getFloatValue(1, '-webkit-animation-delay', CSSPrimitiveValue.CSS_R
GBCOLOR)"); | |
54 </script> | |
55 </body> | |
OLD | NEW |