mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Update web-platform-tests to revision e8bfc205e36ad699601212cd50083870bad9a75d
This commit is contained in:
parent
65dd6d4340
commit
ccdb0a3458
1428 changed files with 118036 additions and 9786 deletions
|
@ -100,7 +100,7 @@ test(function(t) {
|
|||
var anim = createDiv(t).animate(null, { duration: 1000,
|
||||
iterations: 2.3,
|
||||
delay: 500,
|
||||
endDelay: -3000,
|
||||
endDelay: -2500,
|
||||
fill: 'forwards' });
|
||||
anim.finish();
|
||||
assert_equals(anim.effect.getComputedTiming().currentIteration, 0);
|
||||
|
|
|
@ -73,7 +73,7 @@ test(function(t) {
|
|||
var animation = createDiv(t).animate(null, { duration: 1, delay: -1 });
|
||||
|
||||
[ { currentTime: -2, phase: 'before' },
|
||||
{ currentTime: -1, phase: 'active' },
|
||||
{ currentTime: -1, phase: 'before' },
|
||||
{ currentTime: 0, phase: 'after' } ]
|
||||
.forEach(function(test) {
|
||||
assert_phase_at_time(animation, test.phase, test.currentTime);
|
||||
|
@ -121,7 +121,8 @@ test(function(t) {
|
|||
var animation = createDiv(t).animate(null, { duration: 1, endDelay: -2 });
|
||||
|
||||
[ { currentTime: -2, phase: 'before' },
|
||||
{ currentTime: -1, phase: 'after' } ]
|
||||
{ currentTime: -1, phase: 'before' },
|
||||
{ currentTime: 0, phase: 'after' } ]
|
||||
.forEach(function(test) {
|
||||
assert_phase_at_time(animation, test.phase, test.currentTime);
|
||||
});
|
||||
|
@ -133,8 +134,8 @@ test(function(t) {
|
|||
delay: 1,
|
||||
endDelay: -1 });
|
||||
|
||||
[ { currentTime: 0, phase: 'before' },
|
||||
{ currentTime: 1, phase: 'active' },
|
||||
[ { currentTime: 0, phase: 'before' },
|
||||
{ currentTime: 1, phase: 'active' },
|
||||
{ currentTime: 2, phase: 'after' } ]
|
||||
.forEach(function(test) {
|
||||
assert_phase_at_time(animation, test.phase, test.currentTime);
|
||||
|
@ -147,8 +148,9 @@ test(function(t) {
|
|||
delay: -1,
|
||||
endDelay: -1 });
|
||||
|
||||
[ { currentTime: -2, phase: 'before' },
|
||||
{ currentTime: -1, phase: 'after' } ]
|
||||
[ { currentTime: -2, phase: 'before' },
|
||||
{ currentTime: -1, phase: 'before' },
|
||||
{ currentTime: 0, phase: 'after' } ]
|
||||
.forEach(function(test) {
|
||||
assert_phase_at_time(animation, test.phase, test.currentTime);
|
||||
});
|
||||
|
@ -160,8 +162,10 @@ test(function(t) {
|
|||
delay: -1,
|
||||
endDelay: -2 });
|
||||
|
||||
[ { currentTime: -3, phase: 'before' },
|
||||
{ currentTime: -2, phase: 'after' } ]
|
||||
[ { currentTime: -3, phase: 'before' },
|
||||
{ currentTime: -2, phase: 'before' },
|
||||
{ currentTime: -1, phase: 'before' },
|
||||
{ currentTime: 0, phase: 'after' } ]
|
||||
.forEach(function(test) {
|
||||
assert_phase_at_time(animation, test.phase, test.currentTime);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Setting the target effect tests</title>
|
||||
<link rel='help' href='https://w3c.github.io/web-animations/#setting-the-target-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';
|
||||
|
||||
promise_test(function(t) {
|
||||
var anim = createDiv(t).animate({ marginLeft: [ '0px', '100px' ] },
|
||||
100 * MS_PER_SEC);
|
||||
assert_equals(anim.playState, 'pending');
|
||||
|
||||
var retPromise = anim.ready.then(function() {
|
||||
assert_unreached('ready promise is fulfilled');
|
||||
}).catch(function(err) {
|
||||
assert_equals(err.name, 'AbortError',
|
||||
'ready promise is rejected with AbortError');
|
||||
});
|
||||
|
||||
anim.effect = null;
|
||||
assert_equals(anim.playState, 'paused');
|
||||
|
||||
return retPromise;
|
||||
}, 'If new effect is null and old effect is not null, we reset the pending ' +
|
||||
'tasks and ready promise is rejected');
|
||||
|
||||
promise_test(function(t) {
|
||||
var anim = new Animation();
|
||||
anim.pause();
|
||||
assert_equals(anim.playState, 'pending');
|
||||
|
||||
anim.effect = new KeyframeEffectReadOnly(createDiv(t),
|
||||
{ marginLeft: [ '0px', '100px' ] },
|
||||
100 * MS_PER_SEC);
|
||||
assert_equals(anim.playState, 'pending');
|
||||
|
||||
return anim.ready.then(function() {
|
||||
assert_equals(anim.playState, 'paused');
|
||||
});
|
||||
}, 'If animation has a pending pause task, reschedule that task to run ' +
|
||||
'as soon as animation is ready.');
|
||||
|
||||
promise_test(function(t) {
|
||||
var anim = new Animation();
|
||||
anim.play();
|
||||
assert_equals(anim.playState, 'pending');
|
||||
|
||||
anim.effect = new KeyframeEffectReadOnly(createDiv(t),
|
||||
{ marginLeft: [ '0px', '100px' ] },
|
||||
100 * MS_PER_SEC);
|
||||
assert_equals(anim.playState, 'pending');
|
||||
|
||||
return anim.ready.then(function() {
|
||||
assert_equals(anim.playState, 'running');
|
||||
});
|
||||
}, 'If animation has a pending play task, reschedule that task to run ' +
|
||||
'as soon as animation is ready to play new effect.');
|
||||
|
||||
promise_test(function(t) {
|
||||
var animA = createDiv(t).animate({ marginLeft: [ '0px', '100px' ] },
|
||||
100 * MS_PER_SEC);
|
||||
var animB = new Animation();
|
||||
|
||||
return animA.ready.then(function() {
|
||||
animB.effect = animA.effect;
|
||||
assert_equals(animA.effect, null);
|
||||
assert_equals(animA.playState, 'finished');
|
||||
});
|
||||
}, 'When setting the effect of an animation to the effect of an existing ' +
|
||||
'animation, the existing animation\'s target effect should be set to null.');
|
||||
|
||||
test(function(t) {
|
||||
var animA = createDiv(t).animate({ marginLeft: [ '0px', '100px' ] },
|
||||
100 * MS_PER_SEC);
|
||||
var animB = new Animation();
|
||||
var effect = animA.effect;
|
||||
animA.currentTime = 50 * MS_PER_SEC;
|
||||
animB.currentTime = 20 * MS_PER_SEC;
|
||||
assert_equals(effect.getComputedTiming().progress, 0.5,
|
||||
'Original timing comes from first animation');
|
||||
animB.effect = effect;
|
||||
assert_equals(effect.getComputedTiming().progress, 0.2,
|
||||
'After setting the effect on a different animation, ' +
|
||||
'it uses the new animation\'s timing');
|
||||
}, 'After setting the target effect of animation to the target effect of an ' +
|
||||
'existing animation, the target effect\'s timing is updated to reflect ' +
|
||||
'the current time of the new animation.');
|
||||
|
||||
</script>
|
||||
</body>
|
|
@ -10,27 +10,11 @@
|
|||
<script>
|
||||
'use strict';
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
// NOTE TO THE POOR PERSON WHO HAS TO MERGE THIS WITH THE TEST OF THE SAME
|
||||
// NAME FROM BLINK
|
||||
// TESTS FOR UPDATING THE HOLD TIME
|
||||
//
|
||||
// There is a pull request from Blink at:
|
||||
//
|
||||
// https://github.com/w3c/web-platform-tests/pull/3328
|
||||
//
|
||||
// which this file will surely conflict with.
|
||||
//
|
||||
// However, those tests cover a different part of the same algorithm. They
|
||||
// are mostly concerned with testing events and promises rather than the
|
||||
// timing part of the algorithm.
|
||||
//
|
||||
// The tests below cover the first part of the algorithm. So, please keep both
|
||||
// sets of tests and delete this comment. Preferably put the tests in this
|
||||
// file first.
|
||||
//
|
||||
// Thank you!
|
||||
//
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
// CASE 1: playback rate > 0 and current time >= target effect end
|
||||
// (Also the start time is resolved and there is pending task)
|
||||
|
@ -43,9 +27,9 @@ promise_test(function(t) {
|
|||
// otherwise we don't have a resolved start time. We test the case
|
||||
// where the start time is unresolved in a subsequent test.
|
||||
return anim.ready.then(function() {
|
||||
// Seek to 1ms before the target end and wait a frame (> 16ms)
|
||||
// Seek to 1ms before the target end and then wait 1ms
|
||||
anim.currentTime = 100 * MS_PER_SEC - 1;
|
||||
return waitForAnimationFrames(1);
|
||||
return waitForAnimationFramesWithDelay(1);
|
||||
}).then(function() {
|
||||
assert_equals(anim.currentTime, 100 * MS_PER_SEC,
|
||||
'Hold time is set to target end clamping current time');
|
||||
|
@ -96,9 +80,9 @@ promise_test(function(t) {
|
|||
anim.playbackRate = -1;
|
||||
anim.play(); // Make sure animation is not initially finished
|
||||
return anim.ready.then(function() {
|
||||
// Seek to 1ms before 0 end and wait a frame (> 16ms)
|
||||
// Seek to 1ms before 0 and then wait 1ms
|
||||
anim.currentTime = 1;
|
||||
return waitForAnimationFrames(1);
|
||||
return waitForAnimationFramesWithDelay(1);
|
||||
}).then(function() {
|
||||
assert_equals(anim.currentTime, 0 * MS_PER_SEC,
|
||||
'Hold time is set to zero clamping current time');
|
||||
|
@ -327,5 +311,100 @@ test(function(t) {
|
|||
}, 'Updating the finished state when start time is unresolved and'
|
||||
+ ' did seek = true');
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
//
|
||||
// TESTS FOR RUNNING FINISH NOTIFICATION STEPS
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
function waitForFinishEventAndPromise(animation) {
|
||||
var eventPromise = new Promise(function(resolve) {
|
||||
animation.onfinish = function() { resolve(); }
|
||||
});
|
||||
return Promise.all([eventPromise, animation.finished]);
|
||||
}
|
||||
|
||||
promise_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
animation.onfinish =
|
||||
t.unreached_func('Seeking to finish should not fire finish event');
|
||||
animation.finished.then(
|
||||
t.unreached_func('Seeking to finish should not resolve finished promise'));
|
||||
animation.currentTime = 1;
|
||||
animation.currentTime = 0;
|
||||
animation.pause();
|
||||
return waitForAnimationFrames(3);
|
||||
}, 'Finish notification steps don\'t run when the animation seeks to finish'
|
||||
+ ' and then seeks back again');
|
||||
|
||||
promise_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
return animation.ready.then(function() {
|
||||
return waitForFinishEventAndPromise(animation);
|
||||
});
|
||||
}, 'Finish notification steps run when the animation completes normally');
|
||||
|
||||
promise_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
return animation.ready.then(function() {
|
||||
animation.currentTime = 10;
|
||||
return waitForFinishEventAndPromise(animation);
|
||||
});
|
||||
}, 'Finish notification steps run when the animation seeks past finish');
|
||||
|
||||
promise_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
return animation.ready.then(function() {
|
||||
// Register for notifications now since once we seek away from being
|
||||
// finished the 'finished' promise will be replaced.
|
||||
var finishNotificationSteps = waitForFinishEventAndPromise(animation);
|
||||
animation.finish();
|
||||
animation.currentTime = 0;
|
||||
animation.pause();
|
||||
return finishNotificationSteps;
|
||||
});
|
||||
}, 'Finish notification steps run when the animation completes with .finish(),'
|
||||
+ ' even if we then seek away');
|
||||
|
||||
promise_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
var initialFinishedPromise = animation.finished;
|
||||
|
||||
return animation.finished.then(function(target) {
|
||||
animation.currentTime = 0;
|
||||
assert_not_equals(initialFinishedPromise, animation.finished);
|
||||
});
|
||||
}, 'Animation finished promise is replaced after seeking back to start');
|
||||
|
||||
promise_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
var initialFinishedPromise = animation.finished;
|
||||
|
||||
return animation.finished.then(function(target) {
|
||||
animation.play();
|
||||
assert_not_equals(initialFinishedPromise, animation.finished);
|
||||
});
|
||||
}, 'Animation finished promise is replaced after replaying from start');
|
||||
|
||||
async_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
animation.onfinish = function(event) {
|
||||
animation.currentTime = 0;
|
||||
animation.onfinish = function(event) {
|
||||
t.done();
|
||||
};
|
||||
};
|
||||
}, 'Animation finish event is fired again after seeking back to start');
|
||||
|
||||
async_test(function(t) {
|
||||
var animation = createDiv(t).animate(null, 1);
|
||||
animation.onfinish = function(event) {
|
||||
animation.play();
|
||||
animation.onfinish = function(event) {
|
||||
t.done();
|
||||
};
|
||||
};
|
||||
}, 'Animation finish event is fired again after replaying from start');
|
||||
|
||||
</script>
|
||||
</body>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue