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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 function loadScript(url) { | 178 function loadScript(url) { |
179 return new Promise(function(resolve) { | 179 return new Promise(function(resolve) { |
180 var script = document.createElement('script'); | 180 var script = document.createElement('script'); |
181 script.src = url; | 181 script.src = url; |
182 script.onload = resolve; | 182 script.onload = resolve; |
183 document.head.appendChild(script); | 183 document.head.appendChild(script); |
184 }); | 184 }); |
185 } | 185 } |
186 | 186 |
| 187 function toCamelCase(property) { |
| 188 var i = property.length; |
| 189 while ((i = property.lastIndexOf('-', i - 1)) !== -1) { |
| 190 property = property.substring(0, i) + property[i + 1].toUpperCase() + prop
erty.substring(i + 2); |
| 191 } |
| 192 return property; |
| 193 } |
| 194 |
187 function createTargetContainer(parent, className) { | 195 function createTargetContainer(parent, className) { |
188 var targetContainer = createElement(parent); | 196 var targetContainer = createElement(parent); |
189 targetContainer.classList.add('container'); | 197 targetContainer.classList.add('container'); |
190 var template = document.querySelector('#target-template'); | 198 var template = document.querySelector('#target-template'); |
191 if (template) { | 199 if (template) { |
192 targetContainer.appendChild(template.content.cloneNode(true)); | 200 targetContainer.appendChild(template.content.cloneNode(true)); |
193 } | 201 } |
194 var target = targetContainer.querySelector('.target') || targetContainer; | 202 var target = targetContainer.querySelector('.target') || targetContainer; |
195 target.classList.add('target', className); | 203 target.classList.add('target', className); |
196 target.parentElement.classList.add('parent'); | 204 target.parentElement.classList.add('parent'); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 return compositionTest.expectations.map(function(expectation) { | 340 return compositionTest.expectations.map(function(expectation) { |
333 var actualTargetContainer = createTargetContainer(testContainer, 'actual')
; | 341 var actualTargetContainer = createTargetContainer(testContainer, 'actual')
; |
334 var expectedTargetContainer = createTargetContainer(testContainer, 'expect
ed'); | 342 var expectedTargetContainer = createTargetContainer(testContainer, 'expect
ed'); |
335 expectedTargetContainer.target.style[property] = expectation.is; | 343 expectedTargetContainer.target.style[property] = expectation.is; |
336 var target = actualTargetContainer.target; | 344 var target = actualTargetContainer.target; |
337 target.style[property] = underlying; | 345 target.style[property] = underlying; |
338 target.interpolate = function() { | 346 target.interpolate = function() { |
339 webAnimationsInterpolation.interpolateKeyframes([{ | 347 webAnimationsInterpolation.interpolateKeyframes([{ |
340 offset: 0, | 348 offset: 0, |
341 composite: fromComposite, | 349 composite: fromComposite, |
342 [property]: from, | 350 [toCamelCase(property)]: from, |
343 }, { | 351 }, { |
344 offset: 1, | 352 offset: 1, |
345 composite: toComposite, | 353 composite: toComposite, |
346 [property]: to, | 354 [toCamelCase(property)]: to, |
347 }], expectation.at, target); | 355 }], expectation.at, target); |
348 }; | 356 }; |
349 target.measure = function() { | 357 target.measure = function() { |
350 var actualValue = getComputedStyle(target)[property]; | 358 var actualValue = getComputedStyle(target)[property]; |
351 test(function() { | 359 test(function() { |
352 assert_equals( | 360 assert_equals( |
353 normalizeValue(actualValue), | 361 normalizeValue(actualValue), |
354 normalizeValue(getComputedStyle(expectedTargetContainer.target)[prop
erty])); | 362 normalizeValue(getComputedStyle(expectedTargetContainer.target)[prop
erty])); |
355 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}]
`); | 363 }, `${testText} at (${expectation.at}) is [${sanitizeUrls(actualValue)}]
`); |
356 if (rebaselineExpectation) { | 364 if (rebaselineExpectation) { |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 loadScript('../../resources/testharness.js').then(function() { | 421 loadScript('../../resources/testharness.js').then(function() { |
414 return loadScript('../../resources/testharnessreport.js'); | 422 return loadScript('../../resources/testharnessreport.js'); |
415 }).then(function() { | 423 }).then(function() { |
416 var asyncHandle = async_test('This test uses interpolation-test.js.') | 424 var asyncHandle = async_test('This test uses interpolation-test.js.') |
417 requestAnimationFrame(function() { | 425 requestAnimationFrame(function() { |
418 runTests(); | 426 runTests(); |
419 asyncHandle.done() | 427 asyncHandle.done() |
420 }); | 428 }); |
421 }); | 429 }); |
422 })(); | 430 })(); |
OLD | NEW |