| 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.textUnderlinePosition = value; |
| 5 shouldBe("e.style.getPropertyCSSValue('" + propertyCSS + "').toString()"
, "'" + type + "'"); | 5 shouldBeEqualToString("e.style.textUnderlinePosition", inlineValue); |
| 6 shouldBe("e.style.getPropertyCSSValue('" + propertyCSS + "').cssText", "
'" + value + "'"); | 6 computedStyle = window.getComputedStyle(e, null); |
| 7 } else | 7 shouldBeEqualToString("computedStyle.textUnderlinePosition", 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-underline-position 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-underline-position property returns values p
roperly.") | |
| 20 | 12 |
| 21 // FIXME: This test tests property values 'auto' and 'under'. We don't fully mat
ch | 13 // FIXME: This test tests property values 'auto' and 'under'. We don't fully mat
ch |
| 22 // the specification as we don't support [ left | right ] and this is left for a
nother implementation | 14 // the specification as we don't support [ left | right ] and this is left for a
nother implementation |
| 23 // as the rendering will need to be added. | 15 // as the rendering will need to be added. |
| 24 | 16 |
| 25 var testContainer = document.createElement("div"); | 17 var testContainer = document.createElement("div"); |
| 26 testContainer.contentEditable = true; | 18 testContainer.contentEditable = true; |
| 27 document.body.appendChild(testContainer); | 19 document.body.appendChild(testContainer); |
| 28 | 20 |
| 29 testContainer.innerHTML = '<div id="test">hello world</div>'; | 21 testContainer.innerHTML = '<div id="test">hello world</div>'; |
| 30 | 22 |
| 31 debug("Initial value:"); | 23 debug("Initial value:"); |
| 32 e = document.getElementById('test'); | 24 e = document.getElementById('test'); |
| 33 testElementStyle("textUnderlinePosition", "text-underline-position", null, ''); | 25 test(null, "", "auto"); |
| 34 testComputedStyle("textUnderlinePosition", "text-underline-position", "[object C
SSPrimitiveValue]", "auto"); | |
| 35 debug(''); | |
| 36 | 26 |
| 37 debug("Value '':"); | 27 debug("Value '':"); |
| 38 e.style.textUnderlinePosition = ''; | 28 test("", "", "auto"); |
| 39 testElementStyle("textUnderlinePosition", "text-underline-position", null, ''); | |
| 40 testComputedStyle("textUnderlinePosition", "text-underline-position", "[object C
SSPrimitiveValue]", "auto"); | |
| 41 debug(''); | |
| 42 | 29 |
| 43 debug("Initial value (explicit):"); | 30 debug("Initial value (explicit):"); |
| 44 e.style.textUnderlinePosition = 'initial'; | 31 test("initial", "initial", "auto"); |
| 45 testElementStyle("textUnderlinePosition", "text-underline-position", "[object CS
SValue]", "initial"); | |
| 46 testComputedStyle("textUnderlinePosition", "text-underline-position", "[object C
SSPrimitiveValue]", "auto"); | |
| 47 debug(''); | |
| 48 | 32 |
| 49 debug("Value 'auto':"); | 33 debug("Value 'auto':"); |
| 50 e.style.textUnderlinePosition = 'auto'; | 34 test("auto", "auto", "auto"); |
| 51 testElementStyle("textUnderlinePosition", "text-underline-position", "[object CS
SPrimitiveValue]", "auto"); | |
| 52 testComputedStyle("textUnderlinePosition", "text-underline-position", "[object C
SSPrimitiveValue]", "auto"); | |
| 53 debug(''); | |
| 54 | 35 |
| 55 debug("Value 'under':"); | 36 debug("Value 'under':"); |
| 56 e.style.textUnderlinePosition = 'under'; | 37 test("under", "under", "under"); |
| 57 testElementStyle("textUnderlinePosition", "text-underline-position", "[object CS
SPrimitiveValue]", "under"); | |
| 58 testComputedStyle("textUnderlinePosition", "text-underline-position", "[object C
SSPrimitiveValue]", "under"); | |
| 59 debug(''); | |
| 60 | 38 |
| 61 testContainer.innerHTML = '<div id="test-parent" style="text-underline-position:
under;">hello <span id="test-ancestor">world</span></div>'; | 39 testContainer.innerHTML = '<div id="test-parent" style="text-underline-position:
under;">hello <span id="test-ancestor">world</span></div>'; |
| 62 debug("Ancestor inherits values from parent:"); | 40 debug("Ancestor inherits values from parent:"); |
| 63 e = document.getElementById('test-ancestor'); | 41 e = document.getElementById('test-ancestor'); |
| 64 testElementStyle("textUnderlinePosition", "text-underline-position", null, ""); | 42 test(null, "", "under"); |
| 65 testComputedStyle("textUnderlinePosition", "text-underline-position", "[object C
SSPrimitiveValue]", "under"); | |
| 66 debug(''); | |
| 67 | 43 |
| 68 debug("Value 'auto under':"); | 44 debug("Value 'auto under':"); |
| 69 e.style.textUnderlinePosition = 'auto under'; | 45 test("auto under", "", "under"); |
| 70 testElementStyle("textUnderlinePosition", "text-underline-position", null, ""); | |
| 71 debug(''); | |
| 72 | 46 |
| 73 debug("Value 'under under':"); | 47 debug("Value 'under under':"); |
| 74 e.style.textUnderlinePosition = 'under under'; | 48 test("under under", "", "under"); |
| 75 testElementStyle("textUnderlinePosition", "text-underline-position", null, ""); | |
| 76 debug(''); | |
| 77 | 49 |
| 78 debug("Value 'under under under':"); | 50 debug("Value 'auto alphabetic under':"); |
| 79 e.style.textUnderlinePosition = 'auto alphabetic under'; | 51 test("auto alphabetic under", "", "under"); |
| 80 testElementStyle("textUnderlinePosition", "text-underline-position", null, ""); | |
| 81 debug(''); | |
| 82 | 52 |
| 83 document.body.removeChild(testContainer); | 53 document.body.removeChild(testContainer); |
| OLD | NEW |