Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317

This commit is contained in:
Josh Matthews 2018-01-04 13:44:24 -05:00
parent aa199307c8
commit 2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.cancel()</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-cancel">
<title>Animation.cancel</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-cancel">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
@ -10,11 +10,13 @@
<script>
'use strict';
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({transform: ['translate(100px)', 'translate(100px)']},
100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(
{ transform: ['translate(100px)', 'translate(100px)'] },
100 * MS_PER_SEC
);
return animation.ready.then(() => {
assert_not_equals(getComputedStyle(div).transform, 'none',
'transform style is animated before cancelling');
animation.cancel();
@ -23,10 +25,10 @@ promise_test(function(t) {
});
}, 'Animated style is cleared after calling Animation.cancel()');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({marginLeft: ['100px', '200px']},
100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate({ marginLeft: ['100px', '200px'] },
100 * MS_PER_SEC);
animation.effect.timing.easing = 'linear';
animation.cancel();
assert_equals(getComputedStyle(div).marginLeft, '0px',
@ -38,11 +40,11 @@ test(function(t) {
+ ' seeked');
}, 'After cancelling an animation, it can still be seeked');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({marginLeft:['100px', '200px']},
100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({ marginLeft:['100px', '200px'] },
100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.cancel();
assert_equals(getComputedStyle(div).marginLeft, '0px',
'margin-left style is not animated after cancelling');
@ -50,7 +52,7 @@ promise_test(function(t) {
assert_equals(getComputedStyle(div).marginLeft, '100px',
'margin-left style is animated after re-starting animation');
return animation.ready;
}).then(function() {
}).then(() => {
assert_equals(animation.playState, 'running',
'Animation succeeds in running after being re-started');
});

View file

@ -1,8 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation constructor tests</title>
<link rel="help" href="http://w3c.github.io/web-animations/#dom-animation-animation">
<link rel="author" title="Hiroyuki Ikezoe" href="mailto:hiikezoe@mozilla-japan.org">
<title>Animation constructor</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-animation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
@ -10,9 +9,9 @@
<div id="log"></div>
<div id="target"></div>
<script>
"use strict";
'use strict';
var gTarget = document.getElementById("target");
const gTarget = document.getElementById('target');
function createEffect() {
return new KeyframeEffectReadOnly(gTarget, { opacity: [0, 1] });
@ -22,94 +21,94 @@ function createNull() {
return null;
}
var gTestArguments = [
const gTestArguments = [
{
createEffect: createNull,
timeline: null,
expectedTimeline: null,
expectedTimelineDescription: "null",
description: "with null effect and null timeline"
expectedTimelineDescription: 'null',
description: 'with null effect and null timeline'
},
{
createEffect: createNull,
timeline: document.timeline,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with null effect and non-null timeline"
expectedTimelineDescription: 'document.timeline',
description: 'with null effect and non-null timeline'
},
{
createEffect: createNull,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with null effect and no timeline parameter"
expectedTimelineDescription: 'document.timeline',
description: 'with null effect and no timeline parameter'
},
{
createEffect: createEffect,
timeline: null,
expectedTimeline: null,
expectedTimelineDescription: "null",
description: "with non-null effect and null timeline"
expectedTimelineDescription: 'null',
description: 'with non-null effect and null timeline'
},
{
createEffect: createEffect,
timeline: document.timeline,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with non-null effect and non-null timeline"
expectedTimelineDescription: 'document.timeline',
description: 'with non-null effect and non-null timeline'
},
{
createEffect: createEffect,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with non-null effect and no timeline parameter"
expectedTimelineDescription: 'document.timeline',
description: 'with non-null effect and no timeline parameter'
},
];
gTestArguments.forEach(function(args) {
test(function(t) {
var effect = args.createEffect();
var animation = new Animation(effect, args.timeline);
for (const args of gTestArguments) {
test(t => {
const effect = args.createEffect();
const animation = new Animation(effect, args.timeline);
assert_not_equals(animation, null,
"An animation sohuld be created");
'An animation sohuld be created');
assert_equals(animation.effect, effect,
"Animation returns the same effect passed to " +
"the Constructor");
'Animation returns the same effect passed to ' +
'the Constructor');
assert_equals(animation.timeline, args.expectedTimeline,
"Animation timeline should be " + args.expectedTimelineDescription);
assert_equals(animation.playState, "idle",
"Animation.playState should be initially 'idle'");
}, "Animation can be constructed " + args.description);
});
'Animation timeline should be ' + args.expectedTimelineDescription);
assert_equals(animation.playState, 'idle',
'Animation.playState should be initially \'idle\'');
}, 'Animation can be constructed ' + args.description);
}
test(function(t) {
var effect = new KeyframeEffectReadOnly(null,
{ left: ["10px", "20px"] },
{ duration: 10000,
fill: "forwards" });
var anim = new Animation(effect, document.timeline);
test(t => {
const effect = new KeyframeEffectReadOnly(null,
{ left: ['10px', '20px'] },
{ duration: 10000,
fill: 'forwards' });
const anim = new Animation(effect, document.timeline);
anim.pause();
assert_equals(effect.getComputedTiming().progress, 0.0);
anim.currentTime += 5000;
assert_equals(effect.getComputedTiming().progress, 0.5);
anim.finish();
assert_equals(effect.getComputedTiming().progress, 1.0);
}, "Animation constructed by an effect with null target runs normally");
}, 'Animation constructed by an effect with null target runs normally');
async_test(function(t) {
var iframe = document.createElement('iframe');
async_test(t => {
const iframe = document.createElement('iframe');
iframe.addEventListener('load', t.step_func(function() {
var div = createDiv(t, iframe.contentDocument);
var effect = new KeyframeEffectReadOnly(div, null, 10000);
var anim = new Animation(effect);
iframe.addEventListener('load', t.step_func(() => {
const div = createDiv(t, iframe.contentDocument);
const effect = new KeyframeEffectReadOnly(div, null, 10000);
const anim = new Animation(effect);
assert_equals(anim.timeline, document.timeline);
iframe.remove();
t.done();
}));
document.body.appendChild(iframe);
}, "Animation constructed with a keyframe that target element is in iframe");
}, 'Animation constructed with a keyframe that target element is in iframe');
</script>
</body>

View file

@ -1,29 +1,29 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.effect tests</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-effect">
<title>Animation.effect</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-effect">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
test(function(t) {
var anim = new Animation();
assert_equals(anim.effect, null, "initial effect is null");
test(t => {
const anim = new Animation();
assert_equals(anim.effect, null, 'initial effect is null');
var newEffect = new KeyframeEffectReadOnly(createDiv(t), null);
const newEffect = new KeyframeEffectReadOnly(createDiv(t), null);
anim.effect = newEffect;
assert_equals(anim.effect, newEffect, "new effect is set");
}, "effect is set correctly.");
assert_equals(anim.effect, newEffect, 'new effect is set');
}, 'effect is set correctly.');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({ left: ['100px', '100px'] },
{ fill: 'forwards' });
var effect = animation.effect;
test(t => {
const div = createDiv(t);
const animation = div.animate({ left: ['100px', '100px'] },
{ fill: 'forwards' });
const effect = animation.effect;
assert_equals(getComputedStyle(div).left, '100px',
'animation is initially having an effect');

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.finish()</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-finish">
<title>Animation.finish</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-finish">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
@ -10,32 +10,32 @@
<script>
'use strict';
var gKeyFrames = { 'marginLeft': ['100px', '200px'] };
const gKeyFrames = { 'marginLeft': ['100px', '200px'] };
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.playbackRate = 0;
assert_throws({name: 'InvalidStateError'}, function() {
assert_throws({name: 'InvalidStateError'}, () => {
animation.finish();
});
}, 'Test exceptions when finishing non-running animation');
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames,
{duration : 100 * MS_PER_SEC,
iterations : Infinity});
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames,
{ duration : 100 * MS_PER_SEC,
iterations : Infinity });
assert_throws({name: 'InvalidStateError'}, function() {
assert_throws({name: 'InvalidStateError'}, () => {
animation.finish();
});
}, 'Test exceptions when finishing infinite animation');
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.finish();
assert_equals(animation.currentTime, 100 * MS_PER_SEC,
@ -43,9 +43,9 @@ test(function(t) {
'of the active duration');
}, 'Test finishing of animation');
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
// 1s past effect end
animation.currentTime =
animation.effect.getComputedTiming().endTime + 1 * MS_PER_SEC;
@ -56,11 +56,11 @@ test(function(t) {
'end of the active duration');
}, 'Test finishing of animation with a current time past the effect end');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.currentTime = 100 * MS_PER_SEC;
return animation.finished.then(function() {
return animation.finished.then(() => {
animation.playbackRate = -1;
animation.finish();
@ -70,11 +70,11 @@ promise_test(function(t) {
});
}, 'Test finishing of reversed animation');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.currentTime = 100 * MS_PER_SEC;
return animation.finished.then(function() {
return animation.finished.then(() => {
animation.playbackRate = -1;
animation.currentTime = -1000;
animation.finish();
@ -85,11 +85,11 @@ promise_test(function(t) {
});
}, 'Test finishing of reversed animation with a current time less than zero');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.pause();
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.finish();
assert_equals(animation.playState, 'finished',
@ -102,9 +102,9 @@ promise_test(function(t) {
});
}, 'Test finish() while paused');
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.pause();
// Update playbackRate so we can test that the calculated startTime
// respects it
@ -121,9 +121,9 @@ test(function(t) {
'be set after calling finish()');
}, 'Test finish() while pause-pending with positive playbackRate');
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.pause();
animation.playbackRate = -2;
animation.finish();
@ -136,9 +136,9 @@ test(function(t) {
'set after calling finish()');
}, 'Test finish() while pause-pending with negative playbackRate');
test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
animation.playbackRate = 0.5;
animation.finish();
@ -155,10 +155,10 @@ test(function(t) {
// - In that case even after calling finish() we should still be pending but
// the current time should be updated
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.pause();
animation.play();
// We are now in the unusual situation of being play-pending whilst having
@ -172,13 +172,13 @@ promise_test(function(t) {
});
}, 'Test finish() during aborted pause');
promise_test(function(t) {
var div = createDiv(t);
promise_test(t => {
const div = createDiv(t);
div.style.marginLeft = '10px';
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
return animation.ready.then(function() {
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.finish();
var marginLeft = parseFloat(getComputedStyle(div).marginLeft);
const marginLeft = parseFloat(getComputedStyle(div).marginLeft);
assert_equals(marginLeft, 10,
'The computed style should be reset when finish() is ' +
@ -186,34 +186,34 @@ promise_test(function(t) {
});
}, 'Test resetting of computed style');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
var resolvedFinished = false;
animation.finished.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(gKeyFrames, 100 * MS_PER_SEC);
let resolvedFinished = false;
animation.finished.then(() => {
resolvedFinished = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.finish();
}).then(function() {
}).then(() => {
assert_true(resolvedFinished,
'Animation.finished should be resolved soon after ' +
'Animation.finish()');
});
}, 'Test finish() resolves finished promise synchronously');
promise_test(function(t) {
var effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
var animation = new Animation(effect, document.timeline);
var resolvedFinished = false;
animation.finished.then(function() {
promise_test(t => {
const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
const animation = new Animation(effect, document.timeline);
let resolvedFinished = false;
animation.finished.then(() => {
resolvedFinished = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.finish();
}).then(function() {
}).then(() => {
assert_true(resolvedFinished,
'Animation.finished should be resolved soon after ' +
'Animation.finish()');
@ -221,20 +221,20 @@ promise_test(function(t) {
}, 'Test finish() resolves finished promise synchronously with an animation ' +
'without a target');
promise_test(function(t) {
var effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
var animation = new Animation(effect, document.timeline);
promise_test(t => {
const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
const animation = new Animation(effect, document.timeline);
animation.play();
var resolvedFinished = false;
animation.finished.then(function() {
let resolvedFinished = false;
animation.finished.then(() => {
resolvedFinished = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.currentTime = animation.effect.getComputedTiming().endTime - 1;
return waitForAnimationFrames(2);
}).then(function() {
}).then(() => {
assert_true(resolvedFinished,
'Animation.finished should be resolved soon after ' +
'Animation finishes normally');

View file

@ -1,20 +1,20 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.finished</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-finished">
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-finished">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
return animation.ready.then(() => {
assert_equals(animation.finished, previousFinishedPromise,
'Finished promise is the same object when playing starts');
animation.pause();
@ -27,18 +27,18 @@ promise_test(function(t) {
animation.currentTime = 100 * MS_PER_SEC;
return animation.finished;
}).then(function() {
}).then(() => {
assert_equals(animation.finished, previousFinishedPromise,
'Finished promise is the same object when playing completes');
});
}, 'Test pausing then playing does not change the finished promise');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let previousFinishedPromise = animation.finished;
animation.finish();
return animation.finished.then(function() {
return animation.finished.then(() => {
assert_equals(animation.finished, previousFinishedPromise,
'Finished promise is the same object when playing completes');
animation.play();
@ -53,12 +53,12 @@ promise_test(function(t) {
});
}, 'Test restarting a finished animation');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let previousFinishedPromise;
animation.finish();
return animation.finished.then(function() {
return animation.finished.then(() => {
previousFinishedPromise = animation.finished;
animation.playbackRate = -1;
assert_not_equals(animation.finished, previousFinishedPromise,
@ -66,7 +66,7 @@ promise_test(function(t) {
'finished promise');
animation.currentTime = 0;
return animation.finished;
}).then(function() {
}).then(() => {
previousFinishedPromise = animation.finished;
animation.play();
assert_not_equals(animation.finished, previousFinishedPromise,
@ -75,12 +75,12 @@ promise_test(function(t) {
});
}, 'Test restarting a reversed finished animation');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
animation.finish();
return animation.finished.then(function() {
return animation.finished.then(() => {
animation.currentTime = 100 * MS_PER_SEC + 1000;
assert_equals(animation.finished, previousFinishedPromise,
'Finished promise is unchanged jumping past end of ' +
@ -88,71 +88,71 @@ promise_test(function(t) {
});
}, 'Test redundant finishing of animation');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
// Setup callback to run if finished promise is resolved
var finishPromiseResolved = false;
animation.finished.then(function() {
let finishPromiseResolved = false;
animation.finished.then(() => {
finishPromiseResolved = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
// Jump to mid-way in interval and pause
animation.currentTime = 100 * MS_PER_SEC / 2;
animation.pause();
return animation.ready;
}).then(function() {
}).then(() => {
// Jump to the end
// (But don't use finish() since that should unpause as well)
animation.currentTime = 100 * MS_PER_SEC;
return waitForAnimationFrames(2);
}).then(function() {
}).then(() => {
assert_false(finishPromiseResolved,
'Finished promise should not resolve when paused');
});
}, 'Finished promise does not resolve when paused');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
// Setup callback to run if finished promise is resolved
var finishPromiseResolved = false;
animation.finished.then(function() {
let finishPromiseResolved = false;
animation.finished.then(() => {
finishPromiseResolved = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
// Jump to mid-way in interval and pause
animation.currentTime = 100 * MS_PER_SEC / 2;
animation.pause();
// Jump to the end
animation.currentTime = 100 * MS_PER_SEC;
return waitForAnimationFrames(2);
}).then(function() {
}).then(() => {
assert_false(finishPromiseResolved,
'Finished promise should not resolve when pause-pending');
});
}, 'Finished promise does not resolve when pause-pending');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.finish();
return animation.finished.then(function(resolvedAnimation) {
return animation.finished.then(resolvedAnimation => {
assert_equals(resolvedAnimation, animation,
'Object identity of animation passed to Promise callback'
+ ' matches the animation object owning the Promise');
});
}, 'The finished promise is fulfilled with its Animation');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
// Set up listeners on finished promise
var retPromise = animation.finished.then(function() {
const retPromise = animation.finished.then(() => {
assert_unreached('finished promise was fulfilled');
}).catch(function(err) {
}).catch(err => {
assert_equals(err.name, 'AbortError',
'finished promise is rejected with AbortError');
assert_not_equals(animation.finished, previousFinishedPromise,
@ -163,52 +163,31 @@ promise_test(function(t) {
animation.cancel();
return retPromise;
}, 'finished promise is rejected when an animation is cancelled by calling ' +
}, 'finished promise is rejected when an animation is canceled by calling ' +
'cancel()');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
animation.finish();
return animation.finished.then(function() {
return animation.finished.then(() => {
animation.cancel();
assert_not_equals(animation.finished, previousFinishedPromise,
'A new finished promise should be created when'
+ ' cancelling a finished animation');
+ ' canceling a finished animation');
});
}, 'cancelling an already-finished animation replaces the finished promise');
}, 'canceling an already-finished animation replaces the finished promise');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.cancel();
// The spec says we still create a new finished promise and reject the old
// one even if we're already idle. That behavior might change, but for now
// test that we do that.
var retPromise = animation.finished.catch(function(err) {
assert_equals(err.name, 'AbortError',
'finished promise is rejected with AbortError');
});
// Redundant call to cancel();
var previousFinishedPromise = animation.finished;
animation.cancel();
assert_not_equals(animation.finished, previousFinishedPromise,
'A redundant call to cancel() should still generate a new'
+ ' finished promise');
return retPromise;
}, 'cancelling an idle animation still replaces the finished promise');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const HALF_DUR = 100 * MS_PER_SEC / 2;
const QUARTER_DUR = 100 * MS_PER_SEC / 4;
var gotNextFrame = false;
var currentTimeBeforeShortening;
let gotNextFrame = false;
let currentTimeBeforeShortening;
animation.currentTime = HALF_DUR;
return animation.ready.then(function() {
return animation.ready.then(() => {
currentTimeBeforeShortening = animation.currentTime;
animation.effect.timing.duration = QUARTER_DUR;
// Below we use gotNextFrame to check that shortening of the animation
@ -216,17 +195,17 @@ promise_test(function(t) {
// getting resolved on the next animation frame. This relies on the fact
// that the promises are resolved as a micro-task before the next frame
// happens.
waitForAnimationFrames(1).then(function() {
waitForAnimationFrames(1).then(() => {
gotNextFrame = true;
});
return animation.finished;
}).then(function() {
}).then(() => {
assert_false(gotNextFrame, 'shortening of the animation duration should ' +
'resolve the finished promise');
assert_equals(animation.currentTime, currentTimeBeforeShortening,
'currentTime should be unchanged when duration shortened');
var previousFinishedPromise = animation.finished;
const previousFinishedPromise = animation.finished;
animation.effect.timing.duration = 100 * MS_PER_SEC;
assert_not_equals(animation.finished, previousFinishedPromise,
'Finished promise should change after lengthening the ' +
@ -234,16 +213,16 @@ promise_test(function(t) {
});
}, 'Test finished promise changes for animation duration changes');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var retPromise = animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const retPromise = animation.ready.then(() => {
animation.playbackRate = 0;
animation.currentTime = 100 * MS_PER_SEC + 1000;
return waitForAnimationFrames(2);
});
animation.finished.then(t.step_func(function() {
animation.finished.then(t.step_func(() => {
assert_unreached('finished promise should not resolve when playbackRate ' +
'is zero');
}));
@ -251,21 +230,21 @@ promise_test(function(t) {
return retPromise;
}, 'Test finished promise changes when playbackRate == 0');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.playbackRate = -1;
return animation.finished;
});
}, 'Test finished promise resolves when reaching to the natural boundary.');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
animation.finish();
return animation.finished.then(function() {
return animation.finished.then(() => {
animation.currentTime = 0;
assert_not_equals(animation.finished, previousFinishedPromise,
'Finished promise should change once a prior ' +
@ -275,10 +254,10 @@ promise_test(function(t) {
}, 'Test finished promise changes when a prior finished promise resolved ' +
'and the animation falls out finished state');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
animation.currentTime = 100 * MS_PER_SEC;
animation.currentTime = 100 * MS_PER_SEC / 2;
assert_equals(animation.finished, previousFinishedPromise,
@ -287,10 +266,10 @@ test(function(t) {
}, 'Test no new finished promise generated when finished state ' +
'is checked asynchronously');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var previousFinishedPromise = animation.finished;
test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
const previousFinishedPromise = animation.finished;
animation.finish();
animation.currentTime = 100 * MS_PER_SEC / 2;
assert_not_equals(animation.finished, previousFinishedPromise,
@ -299,17 +278,17 @@ test(function(t) {
}, 'Test new finished promise generated when finished state ' +
'is checked synchronously');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var resolvedFinished = false;
animation.finished.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let resolvedFinished = false;
animation.finished.then(() => {
resolvedFinished = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.finish();
animation.currentTime = 100 * MS_PER_SEC / 2;
}).then(function() {
}).then(() => {
assert_true(resolvedFinished,
'Animation.finished should be resolved even if ' +
'the finished state is changed soon');
@ -318,18 +297,18 @@ promise_test(function(t) {
}, 'Test synchronous finished promise resolved even if finished state ' +
'is changed soon');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var resolvedFinished = false;
animation.finished.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let resolvedFinished = false;
animation.finished.then(() => {
resolvedFinished = true;
});
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.currentTime = 100 * MS_PER_SEC;
animation.finish();
}).then(function() {
}).then(() => {
assert_true(resolvedFinished,
'Animation.finished should be resolved soon after finish() is ' +
'called even if there are other asynchronous promises just before it');
@ -337,26 +316,26 @@ promise_test(function(t) {
}, 'Test synchronous finished promise resolved even if asynchronous ' +
'finished promise happens just before synchronous promise');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.finished.then(t.step_func(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.finished.then(t.step_func(() => {
assert_unreached('Animation.finished should not be resolved');
}));
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.currentTime = 100 * MS_PER_SEC;
animation.currentTime = 100 * MS_PER_SEC / 2;
});
}, 'Test finished promise is not resolved when the animation ' +
'falls out finished state immediately');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.currentTime = 100 * MS_PER_SEC;
animation.finished.then(t.step_func(function() {
animation.finished.then(t.step_func(() => {
assert_unreached('Animation.finished should not be resolved');
}));
animation.currentTime = 0;
@ -366,24 +345,24 @@ promise_test(function(t) {
'falls out finished state even though the current finished ' +
'promise is generated soon after animation state became finished');
promise_test(function(t) {
var animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
var ready = false;
promise_test(t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
let ready = false;
animation.ready.then(
t.step_func(function() {
t.step_func(() => {
ready = true;
}),
t.unreached_func('Ready promise must not be rejected')
);
var testSuccess = animation.finished.then(
t.step_func(function() {
const testSuccess = animation.finished.then(
t.step_func(() => {
assert_true(ready, 'Ready promise has resolved');
}),
t.unreached_func('Finished promise must not be rejected')
);
var timeout = waitForAnimationFrames(3).then(function() {
const timeout = waitForAnimationFrames(3).then(() => {
return Promise.reject('Finished promise did not arrive in time');
});
@ -391,24 +370,24 @@ promise_test(function(t) {
return Promise.race([timeout, testSuccess]);
}, 'Finished promise should be resolved after the ready promise is resolved');
promise_test(function(t) {
var animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
var caught = false;
promise_test(t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
let caught = false;
animation.ready.then(
t.unreached_func('Ready promise must not be resolved'),
t.step_func(function() {
t.step_func(() => {
caught = true;
})
);
var testSuccess = animation.finished.then(
const testSuccess = animation.finished.then(
t.unreached_func('Finished promise must not be resolved'),
t.step_func(function() {
t.step_func(() => {
assert_true(caught, 'Ready promise has been rejected');
})
);
var timeout = waitForAnimationFrames(3).then(function() {
const timeout = waitForAnimationFrames(3).then(() => {
return Promise.reject('Finished promise was not rejected in time');
});

View file

@ -1,24 +1,24 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.id</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-id">
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-id">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
assert_equals(animation.id, '', 'id for Animation is initially empty');
}, 'Animation.id initial value');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.id = 'anim';
assert_equals(animation.id, 'anim', 'animation.id reflects the value set');

View file

@ -1,7 +1,7 @@
<!doctype html>
<meta charset=utf-8>
<title>Animation IDL</title>
<link rel="help" href="https://w3c.github.io/web-animations/#animation">
<link rel="help" href="https://drafts.csswg.org/web-animations/#animation">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/WebIDLParser.js"></script>
@ -20,6 +20,7 @@ interface Animation : EventTarget {
attribute double? currentTime;
attribute double playbackRate;
readonly attribute AnimationPlayState playState;
readonly attribute boolean pending;
readonly attribute Promise<Animation> ready;
readonly attribute Promise<Animation> finished;
attribute EventHandler onfinish;

View file

@ -1,24 +1,24 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.oncancel</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-oncancel">
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-oncancel">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
async_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var finishedTimelineTime;
animation.finished.then().catch(function() {
async_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let finishedTimelineTime;
animation.finished.then().catch(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
animation.oncancel = t.step_func_done(function(event) {
animation.oncancel = t.step_func_done(event => {
assert_equals(event.currentTime, null,
'event.currentTime should be null');
assert_equals(event.timelineTime, finishedTimelineTime,

View file

@ -1,24 +1,24 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.onfinish</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-onfinish">
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-onfinish">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
async_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
var finishedTimelineTime;
animation.finished.then(function() {
async_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
let finishedTimelineTime;
animation.finished.then(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
animation.onfinish = t.step_func_done(function(event) {
animation.onfinish = t.step_func_done(event => {
assert_equals(event.currentTime, 0,
'event.currentTime should be zero');
assert_equals(event.timelineTime, finishedTimelineTime,
@ -30,16 +30,16 @@ async_test(function(t) {
}, 'onfinish event is fired when the currentTime < 0 and ' +
'the playbackRate < 0');
async_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
async_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
var finishedTimelineTime;
animation.finished.then(function() {
let finishedTimelineTime;
animation.finished.then(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
animation.onfinish = t.step_func_done(function(event) {
animation.onfinish = t.step_func_done(event => {
assert_equals(event.currentTime, 100 * MS_PER_SEC,
'event.currentTime should be the effect end');
assert_equals(event.timelineTime, finishedTimelineTime,
@ -51,16 +51,16 @@ async_test(function(t) {
}, 'onfinish event is fired when the currentTime > 0 and ' +
'the playbackRate > 0');
async_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
async_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
var finishedTimelineTime;
animation.finished.then(function() {
let finishedTimelineTime;
animation.finished.then(() => {
finishedTimelineTime = animation.timeline.currentTime;
});
animation.onfinish = t.step_func_done(function(event) {
animation.onfinish = t.step_func_done(event => {
assert_equals(event.currentTime, 100 * MS_PER_SEC,
'event.currentTime should be the effect end');
assert_equals(event.timelineTime, finishedTimelineTime,
@ -71,45 +71,45 @@ async_test(function(t) {
animation.finish();
}, 'onfinish event is fired when animation.finish() is called');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.onfinish = function(event) {
animation.onfinish = event => {
assert_unreached('onfinish event should not be fired');
};
animation.currentTime = 100 * MS_PER_SEC / 2;
animation.pause();
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.currentTime = 100 * MS_PER_SEC;
return waitForAnimationFrames(2);
});
}, 'onfinish event is not fired when paused');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.onfinish = function(event) {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.onfinish = event => {
assert_unreached('onfinish event should not be fired');
};
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.playbackRate = 0;
animation.currentTime = 100 * MS_PER_SEC;
return waitForAnimationFrames(2);
});
}, 'onfinish event is not fired when the playbackRate is zero');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.onfinish = function(event) {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.onfinish = event => {
assert_unreached('onfinish event should not be fired');
};
return animation.ready.then(function() {
return animation.ready.then(() => {
animation.currentTime = 100 * MS_PER_SEC;
animation.currentTime = 100 * MS_PER_SEC / 2;
return waitForAnimationFrames(2);

View file

@ -1,37 +1,37 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.pause()</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-pause">
<title>Animation.pause</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-pause">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 1000 * MS_PER_SEC);
var previousCurrentTime = animation.currentTime;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 1000 * MS_PER_SEC);
let previousCurrentTime = animation.currentTime;
return animation.ready.then(waitForAnimationFrames(1)).then(function() {
return animation.ready.then(waitForAnimationFrames(1)).then(() => {
assert_true(animation.currentTime >= previousCurrentTime,
'currentTime is initially increasing');
animation.pause();
return animation.ready;
}).then(function() {
}).then(() => {
previousCurrentTime = animation.currentTime;
return waitForAnimationFrames(1);
}).then(function() {
}).then(() => {
assert_equals(animation.currentTime, previousCurrentTime,
'currentTime does not increase after calling pause()');
});
}, 'pause() a running animation');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 1000 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 1000 * MS_PER_SEC);
// Go to idle state then pause
animation.cancel();
@ -39,20 +39,20 @@ promise_test(function(t) {
assert_equals(animation.currentTime, 0, 'currentTime is set to 0');
assert_equals(animation.startTime, null, 'startTime is not set');
assert_equals(animation.playState, 'pending', 'initially pause-pending');
assert_equals(animation.playState, 'paused', 'in paused play state');
assert_true(animation.pending, 'initially pause-pending');
// Check it still resolves as expected
return animation.ready.then(function() {
assert_equals(animation.playState, 'paused',
'resolves to paused state asynchronously');
return animation.ready.then(() => {
assert_false(animation.pending, 'no longer pending');
assert_equals(animation.currentTime, 0,
'keeps the initially set currentTime');
});
}, 'pause() from idle');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 1000 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 1000 * MS_PER_SEC);
animation.cancel();
animation.playbackRate = -1;
animation.pause();
@ -60,35 +60,35 @@ promise_test(function(t) {
assert_equals(animation.currentTime, 1000 * MS_PER_SEC,
'currentTime is set to the effect end');
return animation.ready.then(function() {
return animation.ready.then(() => {
assert_equals(animation.currentTime, 1000 * MS_PER_SEC,
'keeps the initially set currentTime');
});
}, 'pause() from idle with a negative playbackRate');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, {duration: 1000 * MS_PER_SEC,
test(t => {
const div = createDiv(t);
const animation = div.animate({}, {duration: 1000 * MS_PER_SEC,
iterations: Infinity});
animation.cancel();
animation.playbackRate = -1;
assert_throws('InvalidStateError',
function () { animation.pause(); },
() => { animation.pause(); },
'Expect InvalidStateError exception on calling pause() ' +
'from idle with a negative playbackRate and ' +
'infinite-duration animation');
}, 'pause() from idle with a negative playbackRate and endless effect');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 1000 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 1000 * MS_PER_SEC);
return animation.ready
.then(function(animation) {
.then(animation => {
animation.finish();
animation.pause();
return animation.ready;
}).then(function(animation) {
}).then(animation => {
assert_equals(animation.currentTime, 1000 * MS_PER_SEC,
'currentTime after pausing finished animation');
});

View file

@ -0,0 +1,35 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.pending</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-pending">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
assert_true(animation.pending);
return animation.ready.then(() => {
assert_false(animation.pending);
});
}, 'reports true -> false when initially played');
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({}, 100 * MS_PER_SEC);
animation.pause();
assert_true(animation.pending);
return animation.ready.then(() => {
assert_false(animation.pending);
});
}, 'reports true -> false when paused');
</script>
</body>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.play()</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-play">
<title>Animation.play</title>
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-play">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
@ -10,19 +10,19 @@
<script>
'use strict';
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({ transform: ['none', 'translate(10px)']},
{ duration : 100 * MS_PER_SEC,
iterations : Infinity});
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate({ transform: ['none', 'translate(10px)']},
{ duration: 100 * MS_PER_SEC,
iterations: Infinity });
return animation.ready.then(() => {
// Seek to a time outside the active range so that play() will have to
// snap back to the start
animation.currentTime = -5 * MS_PER_SEC;
animation.playbackRate = -1;
assert_throws('InvalidStateError',
function () { animation.play(); },
() => { animation.play(); },
'Expected InvalidStateError exception on calling play() ' +
'with a negative playbackRate and infinite-duration ' +
'animation');

View file

@ -1,53 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.playState</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playstate">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
'use strict';
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
assert_equals(animation.playState, 'pending');
return animation.ready.then(function() {
assert_equals(animation.playState, 'running');
});
}, 'Animation.playState reports \'pending\'->\'running\' when initially ' +
'played');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.pause();
assert_equals(animation.playState, 'pending');
return animation.ready.then(function() {
assert_equals(animation.playState, 'paused');
});
}, 'Animation.playState reports \'pending\'->\'paused\' when pausing');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.cancel();
assert_equals(animation.playState, 'idle');
}, 'Animation.playState is \'idle\' when canceled.');
test(function(t) {
var div = createDiv(t);
var animation = div.animate({}, 100 * MS_PER_SEC);
animation.cancel();
animation.currentTime = 50 * MS_PER_SEC;
assert_equals(animation.playState, 'paused',
'After seeking an idle animation, it is effectively paused');
}, 'Animation.playState is \'paused\' after cancelling an animation, ' +
'seeking it makes it paused');
</script>
</body>

View file

@ -1,23 +1,23 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.playbackRate</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-playbackrate">
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-playbackrate">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
function assert_playbackrate(animation,
previousAnimationCurrentTime,
previousTimelineCurrentTime,
description) {
var accuracy = 0.001; /* accuracy of DOMHighResTimeStamp */
var animationCurrentTimeDifference =
const accuracy = 0.001; /* accuracy of DOMHighResTimeStamp */
const animationCurrentTimeDifference =
animation.currentTime - previousAnimationCurrentTime;
var timelineCurrentTimeDifference =
const timelineCurrentTimeDifference =
animation.timeline.currentTime - previousTimelineCurrentTime;
assert_approx_equals(animationCurrentTimeDifference,
@ -26,10 +26,10 @@ function assert_playbackrate(animation,
description);
}
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(null, 100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
return animation.ready.then(() => {
animation.currentTime = 7 * MS_PER_SEC; // ms
animation.playbackRate = 0.5;
@ -43,17 +43,17 @@ promise_test(function(t) {
});
}, 'Test the initial effect of setting playbackRate on currentTime');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(null, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
animation.playbackRate = 2;
var previousTimelineCurrentTime;
var previousAnimationCurrentTime;
return animation.ready.then(function() {
let previousTimelineCurrentTime;
let previousAnimationCurrentTime;
return animation.ready.then(() => {
previousAnimationCurrentTime = animation.currentTime;
previousTimelineCurrentTime = animation.timeline.currentTime;
return waitForAnimationFrames(1);
}).then(function() {
}).then(() => {
assert_playbackrate(animation,
previousAnimationCurrentTime,
previousTimelineCurrentTime,
@ -61,18 +61,18 @@ promise_test(function(t) {
});
}, 'Test the effect of setting playbackRate on currentTime');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(null, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
animation.playbackRate = 2;
var previousTimelineCurrentTime;
var previousAnimationCurrentTime;
return animation.ready.then(function() {
let previousTimelineCurrentTime;
let previousAnimationCurrentTime;
return animation.ready.then(() => {
previousAnimationCurrentTime = animation.currentTime;
previousTimelineCurrentTime = animation.timeline.currentTime;
animation.playbackRate = 1;
return waitForAnimationFrames(1);
}).then(function() {
}).then(() => {
assert_equals(animation.playbackRate, 1,
'sanity check: animation.playbackRate is still 1.');
assert_playbackrate(animation,

View file

@ -1,22 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.ready</title>
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animation-ready">
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animation-ready">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
<body>
<div id="log"></div>
<script>
"use strict";
'use strict';
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(null, 100 * MS_PER_SEC);
var originalReadyPromise = animation.ready;
var pauseReadyPromise;
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
const originalReadyPromise = animation.ready;
let pauseReadyPromise;
return animation.ready.then(function() {
return animation.ready.then(() => {
assert_equals(animation.ready, originalReadyPromise,
'Ready promise is the same object when playing completes');
animation.pause();
@ -26,19 +26,19 @@ promise_test(function(t) {
// Wait for the promise to fulfill since if we abort the pause the ready
// promise object is reused.
return animation.ready;
}).then(function() {
}).then(() => {
animation.play();
assert_not_equals(animation.ready, pauseReadyPromise,
'A new ready promise is created when playing');
});
}, 'A new ready promise is created when play()/pause() is called');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(null, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
return animation.ready.then(function() {
var promiseBeforeCallingPlay = animation.ready;
return animation.ready.then(() => {
const promiseBeforeCallingPlay = animation.ready;
animation.play();
assert_equals(animation.ready, promiseBeforeCallingPlay,
'Ready promise has same object identity after redundant call'
@ -46,11 +46,11 @@ promise_test(function(t) {
});
}, 'Redundant calls to play() do not generate new ready promise objects');
promise_test(function(t) {
var div = createDiv(t);
var animation = div.animate(null, 100 * MS_PER_SEC);
promise_test(t => {
const div = createDiv(t);
const animation = div.animate(null, 100 * MS_PER_SEC);
return animation.ready.then(function(resolvedAnimation) {
return animation.ready.then(resolvedAnimation => {
assert_equals(resolvedAnimation, animation,
'Object identity of Animation passed to Promise callback'
+ ' matches the Animation object owning the Promise');

View file

@ -1,8 +1,8 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Animation.startTime tests</title>
<title>Animation.startTime</title>
<link rel="help"
href="https://w3c.github.io/web-animations/#dom-animation-starttime">
href="https://drafts.csswg.org/web-animations/#dom-animation-starttime">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
@ -11,41 +11,41 @@ href="https://w3c.github.io/web-animations/#dom-animation-starttime">
<script>
'use strict';
test(function(t) {
var animation = new Animation(new KeyframeEffect(createDiv(t), null),
document.timeline);
test(t => {
const animation = new Animation(new KeyframeEffect(createDiv(t), null),
document.timeline);
assert_equals(animation.startTime, null, 'startTime is unresolved');
}, 'startTime of a newly created (idle) animation is unresolved');
test(function(t) {
var animation = new Animation(new KeyframeEffect(createDiv(t), null),
document.timeline);
test(t => {
const animation = new Animation(new KeyframeEffect(createDiv(t), null),
document.timeline);
animation.play();
assert_equals(animation.startTime, null, 'startTime is unresolved');
}, 'startTime of a play-pending animation is unresolved');
test(function(t) {
var animation = new Animation(new KeyframeEffect(createDiv(t), null),
document.timeline);
test(t => {
const animation = new Animation(new KeyframeEffect(createDiv(t), null),
document.timeline);
animation.pause();
assert_equals(animation.startTime, null, 'startTime is unresolved');
}, 'startTime of a pause-pending animation is unresolved');
test(function(t) {
var animation = createDiv(t).animate(null);
test(t => {
const animation = createDiv(t).animate(null);
assert_equals(animation.startTime, null, 'startTime is unresolved');
}, 'startTime of a play-pending animation created using Element.animate'
+ ' shortcut is unresolved');
promise_test(function(t) {
var animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
return animation.ready.then(function() {
promise_test(t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
return animation.ready.then(() => {
assert_greater_than(animation.startTime, 0, 'startTime when running');
});
}, 'startTime is resolved when running');
test(function(t) {
var animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
test(t => {
const animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
animation.cancel();
assert_equals(animation.startTime, null);
assert_equals(animation.currentTime, null);