OLD | NEW |
1 /* | 1 /* |
2 Distributed under both the W3C Test Suite License [1] and the W3C | 2 Distributed under both the W3C Test Suite License [1] and the W3C |
3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the | 3 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
4 policies and contribution forms [3]. | 4 policies and contribution forms [3]. |
5 | 5 |
6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license | 6 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license | 7 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
8 [3] http://www.w3.org/2004/10/27-testcases | 8 [3] http://www.w3.org/2004/10/27-testcases |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 // times based on their precision requirements. | 21 // times based on their precision requirements. |
22 if (!window.assert_times_equal) { | 22 if (!window.assert_times_equal) { |
23 window.assert_times_equal = function(actual, expected, description) { | 23 window.assert_times_equal = function(actual, expected, description) { |
24 assert_approx_equals(actual, expected, TIME_PRECISION, description); | 24 assert_approx_equals(actual, expected, TIME_PRECISION, description); |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 // creates div element, appends it to the document body and | 28 // creates div element, appends it to the document body and |
29 // removes the created element during test cleanup | 29 // removes the created element during test cleanup |
30 function createDiv(test, doc) { | 30 function createDiv(test, doc) { |
| 31 return createElement(test, 'div', doc); |
| 32 } |
| 33 |
| 34 // creates element of given tagName, appends it to the document body and |
| 35 // removes the created element during test cleanup |
| 36 // if tagName is null or undefined, returns div element |
| 37 function createElement(test, tagName, doc) { |
31 if (!doc) { | 38 if (!doc) { |
32 doc = document; | 39 doc = document; |
33 } | 40 } |
34 var div = doc.createElement('div'); | 41 var element = doc.createElement(tagName || 'div'); |
35 doc.body.appendChild(div); | 42 doc.body.appendChild(element); |
36 test.add_cleanup(function() { | 43 test.add_cleanup(function() { |
37 div.remove(); | 44 element.remove(); |
38 }); | 45 }); |
39 return div; | 46 return element; |
40 } | 47 } |
41 | 48 |
42 // Creates a style element with the specified rules, appends it to the document | 49 // Creates a style element with the specified rules, appends it to the document |
43 // head and removes the created element during test cleanup. | 50 // head and removes the created element during test cleanup. |
44 // |rules| is an object. For example: | 51 // |rules| is an object. For example: |
45 // { '@keyframes anim': '' , | 52 // { '@keyframes anim': '' , |
46 // '.className': 'animation: anim 100s;' }; | 53 // '.className': 'animation: anim 100s;' }; |
47 // or | 54 // or |
48 // { '.className1::before': 'content: ""; width: 0px; transition: all 10s;', | 55 // { '.className1::before': 'content: ""; width: 0px; transition: all 10s;', |
49 // '.className2::before': 'width: 100px;' }; | 56 // '.className2::before': 'width: 100px;' }; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 function handleFrame() { | 151 function handleFrame() { |
145 if (--frameCount <= 0) { | 152 if (--frameCount <= 0) { |
146 resolve(); | 153 resolve(); |
147 } else { | 154 } else { |
148 window.requestAnimationFrame(handleFrame); // wait another frame | 155 window.requestAnimationFrame(handleFrame); // wait another frame |
149 } | 156 } |
150 } | 157 } |
151 window.requestAnimationFrame(handleFrame); | 158 window.requestAnimationFrame(handleFrame); |
152 }); | 159 }); |
153 } | 160 } |
OLD | NEW |