From 5ca02f7069784cb1d12cbe9c46f3c45818684c38 Mon Sep 17 00:00:00 2001 From: Yi Gu Date: Mon, 1 Jun 2020 21:56:24 +0000 Subject: [PATCH] Bug 1641870 [wpt PR 23847] - [ScrollTimeline] Add timeline to Element.animate(), a=testonly Automatic update from web-platform-tests [ScrollTimeline] Add timeline to Element.animate() This patch adds a timeline option to Element.animate() function based on the recent spec change: https://github.com/w3c/csswg-drafts/issues/5013. Change-Id: Ibf7e6f824f9e013f62da015cebdbc893255142dd Bug: 1080720 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2220352 Commit-Queue: Yi Gu Reviewed-by: Majid Valipour Cr-Commit-Position: refs/heads/master@{#773733} -- wpt-commits: a0740be4f6a5f18e016abd3dcadef53177dde234 wpt-pr: 23847 --- .../animation-with-animatable-interface.html | 70 +++++++++++++++++++ .../interfaces/Animatable/animate.html | 12 ++++ .../resources/keyframe-tests.js | 29 ++++++++ 3 files changed, 111 insertions(+) create mode 100644 testing/web-platform/tests/scroll-animations/animation-with-animatable-interface.html diff --git a/testing/web-platform/tests/scroll-animations/animation-with-animatable-interface.html b/testing/web-platform/tests/scroll-animations/animation-with-animatable-interface.html new file mode 100644 index 0000000000000..4c3fa027fd073 --- /dev/null +++ b/testing/web-platform/tests/scroll-animations/animation-with-animatable-interface.html @@ -0,0 +1,70 @@ + +Scroll-linked animation with Animatable interface + + + + + + + + + +
+
+
+
+
+ + \ No newline at end of file diff --git a/testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html b/testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html index 00e68b429621f..dad633ba9a2ca 100644 --- a/testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html +++ b/testing/web-platform/tests/web-animations/interfaces/Animatable/animate.html @@ -202,6 +202,18 @@ }, 'Element.animate() correctly sets the Animation\'s timeline when ' + 'triggered on an element in a different document'); +for (const subtest of gAnimationTimelineTests) { + test(t => { + const anim = createDiv(t).animate(null, { timeline: subtest.timeline }); + assert_not_equals(anim, null, + 'An animation sohuld be created'); + assert_equals(anim.timeline, subtest.expectedTimeline, + 'Animation timeline should be '+ + subtest.expectedTimelineDescription); + }, 'Element.animate() correctly sets the Animation\'s timeline ' + + subtest.description + ' in KeyframeAnimationOptions.'); +} + test(t => { const anim = createDiv(t).animate(null, 2000); assert_equals(anim.playState, 'running'); diff --git a/testing/web-platform/tests/web-animations/resources/keyframe-tests.js b/testing/web-platform/tests/web-animations/resources/keyframe-tests.js index 3cf3cf22bf866..43e0d7575f2cc 100644 --- a/testing/web-platform/tests/web-animations/resources/keyframe-tests.js +++ b/testing/web-platform/tests/web-animations/resources/keyframe-tests.js @@ -796,3 +796,32 @@ const gInvalidKeyframeEffectOptionTests = [ { desc: 'a variable easing', input: { easing: 'var(--x)' } }, { desc: 'a multi-value easing', input: { easing: 'ease-in-out, ease-out' } }, ]; + +// There is currently only ScrollTimeline that can be constructed and used here +// beyond document timeline. Given that ScrollTimeline is not stable as of yet +// it's tested in scroll-animations/animation-with-animatable-interface.html. +const gAnimationTimelineTests = [ + { + expectedTimeline: document.timeline, + expectedTimelineDescription: 'document.timeline', + description: 'with no timeline parameter' + }, + { + timeline: undefined, + expectedTimeline: document.timeline, + expectedTimelineDescription: 'document.timeline', + description: 'with undefined timeline' + }, + { + timeline: null, + expectedTimeline: null, + expectedTimelineDescription: 'null', + description: 'with null timeline' + }, + { + timeline: document.timeline, + expectedTimeline: document.timeline, + expectedTimelineDescription: 'document.timeline', + description: 'with DocumentTimeline' + }, +]; \ No newline at end of file