|
Line 0
a/LayoutTests/fast/css3-text/css3-text-decoration/getComputedStyle/script-tests/getComputedStyle-text-underline-position.js_sec1
|
|
|
1 |
function testElementStyle(propertyJS, propertyCSS, type, value) |
| 2 |
{ |
| 3 |
if (type != null) { |
| 4 |
shouldBe("e.style." + propertyJS, "'" + value + "'"); |
| 5 |
shouldBe("e.style.getPropertyCSSValue('" + propertyCSS + "').toString()", "'" + type + "'"); |
| 6 |
shouldBe("e.style.getPropertyCSSValue('" + propertyCSS + "').cssText", "'" + value + "'"); |
| 7 |
} else |
| 8 |
shouldBeNull("e.style.getPropertyCSSValue('" + propertyCSS + "')"); |
| 9 |
} |
| 10 |
|
| 11 |
function testComputedStyle(propertyJS, propertyCSS, type, value) |
| 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 -webkit-text-underline-position property returns values properly.") |
| 20 |
|
| 21 |
var testContainer = document.createElement("div"); |
| 22 |
testContainer.contentEditable = true; |
| 23 |
document.body.appendChild(testContainer); |
| 24 |
|
| 25 |
testContainer.innerHTML = '<div id="test">hello world</div>'; |
| 26 |
debug("Initial value:"); |
| 27 |
e = document.getElementById('test'); |
| 28 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", null, ''); |
| 29 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "auto"); |
| 30 |
debug(''); |
| 31 |
|
| 32 |
debug("Value '':"); |
| 33 |
e.style.webkitTextUnderlinePosition = ''; |
| 34 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", null, ''); |
| 35 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "auto"); |
| 36 |
debug(''); |
| 37 |
|
| 38 |
debug("Initial value (explicit):"); |
| 39 |
e.style.webkitTextUnderlinePosition = 'initial'; |
| 40 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValue]", "initial"); |
| 41 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "auto"); |
| 42 |
debug(''); |
| 43 |
|
| 44 |
debug("Value 'auto':"); |
| 45 |
e.style.webkitTextUnderlinePosition = 'auto'; |
| 46 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "auto"); |
| 47 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "auto"); |
| 48 |
debug(''); |
| 49 |
|
| 50 |
debug("Value 'alphabetic':"); |
| 51 |
e.style.webkitTextUnderlinePosition = 'alphabetic'; |
| 52 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "alphabetic"); |
| 53 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSPrimitiveValue]", "alphabetic"); |
| 54 |
debug(''); |
| 55 |
|
| 56 |
debug("Value 'under':"); |
| 57 |
e.style.webkitTextUnderlinePosition = 'under'; |
| 58 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under"); |
| 59 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under"); |
| 60 |
debug(''); |
| 61 |
|
| 62 |
debug("Value 'left':"); |
| 63 |
e.style.webkitTextUnderlinePosition = 'left'; |
| 64 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "left"); |
| 65 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "left"); |
| 66 |
debug(''); |
| 67 |
|
| 68 |
debug("Value 'right':"); |
| 69 |
e.style.webkitTextUnderlinePosition = 'right'; |
| 70 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "right"); |
| 71 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "right"); |
| 72 |
debug(''); |
| 73 |
|
| 74 |
debug("Value 'under left':"); |
| 75 |
e.style.webkitTextUnderlinePosition = 'under left'; |
| 76 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under left"); |
| 77 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under left"); |
| 78 |
debug(''); |
| 79 |
|
| 80 |
testContainer.innerHTML = '<div id="test-parent" style="-webkit-text-underline-position: under left;">hello <span id="test-ancestor">world</span></div>'; |
| 81 |
debug("Ancestor inherits values from parent:"); |
| 82 |
e = document.getElementById('test-ancestor'); |
| 83 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", null, ""); |
| 84 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under left"); |
| 85 |
debug(''); |
| 86 |
|
| 87 |
debug("Value 'under right':"); |
| 88 |
e.style.webkitTextUnderlinePosition = 'under right'; |
| 89 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under right"); |
| 90 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under right"); |
| 91 |
debug(''); |
| 92 |
|
| 93 |
testContainer.innerHTML = '<div id="test-parent" style="-webkit-text-underline-position: under right;">hello <span id="test-ancestor">world</span></div>'; |
| 94 |
debug("Ancestor inherits values from parent:"); |
| 95 |
e = document.getElementById('test-ancestor'); |
| 96 |
testElementStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", null, ""); |
| 97 |
testComputedStyle("webkitTextUnderlinePosition", "-webkit-text-underline-position", "[object CSSValueList]", "under right"); |
| 98 |
debug(''); |
| 99 |
|
| 100 |
document.body.removeChild(testContainer); |