Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that disables it given conditions:
- (os == "android") and debug : https://bugzilla.mozilla.org/show_bug.cgi?id=1560466
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /css/css-transitions/CSSTransition-startTime.tentative.html - WPT Dashboard Interop Dashboard
<!doctype html>
<meta charset=utf-8>
<title>CSSTransition.startTime</title>
<!-- TODO: Add a more specific link for this once it is specified. -->
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.js"></script>
<div id="log"></div>
<script>
'use strict';
test(t => {
const div = addDiv(t, {
style: 'margin-left: 100px; transition: margin-left 100s linear 100s',
});
getComputedStyle(div).marginLeft;
div.style.marginLeft = '200px';
const animation = div.getAnimations()[0];
assert_equals(animation.startTime, null, 'startTime is unresolved');
}, 'The start time of a newly-created transition is unresolved');
promise_test(async t => {
const div = addDiv(t);
div.style.left = '0px';
div.style.top = '0px';
getComputedStyle(div).transitionProperty;
div.style.transition = 'all 100s';
div.style.left = '100px';
div.style.top = '100px';
let animations = div.getAnimations();
assert_equals(animations.length, 2);
await waitForAllAnimations(animations);
assert_equals(animations[0].startTime, animations[1].startTime,
'CSS transitions started together have the same start time');
await waitForAnimationFrames(1);
div.style.backgroundColor = 'green';
animations = div.getAnimations();
assert_equals(animations.length, 3);
await waitForAllAnimations(animations);
assert_less_than(animations[1].startTime, animations[2].startTime,
'A CSS transition added in a later frame has a later start time');
}, 'The start time of transitions is based on when they are generated');
test(t => {
const div = addDiv(t, {
style: 'margin-left: 100px; transition: margin-left 100s linear 100s',
});
getComputedStyle(div).marginLeft;
div.style.marginLeft = '200px';
const animation = div.getAnimations()[0];
const timelineTime = animation.timeline.currentTime;
animation.startTime = timelineTime;
assert_times_equal(
animation.startTime,
timelineTime,
'Check setting of startTime actually works'
);
}, 'The start time of a transition can be set');
promise_test(async t => {
const div = addDiv(t, {
style: 'margin-left: 100px; transition: margin-left 100s linear 100s',
});
getComputedStyle(div).marginLeft;
div.style.marginLeft = '200px';
const animation = div.getAnimations()[0];
await animation.ready;
const timelineTime = animation.timeline.currentTime;
const marginLeft = () => parseFloat(getComputedStyle(div).marginLeft);
animation.startTime = timelineTime - 100 * MS_PER_SEC;
assert_equals(marginLeft(), 100);
animation.startTime = timelineTime - 150 * MS_PER_SEC;
assert_equals(marginLeft(), 150);
}, 'The start time can be set to seek a transition');
promise_test(async t => {
const div = addDiv(t, {
style: 'margin-left: 100px; transition: margin-left 100s linear 100s',
});
const eventWatcher = new EventWatcher(t, div, [
'transitionstart',
'transitionend',
]);
getComputedStyle(div).marginLeft;
div.style.marginLeft = '200px';
const animation = div.getAnimations()[0];
await animation.ready;
const timelineTime = animation.timeline.currentTime;
animation.startTime = timelineTime - 100 * MS_PER_SEC;
await frameTimeout(
eventWatcher.wait_for('transitionstart'),
2,
'transitionstart'
);
animation.startTime = timelineTime - 200 * MS_PER_SEC;
await frameTimeout(
eventWatcher.wait_for('transitionend'),
2,
'transitionend'
);
}, 'Seeking a transition using start time dispatches transition events');
</script>