8 assertIterationTime('1s linear', [
19 assertIterationTime('1s none', [
24 assertIterationTime('1s both', [
29 assertIterationTime('1s forwards', [
34 assertIterationTime('1s backwards', [
40 log('\nFill-mode + reverse direction:');
41 assertIterationTime('1s none reverse', [
46 assertIterationTime('1s both reverse', [
51 assertIterationTime('1s forwards reverse', [
56 assertIterationTime('1s backwards reverse', [
62 log('\nEnd exclusive timing:')
63 assertIterationTime('1s', [
68 log('\nZero duration:')
69 assertIterationTime('none', [
75 assertIterationTime('both', [
81 assertIterationTime('forwards', [
87 assertIterationTime('backwards', [
94 log('\nZero duration + reverse direction:')
95 assertIterationTime('none reverse', [
101 assertIterationTime('both reverse', [
107 assertIterationTime('forwards reverse', [
113 assertIterationTime('backwards reverse', [
120 log('\nZero iterations:')
121 assertIterationTime('1s 0s 0 none', [
128 assertIterationTime('1s 0s 0 both', [
134 assertIterationTime('1s 0s 0 forwards', [
140 assertIterationTime('1s 0s 0 backwards', [
147 log('\nZero iterations, zero duration:')
148 assertIterationTime('0s 0s 0 none', [
154 assertIterationTime('0s 0s 0 both', [
160 assertIterationTime('0s 0s 0 forwards', [
166 assertIterationTime('0s 0s 0 backwards', [
173 log('\nMultiple iterations:')
174 assertIterationTime('1s 2 linear', [
183 assertIterationTime('1s 2 linear reverse', [
190 assertIterationTime('1s 2 linear alternate', [
197 assertIterationTime('1s 2 linear alternate-reverse', [
205 log('\nFractional iterations:')
206 assertIterationTime('1s 0.5 linear', [
213 assertIterationTime('1s 1.5 linear', [
222 assertIterationTime('1s 1.5 linear reverse', [
231 assertIterationTime('1s 1.6 linear forwards', [
235 assertIterationTime('1s 1.6 linear forwards reverse ', [
239 assertIterationTime('1s 0.6 linear backwards reverse', [
244 log('\nInfinite iterations:')
245 assertIterationTime('1s infinite linear', [
249 {is
: 0.4, at
: 1000.4},
253 log('\nInfinite iterations, zero duration:')
254 assertIterationTime('0s infinite linear', [
262 if (window
.testRunner
) {
263 testRunner
.dumpAsText();
266 var testElement
= document
.createElement('div');
267 document
.body
.appendChild(testElement
);
268 testElement
.style
.left
= 'auto';
271 document
.body
.offsetTop
;
273 function log(message
, klass
) {
277 child
= document
.createElement('span');
278 child
.classList
.add(klass
);
279 child
.textContent
= message
;
281 child
= document
.createTextNode(message
);
283 document
.body
.appendChild(child
);
286 var prefix
= 'animation' in document
.body
.style
? '' : '-webkit-';
287 function assertIterationTime(animation
, expectations
) {
288 testElement
.style
.setProperty(prefix
+ 'animation', 'invalid ' + animation
);
291 expectations
.forEach(function(expectation
) {
292 if (expectation
.is
!== null && expectation
.is
!= Math
.round(expectation
.is
* 100) / 100) {
293 console
.log('ERROR: Test requires too much precision. ' + JSON
.stringify(expectation
));
296 testElement
.style
.setProperty(prefix
+ 'animation-name', 'invalid');
299 var delay
= expectation
.at
* -1;
300 testElement
.style
.setProperty(prefix
+ 'animation-delay', delay
+ 's');
301 testElement
.style
.setProperty(prefix
+ 'animation-name', 'test');
303 // FIXME: Set play-state: paused before starting the animation.
304 // For now, updating the style another two times makes this work in WebKit/Blink
305 testElement
.style
.setProperty(prefix
+ 'animation-name', 'test');
307 testElement
.style
.setProperty(prefix
+ 'animation-name', 'test');
310 var result
= getComputedStyle(testElement
).left
;
311 if (result
=== 'auto') {
314 result
= Math
.round(Number(result
.replace(/px$/, '')) * 100) / 100;
316 if (result
=== expectation
.is
) {
317 log('PASS: [' + animation
+ '] iteration time was [' + expectation
.is
+ '] at ' + expectation
.at
+ 's');
319 log('FAIL: [' + animation
+ '] iteration time was [' + result
+ '] at ' + expectation
.at
+ 's' + ' expected [' + expectation
.is
+ ']', 'fail');
327 font-family: monospace;
333 @-webkit-keyframes test {