| OLD | NEW |
| 1 function testElementStyle(propertyJS, propertyCSS, type, value) | 1 function test(value, inlineValue, computedValue) |
| 2 { | 2 { |
| 3 if (type != null) { | 3 if (value !== null) |
| 4 shouldBe("e.style." + propertyJS, "'" + value + "'"); | 4 e.style.textDecorationLine = value; |
| 5 shouldBe("e.style.getPropertyCSSValue('" + propertyCSS + "').toString()"
, "'" + type + "'"); | 5 shouldBeEqualToString("e.style.textDecorationLine", inlineValue); |
| 6 shouldBe("e.style.getPropertyCSSValue('" + propertyCSS + "').cssText", "
'" + value + "'"); | 6 computedStyle = window.getComputedStyle(e, null); |
| 7 } else | 7 shouldBeEqualToString("computedStyle.textDecorationLine", computedValue); |
| 8 shouldBeNull("e.style.getPropertyCSSValue('" + propertyCSS + "')"); | 8 debug(""); |
| 9 } | 9 } |
| 10 | 10 |
| 11 function testComputedStyle(propertyJS, propertyCSS, type, value) | 11 description("Test to make sure text-decoration-line is computed properly.") |
| 12 { | |
| 13 computedStyle = window.getComputedStyle(e, null); | |
| 14 shouldBe("computedStyle." + propertyJS, "'" + value + "'"); | |
| 15 shouldBe("computedStyle.getPropertyCSSValue('" + propertyCSS + "').toString(
)", "'" + type + "'"); | |
| 16 shouldBe("computedStyle.getPropertyCSSValue('" + propertyCSS + "').cssText",
"'" + value + "'"); | |
| 17 } | |
| 18 | |
| 19 description("Test to make sure text-decoration-line property returns values prop
erly.") | |
| 20 | 12 |
| 21 var testContainer = document.createElement("div"); | 13 var testContainer = document.createElement("div"); |
| 22 testContainer.contentEditable = true; | 14 testContainer.contentEditable = true; |
| 23 document.body.appendChild(testContainer); | 15 document.body.appendChild(testContainer); |
| 24 | 16 |
| 25 testContainer.innerHTML = '<div id="test">hello world</div>'; | 17 testContainer.innerHTML = '<div id="test">hello world</div>'; |
| 18 e = document.getElementById('test'); |
| 26 debug("Initial value:"); | 19 debug("Initial value:"); |
| 27 e = document.getElementById('test'); | 20 test(null, "", "none"); |
| 28 testElementStyle("textDecorationLine", "text-decoration-line", null, ''); | |
| 29 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSPrim
itiveValue]", "none"); | |
| 30 debug(''); | |
| 31 | 21 |
| 32 debug("Initial value (explicit):"); | 22 debug("Initial value (explicit):"); |
| 33 e.style.textDecorationLine = 'initial'; | 23 test("initial", "initial", "none"); |
| 34 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
]", "initial"); | |
| 35 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSPrim
itiveValue]", "none"); | |
| 36 debug(''); | |
| 37 | 24 |
| 38 debug("Value 'none':"); | 25 debug("Value 'none':"); |
| 39 e.style.textDecorationLine = 'none'; | 26 test("none", "none", "none"); |
| 40 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSPrimi
tiveValue]", "none"); | |
| 41 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSPrim
itiveValue]", "none"); | |
| 42 debug(''); | |
| 43 | 27 |
| 44 debug("Value 'underline':"); | 28 debug("Value 'underline':"); |
| 45 e.style.textDecorationLine = 'underline'; | 29 test("underline", "underline", "underline"); |
| 46 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
List]", "underline"); | |
| 47 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSValu
eList]", "underline"); | |
| 48 debug(''); | |
| 49 | 30 |
| 50 debug("Value 'overline':"); | 31 debug("Value 'overline':"); |
| 51 e.style.textDecorationLine = 'overline'; | 32 test("overline", "overline", "overline"); |
| 52 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
List]", "overline"); | |
| 53 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSValu
eList]", "overline"); | |
| 54 debug(''); | |
| 55 | 33 |
| 56 debug("Value 'line-through':"); | 34 debug("Value 'line-through':"); |
| 57 e.style.textDecorationLine = 'line-through'; | 35 test("line-through", "line-through", "line-through"); |
| 58 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
List]", "line-through"); | |
| 59 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSValu
eList]", "line-through"); | |
| 60 debug(''); | |
| 61 | 36 |
| 62 debug("Value 'blink' (valid, but ignored on computed style):"); | 37 debug("Value 'blink' (valid, but ignored on computed style):"); |
| 63 e.style.textDecorationLine = 'blink'; | 38 test("blink", "blink", "none"); |
| 64 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
List]", "blink"); | |
| 65 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSPrim
itiveValue]", "none"); | |
| 66 debug(''); | |
| 67 | 39 |
| 68 debug("Value 'underline overline line-through blink':"); | 40 debug("Value 'underline overline line-through blink':"); |
| 69 e.style.textDecorationLine = 'underline overline line-through blink'; | 41 test("underline overline line-through blink", "underline overline line-through b
link", "underline overline line-through"); |
| 70 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
List]", "underline overline line-through blink"); | |
| 71 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSValu
eList]", "underline overline line-through"); | |
| 72 debug(''); | |
| 73 | 42 |
| 74 debug("Value '':"); | 43 debug("Value '':"); |
| 75 e.style.textDecorationLine = ''; | 44 test("", "", "none"); |
| 76 testElementStyle("textDecorationLine", "text-decoration-line", null, ''); | |
| 77 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSPrim
itiveValue]", "none"); | |
| 78 debug(''); | |
| 79 | 45 |
| 80 testContainer.innerHTML = '<div id="test-parent" style="text-decoration-line: un
derline;">hello <span id="test-ancestor" style="text-decoration-line: inherit;">
world</span></div>'; | 46 testContainer.innerHTML = '<div id="test-parent" style="text-decoration-line: un
derline;">hello <span id="test-ancestor" style="text-decoration-line: inherit;">
world</span></div>'; |
| 81 debug("Parent gets 'underline' value:"); | 47 debug("Parent gets 'underline' value:"); |
| 82 e = document.getElementById('test-parent'); | 48 e = document.getElementById('test-parent'); |
| 83 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
List]", "underline"); | 49 test(null, "underline", "underline"); |
| 84 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSValu
eList]", "underline"); | |
| 85 debug(''); | |
| 86 | 50 |
| 87 debug("Ancestor should explicitly inherit value from parent when 'inherit' value
is used:"); | 51 debug("Ancestor should explicitly inherit value from parent when 'inherit' value
is used:"); |
| 88 e = document.getElementById('test-ancestor'); | 52 e = document.getElementById('test-ancestor'); |
| 89 testElementStyle("textDecorationLine", "text-decoration-line", "[object CSSValue
]", "inherit"); | 53 test(null, "inherit", "underline"); |
| 90 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSValu
eList]", "underline"); | |
| 91 debug(''); | |
| 92 | 54 |
| 93 debug("Ancestor should not implicitly inherit value from parent (i.e. when value
is void):"); | 55 debug("Ancestor should not implicitly inherit value from parent (i.e. when value
is void):"); |
| 94 e.style.textDecorationLine = ''; | 56 test("", "", "none"); |
| 95 testElementStyle("textDecorationLine", "text-decoration-line", null, ''); | |
| 96 testComputedStyle("textDecorationLine", "text-decoration-line", "[object CSSPrim
itiveValue]", "none"); | |
| 97 debug(''); | |
| 98 | 57 |
| 99 document.body.removeChild(testContainer); | 58 document.body.removeChild(testContainer); |
| OLD | NEW |