| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 var fragment = document.createDocumentFragment(); | 72 var fragment = document.createDocumentFragment(); |
| 73 var fragmentAttachedListeners = []; | 73 var fragmentAttachedListeners = []; |
| 74 var style = document.createElement('style'); | 74 var style = document.createElement('style'); |
| 75 var cssTests = document.createElement('div'); | 75 var cssTests = document.createElement('div'); |
| 76 cssTests.id = 'css-tests'; | 76 cssTests.id = 'css-tests'; |
| 77 cssTests.textContent = 'CSS Animations:'; | 77 cssTests.textContent = 'CSS Animations:'; |
| 78 var afterTestCallback = null; | 78 var afterTestCallback = null; |
| 79 fragment.appendChild(style); | 79 fragment.appendChild(style); |
| 80 fragment.appendChild(cssTests); | 80 fragment.appendChild(cssTests); |
| 81 | 81 |
| 82 if (webAnimationsTest) { | 82 var waTestsDiv = null; |
| 83 var waTests = document.createElement('div'); | 83 function waTests() { |
| 84 waTests.id = 'web-animations-tests'; | 84 if (!waTestsDiv) { |
| 85 waTests.textContent = 'Web Animations API:'; | 85 waTestsDiv = document.createElement('div'); |
| 86 fragment.appendChild(waTests); | 86 waTestsDiv.id = 'web-animations-tests'; |
| 87 waTestsDiv.textContent = 'Web Animations API:'; |
| 88 fragment.appendChild(waTestsDiv); |
| 89 } |
| 90 return waTestsDiv; |
| 87 } | 91 } |
| 88 | 92 |
| 89 var updateScheduled = false; | 93 var updateScheduled = false; |
| 90 function maybeScheduleUpdate() { | 94 function maybeScheduleUpdate() { |
| 91 if (updateScheduled) { | 95 if (updateScheduled) { |
| 92 return; | 96 return; |
| 93 } | 97 } |
| 94 updateScheduled = true; | 98 updateScheduled = true; |
| 95 setTimeout(function() { | 99 setTimeout(function() { |
| 96 updateScheduled = false; | 100 updateScheduled = false; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 113 var cssResultString = 'CSS Animations:\n'; | 117 var cssResultString = 'CSS Animations:\n'; |
| 114 var waResultString = 'Web Animations API:\n'; | 118 var waResultString = 'Web Animations API:\n'; |
| 115 for (var i = 0; i < targets.length; i++) { | 119 for (var i = 0; i < targets.length; i++) { |
| 116 if (targets[i].testType === 'css') { | 120 if (targets[i].testType === 'css') { |
| 117 cssResultString += targets[i].getResultString() + '\n'; | 121 cssResultString += targets[i].getResultString() + '\n'; |
| 118 } else { | 122 } else { |
| 119 waResultString += targets[i].getResultString() + '\n'; | 123 waResultString += targets[i].getResultString() + '\n'; |
| 120 } | 124 } |
| 121 } | 125 } |
| 122 var results = document.createElement('pre'); | 126 var results = document.createElement('pre'); |
| 123 results.textContent = cssResultString + (webAnimationsTest ? '\n' + waResu
ltString : ''); | 127 results.textContent = cssResultString + (waTestsDiv ? '\n' + waResultStrin
g : ''); |
| 124 results.id = 'results'; | 128 results.id = 'results'; |
| 125 document.body.appendChild(results); | 129 document.body.appendChild(results); |
| 126 } | 130 } |
| 127 } | 131 } |
| 128 | 132 |
| 129 function convertToReference() { | 133 function convertToReference() { |
| 130 console.assert(isRefTest); | 134 console.assert(isRefTest); |
| 131 var scripts = document.querySelectorAll('script'); | 135 var scripts = document.querySelectorAll('script'); |
| 132 for (var i = 0; i < scripts.length; i++) { | 136 for (var i = 0; i < scripts.length; i++) { |
| 133 scripts[i].parentNode.removeChild(scripts[i]); | 137 scripts[i].parentNode.removeChild(scripts[i]); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 198 |
| 195 function describeWATest(params) { | 199 function describeWATest(params) { |
| 196 return 'element.animate() ' + convertPropertyToCamelCase(params.property) +
': from [' + params.from + '] to [' + params.to + ']'; | 200 return 'element.animate() ' + convertPropertyToCamelCase(params.property) +
': from [' + params.from + '] to [' + params.to + ']'; |
| 197 } | 201 } |
| 198 | 202 |
| 199 function assertInterpolation(params, expectations) { | 203 function assertInterpolation(params, expectations) { |
| 200 var testId = defineKeyframes(params); | 204 var testId = defineKeyframes(params); |
| 201 var nextCaseId = 0; | 205 var nextCaseId = 0; |
| 202 var cssTestContainer = createTestContainer(describeCSSTest(params), testId); | 206 var cssTestContainer = createTestContainer(describeCSSTest(params), testId); |
| 203 cssTests.appendChild(cssTestContainer); | 207 cssTests.appendChild(cssTestContainer); |
| 204 if (webAnimationsTest) { | |
| 205 var waTestContainer = createTestContainer(describeWATest(params), testId); | |
| 206 waTests.appendChild(waTestContainer); | |
| 207 } | |
| 208 expectations.forEach(function(expectation) { | 208 expectations.forEach(function(expectation) { |
| 209 cssTestContainer.appendChild(makeInterpolationTest( | 209 cssTestContainer.appendChild(makeInterpolationTest( |
| 210 'css', expectation.at, testId, 'case-' + ++nextCaseId, params, expecta
tion.is)); | 210 'css', expectation.at, testId, 'case-' + ++nextCaseId, params, expecta
tion.is)); |
| 211 }); | 211 }); |
| 212 if (webAnimationsTest) { | 212 // We don't support prefixed properties in Web Animations |
| 213 if (webAnimationsTest && params.property[0] != '-') { |
| 214 var waTestContainer = createTestContainer(describeWATest(params), testId); |
| 215 waTests().appendChild(waTestContainer); |
| 213 expectations.forEach(function(expectation) { | 216 expectations.forEach(function(expectation) { |
| 214 waTestContainer.appendChild(makeInterpolationTest( | 217 waTestContainer.appendChild(makeInterpolationTest( |
| 215 'web-animations', expectation.at, testId, 'case-' + ++nextCaseId, pa
rams, expectation.is)); | 218 'web-animations', expectation.at, testId, 'case-' + ++nextCaseId, pa
rams, expectation.is)); |
| 216 }); | 219 }); |
| 217 } | 220 } |
| 218 maybeScheduleUpdate(); | 221 maybeScheduleUpdate(); |
| 219 } | 222 } |
| 220 | 223 |
| 221 var nextKeyframeId = 0; | 224 var nextKeyframeId = 0; |
| 222 function defineKeyframes(params) { | 225 function defineKeyframes(params) { |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 if (!window.testRunner) { | 411 if (!window.testRunner) { |
| 409 setTimeout(function() { | 412 setTimeout(function() { |
| 410 if (finished) { | 413 if (finished) { |
| 411 return; | 414 return; |
| 412 } | 415 } |
| 413 finishTest(); | 416 finishTest(); |
| 414 }, 10000); | 417 }, 10000); |
| 415 } | 418 } |
| 416 | 419 |
| 417 function disableWebAnimationsTest() { | 420 function disableWebAnimationsTest() { |
| 418 if (webAnimationsTest) { | 421 webAnimationsTest = false; |
| 419 fragment.querySelector('#web-animations-tests').remove(); | |
| 420 webAnimationsTest = false; | |
| 421 } | |
| 422 } | 422 } |
| 423 | 423 |
| 424 window.runAsRefTest = runAsRefTest; | 424 window.runAsRefTest = runAsRefTest; |
| 425 window.testInterpolationAt = testInterpolationAt; | 425 window.testInterpolationAt = testInterpolationAt; |
| 426 window.assertInterpolation = assertInterpolation; | 426 window.assertInterpolation = assertInterpolation; |
| 427 window.convertToReference = convertToReference; | 427 window.convertToReference = convertToReference; |
| 428 window.afterTest = afterTest; | 428 window.afterTest = afterTest; |
| 429 window.disableWebAnimationsTest = disableWebAnimationsTest; | 429 window.disableWebAnimationsTest = disableWebAnimationsTest; |
| 430 })(); | 430 })(); |
| OLD | NEW |