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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 205 |
206 if (finished) | 206 if (finished) |
207 endTest(); | 207 endTest(); |
208 else | 208 else |
209 requestAnimationFrame(runChecksWithRAF.bind(null, checks)); | 209 requestAnimationFrame(runChecksWithRAF.bind(null, checks)); |
210 } | 210 } |
211 | 211 |
212 function runChecksWithPauseAPI(checks) { | 212 function runChecksWithPauseAPI(checks) { |
213 for (var k in checks) { | 213 for (var k in checks) { |
214 var timeMs = Number(k); | 214 var timeMs = Number(k); |
215 log('Pausing at time: ' + timeMs + ', current animations: ' + document.t
imeline.getAnimations().length); | 215 log('Pausing at time: ' + timeMs + ', current animations: ' + document.g
etAnimations().length); |
216 internals.pauseAnimations(timeMs / 1000); | 216 internals.pauseAnimations(timeMs / 1000); |
217 checks[k].forEach(function(check) { check(); }); | 217 checks[k].forEach(function(check) { check(); }); |
218 } | 218 } |
219 endTest(); | 219 endTest(); |
220 } | 220 } |
221 | 221 |
222 function startTest(checks) | 222 function startTest(checks) |
223 { | 223 { |
224 if (hasPauseAnimationAPI) | 224 if (hasPauseAnimationAPI) |
225 runChecksWithPauseAPI(checks); | 225 runChecksWithPauseAPI(checks); |
(...skipping 10 matching lines...) Expand all Loading... |
236 var animStartTime; | 236 var animStartTime; |
237 var isTransitionsTest = false; | 237 var isTransitionsTest = false; |
238 | 238 |
239 function log(message) | 239 function log(message) |
240 { | 240 { |
241 logMessages.push(performance.now() + ' - ' + message); | 241 logMessages.push(performance.now() + ' - ' + message); |
242 } | 242 } |
243 | 243 |
244 function waitForAnimationsToStart(callback) | 244 function waitForAnimationsToStart(callback) |
245 { | 245 { |
246 if (document.timeline.getAnimations().length > 0) { | 246 if (document.getAnimations().length > 0) { |
247 callback(); | 247 callback(); |
248 } else { | 248 } else { |
249 setTimeout(waitForAnimationsToStart.bind(this, callback), 0); | 249 setTimeout(waitForAnimationsToStart.bind(this, callback), 0); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 // FIXME: disablePauseAnimationAPI and doPixelTest | 253 // FIXME: disablePauseAnimationAPI and doPixelTest |
254 function runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI
, doPixelTest, startTestImmediately) | 254 function runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI
, doPixelTest, startTestImmediately) |
255 { | 255 { |
256 log('runAnimationTest'); | 256 log('runAnimationTest'); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 var target = isTransitionsTest ? window : document; | 315 var target = isTransitionsTest ? window : document; |
316 var event = isTransitionsTest ? 'load' : 'webkitAnimationStart'; | 316 var event = isTransitionsTest ? 'load' : 'webkitAnimationStart'; |
317 target.addEventListener(event, begin, false); | 317 target.addEventListener(event, begin, false); |
318 } | 318 } |
319 } | 319 } |
320 | 320 |
321 function runTransitionTest(expected, trigger, callbacks, doPixelTest, disablePau
seAnimationAPI) { | 321 function runTransitionTest(expected, trigger, callbacks, doPixelTest, disablePau
seAnimationAPI) { |
322 isTransitionsTest = true; | 322 isTransitionsTest = true; |
323 runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI, doP
ixelTest); | 323 runAnimationTest(expected, callbacks, trigger, disablePauseAnimationAPI, doP
ixelTest); |
324 } | 324 } |
OLD | NEW |