OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../js/resources/js-test-pre.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <div id="test"></div> |
| 8 <div id="ancestor"><div id="child"></div></div> |
| 9 |
| 10 <script> |
| 11 function testElementStyle(value) |
| 12 { |
| 13 shouldBe("element.style.textJustify", "'" + value + "'"); |
| 14 shouldBe("element.style.getPropertyCSSValue('text-justify').cssText", "'"
+ value + "'"); |
| 15 } |
| 16 |
| 17 function testComputedStyle(value) |
| 18 { |
| 19 computedStyle = window.getComputedStyle(element, null); |
| 20 shouldBe("computedStyle.textJustify", "'" + value + "'"); |
| 21 shouldBe("computedStyle.getPropertyCSSValue('text-justify').cssText", "'"
+ value + "'"); |
| 22 } |
| 23 |
| 24 function valueSettingTest(value) |
| 25 { |
| 26 debug("Value '" + value + "':"); |
| 27 element.style.textJustify = value; |
| 28 testElementStyle(value); |
| 29 testComputedStyle(value); |
| 30 debug(''); |
| 31 } |
| 32 |
| 33 function invalidValueSettingTest(value, presettedValue) |
| 34 { |
| 35 debug("Invalid value test - '" + value + "':"); |
| 36 element.style.textJustify = value; |
| 37 testElementStyle(presettedValue); |
| 38 testComputedStyle(presettedValue); |
| 39 debug(''); |
| 40 } |
| 41 |
| 42 function ownValueTest(ancestorValue, childValue) |
| 43 { |
| 44 debug("Value of ancestor is '" + ancestorValue + ", while child is '" + ch
ildValue + "':"); |
| 45 ancestor.style.textJustify = ancestorValue; |
| 46 child.style.textJustify = childValue; |
| 47 testElementStyle(childValue); |
| 48 testComputedStyle(childValue); |
| 49 debug(''); |
| 50 } |
| 51 |
| 52 function inheritanceTest(ancestorValue) |
| 53 { |
| 54 debug("Value of ancestor is '" + ancestorValue + "':"); |
| 55 ancestor.style.textJustify = ancestorValue; |
| 56 expectedInheritedValue = ancestorValue; |
| 57 testElementStyle(expectedInheritedValue); |
| 58 testComputedStyle(expectedInheritedValue); |
| 59 debug(''); |
| 60 } |
| 61 |
| 62 function computedValueSettingTest(value, expectedComputedValue) |
| 63 { |
| 64 debug("Computed value test - '" + value + "':"); |
| 65 if (value == 'inherit') |
| 66 ancestor.style.textJustify = expectedComputedValue; |
| 67 element.style.textJustify = value; |
| 68 testElementStyle(value); |
| 69 testComputedStyle(expectedComputedValue); |
| 70 debug(''); |
| 71 } |
| 72 |
| 73 description("This test checks that text-justify parses properly the properties
from CSS 3 Text."); |
| 74 |
| 75 element = document.getElementById('test'); |
| 76 |
| 77 valueSettingTest('none'); |
| 78 valueSettingTest('inter-word'); |
| 79 valueSettingTest('distribute'); |
| 80 |
| 81 presettedValue = 'none' |
| 82 debug("Presetted value is none"); |
| 83 element.style.textJustify = presettedValue; |
| 84 invalidValueSettingTest('green', presettedValue); |
| 85 invalidValueSettingTest('inline', presettedValue); |
| 86 |
| 87 presettedValue = 'distribute' |
| 88 debug("Presetted value is distribute"); |
| 89 element.style.textJustify = presettedValue; |
| 90 invalidValueSettingTest('solid', presettedValue); |
| 91 invalidValueSettingTest('normal', presettedValue); |
| 92 |
| 93 element = document.getElementById('child'); |
| 94 ancestor = document.getElementById('ancestor'); |
| 95 |
| 96 computedValueSettingTest('inherit', 'none'); |
| 97 computedValueSettingTest('inherit', 'distribute'); |
| 98 computedValueSettingTest('initial', 'auto'); |
| 99 |
| 100 ownValueTest("inter-word", "distribute"); |
| 101 ownValueTest("none", "inter-word"); |
| 102 </script> |
| 103 <script src="../../../js/resources/js-test-post.js"></script> |
| 104 </body> |
| 105 |
| 106 </html> |
OLD | NEW |