mirror of
https://github.com/servo/servo.git
synced 2025-08-09 15:35:34 +01:00
Update web-platform-tests to revision 50d6ee076e94273080d9f3b69be0bf4eeae156d3
This commit is contained in:
parent
3b9055510a
commit
280c87822d
331 changed files with 4209 additions and 866 deletions
|
@ -107,10 +107,18 @@ promise_test(async t => {
|
|||
const timelineTime = animation.timeline.currentTime;
|
||||
|
||||
animation.startTime = timelineTime - 100 * MS_PER_SEC;
|
||||
await eventWatcher.wait_for('transitionstart');
|
||||
await frameTimeout(
|
||||
eventWatcher.wait_for('transitionstart'),
|
||||
2,
|
||||
'transitionstart'
|
||||
);
|
||||
|
||||
animation.startTime = timelineTime - 200 * MS_PER_SEC;
|
||||
await eventWatcher.wait_for('transitionend');
|
||||
await frameTimeout(
|
||||
eventWatcher.wait_for('transitionend'),
|
||||
2,
|
||||
'transitionend'
|
||||
);
|
||||
}, 'Seeking a transition using start time dispatches transition events');
|
||||
|
||||
</script>
|
||||
|
|
|
@ -275,4 +275,45 @@ root.waitForAnimationFrames = (frameCount, onFrame) => {
|
|||
root.waitForAllAnimations = animations =>
|
||||
Promise.all(animations.map(animation => animation.ready));
|
||||
|
||||
/**
|
||||
* Utility that takes a Promise and a maximum number of frames to wait and
|
||||
* returns a new Promise that behaves as follows:
|
||||
*
|
||||
* - If the provided Promise resolves _before_ the specified number of frames
|
||||
* have passed, resolves with the result of the provided Promise.
|
||||
* - If the provided Promise rejects _before_ the specified number of frames
|
||||
* have passed, rejects with the error result of the provided Promise.
|
||||
* - Otherwise, rejects with a 'Timed out' error message. If |message| is
|
||||
* provided, it will be appended to the error message.
|
||||
*/
|
||||
root.frameTimeout = (promiseToWaitOn, framesToWait, message) => {
|
||||
let framesRemaining = framesToWait;
|
||||
let aborted = false;
|
||||
|
||||
const timeoutPromise = new Promise(function waitAFrame(resolve, reject) {
|
||||
if (aborted) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
if (framesRemaining-- > 0) {
|
||||
requestAnimationFrame(() => {
|
||||
waitAFrame(resolve, reject);
|
||||
});
|
||||
return;
|
||||
}
|
||||
let errorMessage = 'Timed out waiting for Promise to resolve';
|
||||
if (message) {
|
||||
errorMessage += `: ${message}`;
|
||||
}
|
||||
reject(new Error(errorMessage));
|
||||
});
|
||||
|
||||
const wrappedPromiseToWaitOn = promiseToWaitOn.then(result => {
|
||||
aborted = true;
|
||||
return result;
|
||||
});
|
||||
|
||||
return Promise.race([timeoutPromise, wrappedPromiseToWaitOn]);
|
||||
};
|
||||
|
||||
})(window);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue