| OLD | NEW |
| 1 /* This is the helper script for animation tests: | 1 /* This is the helper script for animation tests: |
| 2 | 2 |
| 3 Test page requirements: | 3 Test page requirements: |
| 4 - The body must contain an empty div with id "result" | 4 - The body must contain an empty div with id "result" |
| 5 - Call this function directly from the <script> inside the test page | 5 - Call this function directly from the <script> inside the test page |
| 6 | 6 |
| 7 runAnimationTest and runTransitionTest parameters: | 7 runAnimationTest and runTransitionTest parameters: |
| 8 expected [required]: an array of arrays defining a set of CSS properties tha
t must have given values at specific times (see below) | 8 expected [required]: an array of arrays defining a set of CSS properties tha
t must have given values at specific times (see below) |
| 9 callbacks [optional]: a function to be executed immediately after animation
starts; | 9 callbacks [optional]: a function to be executed immediately after animation
starts; |
| 10 or, an object in the form {time: function} containing
functions to be | 10 or, an object in the form {time: function} containing
functions to be |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 if (finished) | 199 if (finished) |
| 200 endTest(); | 200 endTest(); |
| 201 else | 201 else |
| 202 requestAnimationFrame(runChecksWithRAF.bind(null, checks)); | 202 requestAnimationFrame(runChecksWithRAF.bind(null, checks)); |
| 203 } | 203 } |
| 204 | 204 |
| 205 function runChecksWithPauseAPI(checks) { | 205 function runChecksWithPauseAPI(checks) { |
| 206 for (var k in checks) { | 206 for (var k in checks) { |
| 207 var timeMs = Number(k); | 207 var timeMs = Number(k); |
| 208 log('Pausing at time: ' + timeMs + ', current players: ' + document.time
line.getAnimationPlayers().length); | 208 log('Pausing at time: ' + timeMs + ', current animations: ' + document.t
imeline.getAnimations().length); |
| 209 internals.pauseAnimations(timeMs / 1000); | 209 internals.pauseAnimations(timeMs / 1000); |
| 210 checks[k].forEach(function(check) { check(); }); | 210 checks[k].forEach(function(check) { check(); }); |
| 211 } | 211 } |
| 212 endTest(); | 212 endTest(); |
| 213 } | 213 } |
| 214 | 214 |
| 215 function startTest(checks) | 215 function startTest(checks) |
| 216 { | 216 { |
| 217 if (hasPauseAnimationAPI) | 217 if (hasPauseAnimationAPI) |
| 218 runChecksWithPauseAPI(checks); | 218 runChecksWithPauseAPI(checks); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 229 var animStartTime; | 229 var animStartTime; |
| 230 var isTransitionsTest = false; | 230 var isTransitionsTest = false; |
| 231 | 231 |
| 232 function log(message) | 232 function log(message) |
| 233 { | 233 { |
| 234 logMessages.push(performance.now() + ' - ' + message); | 234 logMessages.push(performance.now() + ' - ' + message); |
| 235 } | 235 } |
| 236 | 236 |
| 237 function waitForAnimationsToStart(callback) | 237 function waitForAnimationsToStart(callback) |
| 238 { | 238 { |
| 239 if (document.timeline.getAnimationPlayers().length > 0) { | 239 if (document.timeline.getAnimations().length > 0) { |
| 240 callback(); | 240 callback(); |
| 241 } else { | 241 } else { |
| 242 setTimeout(waitForAnimationsToStart.bind(this, callback), 0); | 242 setTimeout(waitForAnimationsToStart.bind(this, callback), 0); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 // FIXME: disablePauseAnimationAPI and doPixelTest | 246 // FIXME: disablePauseAnimationAPI and doPixelTest |
| 247 function runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI
, doPixelTest, startTestImmediately) | 247 function runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI
, doPixelTest, startTestImmediately) |
| 248 { | 248 { |
| 249 log('runAnimationTest'); | 249 log('runAnimationTest'); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 var target = isTransitionsTest ? window : document; | 308 var target = isTransitionsTest ? window : document; |
| 309 var event = isTransitionsTest ? 'load' : 'webkitAnimationStart'; | 309 var event = isTransitionsTest ? 'load' : 'webkitAnimationStart'; |
| 310 target.addEventListener(event, begin, false); | 310 target.addEventListener(event, begin, false); |
| 311 } | 311 } |
| 312 } | 312 } |
| 313 | 313 |
| 314 function runTransitionTest(expected, trigger, callbacks, doPixelTest, disablePau
seAnimationAPI) { | 314 function runTransitionTest(expected, trigger, callbacks, doPixelTest, disablePau
seAnimationAPI) { |
| 315 isTransitionsTest = true; | 315 isTransitionsTest = true; |
| 316 runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI, doP
ixelTest); | 316 runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI, doP
ixelTest); |
| 317 } | 317 } |
| OLD | NEW |