Implement getComputedStyle

This commit is contained in:
David Zbarsky 2015-07-27 23:05:18 -04:00
parent 416931f4be
commit e484d6b5e3
24 changed files with 886 additions and 152 deletions

View file

@ -533,6 +533,12 @@
"url": "/_mozilla/mozilla/getBoundingClientRect.html"
}
],
"mozilla/getComputedStyle.html": [
{
"path": "mozilla/getComputedStyle.html",
"url": "/_mozilla/mozilla/getComputedStyle.html"
}
],
"mozilla/getPropertyPriority.html": [
{
"path": "mozilla/getPropertyPriority.html",
@ -974,4 +980,4 @@
"rev": null,
"url_base": "/_mozilla/",
"version": 2
}
}

View file

@ -0,0 +1,45 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
#foo:before {
color: red;
}
#foo {
width: 50px;
}
</style>
</head>
<body>
<div id="foo"></div>
<script>
test(function() {
var div = document.getElementById("foo");
var cs = getComputedStyle(div);
assert_equals(cs.getPropertyValue("left"), "auto");
assert_equals(cs.getPropertyValue("right"), "auto");
assert_equals(cs.getPropertyValue("top"), "auto");
assert_equals(cs.getPropertyValue("bottom"), "auto");
assert_equals(cs.getPropertyValue("width"), "50px");
assert_equals(cs.getPropertyValue("height"), "auto");
assert_equals(cs.getPropertyValue("color"), "rgb(0, 0, 0)");
}, "Element's resolved values");
test(function() {
var div = document.getElementById("foo");
assert_equals(getComputedStyle(div, ':before').getPropertyValue("color"), "rgb(255, 0, 0)");
assert_equals(getComputedStyle(div, '::before').getPropertyValue("color"), "rgb(255, 0, 0)");
}, "Existing :before pseudoelement");
test(function() {
var div = document.getElementById("foo");
assert_equals(getComputedStyle(div, ':after').getPropertyValue("color"), "");
assert_equals(getComputedStyle(div, '::after').getPropertyValue("color"), "");
}, "Missing :after pseudoelement");
</script>
</body>
</html>