haikuwebkit/LayoutTests/fast/css3-text/css3-word-spacing-percentage/word-spacing-percentage-par...

42 lines
1.3 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script type="text/javascript">
function testPercentageIsValid(stylesheet, percentage) {
cssRule = stylesheet.cssRules.item(0);
shouldBe("cssRule.type", "cssRule.STYLE_RULE");
declaration = cssRule.style;
shouldBe("declaration.length", "1");
shouldBe("declaration.getPropertyValue('word-spacing')", '"' + percentage.toString() + '%' + '"');
stylesheet.deleteRule(0);
}
function testInvalidRule(stylesheet) {
cssRule = stylesheet.cssRules.item(0);
shouldBe("cssRule.type", "cssRule.STYLE_RULE");
declaration = cssRule.style;
shouldBe("declaration.length", "0");
stylesheet.deleteRule(0);
}
var styleElement = document.createElement("style");
document.head.appendChild(styleElement);
stylesheet = styleElement.sheet;
stylesheet.insertRule(".p { word-spacing: 100%; }", 0);
testPercentageIsValid(stylesheet, 100);
stylesheet.insertRule(".p { word-spacing: 100.5%; }", 0);
testPercentageIsValid(stylesheet, 100.5);
stylesheet.insertRule(".p { word-spacing: garbage%; }", 0);
testInvalidRule(stylesheet);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>