blob: 24aa5c25f4a66c05b4262e3990039177abf3add6 [file] [log] [blame]
<!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>