mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Update web-platform-tests to revision be5419e845d39089ba6dc338c1bd0fa279108317
This commit is contained in:
parent
aa199307c8
commit
2b6f573eb5
3440 changed files with 109438 additions and 41750 deletions
|
@ -1,8 +1,8 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animatable.animate tests in combination with elements in documents
|
||||
<title>Animatable.animate in combination with elements in documents
|
||||
without a browsing context</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animatable-animate">
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animatable-animate">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -76,16 +76,15 @@ promise_test(t => {
|
|||
const div = xhrdoc.getElementById('test');
|
||||
anim = div.animate(null);
|
||||
anim.timeline = document.timeline;
|
||||
assert_equals(anim.playState, 'pending',
|
||||
'The animation should be initially pending');
|
||||
assert_true(anim.pending, 'The animation should be initially pending');
|
||||
return waitForAnimationFrames(2);
|
||||
}).then(() => {
|
||||
// Because the element is in a document without a browsing context, it will
|
||||
// not be rendered and hence the user agent will never deem it ready to
|
||||
// animate.
|
||||
assert_equals(anim.playState, 'pending',
|
||||
'The animation should still be pending after replacing'
|
||||
+ ' the document timeline');
|
||||
assert_true(anim.pending,
|
||||
'The animation should still be pending after replacing'
|
||||
+ ' the document timeline');
|
||||
});
|
||||
}, 'Replacing the timeline of an animation targetting an element in a'
|
||||
+ ' document without a browsing context leaves it in the pending state');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animatable.animate tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animatable-animate">
|
||||
<title>Animatable.animate</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animatable-animate">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -16,16 +16,16 @@
|
|||
|
||||
// Tests on Element
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate(null);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(null);
|
||||
assert_class_string(anim, 'Animation', 'Returned object is an Animation');
|
||||
}, 'Element.animate() creates an Animation object');
|
||||
|
||||
test(function(t) {
|
||||
var iframe = window.frames[0];
|
||||
var div = createDiv(t, iframe.document);
|
||||
var anim = Element.prototype.animate.call(div, null);
|
||||
test(t => {
|
||||
const iframe = window.frames[0];
|
||||
const div = createDiv(t, iframe.document);
|
||||
const anim = Element.prototype.animate.call(div, null);
|
||||
assert_equals(Object.getPrototypeOf(anim), iframe.Animation.prototype,
|
||||
'The prototype of the created Animation is that defined on'
|
||||
+ ' the relevant global for the target element');
|
||||
|
@ -35,17 +35,17 @@ test(function(t) {
|
|||
}, 'Element.animate() creates an Animation object in the relevant realm of'
|
||||
+ ' the target element');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = Element.prototype.animate.call(div, null);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = Element.prototype.animate.call(div, null);
|
||||
assert_class_string(anim.effect, 'KeyframeEffect',
|
||||
'Returned Animation has a KeyframeEffect');
|
||||
}, 'Element.animate() creates an Animation object with a KeyframeEffect');
|
||||
|
||||
test(function(t) {
|
||||
var iframe = window.frames[0];
|
||||
var div = createDiv(t, iframe.document);
|
||||
var anim = Element.prototype.animate.call(div, null);
|
||||
test(t => {
|
||||
const iframe = window.frames[0];
|
||||
const div = createDiv(t, iframe.document);
|
||||
const anim = Element.prototype.animate.call(div, null);
|
||||
assert_equals(Object.getPrototypeOf(anim.effect),
|
||||
iframe.KeyframeEffect.prototype,
|
||||
'The prototype of the created KeyframeEffect is that defined on'
|
||||
|
@ -57,10 +57,10 @@ test(function(t) {
|
|||
}, 'Element.animate() creates an Animation object with a KeyframeEffect'
|
||||
+ ' that is created in the relevant realm of the target element');
|
||||
|
||||
test(function(t) {
|
||||
var iframe = window.frames[0];
|
||||
var div = createDiv(t, iframe.document);
|
||||
var anim = div.animate(null);
|
||||
test(t => {
|
||||
const iframe = window.frames[0];
|
||||
const div = createDiv(t, iframe.document);
|
||||
const anim = div.animate(null);
|
||||
assert_equals(Object.getPrototypeOf(anim.effect.timing),
|
||||
iframe.AnimationEffectTiming.prototype,
|
||||
'The prototype of the created AnimationEffectTiming is that'
|
||||
|
@ -73,91 +73,91 @@ test(function(t) {
|
|||
+ ' whose AnimationEffectTiming object is created in the relevant realm'
|
||||
+ ' of the target element');
|
||||
|
||||
gEmptyKeyframeListTests.forEach(function(subTest) {
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate(subTest, 2000);
|
||||
for (const subtest of gEmptyKeyframeListTests) {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(subtest, 2000);
|
||||
assert_not_equals(anim, null);
|
||||
}, 'Element.animate() accepts empty keyframe lists ' +
|
||||
`(input: ${JSON.stringify(subTest)})`);
|
||||
});
|
||||
`(input: ${JSON.stringify(subtest)})`);
|
||||
}
|
||||
|
||||
gKeyframesTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate(subtest.input, 2000);
|
||||
for (const subtest of gKeyframesTests) {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(subtest.input, 2000);
|
||||
assert_frame_lists_equal(anim.effect.getKeyframes(), subtest.output);
|
||||
}, 'Element.animate() accepts ' + subtest.desc);
|
||||
});
|
||||
}, `Element.animate() accepts ${subtest.desc}`);
|
||||
}
|
||||
|
||||
gInvalidKeyframesTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws(new TypeError, function() {
|
||||
for (const subtest of gInvalidKeyframesTests) {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws(new TypeError, () => {
|
||||
div.animate(subtest.input, 2000);
|
||||
});
|
||||
}, 'Element.animate() does not accept ' + subtest.desc);
|
||||
});
|
||||
}, `Element.animate() does not accept ${subtest.desc}`);
|
||||
}
|
||||
|
||||
gInvalidEasings.forEach(invalidEasing => {
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
for (const invalidEasing of gInvalidEasings) {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws(new TypeError, () => {
|
||||
div.animate({ easing: invalidEasing }, 2000);
|
||||
});
|
||||
}, `Element.animate() does not accept invalid easing: '${invalidEasing}'`);
|
||||
});
|
||||
}
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_equals(anim.effect.timing.duration, 2000);
|
||||
// Also check that unspecified parameters receive their default values
|
||||
assert_equals(anim.effect.timing.fill, 'auto');
|
||||
}, 'Element.animate() accepts a double as an options argument');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: Infinity, fill: 'forwards' });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: Infinity, fill: 'forwards' });
|
||||
assert_equals(anim.effect.timing.duration, Infinity);
|
||||
assert_equals(anim.effect.timing.fill, 'forwards');
|
||||
// Also check that unspecified parameters receive their default values
|
||||
assert_equals(anim.effect.timing.direction, 'normal');
|
||||
}, 'Element.animate() accepts a KeyframeAnimationOptions argument');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] });
|
||||
assert_equals(anim.effect.timing.duration, 'auto');
|
||||
}, 'Element.animate() accepts an absent options argument');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_equals(anim.id, '');
|
||||
}, 'Element.animate() correctly sets the id attribute when no id is specified');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, { id: 'test' });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, { id: 'test' });
|
||||
assert_equals(anim.id, 'test');
|
||||
}, 'Element.animate() correctly sets the id attribute');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_equals(anim.timeline, document.timeline);
|
||||
}, 'Element.animate() correctly sets the Animation\'s timeline');
|
||||
|
||||
async_test(function(t) {
|
||||
var iframe = document.createElement('iframe');
|
||||
async_test(t => {
|
||||
const iframe = document.createElement('iframe');
|
||||
iframe.width = 10;
|
||||
iframe.height = 10;
|
||||
|
||||
iframe.addEventListener('load', t.step_func(function() {
|
||||
var div = createDiv(t, iframe.contentDocument);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
iframe.addEventListener('load', t.step_func(() => {
|
||||
const div = createDiv(t, iframe.contentDocument);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_equals(anim.timeline, iframe.contentDocument.timeline);
|
||||
iframe.remove();
|
||||
t.done();
|
||||
|
@ -167,23 +167,23 @@ async_test(function(t) {
|
|||
}, 'Element.animate() correctly sets the Animation\'s timeline when ' +
|
||||
'triggered on an element in a different document');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_equals(anim.playState, 'pending');
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_equals(anim.playState, 'running');
|
||||
}, 'Element.animate() calls play on the Animation');
|
||||
|
||||
// Tests on CSSPseudoElement
|
||||
|
||||
test(function(t) {
|
||||
var pseudoTarget = createPseudo(t, 'before');
|
||||
var anim = pseudoTarget.animate(null);
|
||||
test(t => {
|
||||
const pseudoTarget = createPseudo(t, 'before');
|
||||
const anim = pseudoTarget.animate(null);
|
||||
assert_class_string(anim, 'Animation', 'The returned object is an Animation');
|
||||
}, 'CSSPseudoElement.animate() creates an Animation object');
|
||||
|
||||
test(function(t) {
|
||||
var pseudoTarget = createPseudo(t, 'before');
|
||||
var anim = pseudoTarget.animate(null);
|
||||
test(t => {
|
||||
const pseudoTarget = createPseudo(t, 'before');
|
||||
const anim = pseudoTarget.animate(null);
|
||||
assert_equals(anim.effect.target, pseudoTarget,
|
||||
'The returned Animation targets to the correct object');
|
||||
}, 'CSSPseudoElement.animate() creates an Animation object targeting ' +
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Animatable.getAnimations tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animatable-getanimations">
|
||||
<title>Animatable.getAnimations</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animatable-getanimations">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -9,62 +9,148 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_array_equals(div.getAnimations(), []);
|
||||
}, 'Test getAnimations on element with no animations');
|
||||
}, 'Returns an empty array for an element with no animations');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animationA = div.animate(null, 100 * MS_PER_SEC);
|
||||
var animationB = div.animate(null, 100 * MS_PER_SEC);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animationA = div.animate(null, 100 * MS_PER_SEC);
|
||||
const animationB = div.animate(null, 100 * MS_PER_SEC);
|
||||
assert_array_equals(div.getAnimations(), [animationA, animationB]);
|
||||
}, 'Test getAnimations on element with two animations');
|
||||
}, 'Returns both animations for an element with two animations');
|
||||
|
||||
test(function(t) {
|
||||
var divA = createDiv(t);
|
||||
var divB = createDiv(t);
|
||||
var animationA = divA.animate(null, 100 * MS_PER_SEC);
|
||||
var animationB = divB.animate(null, 100 * MS_PER_SEC);
|
||||
test(t => {
|
||||
const divA = createDiv(t);
|
||||
const divB = createDiv(t);
|
||||
const animationA = divA.animate(null, 100 * MS_PER_SEC);
|
||||
const animationB = divB.animate(null, 100 * MS_PER_SEC);
|
||||
assert_array_equals(divA.getAnimations(), [animationA], 'divA');
|
||||
assert_array_equals(divB.getAnimations(), [animationB], 'divB');
|
||||
}, 'Test getAnimations on separate elements with separate animations');
|
||||
}, 'Returns only the animations specific to each sibling element');
|
||||
|
||||
test(function(t) {
|
||||
var divParent = createDiv(t);
|
||||
var divChild = createDiv(t);
|
||||
test(t => {
|
||||
const divParent = createDiv(t);
|
||||
const divChild = createDiv(t);
|
||||
divParent.appendChild(divChild);
|
||||
var animationParent = divParent.animate(null, 100 * MS_PER_SEC);
|
||||
var animationChild = divChild.animate(null, 100 * MS_PER_SEC);
|
||||
assert_array_equals(divParent.getAnimations(), [animationParent], 'divParent');
|
||||
const animationParent = divParent.animate(null, 100 * MS_PER_SEC);
|
||||
const animationChild = divChild.animate(null, 100 * MS_PER_SEC);
|
||||
assert_array_equals(divParent.getAnimations(), [animationParent],
|
||||
'divParent');
|
||||
assert_array_equals(divChild.getAnimations(), [animationChild], 'divChild');
|
||||
}, 'Test getAnimations on parent and child elements with separate animations');
|
||||
}, 'Returns only the animations specific to each parent/child element');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(null, 100 * MS_PER_SEC);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null, 100 * MS_PER_SEC);
|
||||
animation.finish();
|
||||
assert_array_equals(div.getAnimations(), []);
|
||||
}, 'Test getAnimations on element with finished fill none animation');
|
||||
}, 'Does not return finished animations that do not fill forwards');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(null, {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null, {
|
||||
duration: 100 * MS_PER_SEC,
|
||||
fill: 'forwards',
|
||||
});
|
||||
animation.finish();
|
||||
assert_array_equals(div.getAnimations(), [animation]);
|
||||
}, 'Test getAnimations on element with finished fill forwards animation');
|
||||
}, 'Returns finished animations that fill forwards');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var animation = div.animate(null, {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null, {
|
||||
duration: 100 * MS_PER_SEC,
|
||||
delay: 100 * MS_PER_SEC,
|
||||
});
|
||||
assert_array_equals(div.getAnimations(), [animation]);
|
||||
}, 'Test getAnimations on element with delayed animation');
|
||||
}, 'Returns animations in their delay phase');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null, 100 * MS_PER_SEC);
|
||||
|
||||
animation.finish();
|
||||
assert_array_equals(div.getAnimations(), [],
|
||||
'Animation should not be returned when it is finished');
|
||||
|
||||
animation.effect.timing.duration += 100 * MS_PER_SEC;
|
||||
assert_array_equals(div.getAnimations(), [animation],
|
||||
'Animation should be returned after extending the'
|
||||
+ ' duration');
|
||||
|
||||
animation.effect.timing.duration = 0;
|
||||
assert_array_equals(div.getAnimations(), [],
|
||||
'Animation should not be returned after setting the'
|
||||
+ ' duration to zero');
|
||||
}, 'Returns animations based on dynamic changes to individual'
|
||||
+ ' animations\' duration');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null, 100 * MS_PER_SEC);
|
||||
|
||||
animation.effect.timing.endDelay = -200 * MS_PER_SEC;
|
||||
assert_array_equals(div.getAnimations(), [],
|
||||
'Animation should not be returned after setting a'
|
||||
+ ' negative end delay such that the end time is less'
|
||||
+ ' than the current time');
|
||||
|
||||
animation.effect.timing.endDelay = 100 * MS_PER_SEC;
|
||||
assert_array_equals(div.getAnimations(), [animation],
|
||||
'Animation should be returned after setting a positive'
|
||||
+ ' end delay such that the end time is more than the'
|
||||
+ ' current time');
|
||||
}, 'Returns animations based on dynamic changes to individual'
|
||||
+ ' animations\' end delay');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null, 100 * MS_PER_SEC);
|
||||
|
||||
animation.finish();
|
||||
assert_array_equals(div.getAnimations(), [],
|
||||
'Animation should not be returned when it is finished');
|
||||
|
||||
animation.effect.timing.iterations = 10;
|
||||
assert_array_equals(div.getAnimations(), [animation],
|
||||
'Animation should be returned after inreasing the'
|
||||
+ ' number of iterations');
|
||||
|
||||
animation.effect.timing.iterations = 0;
|
||||
assert_array_equals(div.getAnimations(), [],
|
||||
'Animations should not be returned after setting the'
|
||||
+ ' iteration count to zero');
|
||||
|
||||
animation.effect.timing.iterations = Infinity;
|
||||
assert_array_equals(div.getAnimations(), [animation],
|
||||
'Animation should be returned after inreasing the'
|
||||
+ ' number of iterations to infinity');
|
||||
}, 'Returns animations based on dynamic changes to individual'
|
||||
+ ' animations\' iteration count');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const animation = div.animate(null,
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
delay: 50 * MS_PER_SEC,
|
||||
endDelay: -50 * MS_PER_SEC });
|
||||
|
||||
assert_array_equals(div.getAnimations(), [animation],
|
||||
'Animation should be returned at during delay phase');
|
||||
|
||||
animation.currentTime = 50 * MS_PER_SEC;
|
||||
assert_array_equals(div.getAnimations(), [animation],
|
||||
'Animation should be returned after seeking to the start'
|
||||
+ ' of the active interval');
|
||||
|
||||
animation.currentTime = 100 * MS_PER_SEC;
|
||||
assert_array_equals(div.getAnimations(), [],
|
||||
'Animation should not be returned after seeking to the'
|
||||
+ ' clipped end of the active interval');
|
||||
}, 'Returns animations based on dynamic changes to individual'
|
||||
+ ' animations\' current time');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
|
|
|
@ -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>
|
|
@ -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');
|
||||
|
|
|
@ -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>
|
|
@ -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,
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>delay tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-delay">
|
||||
<link rel="author" title="Daisuke Akatsuka" href="mailto:daisuke@mozilla-japan.org">
|
||||
<title>AnimationEffectTiming.delay</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-delay">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,69 +10,69 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.delay, 0);
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value 0');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
anim.effect.timing.delay = 100;
|
||||
assert_equals(anim.effect.timing.delay, 100, 'set delay 100');
|
||||
assert_equals(anim.effect.getComputedTiming().delay, 100,
|
||||
'getComputedTiming() after set delay 100');
|
||||
}, 'set delay 100');
|
||||
}, 'Can be set to a positive number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
anim.effect.timing.delay = -100;
|
||||
assert_equals(anim.effect.timing.delay, -100, 'set delay -100');
|
||||
assert_equals(anim.effect.getComputedTiming().delay, -100,
|
||||
'getComputedTiming() after set delay -100');
|
||||
}, 'set delay -100');
|
||||
}, 'Can be set to a negative number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
anim.effect.timing.delay = 100;
|
||||
assert_equals(anim.effect.getComputedTiming().progress, null);
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, null);
|
||||
}, 'Test adding a positive delay to an animation without a backwards fill ' +
|
||||
'makes it no longer active');
|
||||
}, 'Can set a positive delay on an animation without a backwards fill to'
|
||||
+ ' make it no longer active');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ fill: 'both',
|
||||
duration: 100 });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ fill: 'both',
|
||||
duration: 100 });
|
||||
anim.effect.timing.delay = -50;
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 0.5);
|
||||
}, 'Test seeking an animation by setting a negative delay');
|
||||
}, 'Can set a negative delay to seek into the active interval');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ fill: 'both',
|
||||
duration: 100 });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ fill: 'both',
|
||||
duration: 100 });
|
||||
anim.effect.timing.delay = -100;
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1);
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 0);
|
||||
}, 'Test finishing an animation using a large negative delay');
|
||||
}, 'Can set a large negative delay to finishing an animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate(null);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(null);
|
||||
for (let invalid of [NaN, Infinity]) {
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.delay = invalid;
|
||||
}, 'setting ' + invalid);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
}, `setting ${invalid}`);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({}, { delay: invalid });
|
||||
}, 'animate() with ' + invalid);
|
||||
}, `animate() with ${invalid}`);
|
||||
}
|
||||
}, 'Setting invalid values should throw TypeError');
|
||||
}, 'Throws when setting invalid values');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>direction tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-direction">
|
||||
<link rel="author" title="Ryo Kato" href="mailto:foobar094@gmail.com">
|
||||
<title>AnimationEffectTiming.direction</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-direction">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,22 +10,99 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.direction, 'normal');
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value \'normal\'');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
|
||||
var directions = ['normal', 'reverse', 'alternate', 'alternate-reverse'];
|
||||
directions.forEach(function(direction) {
|
||||
const directions = ['normal', 'reverse', 'alternate', 'alternate-reverse'];
|
||||
for (const direction of directions) {
|
||||
anim.effect.timing.direction = direction;
|
||||
assert_equals(anim.effect.timing.direction, direction,
|
||||
'set direction to ' + direction);
|
||||
});
|
||||
}, 'set direction to a valid keyword');
|
||||
`set direction to ${direction}`);
|
||||
}
|
||||
}, 'Can be set to each of the possible keywords');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(null, { duration: 10000, direction: 'normal' });
|
||||
anim.currentTime = 7000;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.7,
|
||||
'progress before updating direction');
|
||||
|
||||
anim.effect.timing.direction = 'reverse';
|
||||
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.3,
|
||||
'progress after updating direction');
|
||||
}, 'Can be changed from \'normal\' to \'reverse\' while in progress');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 10000,
|
||||
direction: 'normal' });
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 0,
|
||||
'progress before updating direction');
|
||||
|
||||
anim.effect.timing.direction = 'reverse';
|
||||
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'progress after updating direction');
|
||||
}, 'Can be changed from \'normal\' to \'reverse\' while at start of active'
|
||||
+ ' interval');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ fill: 'backwards',
|
||||
duration: 10000,
|
||||
delay: 10000,
|
||||
direction: 'normal' });
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 0,
|
||||
'progress before updating direction');
|
||||
|
||||
anim.effect.timing.direction = 'reverse';
|
||||
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'progress after updating direction');
|
||||
}, 'Can be changed from \'normal\' to \'reverse\' while filling backwards');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterations: 2,
|
||||
duration: 10000,
|
||||
direction: 'normal' });
|
||||
anim.currentTime = 17000;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.7,
|
||||
'progress before updating direction');
|
||||
|
||||
anim.effect.timing.direction = 'alternate';
|
||||
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.3,
|
||||
'progress after updating direction');
|
||||
}, 'Can be changed from \'normal\' to \'alternate\' while in progress');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterations: 2,
|
||||
duration: 10000,
|
||||
direction: 'alternate' });
|
||||
anim.currentTime = 17000;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.3,
|
||||
'progress before updating direction');
|
||||
|
||||
anim.effect.timing.direction = 'alternate-reverse';
|
||||
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.7,
|
||||
'progress after updating direction');
|
||||
}, 'Can be changed from \'alternate\' to \'alternate-reverse\' while in'
|
||||
+ ' progress');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>duration tests</title>
|
||||
<link rel="help" href="http://w3c.github.io/web-animations/#dom-animationeffecttiming-duration">
|
||||
<link rel="author" title="Ryo Motozawa" href="mailto:motozawa@mozilla-japan.org">
|
||||
<title>AnimationEffectTiming.duration</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-duration">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,148 +10,150 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.duration, 'auto');
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value \'auto\'');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.duration = 123.45;
|
||||
assert_times_equal(anim.effect.timing.duration, 123.45,
|
||||
'set duration 123.45');
|
||||
assert_times_equal(anim.effect.getComputedTiming().duration, 123.45,
|
||||
'getComputedTiming() after set duration 123.45');
|
||||
}, 'set duration 123.45');
|
||||
}, 'Can be set to a double value');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.duration = 'auto';
|
||||
assert_equals(anim.effect.timing.duration, 'auto', 'set duration \'auto\'');
|
||||
assert_equals(anim.effect.getComputedTiming().duration, 0,
|
||||
'getComputedTiming() after set duration \'auto\'');
|
||||
}, 'set duration auto');
|
||||
}, 'Can be set to the string \'auto\'');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, { duration: 'auto' });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, { duration: 'auto' });
|
||||
assert_equals(anim.effect.timing.duration, 'auto', 'set duration \'auto\'');
|
||||
assert_equals(anim.effect.getComputedTiming().duration, 0,
|
||||
'getComputedTiming() after set duration \'auto\'');
|
||||
}, 'set auto duration in animate as object');
|
||||
}, 'Can be set to \'auto\' using a dictionary object');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.duration = Infinity;
|
||||
assert_equals(anim.effect.timing.duration, Infinity, 'set duration Infinity');
|
||||
assert_equals(anim.effect.getComputedTiming().duration, Infinity,
|
||||
'getComputedTiming() after set duration Infinity');
|
||||
}, 'set duration Infinity');
|
||||
}, 'Can be set to Infinity');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, -1);
|
||||
});
|
||||
}, 'set negative duration in animate using a duration parameter');
|
||||
}, 'animate() throws when passed a negative number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, -Infinity);
|
||||
});
|
||||
}, 'set negative Infinity duration in animate using a duration parameter');
|
||||
}, 'animate() throws when passed negative Infinity');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, NaN);
|
||||
});
|
||||
}, 'set NaN duration in animate using a duration parameter');
|
||||
}, 'animate() throws when passed a NaN value');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, { duration: -1 });
|
||||
});
|
||||
}, 'set negative duration in animate using an options object');
|
||||
}, 'animate() throws when passed a negative number using a dictionary object');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, { duration: -Infinity });
|
||||
});
|
||||
}, 'set negative Infinity duration in animate using an options object');
|
||||
}, 'animate() throws when passed negative Infinity using a dictionary object');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, { duration: NaN });
|
||||
});
|
||||
}, 'set NaN duration in animate using an options object');
|
||||
}, 'animate() throws when passed a NaN value using a dictionary object');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, { duration: 'abc' });
|
||||
});
|
||||
}, 'set abc string duration in animate using an options object');
|
||||
}, 'animate() throws when passed a string other than \'auto\' using a'
|
||||
+ ' dictionary object');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({ opacity: [ 0, 1 ] }, { duration: '100' });
|
||||
});
|
||||
}, 'set 100 string duration in animate using an options object');
|
||||
}, 'animate() throws when passed a string containing a number using a'
|
||||
+ ' dictionary object');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.duration = -1;
|
||||
});
|
||||
}, 'set negative duration');
|
||||
}, 'Throws when setting a negative number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.duration = -Infinity;
|
||||
});
|
||||
}, 'set negative Infinity duration');
|
||||
}, 'Throws when setting negative infinity');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.duration = NaN;
|
||||
});
|
||||
}, 'set NaN duration');
|
||||
}, 'Throws when setting a NaN value');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.duration = 'abc';
|
||||
});
|
||||
}, 'set duration abc');
|
||||
}, 'Throws when setting a string other than \'auto\'');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.duration = '100';
|
||||
});
|
||||
}, 'set duration string 100');
|
||||
}, 'Throws when setting a string containing a number');
|
||||
|
||||
promise_test(function(t) {
|
||||
var anim = createDiv(t).animate(null, 100 * MS_PER_SEC);
|
||||
return anim.ready.then(function() {
|
||||
var originalStartTime = anim.startTime;
|
||||
var originalCurrentTime = anim.currentTime;
|
||||
promise_test(t => {
|
||||
const anim = createDiv(t).animate(null, 100 * MS_PER_SEC);
|
||||
return anim.ready.then(() => {
|
||||
const originalStartTime = anim.startTime;
|
||||
const originalCurrentTime = anim.currentTime;
|
||||
assert_equals(anim.effect.getComputedTiming().duration, 100 * MS_PER_SEC,
|
||||
'Initial duration should be as set on KeyframeEffect');
|
||||
|
||||
|
@ -168,5 +169,22 @@ promise_test(function(t) {
|
|||
});
|
||||
}, 'Extending an effect\'s duration does not change the start or current time');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(null, { duration: 100000, fill: 'both' });
|
||||
anim.finish();
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'progress when animation is finished');
|
||||
anim.effect.timing.duration *= 2;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.5,
|
||||
'progress after doubling the duration');
|
||||
anim.effect.timing.duration = 0;
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'progress after setting duration to zero');
|
||||
anim.effect.timing.duration = 'auto';
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'progress after setting duration to \'auto\'');
|
||||
}, 'Can be updated while the animation is in progress');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>easing tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-easing">
|
||||
<title>AnimationEffectTiming.easing</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-easing">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,68 +11,68 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.easing, 'linear');
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value \'linear\'');
|
||||
|
||||
function assert_progress(animation, currentTime, easingFunction) {
|
||||
animation.currentTime = currentTime;
|
||||
var portion = currentTime / animation.effect.timing.duration;
|
||||
const portion = currentTime / animation.effect.timing.duration;
|
||||
assert_approx_equals(animation.effect.getComputedTiming().progress,
|
||||
easingFunction(portion),
|
||||
0.01,
|
||||
'The progress of the animation should be approximately ' +
|
||||
easingFunction(portion) + ' at ' + currentTime + 'ms');
|
||||
'The progress of the animation should be approximately'
|
||||
+ ` ${easingFunction(portion)} at ${currentTime}ms`);
|
||||
}
|
||||
|
||||
gEasingTests.forEach(function(options) {
|
||||
test(function(t) {
|
||||
var target = createDiv(t);
|
||||
var anim = target.animate([ { opacity: 0 }, { opacity: 1 } ],
|
||||
{ duration: 1000 * MS_PER_SEC,
|
||||
fill: 'forwards' });
|
||||
for (const options of gEasingTests) {
|
||||
test(t => {
|
||||
const target = createDiv(t);
|
||||
const anim = target.animate([ { opacity: 0 }, { opacity: 1 } ],
|
||||
{ duration: 1000 * MS_PER_SEC,
|
||||
fill: 'forwards' });
|
||||
anim.effect.timing.easing = options.easing;
|
||||
assert_equals(anim.effect.timing.easing,
|
||||
options.serialization || options.easing);
|
||||
|
||||
var easing = options.easingFunction;
|
||||
const easing = options.easingFunction;
|
||||
assert_progress(anim, 0, easing);
|
||||
assert_progress(anim, 250 * MS_PER_SEC, easing);
|
||||
assert_progress(anim, 500 * MS_PER_SEC, easing);
|
||||
assert_progress(anim, 750 * MS_PER_SEC, easing);
|
||||
assert_progress(anim, 1000 * MS_PER_SEC, easing);
|
||||
}, options.desc);
|
||||
});
|
||||
}
|
||||
|
||||
gInvalidEasings.forEach(function(invalidEasing) {
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
|
||||
for (const invalidEasing of gInvalidEasings) {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 100 * MS_PER_SEC);
|
||||
assert_throws({ name: 'TypeError' },
|
||||
function() {
|
||||
() => {
|
||||
anim.effect.timing.easing = invalidEasing;
|
||||
});
|
||||
}, 'Invalid effect easing value test: \'' + invalidEasing + '\'');
|
||||
});
|
||||
}, `Throws on invalid easing: '${invalidEasing}'`);
|
||||
}
|
||||
|
||||
gRoundtripEasings.forEach(easing => {
|
||||
test(function(t) {
|
||||
for (const easing of gRoundtripEasings) {
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
anim.effect.timing.easing = easing;
|
||||
assert_equals(anim.effect.timing.easing, easing);
|
||||
}, `Canonical easing '${easing}' is returned as set`);
|
||||
});
|
||||
}
|
||||
|
||||
test(function(t) {
|
||||
var delay = 1000 * MS_PER_SEC;
|
||||
test(t => {
|
||||
const delay = 1000 * MS_PER_SEC;
|
||||
|
||||
var target = createDiv(t);
|
||||
var anim = target.animate([ { opacity: 0 }, { opacity: 1 } ],
|
||||
{ duration: 1000 * MS_PER_SEC,
|
||||
fill: 'both',
|
||||
delay: delay,
|
||||
easing: 'steps(2, start)' });
|
||||
const target = createDiv(t);
|
||||
const anim = target.animate([ { opacity: 0 }, { opacity: 1 } ],
|
||||
{ duration: 1000 * MS_PER_SEC,
|
||||
fill: 'both',
|
||||
delay: delay,
|
||||
easing: 'steps(2, start)' });
|
||||
|
||||
anim.effect.timing.easing = 'steps(2, end)';
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 0,
|
||||
|
@ -90,7 +90,7 @@ test(function(t) {
|
|||
anim.effect.timing.easing = 'steps(2, end)';
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'easing replace to steps(2, end) again at after phase');
|
||||
}, 'Change the easing while the animation is running');
|
||||
}, 'Allows the easing to be changed while the animation is in progress');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>endDelay tests</title>
|
||||
<link rel="help" href="http://w3c.github.io/web-animations/#dom-animationeffecttiming-enddelay">
|
||||
<link rel="author" title="Ryo Motozawa" href="mailto:motozawa@mozilla-japan.org">
|
||||
<title>AnimationEffectTiming.endDelay</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-enddelay">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,79 +10,80 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.endDelay, 0);
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value 0');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.endDelay = 123.45;
|
||||
assert_times_equal(anim.effect.timing.endDelay, 123.45,
|
||||
'set endDelay 123.45');
|
||||
assert_times_equal(anim.effect.getComputedTiming().endDelay, 123.45,
|
||||
'getComputedTiming() after set endDelay 123.45');
|
||||
}, 'set endDelay 123.45');
|
||||
}, 'Can be set to a positive number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.endDelay = -1000;
|
||||
assert_equals(anim.effect.timing.endDelay, -1000, 'set endDelay -1000');
|
||||
assert_equals(anim.effect.getComputedTiming().endDelay, -1000,
|
||||
'getComputedTiming() after set endDelay -1000');
|
||||
}, 'set endDelay -1000');
|
||||
}, 'Can be set to a negative number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({name: "TypeError"}, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.endDelay = Infinity;
|
||||
}, 'we can not assign Infinity to timing.endDelay');
|
||||
}, 'set endDelay Infinity');
|
||||
}, 'Throws when setting infinity');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({name: "TypeError"}, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.endDelay = -Infinity;
|
||||
}, 'we can not assign negative Infinity to timing.endDelay');
|
||||
}, 'set endDelay negative Infinity');
|
||||
}, 'Throws when setting negative infinity');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 100000, endDelay: 50000 });
|
||||
anim.onfinish = t.step_func(function(event) {
|
||||
assert_unreached('onfinish event should not be fired');
|
||||
async_test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 100000, endDelay: 50000 });
|
||||
anim.onfinish = t.step_func(event => {
|
||||
assert_unreached('finish event should not be fired');
|
||||
});
|
||||
|
||||
anim.ready.then(function() {
|
||||
anim.ready.then(() => {
|
||||
anim.currentTime = 100000;
|
||||
return waitForAnimationFrames(2);
|
||||
}).then(t.step_func(function() {
|
||||
}).then(t.step_func(() => {
|
||||
t.done();
|
||||
}));
|
||||
}, 'onfinish event is not fired duration endDelay');
|
||||
}, 'finish event is not fired at the end of the active interval when the'
|
||||
+ ' endDelay has not expired');
|
||||
|
||||
async_test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 100000, endDelay: 30000 });
|
||||
anim.ready.then(function() {
|
||||
async_test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 100000, endDelay: 30000 });
|
||||
anim.ready.then(() => {
|
||||
anim.currentTime = 110000; // during endDelay
|
||||
anim.onfinish = t.step_func(function(event) {
|
||||
anim.onfinish = t.step_func(event => {
|
||||
assert_unreached('onfinish event should not be fired during endDelay');
|
||||
});
|
||||
return waitForAnimationFrames(2);
|
||||
}).then(t.step_func(function() {
|
||||
anim.onfinish = t.step_func(function(event) {
|
||||
}).then(t.step_func(() => {
|
||||
anim.onfinish = t.step_func(event => {
|
||||
t.done();
|
||||
});
|
||||
anim.currentTime = 130000; // after endTime
|
||||
}));
|
||||
}, 'onfinish event is fired currentTime is after endTime');
|
||||
}, 'finish event is fired after the endDelay has expired');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>fill tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-fill">
|
||||
<title>AnimationEffectTiming.fill</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-fill">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -10,20 +10,21 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.fill, 'auto');
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value \'auto\'');
|
||||
|
||||
["none", "forwards", "backwards", "both", ].forEach(function(fill){
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
for (const fill of ['none', 'forwards', 'backwards', 'both']) {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 100);
|
||||
anim.effect.timing.fill = fill;
|
||||
assert_equals(anim.effect.timing.fill, fill, 'set fill ' + fill);
|
||||
assert_equals(anim.effect.getComputedTiming().fill, fill, 'getComputedTiming() after set fill ' + fill);
|
||||
}, 'set fill ' + fill);
|
||||
});
|
||||
assert_equals(anim.effect.getComputedTiming().fill, fill,
|
||||
'getComputedTiming() after set fill ' + fill);
|
||||
}, `Can set fill to ${fill}`);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Element.getAnimations tests</title>
|
||||
<link rel="help" href="http://w3c.github.io/web-animations/#animationeffecttiming">
|
||||
<link rel="author" title="Ryo Motozawa" href="mailto:motozawa@mozilla-japan.org">
|
||||
<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';
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.finish();
|
||||
assert_equals(div.getAnimations().length, 0, 'animation finished');
|
||||
anim.effect.timing.duration += 100000;
|
||||
assert_equals(div.getAnimations()[0], anim, 'set duration 102000');
|
||||
anim.effect.timing.duration = 0;
|
||||
assert_equals(div.getAnimations().length, 0, 'set duration 0');
|
||||
anim.effect.timing.duration = 'auto';
|
||||
assert_equals(div.getAnimations().length, 0, 'set duration \'auto\'');
|
||||
}, 'when duration is changed');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
|
||||
anim.effect.timing.endDelay = -3000;
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'set negative endDelay so as endTime is less than currentTime');
|
||||
anim.effect.timing.endDelay = 1000;
|
||||
assert_equals(div.getAnimations()[0], anim,
|
||||
'set positive endDelay so as endTime is more than currentTime');
|
||||
|
||||
anim.effect.timing.duration = 1000;
|
||||
anim.currentTime = 1500;
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'set currentTime less than endTime');
|
||||
anim.effect.timing.endDelay = -500;
|
||||
anim.currentTime = 400;
|
||||
assert_equals(div.getAnimations()[0], anim,
|
||||
'set currentTime less than endTime when endDelay is negative value');
|
||||
anim.currentTime = 500;
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'set currentTime same as endTime when endDelay is negative value');
|
||||
anim.currentTime = 1000;
|
||||
assert_equals(div.getAnimations().length, 0,
|
||||
'set currentTime same as duration when endDelay is negative value');
|
||||
}, 'when endDelay is changed');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.finish();
|
||||
assert_equals(div.getAnimations().length, 0, 'animation finished');
|
||||
anim.effect.timing.iterations = 10;
|
||||
assert_equals(div.getAnimations()[0], anim, 'set iterations 10');
|
||||
anim.effect.timing.iterations = 0;
|
||||
assert_equals(div.getAnimations().length, 0, 'set iterations 0');
|
||||
anim.effect.timing.iterations = Infinity;
|
||||
assert_equals(div.getAnimations().length, 1, 'set iterations Infinity');
|
||||
}, 'when iterations is changed');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 1000, delay: 500, endDelay: -500 });
|
||||
assert_equals(div.getAnimations()[0], anim, 'when currentTime 0');
|
||||
anim.currentTime = 500;
|
||||
assert_equals(div.getAnimations()[0], anim, 'set currentTime 500');
|
||||
anim.currentTime = 1000;
|
||||
assert_equals(div.getAnimations().length, 0, 'set currentTime 1000');
|
||||
}, 'when currentTime changed in duration:1000, delay: 500, endDelay: -500');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 1000, delay: -500, endDelay: -500 });
|
||||
assert_equals(div.getAnimations().length, 0, 'when currentTime 0');
|
||||
anim.currentTime = 500;
|
||||
assert_equals(div.getAnimations().length, 0, 'set currentTime 500');
|
||||
anim.currentTime = 1000;
|
||||
assert_equals(div.getAnimations().length, 0, 'set currentTime 1000');
|
||||
}, 'when currentTime changed in duration:1000, delay: -500, endDelay: -500');
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -1,172 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>getComputedStyle tests</title>
|
||||
<link rel="help" href="http://w3c.github.io/web-animations/#animationeffecttiming">
|
||||
<link rel="author" title="Ryo Motozawa" href="mailto:motozawa@mozilla-japan.org">
|
||||
<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';
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100000);
|
||||
anim.finish();
|
||||
assert_equals(getComputedStyle(div).opacity, '1', 'animation finished');
|
||||
anim.effect.timing.duration *= 2;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.5', 'set double duration');
|
||||
anim.effect.timing.duration = 0;
|
||||
assert_equals(getComputedStyle(div).opacity, '1', 'set duration 0');
|
||||
anim.effect.timing.duration = 'auto';
|
||||
assert_equals(getComputedStyle(div).opacity, '1', 'set duration \'auto\'');
|
||||
}, 'changed duration immediately updates its computed styles');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 100000);
|
||||
anim.finish();
|
||||
assert_equals(getComputedStyle(div).opacity, '1', 'animation finished');
|
||||
anim.effect.timing.iterations = 2;
|
||||
assert_equals(getComputedStyle(div).opacity, '0', 'set 2 iterations');
|
||||
anim.effect.timing.iterations = 0;
|
||||
assert_equals(getComputedStyle(div).opacity, '1', 'set iterations 0');
|
||||
anim.effect.timing.iterations = Infinity;
|
||||
assert_equals(getComputedStyle(div).opacity, '0', 'set iterations Infinity');
|
||||
}, 'changed iterations immediately updates its computed styles');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 1, 0 ] },
|
||||
{ duration: 10000, endDelay: 1000, fill: 'none' });
|
||||
|
||||
anim.currentTime = 9000;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.1',
|
||||
'set currentTime during duration');
|
||||
|
||||
anim.currentTime = 10900;
|
||||
assert_equals(getComputedStyle(div).opacity, '1',
|
||||
'set currentTime during endDelay');
|
||||
|
||||
anim.currentTime = 11100;
|
||||
assert_equals(getComputedStyle(div).opacity, '1',
|
||||
'set currentTime after endDelay');
|
||||
}, 'change currentTime when fill is none and endDelay is positive');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 1, 0 ] },
|
||||
{ duration: 10000,
|
||||
endDelay: 1000,
|
||||
fill: 'forwards' });
|
||||
anim.currentTime = 5000;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.5',
|
||||
'set currentTime during duration');
|
||||
|
||||
anim.currentTime = 9999;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.0001',
|
||||
'set currentTime just a little before duration');
|
||||
|
||||
anim.currentTime = 10900;
|
||||
assert_equals(getComputedStyle(div).opacity, '0',
|
||||
'set currentTime during endDelay');
|
||||
|
||||
anim.currentTime = 11100;
|
||||
assert_equals(getComputedStyle(div).opacity, '0',
|
||||
'set currentTime after endDelay');
|
||||
}, 'change currentTime when fill forwards and endDelay is positive');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 1, 0 ] },
|
||||
{ duration: 10000, endDelay: -5000, fill: 'none' });
|
||||
|
||||
anim.currentTime = 1000;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.9',
|
||||
'set currentTime before endTime');
|
||||
|
||||
anim.currentTime = 10000;
|
||||
assert_equals(getComputedStyle(div).opacity, '1',
|
||||
'set currentTime after endTime');
|
||||
}, 'change currentTime when fill none and endDelay is negative');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 1, 0 ] },
|
||||
{ duration: 10000,
|
||||
endDelay: -5000,
|
||||
fill: 'forwards' });
|
||||
|
||||
anim.currentTime = 1000;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.9',
|
||||
'set currentTime before endTime');
|
||||
|
||||
anim.currentTime = 5000;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.5',
|
||||
'set currentTime same as endTime');
|
||||
|
||||
anim.currentTime = 10000;
|
||||
assert_equals(getComputedStyle(div).opacity, '0',
|
||||
'set currentTime after endTime');
|
||||
}, 'change currentTime when fill forwards and endDelay is negative');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ duration: 10000,
|
||||
direction: 'normal' });
|
||||
|
||||
anim.currentTime = 7000;
|
||||
anim.effect.timing.direction = 'reverse';
|
||||
|
||||
assert_equals(getComputedStyle(div).opacity, '0.3',
|
||||
'change direction from "normal" to "reverse"');
|
||||
}, 'change direction from "normal" to "reverse"');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterations: 2,
|
||||
duration: 10000,
|
||||
direction: 'normal' });
|
||||
|
||||
anim.currentTime = 17000;
|
||||
anim.effect.timing.direction = 'alternate';
|
||||
|
||||
assert_equals(getComputedStyle(div).opacity, '0.3',
|
||||
'change direction from "normal" to "alternate"');
|
||||
}, 'change direction from "normal" to "alternate"');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterations: 2,
|
||||
duration: 10000,
|
||||
direction: 'normal' });
|
||||
|
||||
anim.currentTime = 17000;
|
||||
anim.effect.timing.direction = 'alternate-reverse';
|
||||
|
||||
assert_equals(getComputedStyle(div).opacity, '0.7',
|
||||
'change direction from "normal" to "alternate-reverse"');
|
||||
}, 'change direction from "normal" to "alternate-reverse"');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ fill: 'backwards',
|
||||
duration: 10000,
|
||||
direction: 'normal' });
|
||||
|
||||
// test for a flip of value at the currentTime = 0
|
||||
anim.effect.timing.direction = 'reverse';
|
||||
|
||||
assert_equals(getComputedStyle(div).opacity, '1',
|
||||
'change direction from "normal" to "reverse" ' +
|
||||
'at the starting point');
|
||||
}, 'change direction from "normal" to "reverse" when currentTime is 0');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -0,0 +1,201 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>AnimationEffectTiming.getComputedTiming</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffectreadonly-getcomputedtiming">
|
||||
<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';
|
||||
|
||||
test(t => {
|
||||
const effect = new KeyframeEffect(null, null);
|
||||
|
||||
const ct = effect.getComputedTiming();
|
||||
assert_equals(ct.delay, 0, 'computed delay');
|
||||
assert_equals(ct.fill, 'none', 'computed fill');
|
||||
assert_equals(ct.iterations, 1.0, 'computed iterations');
|
||||
assert_equals(ct.duration, 0, 'computed duration');
|
||||
assert_equals(ct.direction, 'normal', 'computed direction');
|
||||
}, 'values of getComputedTiming() when a KeyframeEffect is ' +
|
||||
'constructed without any KeyframeEffectOptions object');
|
||||
|
||||
const gGetComputedTimingTests = [
|
||||
{ desc: 'an empty KeyframeEffectOptions object',
|
||||
input: { },
|
||||
expected: { } },
|
||||
{ desc: 'a normal KeyframeEffectOptions object',
|
||||
input: { delay: 1000,
|
||||
fill: 'auto',
|
||||
iterations: 5.5,
|
||||
duration: 'auto',
|
||||
direction: 'alternate' },
|
||||
expected: { delay: 1000,
|
||||
fill: 'none',
|
||||
iterations: 5.5,
|
||||
duration: 0,
|
||||
direction: 'alternate' } },
|
||||
{ desc: 'a double value',
|
||||
input: 3000,
|
||||
timing: { duration: 3000 },
|
||||
expected: { delay: 0,
|
||||
fill: 'none',
|
||||
iterations: 1,
|
||||
duration: 3000,
|
||||
direction: 'normal' } },
|
||||
{ desc: '+Infinity',
|
||||
input: Infinity,
|
||||
expected: { duration: Infinity } },
|
||||
{ desc: 'an Infinity duration',
|
||||
input: { duration: Infinity },
|
||||
expected: { duration: Infinity } },
|
||||
{ desc: 'an auto duration',
|
||||
input: { duration: 'auto' },
|
||||
expected: { duration: 0 } },
|
||||
{ desc: 'an Infinity iterations',
|
||||
input: { iterations: Infinity },
|
||||
expected: { iterations: Infinity } },
|
||||
{ desc: 'an auto fill',
|
||||
input: { fill: 'auto' },
|
||||
expected: { fill: 'none' } },
|
||||
{ desc: 'a forwards fill',
|
||||
input: { fill: 'forwards' },
|
||||
expected: { fill: 'forwards' } }
|
||||
];
|
||||
|
||||
for (const stest of gGetComputedTimingTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffect(null, null, stest.input);
|
||||
|
||||
// Helper function to provide default expected values when the test does
|
||||
// not supply them.
|
||||
const expected = (field, defaultValue) => {
|
||||
return field in stest.expected ? stest.expected[field] : defaultValue;
|
||||
};
|
||||
|
||||
const ct = effect.getComputedTiming();
|
||||
assert_equals(ct.delay, expected('delay', 0),
|
||||
'computed delay');
|
||||
assert_equals(ct.fill, expected('fill', 'none'),
|
||||
'computed fill');
|
||||
assert_equals(ct.iterations, expected('iterations', 1),
|
||||
'computed iterations');
|
||||
assert_equals(ct.duration, expected('duration', 0),
|
||||
'computed duration');
|
||||
assert_equals(ct.direction, expected('direction', 'normal'),
|
||||
'computed direction');
|
||||
|
||||
}, 'values of getComputedTiming() when a KeyframeEffect is'
|
||||
+ ` constructed by ${stest.desc}`);
|
||||
}
|
||||
|
||||
const gActiveDurationTests = [
|
||||
{ desc: 'an empty KeyframeEffectOptions object',
|
||||
input: { },
|
||||
expected: 0 },
|
||||
{ desc: 'a non-zero duration and default iteration count',
|
||||
input: { duration: 1000 },
|
||||
expected: 1000 },
|
||||
{ desc: 'a non-zero duration and integral iteration count',
|
||||
input: { duration: 1000, iterations: 7 },
|
||||
expected: 7000 },
|
||||
{ desc: 'a non-zero duration and fractional iteration count',
|
||||
input: { duration: 1000, iterations: 2.5 },
|
||||
expected: 2500 },
|
||||
{ desc: 'an non-zero duration and infinite iteration count',
|
||||
input: { duration: 1000, iterations: Infinity },
|
||||
expected: Infinity },
|
||||
{ desc: 'an non-zero duration and zero iteration count',
|
||||
input: { duration: 1000, iterations: 0 },
|
||||
expected: 0 },
|
||||
{ desc: 'a zero duration and default iteration count',
|
||||
input: { duration: 0 },
|
||||
expected: 0 },
|
||||
{ desc: 'a zero duration and fractional iteration count',
|
||||
input: { duration: 0, iterations: 2.5 },
|
||||
expected: 0 },
|
||||
{ desc: 'a zero duration and infinite iteration count',
|
||||
input: { duration: 0, iterations: Infinity },
|
||||
expected: 0 },
|
||||
{ desc: 'a zero duration and zero iteration count',
|
||||
input: { duration: 0, iterations: 0 },
|
||||
expected: 0 },
|
||||
{ desc: 'an infinite duration and default iteration count',
|
||||
input: { duration: Infinity },
|
||||
expected: Infinity },
|
||||
{ desc: 'an infinite duration and zero iteration count',
|
||||
input: { duration: Infinity, iterations: 0 },
|
||||
expected: 0 },
|
||||
{ desc: 'an infinite duration and fractional iteration count',
|
||||
input: { duration: Infinity, iterations: 2.5 },
|
||||
expected: Infinity },
|
||||
{ desc: 'an infinite duration and infinite iteration count',
|
||||
input: { duration: Infinity, iterations: Infinity },
|
||||
expected: Infinity },
|
||||
];
|
||||
|
||||
for (const stest of gActiveDurationTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffect(null, null, stest.input);
|
||||
|
||||
assert_equals(effect.getComputedTiming().activeDuration,
|
||||
stest.expected);
|
||||
|
||||
}, `getComputedTiming().activeDuration for ${stest.desc}`);
|
||||
}
|
||||
|
||||
const gEndTimeTests = [
|
||||
{ desc: 'an empty KeyframeEffectOptions object',
|
||||
input: { },
|
||||
expected: 0 },
|
||||
{ desc: 'a non-zero duration and default iteration count',
|
||||
input: { duration: 1000 },
|
||||
expected: 1000 },
|
||||
{ desc: 'a non-zero duration and non-default iteration count',
|
||||
input: { duration: 1000, iterations: 2.5 },
|
||||
expected: 2500 },
|
||||
{ desc: 'a non-zero duration and non-zero delay',
|
||||
input: { duration: 1000, delay: 1500 },
|
||||
expected: 2500 },
|
||||
{ desc: 'a non-zero duration, non-zero delay and non-default iteration',
|
||||
input: { duration: 1000, delay: 1500, iterations: 2 },
|
||||
expected: 3500 },
|
||||
{ desc: 'an infinite iteration count',
|
||||
input: { duration: 1000, iterations: Infinity },
|
||||
expected: Infinity },
|
||||
{ desc: 'an infinite duration',
|
||||
input: { duration: Infinity, iterations: 10 },
|
||||
expected: Infinity },
|
||||
{ desc: 'an infinite duration and delay',
|
||||
input: { duration: Infinity, iterations: 10, delay: 1000 },
|
||||
expected: Infinity },
|
||||
{ desc: 'an infinite duration and negative delay',
|
||||
input: { duration: Infinity, iterations: 10, delay: -1000 },
|
||||
expected: Infinity },
|
||||
{ desc: 'an non-zero duration and negative delay',
|
||||
input: { duration: 1000, iterations: 2, delay: -1000 },
|
||||
expected: 1000 },
|
||||
{ desc: 'an non-zero duration and negative delay greater than active ' +
|
||||
'duration',
|
||||
input: { duration: 1000, iterations: 2, delay: -3000 },
|
||||
expected: 0 },
|
||||
{ desc: 'a zero duration and negative delay',
|
||||
input: { duration: 0, iterations: 2, delay: -1000 },
|
||||
expected: 0 }
|
||||
];
|
||||
|
||||
for (const stest of gEndTimeTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffect(null, null, stest.input);
|
||||
|
||||
assert_equals(effect.getComputedTiming().endTime,
|
||||
stest.expected);
|
||||
|
||||
}, `getComputedTiming().endTime for ${stest.desc}`);
|
||||
}
|
||||
|
||||
done();
|
||||
</script>
|
||||
</body>
|
|
@ -2,9 +2,9 @@
|
|||
<meta charset=utf-8>
|
||||
<title>AnimationEffectTiming and AnimationEffectTimingReadOnly IDL</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#animationeffecttiming">
|
||||
href="https://drafts.csswg.org/web-animations/#animationeffecttiming">
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#animationeffecttimingreadonly">
|
||||
href="https://drafts.csswg.org/web-animations/#animationeffecttimingreadonly">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>iterationStart tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-iterationstart">
|
||||
<link rel="author" title="Daisuke Akatsuka" href="mailto:daisuke@mozilla-japan.org">
|
||||
<title>AnimationEffectTiming.iterationStart</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-iterationstart">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,66 +10,63 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.iterationStart, 0);
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value 0');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterationStart: 0.2,
|
||||
iterations: 1,
|
||||
fill: 'both',
|
||||
duration: 100,
|
||||
delay: 1 });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterationStart: 0.2,
|
||||
iterations: 1,
|
||||
fill: 'both',
|
||||
duration: 100,
|
||||
delay: 1 });
|
||||
anim.effect.timing.iterationStart = 2.5;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
|
||||
}, 'Test that changing the iterationStart affects computed timing ' +
|
||||
'when backwards-filling');
|
||||
}, 'Changing the value updates computed timing when backwards-filling');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterationStart: 0.2,
|
||||
iterations: 1,
|
||||
fill: 'both',
|
||||
duration: 100,
|
||||
delay: 0 });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterationStart: 0.2,
|
||||
iterations: 1,
|
||||
fill: 'both',
|
||||
duration: 100,
|
||||
delay: 0 });
|
||||
anim.effect.timing.iterationStart = 2.5;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 2);
|
||||
}, 'Test that changing the iterationStart affects computed timing ' +
|
||||
'during the active phase');
|
||||
}, 'Changing the value updates computed timing during the active phase');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterationStart: 0.2,
|
||||
iterations: 1,
|
||||
fill: 'both',
|
||||
duration: 100,
|
||||
delay: 0 });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] },
|
||||
{ iterationStart: 0.2,
|
||||
iterations: 1,
|
||||
fill: 'both',
|
||||
duration: 100,
|
||||
delay: 0 });
|
||||
anim.finish();
|
||||
anim.effect.timing.iterationStart = 2.5;
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0.5);
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 3);
|
||||
}, 'Test that changing the iterationStart affects computed timing ' +
|
||||
'when forwards-filling');
|
||||
}, 'Changing the value updates computed timing when forwards-filling');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate(null);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(null);
|
||||
for (let invalid of [-1, NaN, Infinity]) {
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.iterationStart = invalid;
|
||||
}, 'setting ' + invalid);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
}, `setting ${invalid}`);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
div.animate({}, { iterationStart: invalid });
|
||||
}, 'animate() with ' + invalid);
|
||||
}, `animate() with ${invalid}`);
|
||||
}
|
||||
}, 'Using invalid values should throw TypeError');
|
||||
}, 'Throws when setting invalid values');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>iterations tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffecttiming-iterations">
|
||||
<title>AnimationEffectTiming.iterations</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-animationeffecttiming-iterations">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -10,52 +10,85 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.timing.iterations, 1);
|
||||
}, 'Test default value');
|
||||
}, 'Has the default value 1');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.iterations = 2;
|
||||
assert_equals(anim.effect.timing.iterations, 2, 'set duration 2');
|
||||
assert_equals(anim.effect.getComputedTiming().iterations, 2,
|
||||
'getComputedTiming() after set iterations 2');
|
||||
}, 'set iterations 2');
|
||||
}, 'Can be set to a double value');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
anim.effect.timing.iterations = Infinity;
|
||||
assert_equals(anim.effect.timing.iterations, Infinity, 'set duration Infinity');
|
||||
assert_equals(anim.effect.getComputedTiming().iterations, Infinity,
|
||||
'getComputedTiming() after set iterations Infinity');
|
||||
}, 'set iterations Infinity');
|
||||
}, 'Can be set to infinity');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.iterations = -1;
|
||||
});
|
||||
}, 'set negative iterations');
|
||||
}, 'Throws when setting a negative number');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.iterations = -Infinity;
|
||||
});
|
||||
}, 'set negative infinity iterations ');
|
||||
}, 'Throws when setting negative infinity');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, function() {
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ opacity: [ 0, 1 ] }, 2000);
|
||||
assert_throws({ name: 'TypeError' }, () => {
|
||||
anim.effect.timing.iterations = NaN;
|
||||
});
|
||||
}, 'set NaN iterations');
|
||||
}, 'Throws when setting a NaN value');
|
||||
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate(null, { duration: 100000, fill: 'both' });
|
||||
|
||||
anim.finish();
|
||||
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 1,
|
||||
'progress when animation is finished');
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 0,
|
||||
'current iteration when animation is finished');
|
||||
|
||||
anim.effect.timing.iterations = 2;
|
||||
|
||||
assert_times_equal(anim.effect.getComputedTiming().progress, 0,
|
||||
'progress after adding an iteration');
|
||||
assert_times_equal(anim.effect.getComputedTiming().currentIteration, 1,
|
||||
'current iteration after adding an iteration');
|
||||
|
||||
anim.effect.timing.iterations = 0;
|
||||
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 0,
|
||||
'progress after setting iterations to zero');
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 0,
|
||||
'current iteration after setting iterations to zero');
|
||||
|
||||
anim.effect.timing.iterations = Infinity;
|
||||
|
||||
assert_equals(anim.effect.getComputedTiming().progress, 0,
|
||||
'progress after setting iterations to Infinity');
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 1,
|
||||
'current iteration after setting iterations to Infinity');
|
||||
}, 'Can be updated while the animation is in progress');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -2,21 +2,21 @@
|
|||
<meta charset=utf-8>
|
||||
<title>AnimationPlaybackEvent constructor</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-animationplaybackevent-animationplaybackevent">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-animationplaybackevent-animationplaybackevent">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<div id="log"></div>
|
||||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const evt = new AnimationPlaybackEvent('finish');
|
||||
assert_equals(evt.type, 'finish');
|
||||
assert_equals(evt.currentTime, null);
|
||||
assert_equals(evt.timelineTime, null);
|
||||
}, 'Event created without an event parameter has null time values');
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const evt =
|
||||
new AnimationPlaybackEvent('cancel', {
|
||||
currentTime: -100,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<meta charset=utf-8>
|
||||
<title>AnimationPlaybackEvent IDL</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#animationplaybackevent">
|
||||
href="https://drafts.csswg.org/web-animations/#animationplaybackevent">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>document.getAnimations tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-document-getanimations">
|
||||
<title>Document.getAnimations</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-document-getanimations">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -9,20 +9,20 @@
|
|||
<div id="log"></div>
|
||||
<div id="target"></div>
|
||||
<script>
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
var gKeyFrames = { 'marginLeft': ['100px', '200px'] };
|
||||
const gKeyFrames = { 'marginLeft': ['100px', '200px'] };
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
assert_equals(document.getAnimations().length, 0,
|
||||
'getAnimations returns an empty sequence for a document ' +
|
||||
'with no animations');
|
||||
}, 'Test document.getAnimations for non-animated content');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim1 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
var anim2 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim1 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
const anim2 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
assert_equals(document.getAnimations().length, 2,
|
||||
'getAnimation returns running animations');
|
||||
|
||||
|
@ -32,18 +32,18 @@ test(function(t) {
|
|||
'getAnimation only returns running animations');
|
||||
}, 'Test document.getAnimations for script-generated animations')
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim1 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
var anim2 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim1 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
const anim2 = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
assert_array_equals(document.getAnimations(),
|
||||
[ anim1, anim2 ],
|
||||
'getAnimations() returns running animations');
|
||||
}, 'Test the order of document.getAnimations with script generated animations')
|
||||
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
|
||||
var anim = new Animation(effect, document.timeline);
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(null, gKeyFrames, 100 * MS_PER_SEC);
|
||||
const anim = new Animation(effect, document.timeline);
|
||||
anim.play();
|
||||
|
||||
assert_equals(document.getAnimations().length, 0,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>Document.timeline</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-document-timeline">
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-document-timeline">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -10,7 +10,7 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function() {
|
||||
test(() => {
|
||||
assert_equals(document.timeline, document.timeline,
|
||||
'Document.timeline returns the same object every time');
|
||||
const iframe = document.getElementById('iframe');
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>DocumentTimeline constructor tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#the-documenttimeline-interface">
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#the-documenttimeline-interface">
|
||||
<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 timeline = new DocumentTimeline();
|
||||
test(t => {
|
||||
const timeline = new DocumentTimeline();
|
||||
|
||||
assert_times_equal(timeline.currentTime, document.timeline.currentTime);
|
||||
}, 'An origin time of zero is used when none is supplied');
|
||||
|
||||
test(function(t) {
|
||||
var timeline = new DocumentTimeline({ originTime: 0 });
|
||||
test(t => {
|
||||
const timeline = new DocumentTimeline({ originTime: 0 });
|
||||
assert_times_equal(timeline.currentTime, document.timeline.currentTime);
|
||||
}, 'A zero origin time produces a document timeline with a current time ' +
|
||||
'identical to the default document timeline');
|
||||
|
||||
test(function(t) {
|
||||
var timeline = new DocumentTimeline({ originTime: 10 * MS_PER_SEC });
|
||||
test(t => {
|
||||
const timeline = new DocumentTimeline({ originTime: 10 * MS_PER_SEC });
|
||||
|
||||
assert_times_equal(timeline.currentTime,
|
||||
(document.timeline.currentTime - 10 * MS_PER_SEC));
|
||||
}, 'A positive origin time makes the document timeline\'s current time lag ' +
|
||||
'behind the default document timeline');
|
||||
|
||||
test(function(t) {
|
||||
var timeline = new DocumentTimeline({ originTime: -10 * MS_PER_SEC });
|
||||
test(t => {
|
||||
const timeline = new DocumentTimeline({ originTime: -10 * MS_PER_SEC });
|
||||
|
||||
assert_times_equal(timeline.currentTime,
|
||||
(document.timeline.currentTime + 10 * MS_PER_SEC));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>DocumentTimeline IDL</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#documenttimeline">
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#documenttimeline">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>KeyframeEffect.composite tests</title>
|
||||
<title>KeyframeEffect.composite</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-keyframeeffect-composite">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-composite">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -11,34 +11,34 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
assert_equals(anim.effect.composite, 'replace',
|
||||
'The default value should be replace');
|
||||
}, 'Default value');
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate(null);
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate(null);
|
||||
anim.effect.composite = 'add';
|
||||
assert_equals(anim.effect.composite, 'add',
|
||||
'The effect composite value should be replaced');
|
||||
}, 'Change composite value');
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate({ left: '10px' });
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate({ left: '10px' });
|
||||
|
||||
anim.effect.composite = 'add';
|
||||
var keyframes = anim.effect.getKeyframes();
|
||||
const keyframes = anim.effect.getKeyframes();
|
||||
assert_equals(keyframes[0].composite, undefined,
|
||||
'unspecified keyframe composite value should be absent even ' +
|
||||
'if effect composite is set');
|
||||
}, 'Unspecified keyframe composite value when setting effect composite');
|
||||
|
||||
test(function(t) {
|
||||
var anim = createDiv(t).animate({ left: '10px', composite: 'replace' });
|
||||
test(t => {
|
||||
const anim = createDiv(t).animate({ left: '10px', composite: 'replace' });
|
||||
|
||||
anim.effect.composite = 'add';
|
||||
var keyframes = anim.effect.getKeyframes();
|
||||
const keyframes = anim.effect.getKeyframes();
|
||||
assert_equals(keyframes[0].composite, 'replace',
|
||||
'specified keyframe composite value should not be overridden ' +
|
||||
'by setting effect composite');
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<meta charset=utf-8>
|
||||
<title>KeyframeEffect and KeyframeEffectReadOnly constructor</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-keyframeeffect-keyframeeffect">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-keyframeeffect">
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-keyframeeffectreadonly-keyframeeffectreadonly">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-keyframeeffectreadonly-keyframeeffectreadonly">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -19,16 +19,16 @@
|
|||
|
||||
const target = document.getElementById('target');
|
||||
|
||||
test(function(t) {
|
||||
gEmptyKeyframeListTests.forEach(function(frames) {
|
||||
test(t => {
|
||||
for (const frames of gEmptyKeyframeListTests) {
|
||||
assert_equals(new KeyframeEffectReadOnly(target, frames)
|
||||
.getKeyframes().length,
|
||||
0, 'number of frames for ' + JSON.stringify(frames));
|
||||
});
|
||||
0, `number of frames for ${JSON.stringify(frames)}`);
|
||||
}
|
||||
}, 'A KeyframeEffectReadOnly can be constructed with no frames');
|
||||
|
||||
test(function(t) {
|
||||
gEasingParsingTests.forEach(function(subtest) {
|
||||
test(t => {
|
||||
for (const subtest of gEasingParsingTests) {
|
||||
const easing = subtest[0];
|
||||
const expected = subtest[1];
|
||||
const effect = new KeyframeEffectReadOnly(target, {
|
||||
|
@ -36,98 +36,96 @@ test(function(t) {
|
|||
}, { easing: easing });
|
||||
assert_equals(effect.timing.easing, expected,
|
||||
`resulting easing for '${easing}'`);
|
||||
});
|
||||
}
|
||||
}, 'easing values are parsed correctly when passed to the ' +
|
||||
'KeyframeEffectReadOnly constructor in KeyframeEffectOptions');
|
||||
|
||||
test(function(t) {
|
||||
gInvalidEasings.forEach(invalidEasing => {
|
||||
test(t => {
|
||||
for (const invalidEasing of gInvalidEasings) {
|
||||
assert_throws(new TypeError, () => {
|
||||
new KeyframeEffectReadOnly(target, null, { easing: invalidEasing });
|
||||
}, `TypeError is thrown for easing '${invalidEasing}'`);
|
||||
});
|
||||
}
|
||||
}, 'Invalid easing values are correctly rejected when passed to the ' +
|
||||
'KeyframeEffectReadOnly constructor in KeyframeEffectOptions');
|
||||
|
||||
test(function(t) {
|
||||
const getKeyframe = function(composite) {
|
||||
return { left: [ '10px', '20px' ], composite: composite };
|
||||
};
|
||||
gGoodKeyframeCompositeValueTests.forEach(function(composite) {
|
||||
test(t => {
|
||||
const getKeyframe =
|
||||
composite => ({ left: [ '10px', '20px' ], composite: composite });
|
||||
for (const composite of gGoodKeyframeCompositeValueTests) {
|
||||
const effect = new KeyframeEffectReadOnly(target, getKeyframe(composite));
|
||||
assert_equals(effect.getKeyframes()[0].composite, composite,
|
||||
`resulting composite for '${composite}'`);
|
||||
});
|
||||
gBadCompositeValueTests.forEach(function(composite) {
|
||||
assert_throws(new TypeError, function() {
|
||||
}
|
||||
for (const composite of gBadCompositeValueTests) {
|
||||
assert_throws(new TypeError, () => {
|
||||
new KeyframeEffectReadOnly(target, getKeyframe(composite));
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 'composite values are parsed correctly when passed to the ' +
|
||||
'KeyframeEffectReadOnly constructor in property-indexed keyframes');
|
||||
|
||||
test(function(t) {
|
||||
const getKeyframes = function(composite) {
|
||||
return [
|
||||
test(t => {
|
||||
const getKeyframes = composite =>
|
||||
[
|
||||
{ offset: 0, left: '10px', composite: composite },
|
||||
{ offset: 1, left: '20px' }
|
||||
];
|
||||
};
|
||||
gGoodKeyframeCompositeValueTests.forEach(function(composite) {
|
||||
for (const composite of gGoodKeyframeCompositeValueTests) {
|
||||
const effect = new KeyframeEffectReadOnly(target, getKeyframes(composite));
|
||||
assert_equals(effect.getKeyframes()[0].composite, composite,
|
||||
`resulting composite for '${composite}'`);
|
||||
});
|
||||
gBadCompositeValueTests.forEach(function(composite) {
|
||||
assert_throws(new TypeError, function() {
|
||||
}
|
||||
for (const composite of gBadCompositeValueTests) {
|
||||
assert_throws(new TypeError, () => {
|
||||
new KeyframeEffectReadOnly(target, getKeyframes(composite));
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 'composite values are parsed correctly when passed to the ' +
|
||||
'KeyframeEffectReadOnly constructor in regular keyframes');
|
||||
|
||||
test(function(t) {
|
||||
gGoodOptionsCompositeValueTests.forEach(function(composite) {
|
||||
test(t => {
|
||||
for (const composite of gGoodOptionsCompositeValueTests) {
|
||||
const effect = new KeyframeEffectReadOnly(target, {
|
||||
left: ['10px', '20px']
|
||||
}, { composite: composite });
|
||||
assert_equals(effect.getKeyframes()[0].composite, undefined,
|
||||
`resulting composite for '${composite}'`);
|
||||
});
|
||||
gBadCompositeValueTests.forEach(function(composite) {
|
||||
assert_throws(new TypeError, function() {
|
||||
}
|
||||
for (const composite of gBadCompositeValueTests) {
|
||||
assert_throws(new TypeError, () => {
|
||||
new KeyframeEffectReadOnly(target, {
|
||||
left: ['10px', '20px']
|
||||
}, { composite: composite });
|
||||
});
|
||||
});
|
||||
}
|
||||
}, 'composite value is absent if the composite operation specified on the ' +
|
||||
'keyframe effect is being used');
|
||||
|
||||
gKeyframesTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
for (const subtest of gKeyframesTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(target, subtest.input);
|
||||
assert_frame_lists_equal(effect.getKeyframes(), subtest.output);
|
||||
}, `A KeyframeEffectReadOnly can be constructed with ${subtest.desc}`);
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(target, subtest.input);
|
||||
const secondEffect =
|
||||
new KeyframeEffectReadOnly(target, effect.getKeyframes());
|
||||
assert_frame_lists_equal(secondEffect.getKeyframes(),
|
||||
effect.getKeyframes());
|
||||
}, `A KeyframeEffectReadOnly constructed with ${subtest.desc} roundtrips`);
|
||||
});
|
||||
}
|
||||
|
||||
gInvalidKeyframesTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
assert_throws(new TypeError, function() {
|
||||
for (const subtest of gInvalidKeyframesTests) {
|
||||
test(t => {
|
||||
assert_throws(new TypeError, () => {
|
||||
new KeyframeEffectReadOnly(target, subtest.input);
|
||||
});
|
||||
}, `KeyframeEffectReadOnly constructor throws with ${subtest.desc}`);
|
||||
});
|
||||
}
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(target,
|
||||
{ left: ['10px', '20px'] });
|
||||
|
||||
|
@ -147,8 +145,8 @@ test(function(t) {
|
|||
}, 'A KeyframeEffectReadOnly constructed without any ' +
|
||||
'KeyframeEffectOptions object');
|
||||
|
||||
gKeyframeEffectOptionTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
for (const subtest of gKeyframeEffectOptionTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(target,
|
||||
{ left: ['10px', '20px'] },
|
||||
subtest.input);
|
||||
|
@ -172,19 +170,19 @@ gKeyframeEffectOptionTests.forEach(function(subtest) {
|
|||
'timing direction');
|
||||
|
||||
}, `A KeyframeEffectReadOnly constructed by ${subtest.desc}`);
|
||||
});
|
||||
}
|
||||
|
||||
gInvalidKeyframeEffectOptionTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
assert_throws(new TypeError, function() {
|
||||
for (const subtest of gInvalidKeyframeEffectOptionTests) {
|
||||
test(t => {
|
||||
assert_throws(new TypeError, () => {
|
||||
new KeyframeEffectReadOnly(target,
|
||||
{ left: ['10px', '20px'] },
|
||||
subtest.input);
|
||||
});
|
||||
}, `Invalid KeyframeEffectReadOnly option by ${subtest.desc}`);
|
||||
});
|
||||
}
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(null,
|
||||
{ left: ['10px', '20px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
|
@ -193,10 +191,10 @@ test(function(t) {
|
|||
'Effect created with null target has correct target');
|
||||
}, 'A KeyframeEffectReadOnly constructed with null target');
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const test_error = { name: 'test' };
|
||||
|
||||
assert_throws(test_error, function() {
|
||||
assert_throws(test_error, () => {
|
||||
new KeyframeEffect(target, { get left() { throw test_error }})
|
||||
});
|
||||
}, 'KeyframeEffect constructor propagates exceptions generated by accessing'
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
<meta charset=utf-8>
|
||||
<title>KeyframeEffect and KeyframeEffectReadOnly copy constructor</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-keyframeeffect-keyframeeffect-source">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-keyframeeffect-source">
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-keyframeeffectreadonly-keyframeeffectreadonly-source">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-keyframeeffectreadonly-keyframeeffectreadonly-source">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -13,13 +13,13 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(createDiv(t), null);
|
||||
const copiedEffect = new KeyframeEffectReadOnly(effect);
|
||||
assert_equals(copiedEffect.target, effect.target, 'same target');
|
||||
}, 'Copied KeyframeEffectReadOnly has the same target');
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect =
|
||||
new KeyframeEffectReadOnly(null,
|
||||
[ { marginLeft: '0px' },
|
||||
|
@ -52,7 +52,7 @@ test(function(t) {
|
|||
}
|
||||
}, 'Copied KeyframeEffectReadOnly has the same keyframes');
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect =
|
||||
new KeyframeEffectReadOnly(null, null,
|
||||
{ iterationComposite: 'accumulate' });
|
||||
|
@ -64,7 +64,7 @@ test(function(t) {
|
|||
'same compositeOperation');
|
||||
}, 'Copied KeyframeEffectReadOnly has the same KeyframeEffectOptions');
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(null, null,
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
delay: -1 * MS_PER_SEC,
|
||||
|
@ -90,7 +90,7 @@ test(function(t) {
|
|||
assert_equals(timingA.easing, timingB.easing, 'same easing');
|
||||
}, 'Copied KeyframeEffectReadOnly has the same timing content');
|
||||
|
||||
test(function(t) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffectReadOnly(createDiv(t), null);
|
||||
assert_equals(effect.constructor.name, 'KeyframeEffectReadOnly');
|
||||
assert_equals(effect.timing.constructor.name,
|
||||
|
|
|
@ -1,212 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>KeyframeEffectReadOnly getComputedTiming() tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-animationeffectreadonly-getcomputedtiming">
|
||||
<link rel="author" title="Boris Chiou" href="mailto:boris.chiou@gmail.com">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
<body>
|
||||
<div id="log"></div>
|
||||
<div id="target"></div>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
var target = document.getElementById("target");
|
||||
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffectReadOnly(target,
|
||||
{ left: ["10px", "20px"] });
|
||||
|
||||
var ct = effect.getComputedTiming();
|
||||
assert_equals(ct.delay, 0, "computed delay");
|
||||
assert_equals(ct.fill, "none", "computed fill");
|
||||
assert_equals(ct.iterations, 1.0, "computed iterations");
|
||||
assert_equals(ct.duration, 0, "computed duration");
|
||||
assert_equals(ct.direction, "normal", "computed direction");
|
||||
}, "values of getComputedTiming() when a KeyframeEffectReadOnly is " +
|
||||
"constructed without any KeyframeEffectOptions object");
|
||||
|
||||
var gGetComputedTimingTests = [
|
||||
{ desc: "an empty KeyframeEffectOptions object",
|
||||
input: { },
|
||||
expected: { } },
|
||||
{ desc: "a normal KeyframeEffectOptions object",
|
||||
input: { delay: 1000,
|
||||
fill: "auto",
|
||||
iterations: 5.5,
|
||||
duration: "auto",
|
||||
direction: "alternate" },
|
||||
expected: { delay: 1000,
|
||||
fill: "none",
|
||||
iterations: 5.5,
|
||||
duration: 0,
|
||||
direction: "alternate" } },
|
||||
{ desc: "a double value",
|
||||
input: 3000,
|
||||
timing: { duration: 3000 },
|
||||
expected: { delay: 0,
|
||||
fill: "none",
|
||||
iterations: 1,
|
||||
duration: 3000,
|
||||
direction: "normal" } },
|
||||
{ desc: "+Infinity",
|
||||
input: Infinity,
|
||||
expected: { duration: Infinity } },
|
||||
{ desc: "an Infinity duration",
|
||||
input: { duration: Infinity },
|
||||
expected: { duration: Infinity } },
|
||||
{ desc: "an auto duration",
|
||||
input: { duration: "auto" },
|
||||
expected: { duration: 0 } },
|
||||
{ desc: "an Infinity iterations",
|
||||
input: { iterations: Infinity },
|
||||
expected: { iterations: Infinity } },
|
||||
{ desc: "an auto fill",
|
||||
input: { fill: "auto" },
|
||||
expected: { fill: "none" } },
|
||||
{ desc: "a forwards fill",
|
||||
input: { fill: "forwards" },
|
||||
expected: { fill: "forwards" } }
|
||||
];
|
||||
|
||||
gGetComputedTimingTests.forEach(function(stest) {
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffectReadOnly(target,
|
||||
{ left: ["10px", "20px"] },
|
||||
stest.input);
|
||||
|
||||
// Helper function to provide default expected values when the test does
|
||||
// not supply them.
|
||||
var expected = function(field, defaultValue) {
|
||||
return field in stest.expected ? stest.expected[field] : defaultValue;
|
||||
};
|
||||
|
||||
var ct = effect.getComputedTiming();
|
||||
assert_equals(ct.delay, expected("delay", 0),
|
||||
"computed delay");
|
||||
assert_equals(ct.fill, expected("fill", "none"),
|
||||
"computed fill");
|
||||
assert_equals(ct.iterations, expected("iterations", 1),
|
||||
"computed iterations");
|
||||
assert_equals(ct.duration, expected("duration", 0),
|
||||
"computed duration");
|
||||
assert_equals(ct.direction, expected("direction", "normal"),
|
||||
"computed direction");
|
||||
|
||||
}, "values of getComputedTiming() when a KeyframeEffectReadOnly is " +
|
||||
"constructed by " + stest.desc);
|
||||
});
|
||||
|
||||
var gActiveDurationTests = [
|
||||
{ desc: "an empty KeyframeEffectOptions object",
|
||||
input: { },
|
||||
expected: 0 },
|
||||
{ desc: "a non-zero duration and default iteration count",
|
||||
input: { duration: 1000 },
|
||||
expected: 1000 },
|
||||
{ desc: "a non-zero duration and integral iteration count",
|
||||
input: { duration: 1000, iterations: 7 },
|
||||
expected: 7000 },
|
||||
{ desc: "a non-zero duration and fractional iteration count",
|
||||
input: { duration: 1000, iterations: 2.5 },
|
||||
expected: 2500 },
|
||||
{ desc: "an non-zero duration and infinite iteration count",
|
||||
input: { duration: 1000, iterations: Infinity },
|
||||
expected: Infinity },
|
||||
{ desc: "an non-zero duration and zero iteration count",
|
||||
input: { duration: 1000, iterations: 0 },
|
||||
expected: 0 },
|
||||
{ desc: "a zero duration and default iteration count",
|
||||
input: { duration: 0 },
|
||||
expected: 0 },
|
||||
{ desc: "a zero duration and fractional iteration count",
|
||||
input: { duration: 0, iterations: 2.5 },
|
||||
expected: 0 },
|
||||
{ desc: "a zero duration and infinite iteration count",
|
||||
input: { duration: 0, iterations: Infinity },
|
||||
expected: 0 },
|
||||
{ desc: "a zero duration and zero iteration count",
|
||||
input: { duration: 0, iterations: 0 },
|
||||
expected: 0 },
|
||||
{ desc: "an infinite duration and default iteration count",
|
||||
input: { duration: Infinity },
|
||||
expected: Infinity },
|
||||
{ desc: "an infinite duration and zero iteration count",
|
||||
input: { duration: Infinity, iterations: 0 },
|
||||
expected: 0 },
|
||||
{ desc: "an infinite duration and fractional iteration count",
|
||||
input: { duration: Infinity, iterations: 2.5 },
|
||||
expected: Infinity },
|
||||
{ desc: "an infinite duration and infinite iteration count",
|
||||
input: { duration: Infinity, iterations: Infinity },
|
||||
expected: Infinity },
|
||||
];
|
||||
|
||||
gActiveDurationTests.forEach(function(stest) {
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffectReadOnly(target,
|
||||
{ left: ["10px", "20px"] },
|
||||
stest.input);
|
||||
|
||||
assert_equals(effect.getComputedTiming().activeDuration,
|
||||
stest.expected);
|
||||
|
||||
}, "getComputedTiming().activeDuration for " + stest.desc);
|
||||
});
|
||||
|
||||
var gEndTimeTests = [
|
||||
{ desc: "an empty KeyframeEffectOptions object",
|
||||
input: { },
|
||||
expected: 0 },
|
||||
{ desc: "a non-zero duration and default iteration count",
|
||||
input: { duration: 1000 },
|
||||
expected: 1000 },
|
||||
{ desc: "a non-zero duration and non-default iteration count",
|
||||
input: { duration: 1000, iterations: 2.5 },
|
||||
expected: 2500 },
|
||||
{ desc: "a non-zero duration and non-zero delay",
|
||||
input: { duration: 1000, delay: 1500 },
|
||||
expected: 2500 },
|
||||
{ desc: "a non-zero duration, non-zero delay and non-default iteration",
|
||||
input: { duration: 1000, delay: 1500, iterations: 2 },
|
||||
expected: 3500 },
|
||||
{ desc: "an infinite iteration count",
|
||||
input: { duration: 1000, iterations: Infinity },
|
||||
expected: Infinity },
|
||||
{ desc: "an infinite duration",
|
||||
input: { duration: Infinity, iterations: 10 },
|
||||
expected: Infinity },
|
||||
{ desc: "an infinite duration and delay",
|
||||
input: { duration: Infinity, iterations: 10, delay: 1000 },
|
||||
expected: Infinity },
|
||||
{ desc: "an infinite duration and negative delay",
|
||||
input: { duration: Infinity, iterations: 10, delay: -1000 },
|
||||
expected: Infinity },
|
||||
{ desc: "an non-zero duration and negative delay",
|
||||
input: { duration: 1000, iterations: 2, delay: -1000 },
|
||||
expected: 1000 },
|
||||
{ desc: "an non-zero duration and negative delay greater than active " +
|
||||
"duration",
|
||||
input: { duration: 1000, iterations: 2, delay: -3000 },
|
||||
expected: 0 },
|
||||
{ desc: "a zero duration and negative delay",
|
||||
input: { duration: 0, iterations: 2, delay: -1000 },
|
||||
expected: 0 }
|
||||
];
|
||||
|
||||
gEndTimeTests.forEach(function(stest) {
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffectReadOnly(target,
|
||||
{ left: ["10px", "20px"] },
|
||||
stest.input);
|
||||
|
||||
assert_equals(effect.getComputedTiming().endTime,
|
||||
stest.expected);
|
||||
|
||||
}, "getComputedTiming().endTime for " + stest.desc);
|
||||
});
|
||||
|
||||
done();
|
||||
</script>
|
||||
</body>
|
|
@ -1,9 +1,9 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>KeyframeEffect IDL</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#keyframeeffect">
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#keyframeeffect">
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#keyframeeffectreadonly">
|
||||
href="https://drafts.csswg.org/web-animations/#keyframeeffectreadonly">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="/resources/WebIDLParser.js"></script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title>KeyframeEffect.iterationComposite tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#effect-accumulation-section">
|
||||
<title>KeyframeEffect.iterationComposite</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-iterationcomposite">
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -9,792 +9,13 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ alignContent: ['flex-start', 'flex-end'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).alignContent, 'flex-end',
|
||||
'Animated align-content style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).alignContent, 'flex-start',
|
||||
'Animated align-content style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).alignContent, 'flex-end',
|
||||
'Animated align-content style at 50s of the third iteration');
|
||||
}, 'iterationComposite of discrete type animation (align-content)');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ marginLeft: ['0px', '10px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '5px',
|
||||
'Animated margin-left style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '20px',
|
||||
'Animated margin-left style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '25px',
|
||||
'Animated margin-left style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <length> type animation');
|
||||
|
||||
test(function(t) {
|
||||
var parent = createDiv(t);
|
||||
parent.style.width = '100px';
|
||||
var div = createDiv(t);
|
||||
parent.appendChild(div);
|
||||
|
||||
var anim =
|
||||
div.animate({ width: ['0%', '50%'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).width, '25px',
|
||||
'Animated width style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).width, '100px',
|
||||
'Animated width style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).width, '125px',
|
||||
'Animated width style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <percentage> type animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ color: ['rgb(0, 0, 0)', 'rgb(120, 120, 120)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).color, 'rgb(60, 60, 60)',
|
||||
'Animated color style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).color, 'rgb(240, 240, 240)',
|
||||
'Animated color style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).color, 'rgb(255, 255, 255)',
|
||||
'Animated color style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <color> type animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ color: ['rgb(0, 120, 0)', 'rgb(60, 60, 60)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).color, 'rgb(30, 90, 30)',
|
||||
'Animated color style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).color, 'rgb(120, 240, 120)',
|
||||
'Animated color style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
// The green color is (240 + 180) / 2 = 210
|
||||
assert_equals(getComputedStyle(div).color, 'rgb(150, 210, 150)',
|
||||
'Animated color style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <color> type animation that green component is ' +
|
||||
'decreasing');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ flexGrow: [0, 10] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).flexGrow, '5',
|
||||
'Animated flex-grow style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).flexGrow, '20',
|
||||
'Animated flex-grow style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).flexGrow, '25',
|
||||
'Animated flex-grow style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <number> type animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
div.style.position = 'absolute';
|
||||
var anim =
|
||||
div.animate({ clip: ['rect(0px, 0px, 0px, 0px)',
|
||||
'rect(10px, 10px, 10px, 10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).clip, 'rect(5px, 5px, 5px, 5px)',
|
||||
'Animated clip style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).clip, 'rect(20px, 20px, 20px, 20px)',
|
||||
'Animated clip style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).clip, 'rect(25px, 25px, 25px, 25px)',
|
||||
'Animated clip style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <shape> type animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ width: ['calc(0vw + 0px)', 'calc(0vw + 10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).width, '5px',
|
||||
'Animated calc width style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).width, '20px',
|
||||
'Animated calc width style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).width, '25px',
|
||||
'Animated calc width style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <calc()> value animation');
|
||||
|
||||
test(function(t) {
|
||||
var parent = createDiv(t);
|
||||
parent.style.width = '100px';
|
||||
var div = createDiv(t);
|
||||
parent.appendChild(div);
|
||||
|
||||
var anim =
|
||||
div.animate({ width: ['calc(0% + 0px)', 'calc(10% + 10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).width, '10px',
|
||||
// 100px * 5% + 5px
|
||||
'Animated calc width style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).width,
|
||||
'40px', // 100px * (10% + 10%) + (10px + 10px)
|
||||
'Animated calc width style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).width,
|
||||
'50px', // (40px + 60px) / 2
|
||||
'Animated calc width style at 50s of the third iteration');
|
||||
}, 'iterationComposite of <calc()> value animation that the values can\'t' +
|
||||
'be reduced');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ opacity: [0, 0.4] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.2',
|
||||
'Animated opacity style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).opacity, '0.8',
|
||||
'Animated opacity style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).opacity, '1', // (0.8 + 1.2) * 0.5
|
||||
'Animated opacity style at 50s of the third iteration');
|
||||
}, 'iterationComposite of opacity animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ boxShadow: ['rgb(0, 0, 0) 0px 0px 0px 0px',
|
||||
'rgb(120, 120, 120) 10px 10px 10px 0px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).boxShadow,
|
||||
'rgb(60, 60, 60) 5px 5px 5px 0px',
|
||||
'Animated box-shadow style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).boxShadow,
|
||||
'rgb(240, 240, 240) 20px 20px 20px 0px',
|
||||
'Animated box-shadow style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).boxShadow,
|
||||
'rgb(255, 255, 255) 25px 25px 25px 0px',
|
||||
'Animated box-shadow style at 50s of the third iteration');
|
||||
}, 'iterationComposite of box-shadow animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['blur(0px)', 'blur(10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter, 'blur(5px)',
|
||||
'Animated filter blur style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter, 'blur(20px)',
|
||||
'Animated filter blur style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter, 'blur(25px)',
|
||||
'Animated filter blur style at 50s of the third iteration');
|
||||
}, 'iterationComposite of filter blur animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['brightness(1)',
|
||||
'brightness(180%)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(1.4)',
|
||||
'Animated filter brightness style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(2.6)', // brightness(1) + brightness(0.8) + brightness(0.8)
|
||||
'Animated filter brightness style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(3)', // (brightness(2.6) + brightness(3.4)) * 0.5
|
||||
'Animated filter brightness style at 50s of the third iteration');
|
||||
}, 'iterationComposite of filter brightness for different unit animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['brightness(0)',
|
||||
'brightness(1)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(0.5)',
|
||||
'Animated filter brightness style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(0)', // brightness(1) is an identity element, not accumulated.
|
||||
'Animated filter brightness style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(0.5)', // brightness(1) is an identity element, not accumulated.
|
||||
'Animated filter brightness style at 50s of the third iteration');
|
||||
}, 'iterationComposite of filter brightness animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['drop-shadow(rgb(0, 0, 0) 0px 0px 0px)',
|
||||
'drop-shadow(rgb(120, 120, 120) 10px 10px 10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'drop-shadow(rgb(60, 60, 60) 5px 5px 5px)',
|
||||
'Animated filter drop-shadow style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'drop-shadow(rgb(240, 240, 240) 20px 20px 20px)',
|
||||
'Animated filter drop-shadow style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'drop-shadow(rgb(255, 255, 255) 25px 25px 25px)',
|
||||
'Animated filter drop-shadow style at 50s of the third iteration');
|
||||
}, 'iterationComposite of filter drop-shadow animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['brightness(1) contrast(1)',
|
||||
'brightness(2) contrast(2)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(1.5) contrast(1.5)',
|
||||
'Animated filter list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(3) contrast(3)',
|
||||
'Animated filter list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'brightness(3.5) contrast(3.5)',
|
||||
'Animated filter list at 50s of the third iteration');
|
||||
}, 'iterationComposite of same filter list animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['brightness(1) contrast(1)',
|
||||
'contrast(2) brightness(2)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'contrast(2) brightness(2)', // discrete
|
||||
'Animated filter list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
// We can't accumulate 'contrast(2) brightness(2)' onto
|
||||
// the first list 'brightness(1) contrast(1)' because of
|
||||
// mismatch of the order.
|
||||
'brightness(1) contrast(1)',
|
||||
'Animated filter list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
// We *can* accumulate 'contrast(2) brightness(2)' onto
|
||||
// the same list 'contrast(2) brightness(2)' here.
|
||||
'contrast(4) brightness(4)', // discrete
|
||||
'Animated filter list at 50s of the third iteration');
|
||||
}, 'iterationComposite of discrete filter list because of mismatch ' +
|
||||
'of the order');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ filter: ['sepia(0)',
|
||||
'sepia(1) contrast(2)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'sepia(0.5) contrast(1.5)',
|
||||
'Animated filter list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'sepia(2) contrast(3)',
|
||||
'Animated filter list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).filter,
|
||||
'sepia(2.5) contrast(3.5)',
|
||||
'Animated filter list at 50s of the third iteration');
|
||||
}, 'iterationComposite of different length filter list animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['rotate(0deg)', 'rotate(180deg)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0, 1, -1, 0, 0, 0)', // rotate(90deg)
|
||||
'Animated transform(rotate) style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(1, 0, 0, 1, 0, 0)', // rotate(360deg)
|
||||
'Animated transform(rotate) style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0, 1, -1, 0, 0, 0)', // rotate(450deg)
|
||||
'Animated transform(rotate) style at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform(rotate) animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['scale(0)', 'scale(1)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0.5, 0, 0, 0.5, 0, 0)', // scale(0.5)
|
||||
'Animated transform(scale) style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0, 0, 0, 0, 0, 0)', // scale(0); scale(1) is an identity element,
|
||||
// not accumulated.
|
||||
'Animated transform(scale) style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0.5, 0, 0, 0.5, 0, 0)', // scale(0.5); scale(1) an identity
|
||||
// element, not accumulated.
|
||||
'Animated transform(scale) style at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform: [ scale(0), scale(1) ] animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['scale(1)', 'scale(2)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(1.5, 0, 0, 1.5, 0, 0)', // scale(1.5)
|
||||
'Animated transform(scale) style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(3, 0, 0, 3, 0, 0)', // scale(1 + (2 -1) + (2 -1))
|
||||
'Animated transform(scale) style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(3.5, 0, 0, 3.5, 0, 0)', // (scale(3) + scale(4)) * 0.5
|
||||
'Animated transform(scale) style at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform: [ scale(1), scale(2) ] animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['scale(0)', 'scale(2)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(1, 0, 0, 1, 0, 0)', // scale(1)
|
||||
'Animated transform(scale) style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(2, 0, 0, 2, 0, 0)', // (scale(0) + scale(2-1)*2)
|
||||
'Animated transform(scale) style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(3, 0, 0, 3, 0, 0)', // (scale(2) + scale(4)) * 0.5
|
||||
'Animated transform(scale) style at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform: scale(2) animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['rotate(0deg) translateX(0px)',
|
||||
'rotate(180deg) translateX(10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0, 1, -1, 0, 0, 5)', // rotate(90deg) translateX(5px)
|
||||
'Animated transform list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(1, 0, 0, 1, 20, 0)', // rotate(360deg) translateX(20px)
|
||||
'Animated transform list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(0, 1, -1, 0, 0, 25)', // rotate(450deg) translateX(25px)
|
||||
'Animated transform list at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform list animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['matrix(2, 0, 0, 2, 0, 0)',
|
||||
'matrix(3, 0, 0, 3, 30, 0)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(2.5, 0, 0, 2.5, 15, 0)',
|
||||
'Animated transform of matrix function at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// scale(2) + (scale(3-1)*2) + translateX(30px)*2
|
||||
'matrix(6, 0, 0, 6, 60, 0)',
|
||||
'Animated transform of matrix function at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// from: matrix(6, 0, 0, 6, 60, 0)
|
||||
// to: matrix(7, 0, 0, 7, 90, 0)
|
||||
// = scale(3) + (scale(3-1)*2) + translateX(30px)*3
|
||||
'matrix(6.5, 0, 0, 6.5, 75, 0)',
|
||||
'Animated transform of matrix function at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform of matrix function');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['translateX(0px) scale(2)',
|
||||
'scale(3) translateX(10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// Interpolate between matrix(2, 0, 0, 2, 0, 0) = translateX(0px) scale(2)
|
||||
// and matrix(3, 0, 0, 3, 30, 0) = scale(3) translateX(10px)
|
||||
'matrix(2.5, 0, 0, 2.5, 15, 0)',
|
||||
'Animated transform list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// 'from' and 'to' value are mismatched, so accumulate
|
||||
// matrix(2, 0, 0, 2, 0, 0) onto matrix(3, 0, 0, 3, 30, 0) * 2
|
||||
// = scale(2) + (scale(3-1)*2) + translateX(30px)*2
|
||||
'matrix(6, 0, 0, 6, 60, 0)',
|
||||
'Animated transform list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// Interpolate between matrix(6, 0, 0, 6, 60, 0)
|
||||
// and matrix(7, 0, 0, 7, 210, 0) = scale(7) translate(30px)
|
||||
'matrix(6.5, 0, 0, 6.5, 135, 0)',
|
||||
'Animated transform list at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform list animation whose order is mismatched');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
// Even if each transform list does not have functions which exist in
|
||||
// other pair of the list, we don't fill any missing functions at all.
|
||||
var anim =
|
||||
div.animate({ transform: ['translateX(0px)',
|
||||
'scale(2) translateX(10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// Interpolate between matrix(1, 0, 0, 1, 0, 0) = translateX(0px)
|
||||
// and matrix(2, 0, 0, 2, 20, 0) = scale(2) translateX(10px)
|
||||
'matrix(1.5, 0, 0, 1.5, 10, 0)',
|
||||
'Animated transform list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// 'from' and 'to' value are mismatched, so accumulate
|
||||
// matrix(1, 0, 0, 1, 0, 0) onto matrix(2, 0, 0, 2, 20, 0) * 2
|
||||
// = scale(1) + (scale(2-1)*2) + translateX(20px)*2
|
||||
'matrix(3, 0, 0, 3, 40, 0)',
|
||||
'Animated transform list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// Interpolate between matrix(3, 0, 0, 3, 40, 0)
|
||||
// and matrix(4, 0, 0, 4, 120, 0) =
|
||||
// scale(2 + (2-1)*2) translate(10px * 3)
|
||||
'matrix(3.5, 0, 0, 3.5, 80, 0)',
|
||||
'Animated transform list at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform list animation whose order is mismatched ' +
|
||||
'because of missing functions');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['none',
|
||||
'translateX(10px)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// translateX(none) -> translateX(10px) @ 50%
|
||||
'matrix(1, 0, 0, 1, 5, 0)',
|
||||
'Animated transform list at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// translateX(10px * 2 + none) -> translateX(10px * 2 + 10px) @ 0%
|
||||
'matrix(1, 0, 0, 1, 20, 0)',
|
||||
'Animated transform list at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// translateX(10px * 2 + none) -> translateX(10px * 2 + 10px) @ 50%
|
||||
'matrix(1, 0, 0, 1, 25, 0)',
|
||||
'Animated transform list at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform from none to translate');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['matrix3d(1, 0, 0, 0, ' +
|
||||
'0, 1, 0, 0, ' +
|
||||
'0, 0, 1, 0, ' +
|
||||
'0, 0, 30, 1)',
|
||||
'matrix3d(1, 0, 0, 0, ' +
|
||||
'0, 1, 0, 0, ' +
|
||||
'0, 0, 1, 0, ' +
|
||||
'0, 0, 50, 1)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 40, 1)',
|
||||
'Animated transform of matrix3d function at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// translateZ(30px) + (translateZ(50px)*2)
|
||||
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 130, 1)',
|
||||
'Animated transform of matrix3d function at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
// from: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 130, 1)
|
||||
// to: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 150, 1)
|
||||
'matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 140, 1)',
|
||||
'Animated transform of matrix3d function at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform of matrix3d function');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ transform: ['rotate3d(1, 1, 0, 0deg)',
|
||||
'rotate3d(1, 1, 0, 90deg)'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = 0;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
'matrix(1, 0, 0, 1, 0, 0)', // Actually not rotated at all.
|
||||
'Animated transform of rotate3d function at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
rotate3dToMatrix3d(1, 1, 0, Math.PI), // 180deg
|
||||
'Animated transform of rotate3d function at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_matrix_equals(getComputedStyle(div).transform,
|
||||
rotate3dToMatrix3d(1, 1, 0, 225 * Math.PI / 180), //((270 + 180) * 0.5)deg
|
||||
'Animated transform of rotate3d function at 50s of the third iteration');
|
||||
}, 'iterationComposite of transform of rotate3d function');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ marginLeft: ['10px', '20px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '15px',
|
||||
'Animated margin-left style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '50px', // 10px + 20px + 20px
|
||||
'Animated margin-left style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '55px', // (50px + 60px) * 0.5
|
||||
'Animated margin-left style at 50s of the third iteration');
|
||||
}, 'iterationComposite starts with non-zero value animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim =
|
||||
div.animate({ marginLeft: ['10px', '-10px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime = anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft,
|
||||
'0px',
|
||||
'Animated margin-left style at 50s of the first iteration');
|
||||
anim.currentTime = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft,
|
||||
'-10px', // 10px + -10px + -10px
|
||||
'Animated margin-left style at 0s of the third iteration');
|
||||
anim.currentTime += anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft,
|
||||
'-20px', // (-10px + -30px) * 0.5
|
||||
'Animated margin-left style at 50s of the third iteration');
|
||||
}, 'iterationComposite with negative final value animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ marginLeft: ['0px', '10px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const anim = div.animate({ marginLeft: ['0px', '10px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime =
|
||||
|
@ -809,31 +30,6 @@ test(function(t) {
|
|||
anim.effect.iterationComposite = 'accumulate';
|
||||
assert_equals(getComputedStyle(div).marginLeft, '25px',
|
||||
'Animated style at 50s of the third iteration');
|
||||
}, 'interationComposite changes');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var anim = div.animate({ marginLeft: ['0px', '10px'] },
|
||||
{ duration: 100 * MS_PER_SEC,
|
||||
easing: 'linear',
|
||||
iterations: 10,
|
||||
iterationComposite: 'accumulate' });
|
||||
anim.pause();
|
||||
|
||||
anim.currentTime =
|
||||
anim.effect.timing.duration * 2 + anim.effect.timing.duration / 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '25px',
|
||||
'Animated style at 50s of the third iteration');
|
||||
|
||||
// double its duration.
|
||||
anim.effect.timing.duration = anim.effect.timing.duration * 2;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '12.5px',
|
||||
'Animated style at 25s of the first iteration');
|
||||
|
||||
// half of original.
|
||||
anim.effect.timing.duration = anim.effect.timing.duration / 4;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '50px',
|
||||
'Animated style at 50s of the fourth iteration');
|
||||
}, 'duration changes with iterationComposite(accumulate)');
|
||||
}, 'iterationComposite can be updated while an animation is in progress');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Tests for processing a keyframes argument (property access)</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#processing-a-keyframes-argument">
|
||||
<title>Processing a keyframes argument (property access)</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -201,7 +201,7 @@ test(() => {
|
|||
{ offset: null, computedOffset: 0.5, easing: 'linear', left: '300px' },
|
||||
{ offset: null, computedOffset: 1, easing: 'linear', left: '200px' },
|
||||
]);
|
||||
}, "'easing' and 'offset' are ignored on iterable objects");
|
||||
}, '\'easing\' and \'offset\' are ignored on iterable objects');
|
||||
|
||||
test(() => {
|
||||
const effect = new KeyframeEffect(null, createIterable([
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Tests for processing a keyframes argument (easing)</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#processing-a-keyframes-argument">
|
||||
<title>Processing a keyframes argument (easing)</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#processing-a-keyframes-argument">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>KeyframeEffect setKeyframes() tests</title>
|
||||
<link rel="help" href="https://w3c.github.io/web-animations/#dom-keyframeeffect-setkeyframes">
|
||||
<title>KeyframeEffect.setKeyframes</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-setkeyframes">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="../../testcommon.js"></script>
|
||||
|
@ -13,31 +13,31 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
var target = document.getElementById('target');
|
||||
const target = document.getElementById('target');
|
||||
|
||||
test(function(t) {
|
||||
gEmptyKeyframeListTests.forEach(function(frame) {
|
||||
var effect = new KeyframeEffect(target, {});
|
||||
test(t => {
|
||||
for (const frame of gEmptyKeyframeListTests) {
|
||||
const effect = new KeyframeEffect(target, {});
|
||||
effect.setKeyframes(frame);
|
||||
assert_frame_lists_equal(effect.getKeyframes(), []);
|
||||
});
|
||||
}
|
||||
}, 'Keyframes can be replaced with an empty keyframe');
|
||||
|
||||
gKeyframesTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffect(target, {});
|
||||
for (const subtest of gKeyframesTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffect(target, {});
|
||||
effect.setKeyframes(subtest.input);
|
||||
assert_frame_lists_equal(effect.getKeyframes(), subtest.output);
|
||||
}, 'Keyframes can be replaced with ' + subtest.desc);
|
||||
});
|
||||
}, `Keyframes can be replaced with ${subtest.desc}`);
|
||||
}
|
||||
|
||||
gInvalidKeyframesTests.forEach(function(subtest) {
|
||||
test(function(t) {
|
||||
var effect = new KeyframeEffect(target, {});
|
||||
assert_throws(new TypeError, function() {
|
||||
for (const subtest of gInvalidKeyframesTests) {
|
||||
test(t => {
|
||||
const effect = new KeyframeEffect(target, {});
|
||||
assert_throws(new TypeError, () => {
|
||||
effect.setKeyframes(subtest.input);
|
||||
});
|
||||
}, 'KeyframeEffect constructor throws with ' + subtest.desc);
|
||||
});
|
||||
}, `KeyframeEffect constructor throws with ${subtest.desc}`);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Writable effect.target tests</title>
|
||||
<title>KeyframeEffect.target</title>
|
||||
<link rel="help"
|
||||
href="https://w3c.github.io/web-animations/#dom-keyframeeffect-target">
|
||||
href="https://drafts.csswg.org/web-animations/#dom-keyframeeffect-target">
|
||||
<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';
|
||||
|
||||
var gKeyFrames = { 'marginLeft': ['0px', '100px'] };
|
||||
const gKeyFrames = { 'marginLeft': ['0px', '100px'] };
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
var effect = new KeyframeEffect(null, gKeyFrames, 100 * MS_PER_SEC);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
const effect = new KeyframeEffect(null, gKeyFrames, 100 * MS_PER_SEC);
|
||||
effect.target = div;
|
||||
|
||||
var anim = new Animation(effect, document.timeline);
|
||||
const anim = new Animation(effect, document.timeline);
|
||||
anim.play();
|
||||
|
||||
anim.currentTime = 50 * MS_PER_SEC;
|
||||
|
@ -26,11 +26,11 @@ test(function(t) {
|
|||
'Value at 50% progress');
|
||||
}, 'Test setting target before constructing the associated animation');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
div.style.marginLeft = '10px';
|
||||
var effect = new KeyframeEffect(null, gKeyFrames, 100 * MS_PER_SEC);
|
||||
var anim = new Animation(effect, document.timeline);
|
||||
const effect = new KeyframeEffect(null, gKeyFrames, 100 * MS_PER_SEC);
|
||||
const anim = new Animation(effect, document.timeline);
|
||||
anim.play();
|
||||
|
||||
anim.currentTime = 50 * MS_PER_SEC;
|
||||
|
@ -41,10 +41,10 @@ test(function(t) {
|
|||
'Value at 50% progress after setting new target');
|
||||
}, 'Test setting target from null to a valid target');
|
||||
|
||||
test(function(t) {
|
||||
var div = createDiv(t);
|
||||
test(t => {
|
||||
const div = createDiv(t);
|
||||
div.style.marginLeft = '10px';
|
||||
var anim = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
const anim = div.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
|
||||
anim.currentTime = 50 * MS_PER_SEC;
|
||||
assert_equals(getComputedStyle(div).marginLeft, '50px',
|
||||
|
@ -55,12 +55,12 @@ test(function(t) {
|
|||
'Value after clearing the target')
|
||||
}, 'Test setting target from a valid target to null');
|
||||
|
||||
test(function(t) {
|
||||
var a = createDiv(t);
|
||||
var b = createDiv(t);
|
||||
test(t => {
|
||||
const a = createDiv(t);
|
||||
const b = createDiv(t);
|
||||
a.style.marginLeft = '10px';
|
||||
b.style.marginLeft = '20px';
|
||||
var anim = a.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
const anim = a.animate(gKeyFrames, 100 * MS_PER_SEC);
|
||||
|
||||
anim.currentTime = 50 * MS_PER_SEC;
|
||||
assert_equals(getComputedStyle(a).marginLeft, '50px',
|
Loading…
Add table
Add a link
Reference in a new issue