blob: e6c72862c2963861b1a803d7f85e88d016d13b41 [file] [log] [blame]
<!DOCTYPE html>
<script src='../resources/testharness.js'></script>
<script src='../resources/testharnessreport.js'></script>
<script>
test(function() {
var result = CSSStyleValue.parse('width', '10px');
assert_not_equals(result, null);
assert_true(result instanceof CSSSimpleLength);
assert_equals(result.value, 10);
assert_equals(result.type, 'px');
}, 'Parsing 10px results in a CSSSimpleLength');
test(function() {
assert_equals(CSSStyleValue.parse('width', 'hello'), null);
assert_equals(CSSStyleValue.parse('width', ''), null);
assert_equals(CSSStyleValue.parse('width', null), null);
}, 'Parsing returns null on failure');
test(function() {
assert_throws(new TypeError(), function() {
CSSStyleValue.parse('', '10px');
});
}, 'Passing in empty string to parse for the property name throws');
test(function() {
assert_throws(new TypeError(), function() {
CSSStyleValue.parse('hello', '5px');
});
}, 'Passing in an invalid property name throws');
test(function() {
assert_throws(new TypeError(), function() {
CSSStyleValue.parse('border', '10px');
});
}, 'Attempting to parse a value for a shorthand property throws');
</script>