Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* This is the helper function to run animation tests: | 1 /* This is the helper function to run 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 Function parameters: | 7 Function 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 callback [optional]: a function to be executed just before the test starts ( none by default) | 9 callback [optional]: a function to be executed just before the test starts ( none by default) |
| 10 event [optional]: which DOM event to wait for before starting the test ("web kitAnimationStart" by default) | 10 event [optional]: which DOM event to wait for before starting the test ("web kitAnimationStart" by default) |
| 11 | 11 |
| 12 Each sub-array must contain these items in this order: | 12 Each sub-array must contain these items in this order: |
| 13 - the name of the CSS animation (may be null) [1] | 13 - the name of the CSS animation (may be null) [1] |
| 14 - the time in seconds at which to snapshot the CSS property | 14 - the time in seconds at which to snapshot the CSS property |
| 15 - the id of the element on which to get the CSS property value [2] | 15 - the id of the element on which to get the CSS property value [2] |
| 16 - the name of the CSS property to get [3] | 16 - the name of the CSS property to get [3] |
| 17 - the expected value for the CSS property | 17 - the expected value for the CSS property |
| 18 - the tolerance to use when comparing the effective CSS property value with its expected value | 18 - the tolerance to use when comparing the effective CSS property value with its expected value |
| 19 | 19 |
| 20 [1] If null is passed, a regular setTimeout() will be used instead to snapsh ot the animated property in the future, | 20 [1] If null is passed, a regular setTimeout() will be used instead to snapsh ot the animated property in the future, |
| 21 instead of fast forwarding using the pauseAnimationAtTimeOnElement() JS API from Internals. | 21 instead of fast forwarding using the pauseAnimations() JS API from Internals . |
|
Steve Block
2013/05/06 01:49:06
It looks like the animation name is still used to
dstockwell
2013/05/06 04:01:00
Not passing a name no longer falls back to the set
| |
| 22 | 22 |
| 23 [2] If a single string is passed, it is the id of the element to test. If an array with 2 elements is passed they | 23 [2] If a single string is passed, it is the id of the element to test. If an array with 2 elements is passed they |
| 24 are the ids of 2 elements, whose values are compared for equality. In this c ase the expected value is ignored | 24 are the ids of 2 elements, whose values are compared for equality. In this c ase the expected value is ignored |
| 25 but the tolerance is used in the comparison. If the second element is prefix ed with "static:", no animation on that | 25 but the tolerance is used in the comparison. If the second element is prefix ed with "static:", no animation on that |
| 26 element is required, allowing comparison with an unanimated "expected value" element. | 26 element is required, allowing comparison with an unanimated "expected value" element. |
| 27 | 27 |
| 28 If a string with a '.' is passed, this is an element in an iframe. The strin g before the dot is the iframe id | 28 If a string with a '.' is passed, this is an element in an iframe. The strin g before the dot is the iframe id |
| 29 and the string after the dot is the element name in that iframe. | 29 and the string after the dot is the element name in that iframe. |
| 30 | 30 |
| 31 [3] If the CSS property name is "webkitTransform", expected value must be an array of 1 or more numbers corresponding to the matrix elements, | 31 [3] If the CSS property name is "webkitTransform", expected value must be an array of 1 or more numbers corresponding to the matrix elements, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 // Check for a dot separated string | 233 // Check for a dot separated string |
| 234 var iframeId; | 234 var iframeId; |
| 235 if (!compareElements) { | 235 if (!compareElements) { |
| 236 var array = elementId.split('.'); | 236 var array = elementId.split('.'); |
| 237 if (array.length == 2) { | 237 if (array.length == 2) { |
| 238 iframeId = array[0]; | 238 iframeId = array[0]; |
| 239 elementId = array[1]; | 239 elementId = array[1]; |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 if (animationName && hasPauseAnimationAPI && !internals.pauseAnimationAtTime OnElement(animationName, time, document.getElementById(elementId))) { | 243 if (animationName && hasPauseAnimationAPI) |
| 244 result += "FAIL - animation \"" + animationName + "\" is not running" + "<br>"; | 244 internals.pauseAnimations(time); |
| 245 return; | |
| 246 } | |
| 247 | |
| 248 if (compareElements && !element2Static && animationName && hasPauseAnimation API && !internals.pauseAnimationAtTimeOnElement(animationName, time, document.ge tElementById(elementId2))) { | |
| 249 result += "FAIL - animation \"" + animationName + "\" is not running" + "<br>"; | |
| 250 return; | |
| 251 } | |
| 252 | 245 |
| 253 var computedValue, computedValue2; | 246 var computedValue, computedValue2; |
| 254 if (compareElements) { | 247 if (compareElements) { |
| 255 computedValue = getPropertyValue(property, elementId, iframeId); | 248 computedValue = getPropertyValue(property, elementId, iframeId); |
| 256 computedValue2 = getPropertyValue(property, elementId2, iframeId); | 249 computedValue2 = getPropertyValue(property, elementId2, iframeId); |
| 257 | 250 |
| 258 if (comparePropertyValue(property, computedValue, computedValue2, tolera nce)) | 251 if (comparePropertyValue(property, computedValue, computedValue2, tolera nce)) |
| 259 result += "PASS - \"" + property + "\" property for \"" + elementId + "\" and \"" + elementId2 + | 252 result += "PASS - \"" + property + "\" property for \"" + elementId + "\" and \"" + elementId2 + |
| 260 "\" elements at " + time + "s are close enough to ea ch other" + "<br>"; | 253 "\" elements at " + time + "s are close enough to ea ch other" + "<br>"; |
| 261 else | 254 else |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 379 { | 372 { |
| 380 if (testStarted) return; | 373 if (testStarted) return; |
| 381 testStarted = true; | 374 testStarted = true; |
| 382 | 375 |
| 383 if (callback) | 376 if (callback) |
| 384 callback(); | 377 callback(); |
| 385 | 378 |
| 386 var maxTime = 0; | 379 var maxTime = 0; |
| 387 | 380 |
| 388 for (var i = 0; i < expected.length; ++i) { | 381 for (var i = 0; i < expected.length; ++i) { |
| 389 var animationName = expected[i][0]; | |
| 390 var time = expected[i][1]; | 382 var time = expected[i][1]; |
| 391 | 383 |
| 392 // We can only use the animation fast-forward mechanism if there's an an imation name | 384 if (hasPauseAnimationAPI) |
| 393 // and Internals implements pauseAnimationAtTimeOnElement() | |
| 394 if (animationName && hasPauseAnimationAPI) | |
| 395 checkExpectedValue(expected, i); | 385 checkExpectedValue(expected, i); |
| 396 else { | 386 else { |
| 397 if (time > maxTime) | 387 if (time > maxTime) |
| 398 maxTime = time; | 388 maxTime = time; |
| 399 | 389 |
| 400 window.setTimeout(checkExpectedValueCallback(expected, i), time * 10 00); | 390 window.setTimeout(checkExpectedValueCallback(expected, i), time * 10 00); |
| 401 } | 391 } |
| 402 } | 392 } |
| 403 | 393 |
| 404 if (maxTime > 0) | 394 if (maxTime > 0) |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 433 startTest(expected, callback); | 423 startTest(expected, callback); |
| 434 }, false); | 424 }, false); |
| 435 } | 425 } |
| 436 | 426 |
| 437 function waitForAnimationToStart(element, callback) | 427 function waitForAnimationToStart(element, callback) |
| 438 { | 428 { |
| 439 element.addEventListener('webkitAnimationStart', function() { | 429 element.addEventListener('webkitAnimationStart', function() { |
| 440 window.setTimeout(callback, 0); // delay to give hardware animations a c hance to start | 430 window.setTimeout(callback, 0); // delay to give hardware animations a c hance to start |
| 441 }, false); | 431 }, false); |
| 442 } | 432 } |
| OLD | NEW |