| 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 |
| 11 "use strict"; | 11 'use strict'; |
| 12 |
| 12 var MS_PER_SEC = 1000; | 13 var MS_PER_SEC = 1000; |
| 13 | 14 |
| 15 // The recommended minimum precision to use for time values[1]. |
| 16 // |
| 17 // [1] https://w3c.github.io/web-animations/#precision-of-time-values |
| 18 var TIME_PRECISION = 0.0005; // ms |
| 19 |
| 20 // Allow implementations to substitute an alternative method for comparing |
| 21 // times based on their precision requirements. |
| 22 if (!window.assert_times_equal) { |
| 23 window.assert_times_equal = function(actual, expected, description) { |
| 24 assert_approx_equals(actual, expected, TIME_PRECISION, description); |
| 25 } |
| 26 } |
| 27 |
| 14 // creates div element, appends it to the document body and | 28 // creates div element, appends it to the document body and |
| 15 // removes the created element during test cleanup | 29 // removes the created element during test cleanup |
| 16 function createDiv(test, doc) { | 30 function createDiv(test, doc) { |
| 17 if (!doc) { | 31 if (!doc) { |
| 18 doc = document; | 32 doc = document; |
| 19 } | 33 } |
| 20 var div = doc.createElement('div'); | 34 var div = doc.createElement('div'); |
| 21 doc.body.appendChild(div); | 35 doc.body.appendChild(div); |
| 22 test.add_cleanup(function() { | 36 test.add_cleanup(function() { |
| 23 div.remove(); | 37 div.remove(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 function handleFrame() { | 144 function handleFrame() { |
| 131 if (--frameCount <= 0) { | 145 if (--frameCount <= 0) { |
| 132 resolve(); | 146 resolve(); |
| 133 } else { | 147 } else { |
| 134 window.requestAnimationFrame(handleFrame); // wait another frame | 148 window.requestAnimationFrame(handleFrame); // wait another frame |
| 135 } | 149 } |
| 136 } | 150 } |
| 137 window.requestAnimationFrame(handleFrame); | 151 window.requestAnimationFrame(handleFrame); |
| 138 }); | 152 }); |
| 139 } | 153 } |
| OLD | NEW |