Update web-platform-tests to revision 346d5b51a122f7bb1c7747064499ef281a0200f7

This commit is contained in:
Ms2ger 2016-06-24 10:13:49 +02:00
parent 581c8ba1c8
commit 79b1e6c40c
1728 changed files with 20243 additions and 5349 deletions

View file

@ -19,23 +19,43 @@ var gTestArguments = [
{
effect: null,
timeline: null,
expectedTimeline: null,
expectedTimelineDescription: "null",
description: "with null effect and null timeline"
},
{
effect: null,
timeline: document.timeline,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with null effect and non-null timeline"
},
{
effect: null,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with null effect and no timeline parameter"
},
{
effect: gEffect,
timeline: null,
expectedTimeline: null,
expectedTimelineDescription: "null",
description: "with non-null effect and null timeline"
},
{
effect: gEffect,
timeline: document.timeline,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with non-null effect and non-null timeline"
},
{
effect: gEffect,
expectedTimeline: document.timeline,
expectedTimelineDescription: "document.timeline",
description: "with non-null effect and no timeline parameter"
},
];
gTestArguments.forEach(function(args) {
@ -47,9 +67,8 @@ gTestArguments.forEach(function(args) {
assert_equals(animation.effect, args.effect,
"Animation returns the same effect passed to " +
"the Constructor");
assert_equals(animation.timeline, args.timeline,
"Animation returns the same timeline 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);
@ -69,5 +88,20 @@ test(function(t) {
assert_equals(effect.getComputedTiming().progress, 1.0);
}, "Animation constructed by an effect with null target runs normally");
async_test(function(t) {
var 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);
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");
</script>
</body>

View file

@ -146,5 +146,14 @@ test(function(t) {
t.done();
}, 'reverse() when playbackRate == 0');
test(function(t) {
var div = createDiv(t);
var animation =
new Animation(new KeyframeEffect(div, null, 100 * MS_PER_SEC), null);
assert_throws('InvalidStateError', function() { animation.reverse(); });
}, 'Reversing an animation without an active timeline throws an ' +
'InvalidStateError');
</script>
</body>

View file

@ -0,0 +1,65 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Tests for current time</title>
<link rel="help" href="https://w3c.github.io/web-animations/#current-time">
<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 animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
animation.play();
assert_equals(animation.currentTime, 0,
'Current time returns the hold time set when entering the play-pending ' +
'state');
}, 'The current time returns the hold time when set');
promise_test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
return animation.ready.then(function() {
assert_equals(animation.currentTime, null);
});
}, 'The current time is unresolved when there is no associated timeline ' +
'(and no hold time is set)');
// FIXME: Test that the current time is unresolved when we have an inactive
// timeline if we find a way of creating an inactive timeline!
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
animation.startTime = null;
assert_equals(animation.currentTime, null);
}, 'The current time is unresolved when the start time is unresolved ' +
'(and no hold time is set)');
promise_test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
animation.playbackRate = 2;
animation.startTime = document.timeline.currentTime - 25 * MS_PER_SEC;
var timelineTime = document.timeline.currentTime;
var startTime = animation.startTime;
var playbackRate = animation.playbackRate;
assert_times_equal(animation.currentTime,
(timelineTime - startTime) * playbackRate,
'Animation has a unresolved start time');
}, 'The current time is calculated from the timeline time, start time and ' +
'playback rate');
</script>
</body>

View file

