blob: c63f768a038f878de0b74ad036f5626d4a3b3a07 [file] [log] [blame]
<!DOCTYPE html>
<html>
<style>
* { font-size: 16px; }
div { font-size: 8px; }
</style>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Test parsing and computed style of opacity');
function computedStyle(property, value) {
var div = document.createElement("div");
document.body.appendChild(div);
div.style.setProperty(property, value);
var computedValue = getComputedStyle(div).getPropertyValue(property);
document.body.removeChild(div);
return computedValue;
}
function innerStyle(property, value) {
var div = document.createElement("div");
div.style.setProperty(property, value);
return div.style.getPropertyValue(property);
}
function testComputed(property, value, expected) {
shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
}
function testInner(property, value, expected) {
if (expected === null)
expected = "";
shouldBeEqualToString('innerStyle("' + property + '", "' + value + '")', expected);
}
function negativeTest(property, value) {
testInner(property, value, null);
// FIXME: Computed style not yet implemented.
// testComputed(property, value, 'none');
}
testInner("opacity", "0", "0");
testInner("opacity", "0.5", "0.5");
testInner("opacity", "1", "1");
testInner("opacity", "1000", "1000");
testInner("opacity", "-400", "-400");
testInner("opacity", "20%", "0.2");
testInner("opacity", "-600%", "-6");
testInner("opacity", "700%", "7");
testInner("opacity", "2.5e-1", "0.25");
testInner("opacity", "2.5e1%", "0.25");
testInner("opacity", "100.25%", "1.0025");
testComputed("opacity", "0", "0");
testComputed("opacity", "0.5", "0.5");
testComputed("opacity", "1", "1");
testComputed("opacity", "1000", "1");
testComputed("opacity", "-400", "0");
testComputed("opacity", "25%", "0.25");
testComputed("opacity", "-600%", "0");
testComputed("opacity", "700%", "1");
testComputed("opacity", "2.5e-1", "0.25");
testComputed("opacity", "2.5e1%", "0.25");
testComputed("opacity", "100.25%", "1");
negativeTest("opacity", "2px");
negativeTest("opacity", "auto");
negativeTest("opacity", "none");
negativeTest("opacity", "'str'");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>