blob: a3c4dbae3f9d7e83ab01cf444663653f1f7630a7 [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 border shorthand properties returns CSSValueList properly.")
var testContainer = document.createElement("div");
testContainer.contentEditable = true;
document.body.appendChild(testContainer);
testContainer.innerHTML = '<div id="test">hello</div>';
e = document.getElementById('test');
computedStyle = window.getComputedStyle(e, null);
var properties = new Array("border-bottom","border-top","border-right", "border-left");
for (i = 0; i < properties.length; ++i) {
e.style.cssText = properties[i] + ": 10px solid red;";
shouldBe("computedStyle.getPropertyValue('" + properties[i] + "')", "'10px solid rgb(255, 0, 0)'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').cssText", "'10px solid rgb(255, 0, 0)'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').length", "3");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(0).getFloatValue(CSSPrimitiveValue.CSS_PX)", "10");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(1).getStringValue()", "'solid'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "255");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
e.style.cssText = properties[i] + ": 20em solid blue;";
shouldBe("computedStyle.getPropertyValue('" + properties[i] + "')", "'320px solid rgb(0, 0, 255)'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').cssText", "'320px solid rgb(0, 0, 255)'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').length", "3");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(0).getFloatValue(CSSPrimitiveValue.CSS_PX)", "320");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(1).getStringValue()", "'solid'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "255");
e.style.cssText = properties[i] + ": 10px none green;";
shouldBe("computedStyle.getPropertyValue('" + properties[i] + "')", "'0px none rgb(0, 128, 0)'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').cssText", "'0px none rgb(0, 128, 0)'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').length", "3");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(0).getFloatValue(CSSPrimitiveValue.CSS_PX)", "0");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(1).getStringValue()", "'none'");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "128");
shouldBe("computedStyle.getPropertyCSSValue('" + properties[i] + "').item(2).getRGBColorValue().blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
}
e.style.cssText = "";
e.style.border = "20em solid red";
shouldBe("computedStyle.getPropertyValue('border')", "'320px solid rgb(255, 0, 0)'");
shouldBe("computedStyle.getPropertyCSSValue('border').toString()", "'[object CSSValueList]'");
shouldBe("computedStyle.getPropertyCSSValue('border').cssText", "'320px solid rgb(255, 0, 0)'");
shouldBe("computedStyle.getPropertyCSSValue('border').length", "3");
shouldBe("computedStyle.getPropertyCSSValue('border').item(0).getFloatValue(CSSPrimitiveValue.CSS_PX)", "320");
shouldBe("computedStyle.getPropertyCSSValue('border').item(1).getStringValue()", "'solid'");
shouldBe("computedStyle.getPropertyCSSValue('border').item(2).getRGBColorValue().red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "255");
shouldBe("computedStyle.getPropertyCSSValue('border').item(2).getRGBColorValue().green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
shouldBe("computedStyle.getPropertyCSSValue('border').item(2).getRGBColorValue().blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0");
e.style.border = "20em solid red";
e.style.borderTop = "10px groove blue";
shouldBe("computedStyle.getPropertyValue('border')", "''");
document.body.removeChild(testContainer);
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>