@ -16,10 +16,11 @@ test(function(t)
// time for an animation that does not have an active timeline.
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC));
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
assert_equals(animation.currentTime, null, 'Intial current time');
assert_equals(animation.startTuime, null, 'Intial start time');
assert_equals(animation.startTime, null, 'Intial start time');
animation.currentTime = 1000;
assert_equals(animation.currentTime, 1000,
@ -46,10 +47,11 @@ test(function(t)
// timeline should not clear the current time.
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC));
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
assert_equals(animation.currentTime, null, 'Intial current time');
assert_equals(animation.startTuime, null, 'Intial start time');
assert_equals(animation.startTime, null, 'Intial start time');
animation.currentTime = 1000;
assert_equals(animation.currentTime, 1000,

View file

@ -0,0 +1,276 @@
<!DOCTYPE html>
<meta charset=utf-8>
<title>Setting the timeline tests</title>
<link rel="help" href="https://w3c.github.io/web-animations/#setting-the-timeline">
<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';
// ---------------------------------------------------------------------
//
// Tests from no timeline to timeline
//
// ---------------------------------------------------------------------
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.currentTime = 50 * MS_PER_SEC;
assert_equals(animation.playState, 'paused');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'paused');
assert_times_equal(animation.currentTime, 50 * MS_PER_SEC);
}, 'After setting timeline on paused animation it is still paused');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.currentTime = 200 * MS_PER_SEC;
assert_equals(animation.playState, 'paused');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'paused');
assert_times_equal(animation.currentTime, 200 * MS_PER_SEC);
}, 'After setting timeline on animation paused outside active interval'
+ ' it is still paused');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
assert_equals(animation.playState, 'idle');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'idle');
}, 'After setting timeline on an idle animation without a start time'
+ ' it is still idle');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.startTime = document.timeline.currentTime;
assert_equals(animation.playState, 'idle');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'running');
}, 'After setting timeline on an idle animation with a start time'
+ ' it is running');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.startTime = document.timeline.currentTime - 200 * MS_PER_SEC;
assert_equals(animation.playState, 'idle');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'finished');
}, 'After setting timeline on an idle animation with a sufficiently ancient'
+ ' start time it is finished');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.play();
assert_equals(animation.playState, 'pending');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'pending');
}, 'After setting timeline on a play-pending animation it is still pending');
promise_test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.play();
assert_equals(animation.playState, 'pending');
animation.timeline = document.timeline;
return animation.ready.then(function() {
assert_equals(animation.playState, 'running');
});
}, 'After setting timeline on a play-pending animation it begins playing'
+ ' after pending');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.startTime = document.timeline.currentTime;
animation.pause();
animation.timeline = null;
assert_equals(animation.playState, 'pending');
animation.timeline = document.timeline;
assert_equals(animation.playState, 'pending');
}, 'After setting timeline on a pause-pending animation it is still pending');
promise_test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
null);
animation.startTime = document.timeline.currentTime;
animation.pause();
animation.timeline = null;
assert_equals(animation.playState, 'pending');
animation.timeline = document.timeline;
return animation.ready.then(function() {
assert_equals(animation.playState, 'paused');
});
}, 'After setting timeline on a pause-pending animation it becomes paused'
+ ' after pending');
// ---------------------------------------------------------------------
//
// Tests from timeline to no timeline
//
// ---------------------------------------------------------------------
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
animation.currentTime = 50 * MS_PER_SEC;
assert_equals(animation.playState, 'paused');
animation.timeline = null;
assert_equals(animation.playState, 'paused');
assert_times_equal(animation.currentTime, 50 * MS_PER_SEC);
}, 'After clearing timeline on paused animation it is still paused');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
var initialStartTime = document.timeline.currentTime - 200 * MS_PER_SEC;
animation.startTime = initialStartTime;
assert_equals(animation.playState, 'finished');
animation.timeline = null;
assert_equals(animation.playState, 'idle');
assert_times_equal(animation.startTime, initialStartTime);
}, 'After clearing timeline on finished animation it is idle');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
var initialStartTime = document.timeline.currentTime - 50 * MS_PER_SEC;
animation.startTime = initialStartTime;
assert_equals(animation.playState, 'running');
animation.timeline = null;
assert_equals(animation.playState, 'idle');
assert_times_equal(animation.startTime, initialStartTime);
}, 'After clearing timeline on running animation it is idle');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
assert_equals(animation.playState, 'idle');
animation.timeline = null;
assert_equals(animation.playState, 'idle');
assert_equals(animation.startTime, null);
}, 'After clearing timeline on idle animation it is still idle');
test(function(t) {
var animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
assert_equals(animation.playState, 'pending');
animation.timeline = null;
assert_equals(animation.playState, 'pending');
}, 'After clearing timeline on play-pending animation it is still pending');
promise_test(function(t) {
var animation = createDiv(t).animate(null, 100 * MS_PER_SEC);
assert_equals(animation.playState, 'pending');
animation.timeline = null;
animation.timeline = document.timeline;
assert_equals(animation.playState, 'pending');
return animation.ready.then(function() {
assert_equals(animation.playState, 'running');
});
}, 'After clearing and re-setting timeline on play-pending animation it'
+ ' begins to play');
test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
animation.startTime = document.timeline.currentTime;
animation.pause();
assert_equals(animation.playState, 'pending');
animation.timeline = null;
assert_equals(animation.playState, 'pending');
}, 'After clearing timeline on a pause-pending animation it is still pending');
promise_test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
animation.startTime = document.timeline.currentTime;
animation.pause();
assert_equals(animation.playState, 'pending');
animation.timeline = null;
animation.timeline = document.timeline;
assert_equals(animation.playState, 'pending');
return animation.ready.then(function() {
assert_equals(animation.playState, 'paused');
});
}, 'After clearing and re-setting timeline on a pause-pending animation it'
+ ' becomes paused');
promise_test(function(t) {
var animation =
new Animation(new KeyframeEffect(createDiv(t), null, 100 * MS_PER_SEC),
document.timeline);
var initialStartTime = document.timeline.currentTime - 50 * MS_PER_SEC;
animation.startTime = initialStartTime;
animation.pause();
animation.play();
animation.timeline = null;
animation.timeline = document.timeline;
assert_equals(animation.playState, 'pending');
return animation.ready.then(function() {
assert_equals(animation.playState, 'running');
assert_times_equal(animation.startTime, initialStartTime);
});
}, 'After clearing and re-setting timeline on an animation in the middle of'
+ ' an aborted pause, it continues playing using the same start time');
</script>
</body>