fune/testing/web-platform/tests/css/css-transitions/CSSTransition-startTime.tentative.html
Brian Birtles c23be2ef0f Bug 1467344 - Move tests from dom/animations/tests/css-transitions to WPT; r=hiro
--HG--
rename : dom/animation/test/css-transitions/test_animation-computed-timing.html => testing/web-platform/tests/css/css-transitions/AnimationEffect-getComputedTiming.tentative.html
rename : dom/animation/test/css-transitions/test_pseudoElement-get-animations.html => testing/web-platform/tests/css/css-transitions/CSSPseudoElement-getAnimations.tentative.html
rename : dom/animation/test/css-transitions/test_animation-cancel.html => testing/web-platform/tests/css/css-transitions/CSSTransition-canceling.tentative.html
rename : dom/animation/test/css-transitions/test_animation-currenttime.html => testing/web-platform/tests/css/css-transitions/CSSTransition-currentTime.tentative.html
rename : dom/animation/test/css-transitions/test_setting-effect.html => testing/web-platform/tests/css/css-transitions/CSSTransition-effect.tentative.html
rename : dom/animation/test/css-transitions/test_animation-finished.html => testing/web-platform/tests/css/css-transitions/CSSTransition-finished.tentative.html
rename : dom/animation/test/css-transitions/test_animation-ready.html => testing/web-platform/tests/css/css-transitions/CSSTransition-ready.tentative.html
rename : dom/animation/test/css-transitions/test_animation-starttime.html => testing/web-platform/tests/css/css-transitions/CSSTransition-startTime.tentative.html
rename : dom/animation/test/css-transitions/test_csstransition-transitionproperty.html => testing/web-platform/tests/css/css-transitions/CSSTransition-transitionProperty.tentative.html
rename : dom/animation/test/css-transitions/test_document-get-animations.html => testing/web-platform/tests/css/css-transitions/Document-getAnimations.tentative.html
rename : dom/animation/test/css-transitions/test_element-get-animations.html => testing/web-platform/tests/css/css-transitions/Element-getAnimations.tentative.html
rename : dom/animation/test/css-transitions/test_keyframeeffect-getkeyframes.html => testing/web-platform/tests/css/css-transitions/KeyframeEffect-getKeyframes.tentative.html
rename : dom/animation/test/css-transitions/test_effect-target.html => testing/web-platform/tests/css/css-transitions/KeyframeEffect-target.tentative.html
rename : dom/animation/test/css-transitions/test_event-dispatch.html => testing/web-platform/tests/css/css-transitions/event-dispatch.tentative.html
extra : rebase_source : f09d4ff00f5be59ec5f90b211eebb074bdc17781
2018-08-16 14:41:04 +09:00

114 lines
3.3 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>CSSTransition.startTime</title>
<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 waitForFrame();
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 eventWatcher.wait_for('transitionstart');
animation.startTime = timelineTime - 200 * MS_PER_SEC;
await eventWatcher.wait_for('transitionend');
}, 'Seeking a transition using start time dispatches transition events');
</script>