forked from mirrors/gecko-dev
--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
133 lines
3 KiB
HTML
133 lines
3 KiB
HTML
<!doctype html>
|
|
<meta charset=utf-8>
|
|
<title>KeyframeEffect.getKeyframes() for CSS transitions</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script src="support/helper.js"></script>
|
|
<style>
|
|
:root {
|
|
--var-100px: 100px;
|
|
}
|
|
</style>
|
|
<div id="log"></div>
|
|
<script>
|
|
'use strict';
|
|
|
|
const getKeyframes = e => {
|
|
return e.getAnimations()[0].effect.getKeyframes();
|
|
};
|
|
|
|
const assert_frames_equal = (a, b, name) => {
|
|
assert_equals(
|
|
Object.keys(a).sort().toString(),
|
|
Object.keys(b).sort().toString(),
|
|
`properties on ${name}`
|
|
);
|
|
for (const p in a) {
|
|
assert_equals(a[p], b[p], `value for '${p}' on ${name}`);
|
|
}
|
|
};
|
|
|
|
test(t => {
|
|
const div = addDiv(t);
|
|
|
|
div.style.left = '0px';
|
|
getComputedStyle(div).transitionProperty;
|
|
div.style.transition = 'left 100s';
|
|
div.style.left = '100px';
|
|
|
|
const frames = getKeyframes(div);
|
|
|
|
assert_equals(frames.length, 2, 'number of frames');
|
|
|
|
const expected = [
|
|
{ offset: 0,
|
|
computedOffset: 0,
|
|
easing: 'ease',
|
|
composite: 'auto',
|
|
left: '0px',
|
|
},
|
|
{
|
|
offset: 1,
|
|
computedOffset: 1,
|
|
easing: 'linear',
|
|
composite: 'auto',
|
|
left: '100px',
|
|
},
|
|
];
|
|
|
|
for (let i = 0; i < frames.length; i++) {
|
|
assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);
|
|
}
|
|
}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'
|
|
+ ' transition');
|
|
|
|
test(t => {
|
|
const div = addDiv(t);
|
|
|
|
div.style.left = '0px';
|
|
getComputedStyle(div).transitionProperty;
|
|
div.style.transition = 'left 100s steps(2,end)';
|
|
div.style.left = '100px';
|
|
|
|
const frames = getKeyframes(div);
|
|
|
|
assert_equals(frames.length, 2, 'number of frames');
|
|
|
|
const expected = [
|
|
{
|
|
offset: 0,
|
|
computedOffset: 0,
|
|
easing: 'steps(2)',
|
|
composite: 'auto',
|
|
left: '0px',
|
|
},
|
|
{
|
|
offset: 1,
|
|
computedOffset: 1,
|
|
easing: 'linear',
|
|
composite: 'auto',
|
|
left: '100px',
|
|
},
|
|
];
|
|
|
|
for (let i = 0; i < frames.length; i++) {
|
|
assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);
|
|
}
|
|
}, 'KeyframeEffect.getKeyframes() returns expected frames for a simple'
|
|
+ ' transition with a non-default easing function');
|
|
|
|
test(t => {
|
|
const div = addDiv(t);
|
|
div.style.left = '0px';
|
|
getComputedStyle(div).transitionProperty;
|
|
div.style.transition = 'left 100s';
|
|
div.style.left = 'var(--var-100px)';
|
|
|
|
const frames = getKeyframes(div);
|
|
|
|
// CSS transition endpoints are based on the computed value so we
|
|
// shouldn't see the variable reference
|
|
const expected = [
|
|
{
|
|
offset: 0,
|
|
computedOffset: 0,
|
|
easing: 'ease',
|
|
composite: 'auto',
|
|
left: '0px',
|
|
},
|
|
{
|
|
offset: 1,
|
|
computedOffset: 1,
|
|
easing: 'linear',
|
|
composite: 'auto',
|
|
left: '100px',
|
|
},
|
|
];
|
|
for (let i = 0; i < frames.length; i++) {
|
|
assert_frames_equal(frames[i], expected[i], `ComputedKeyframe #${i}`);
|
|
}
|
|
}, 'KeyframeEffect.getKeyframes() returns expected frames for a'
|
|
+ ' transition with a CSS variable endpoint');
|
|
|
|
</script>
|