OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src='../resources/testharness.js'></script> | 2 <script src='../resources/testharness.js'></script> |
3 <script src='../resources/testharnessreport.js'></script> | 3 <script src='../resources/testharnessreport.js'></script> |
4 <script> | 4 <script> |
5 | 5 |
6 test(function() { | 6 test(function() { |
7 var result = CSSStyleValue.parse('width', '10px'); | 7 var result = CSSStyleValue.parse('width', '10px'); |
8 | 8 |
9 assert_not_equals(result, null); | 9 assert_not_equals(result, null); |
10 assert_equals(result.constructor.name, CSSSimpleLength.name); | 10 assert_equals(result.constructor.name, CSSUnitValue.name); |
11 assert_equals(result.value, 10); | 11 assert_equals(result.value, 10); |
12 assert_equals(result.type, 'px'); | 12 assert_equals(result.type, 'px'); |
13 }, 'Parsing 10px results in a CSSSimpleLength'); | 13 }, 'Parsing 10px results in a CSSUnitValue'); |
14 | 14 |
15 test(function() { | 15 test(function() { |
16 assert_equals(CSSStyleValue.parse('width', 'hello'), null); | 16 assert_equals(CSSStyleValue.parse('width', 'hello'), null); |
17 assert_equals(CSSStyleValue.parse('width', ''), null); | 17 assert_equals(CSSStyleValue.parse('width', ''), null); |
18 assert_equals(CSSStyleValue.parse('width', null), null); | 18 assert_equals(CSSStyleValue.parse('width', null), null); |
19 }, 'Parsing returns null on failure'); | 19 }, 'Parsing returns null on failure'); |
20 | 20 |
21 test(function() { | 21 test(function() { |
22 assert_throws(new TypeError(), function() { | 22 assert_throws(new TypeError(), function() { |
23 CSSStyleValue.parse('', '10px'); | 23 CSSStyleValue.parse('', '10px'); |
24 }); | 24 }); |
25 }, 'Passing in empty string to parse for the property name throws'); | 25 }, 'Passing in empty string to parse for the property name throws'); |
26 | 26 |
27 test(function() { | 27 test(function() { |
28 assert_throws(new TypeError(), function() { | 28 assert_throws(new TypeError(), function() { |
29 CSSStyleValue.parse('hello', '5px'); | 29 CSSStyleValue.parse('hello', '5px'); |
30 }); | 30 }); |
31 }, 'Passing in an invalid property name throws'); | 31 }, 'Passing in an invalid property name throws'); |
32 | 32 |
33 test(function() { | 33 test(function() { |
34 assert_throws(new TypeError(), function() { | 34 assert_throws(new TypeError(), function() { |
35 CSSStyleValue.parse('border', '10px'); | 35 CSSStyleValue.parse('border', '10px'); |
36 }); | 36 }); |
37 }, 'Attempting to parse a value for a shorthand property throws'); | 37 }, 'Attempting to parse a value for a shorthand property throws'); |
38 | 38 |
39 </script> | 39 </script> |
OLD | NEW |