2 <title>Named view-timeline lookup
</title>
3 <link rel=
"help" src=
"https://drafts.csswg.org/scroll-animations-1/#view-timelines-named">
4 <script src=
"/resources/testharness.js"></script>
5 <script src=
"/resources/testharnessreport.js"></script>
6 <script src=
"/web-animations/testcommon.js"></script>
7 <script src=
"support/testcommon.js"></script>
25 async
function inflate(t
, template
) {
26 t
.add_cleanup(() => main
.replaceChildren());
27 return runAndWaitForFrameUpdate(() => {
28 main
.append(template
.content
.cloneNode(true));
33 <template id=timeline_self
>
38 animation: anim
1s linear;
39 animation-timeline: --t1;
42 <div id=scroller class=scroller
>
52 promise_test(async (t
) => {
53 await
inflate(t
, timeline_self
);
54 assert_equals(getComputedStyle(target
).zIndex
, '100');
55 }, 'view-timeline on self');
58 <template id=timeline_preceding_sibling
>
68 animation: anim
1s linear;
69 animation-timeline: --t1;
72 <div id=scroller class=scroller
>
74 <div id=timeline
></div>
83 promise_test(async (t
) => {
84 await
inflate(t
, timeline_preceding_sibling
);
85 assert_equals(getComputedStyle(target
).zIndex
, '75');
86 }, 'timeline-scope on preceding sibling');
89 <template id=timeline_ancestor
>
96 animation: anim
1s linear;
97 animation-timeline: --t1;
100 <div id=scroller class=scroller
>
106 <div id=target
></div>
114 promise_test(async (t
) => {
115 await
inflate(t
, timeline_ancestor
);
116 assert_equals(getComputedStyle(target
).zIndex
, '25');
117 }, 'view-timeline on ancestor');
120 <template id=timeline_ancestor_sibling
>
123 timeline-scope: --t1;
130 animation: anim
1s linear;
131 animation-timeline: --t1;
134 <div id=scroller class=scroller
>
136 <div id=timeline
></div>
140 <div id=target
></div>
148 promise_test(async (t
) => {
149 await
inflate(t
, timeline_ancestor_sibling
);
150 assert_equals(getComputedStyle(target
).zIndex
, '75');
151 }, 'timeline-scope on ancestor sibling');
154 <template id=timeline_ancestor_sibling_conflict
>
157 timeline-scope: --t1;
159 #timeline1, #timeline2 {
164 animation: anim
1s linear;
165 animation-timeline: --t1;
168 <div id=scroller class=scroller
>
170 <div id=timeline1
></div>
172 <div id=timeline2
></div>
175 <div id=target
></div>
183 promise_test(async (t
) => {
184 await
inflate(t
, timeline_ancestor_sibling_conflict
);
185 assert_equals(getComputedStyle(target
).zIndex
, 'auto');
186 }, 'timeline-scope on ancestor sibling, conflict remains unresolved');
189 <template id=timeline_ancestor_closer_timeline_wins
>
192 timeline-scope: --t1;
199 timeline-scope: --t1; /* Inactive */
202 animation: anim
1s linear;
203 animation-timeline: --t1;
206 <div id=scroller class=scroller
>
208 <div id=timeline
></div>
211 <div id=target
></div>
218 promise_test(async (t
) => {
219 await
inflate(t
, timeline_ancestor_closer_timeline_wins
);
220 assert_equals(getComputedStyle(target
).zIndex
, 'auto');
221 }, 'timeline-scope on ancestor sibling, closer timeline wins');
224 <template id=timeline_ancestor_scroll_timeline_wins_on_same_element
>
228 view-timeline-inset:
50px;
229 scroll-timeline: --t1;
232 animation: anim
1s linear;
233 animation-timeline: --t1;
236 <div id=scroller class=scroller
>
237 <div id=target
></div>
246 promise_test(async (t
) => {
247 await
inflate(t
, timeline_ancestor_scroll_timeline_wins_on_same_element
);
248 // In case of a name conflict on the same element, scroll progress timelines
249 // take precedence over view progress timelines.
250 // https://drafts.csswg.org/scroll-animations-1/#timeline-scope
251 assert_equals(getComputedStyle(target
).zIndex
, '0');
252 }, 'view-timeline on ancestor sibling, scroll-timeline wins on same element');