blob: 0abbabee6c28ce5a86a44ddabbd5fca01a8994c5 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>
description("Test to make sure padding shorthand property returns CSSValueList properly.")
var testContainer = document.createElement("div");
testContainer.contentEditable = true;
document.body.appendChild(testContainer);
testContainer.innerHTML = '<div style="width:100px;height:100px"><div id="test">hello</div></div>';
e = document.getElementById('test');
computedStyle = window.getComputedStyle(e, null);
e.style.padding = "10px 5px 4px 3px";
shouldBe("computedStyle.getPropertyValue('padding')", "'10px 5px 4px 3px'");
shouldBe("computedStyle.getPropertyCSSValue('padding').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('padding').length", "4");
shouldBe("computedStyle.getPropertyCSSValue('padding').cssText", "'10px 5px 4px 3px'");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "10");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "5");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "4");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "3");
e.style.padding = "4em 5em 6em 7em";
shouldBe("computedStyle.getPropertyValue('padding')", "'64px 80px 96px 112px'");
shouldBe("computedStyle.getPropertyCSSValue('padding').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('padding').length", "4");
shouldBe("computedStyle.getPropertyCSSValue('padding').cssText", "'64px 80px 96px 112px'");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "64");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "80");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "96");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "112");
e.style.padding = "5% 6% 7% 8%";
shouldBe("computedStyle.getPropertyValue('padding')", "'5px 6px 7px 8px'");
shouldBe("computedStyle.getPropertyCSSValue('padding').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('padding').length", "4");
shouldBe("computedStyle.getPropertyCSSValue('padding').cssText", "'5px 6px 7px 8px'");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(0).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "5");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(1).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "6");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(2).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "7");
shouldBe("computedStyle.getPropertyCSSValue('padding').item(3).getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "8");
document.body.removeChild(testContainer);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>