| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2015 Google Inc. All rights reserved. | 2 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 target.style.animationTimingFunction = createEasing(at); | 95 target.style.animationTimingFunction = createEasing(at); |
| 96 }, | 96 }, |
| 97 rebaseline: false, | 97 rebaseline: false, |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 var cssTransitionsInterpolation = { | 100 var cssTransitionsInterpolation = { |
| 101 name: 'CSS Transitions', | 101 name: 'CSS Transitions', |
| 102 supportsProperty: function() {return true;}, | 102 supportsProperty: function() {return true;}, |
| 103 supportsValue: function() {return true;}, | 103 supportsValue: function() {return true;}, |
| 104 setup: function(property, from, target) { | 104 setup: function(property, from, target) { |
| 105 target.style[property] = isNeutralKeyframe(from) ? '' : from; | 105 target.style.setProperty(property, isNeutralKeyframe(from) ? '' : from); |
| 106 }, | 106 }, |
| 107 nonInterpolationExpectations: function(from, to) { | 107 nonInterpolationExpectations: function(from, to) { |
| 108 return expectFlip(from, to, -Infinity); | 108 return expectFlip(from, to, -Infinity); |
| 109 }, | 109 }, |
| 110 interpolate: function(property, from, to, at, target) { | 110 interpolate: function(property, from, to, at, target) { |
| 111 target.style.transitionDuration = '2e10s'; | 111 target.style.transitionDuration = '2e10s'; |
| 112 target.style.transitionDelay = '-1e10s'; | 112 target.style.transitionDelay = '-1e10s'; |
| 113 target.style.transitionTimingFunction = createEasing(at); | 113 target.style.transitionTimingFunction = createEasing(at); |
| 114 target.style.transitionProperty = property; | 114 target.style.transitionProperty = property; |
| 115 target.style[property] = isNeutralKeyframe(to) ? '' : to; | 115 target.style.setProperty(property, isNeutralKeyframe(to) ? '' : to); |
| 116 }, | 116 }, |
| 117 rebaseline: false, | 117 rebaseline: false, |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 var webAnimationsInterpolation = { | 120 var webAnimationsInterpolation = { |
| 121 name: 'Web Animations', | 121 name: 'Web Animations', |
| 122 supportsProperty: function(property) {return property.indexOf('-webkit-') !=
= 0;}, | 122 supportsProperty: function(property) {return property.indexOf('-webkit-') !=
= 0;}, |
| 123 supportsValue: function(value) {return value !== '';}, | 123 supportsValue: function(value) {return value !== '';}, |
| 124 setup: function() {}, | 124 setup: function() {}, |
| 125 nonInterpolationExpectations: function(from, to) { | 125 nonInterpolationExpectations: function(from, to) { |
| 126 return expectFlip(from, to, 0.5); | 126 return expectFlip(from, to, 0.5); |
| 127 }, | 127 }, |
| 128 interpolate: function(property, from, to, at, target) { | 128 interpolate: function(property, from, to, at, target) { |
| 129 this.interpolateComposite(property, from, 'replace', to, 'replace', at, ta
rget); | 129 this.interpolateComposite(property, from, 'replace', to, 'replace', at, ta
rget); |
| 130 }, | 130 }, |
| 131 interpolateComposite: function(property, from, fromComposite, to, toComposit
e, at, target) { | 131 interpolateComposite: function(property, from, fromComposite, to, toComposit
e, at, target) { |
| 132 // Convert to camelCase | 132 // Convert standard properties to camelCase. |
| 133 for (var i = property.length - 2; i > 0; --i) { | 133 if (!property.startsWith('--')) { |
| 134 if (property[i] === '-') { | 134 for (var i = property.length - 2; i > 0; --i) { |
| 135 property = property.substring(0, i) + property[i + 1].toUpperCase() +
property.substring(i + 2); | 135 if (property[i] === '-') { |
| 136 property = property.substring(0, i) + property[i + 1].toUpperCase()
+ property.substring(i + 2); |
| 137 } |
| 136 } | 138 } |
| 137 } | 139 } |
| 138 var keyframes = []; | 140 var keyframes = []; |
| 139 if (!isNeutralKeyframe(from)) { | 141 if (!isNeutralKeyframe(from)) { |
| 140 keyframes.push({ | 142 keyframes.push({ |
| 141 offset: 0, | 143 offset: 0, |
| 142 composite: fromComposite, | 144 composite: fromComposite, |
| 143 [property]: from, | 145 [property]: from, |
| 144 }); | 146 }); |
| 145 } | 147 } |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 var testText = `${interpolationMethod.name}: property <${property}> from ${k
eyframeText(from)} to ${keyframeText(to)}`; | 307 var testText = `${interpolationMethod.name}: property <${property}> from ${k
eyframeText(from)} to ${keyframeText(to)}`; |
| 306 var testContainer = createElement(interpolationMethodContainer, 'div', testT
ext); | 308 var testContainer = createElement(interpolationMethodContainer, 'div', testT
ext); |
| 307 createElement(testContainer, 'br'); | 309 createElement(testContainer, 'br'); |
| 308 var expectations = interpolationTest.expectations; | 310 var expectations = interpolationTest.expectations; |
| 309 if (expectations === expectNoInterpolation) { | 311 if (expectations === expectNoInterpolation) { |
| 310 expectations = interpolationMethod.nonInterpolationExpectations(from, to); | 312 expectations = interpolationMethod.nonInterpolationExpectations(from, to); |
| 311 } | 313 } |
| 312 return expectations.map(function(expectation) { | 314 return expectations.map(function(expectation) { |
| 313 var actualTargetContainer = createTargetContainer(testContainer, 'actual')
; | 315 var actualTargetContainer = createTargetContainer(testContainer, 'actual')
; |
| 314 var expectedTargetContainer = createTargetContainer(testContainer, 'expect
ed'); | 316 var expectedTargetContainer = createTargetContainer(testContainer, 'expect
ed'); |
| 315 expectedTargetContainer.target.style[property] = expectation.is; | 317 expectedTargetContainer.target.style.setProperty(property, expectation.is)
; |
| 316 var target = actualTargetContainer.target; | 318 var target = actualTargetContainer.target; |
| 317 interpolationMethod.setup(property, from, target); | 319 interpolationMethod.setup(property, from, target); |
| 318 target.interpolate = function() { | 320 target.interpolate = function() { |
| 319 interpolationMethod.interpolate(property, from, to, expectation.at, targ
et); | 321 interpolationMethod.interpolate(property, from, to, expectation.at, targ
et); |
| 320 }; | 322 }; |
| 321 target.measure = function() { | 323 target.measure = function() { |
| 322 var actualValue = getComputedStyle(target)[property]; | 324 var actualValue = getComputedStyle(target).getPropertyValue(property); |
| 323 test(function() { | 325 test(function() { |
| 324 assert_equals( | 326 assert_equals( |
| 325 normalizeValue(actualValue), | 327 normalizeValue(actualValue), |
| 326 normalizeValue(getComputedStyle(expectedTargetContainer.target)[prop
erty])); | 328 normalizeValue(getComputedStyle(expectedTargetContainer.target).getP
ropertyValue(property))); |
| 327 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}]
`); | 329 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}]
`); |
| 328 if (rebaselineExpectation) { | 330 if (rebaselineExpectation) { |
| 329 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: '$
{actualValue}'},\n`; | 331 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: '$
{actualValue}'},\n`; |
| 330 } | 332 } |
| 331 }; | 333 }; |
| 332 return target; | 334 return target; |
| 333 }); | 335 }); |
| 334 } | 336 } |
| 335 | 337 |
| 336 function createCompositionTestTargets(compositionContainer, compositionTest, r
ebaselineContainer) { | 338 function createCompositionTestTargets(compositionContainer, compositionTest, r
ebaselineContainer) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 362 var rebaselineExpectation; | 364 var rebaselineExpectation; |
| 363 rebaseline.appendChild(rebaselineExpectation = document.createTextNode('')
); | 365 rebaseline.appendChild(rebaselineExpectation = document.createTextNode('')
); |
| 364 rebaseline.appendChild(document.createTextNode(']);\n\n')); | 366 rebaseline.appendChild(document.createTextNode(']);\n\n')); |
| 365 } | 367 } |
| 366 var testText = `Compositing: property <${property}> underlying [${underlying
}] from ${fromComposite} [${from}] to ${toComposite} [${to}]`; | 368 var testText = `Compositing: property <${property}> underlying [${underlying
}] from ${fromComposite} [${from}] to ${toComposite} [${to}]`; |
| 367 var testContainer = createElement(compositionContainer, 'div', testText); | 369 var testContainer = createElement(compositionContainer, 'div', testText); |
| 368 createElement(testContainer, 'br'); | 370 createElement(testContainer, 'br'); |
| 369 return compositionTest.expectations.map(function(expectation) { | 371 return compositionTest.expectations.map(function(expectation) { |
| 370 var actualTargetContainer = createTargetContainer(testContainer, 'actual')
; | 372 var actualTargetContainer = createTargetContainer(testContainer, 'actual')
; |
| 371 var expectedTargetContainer = createTargetContainer(testContainer, 'expect
ed'); | 373 var expectedTargetContainer = createTargetContainer(testContainer, 'expect
ed'); |
| 372 expectedTargetContainer.target.style[property] = expectation.is; | 374 expectedTargetContainer.target.style.setProperty(property, expectation.is)
; |
| 373 var target = actualTargetContainer.target; | 375 var target = actualTargetContainer.target; |
| 374 target.style[property] = underlying; | 376 target.style.setProperty(property, underlying); |
| 375 target.interpolate = function() { | 377 target.interpolate = function() { |
| 376 webAnimationsInterpolation.interpolateComposite(property, from, fromComp
osite, to, toComposite, expectation.at, target); | 378 webAnimationsInterpolation.interpolateComposite(property, from, fromComp
osite, to, toComposite, expectation.at, target); |
| 377 }; | 379 }; |
| 378 target.measure = function() { | 380 target.measure = function() { |
| 379 var actualValue = getComputedStyle(target)[property]; | 381 var actualValue = getComputedStyle(target).getPropertyValue(property); |
| 380 test(function() { | 382 test(function() { |
| 381 assert_equals( | 383 assert_equals( |
| 382 normalizeValue(actualValue), | 384 normalizeValue(actualValue), |
| 383 normalizeValue(getComputedStyle(expectedTargetContainer.target)[prop
erty])); | 385 normalizeValue(getComputedStyle(expectedTargetContainer.target).getP
ropertyValue(property))); |
| 384 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}]
`); | 386 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}]
`); |
| 385 if (rebaselineExpectation) { | 387 if (rebaselineExpectation) { |
| 386 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: '$
{actualValue}'},\n`; | 388 rebaselineExpectation.textContent += ` {at: ${expectation.at}, is: '$
{actualValue}'},\n`; |
| 387 } | 389 } |
| 388 }; | 390 }; |
| 389 return target; | 391 return target; |
| 390 }); | 392 }); |
| 391 } | 393 } |
| 392 | 394 |
| 393 function validateTestInputs(property, from, to, underlying) { | 395 function validateTestInputs(property, from, to, underlying) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 asyncHandle.done() | 466 asyncHandle.done() |
| 465 }); | 467 }); |
| 466 }); | 468 }); |
| 467 | 469 |
| 468 window.assertInterpolation = assertInterpolation; | 470 window.assertInterpolation = assertInterpolation; |
| 469 window.assertNoInterpolation = assertNoInterpolation; | 471 window.assertNoInterpolation = assertNoInterpolation; |
| 470 window.assertComposition = assertComposition; | 472 window.assertComposition = assertComposition; |
| 471 window.afterTest = afterTest; | 473 window.afterTest = afterTest; |
| 472 window.neutralKeyframe = neutralKeyframe; | 474 window.neutralKeyframe = neutralKeyframe; |
| 473 })(); | 475 })(); |
| OLD | NEW |