summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scroll-animations/css/scroll-timeline-axis-writing-mode.html
blob: 90912bfc2270558d4810cd3a183d666c2118c32f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
<link rel="help" src="https://drafts.csswg.org/scroll-animations-1/#scroll-timeline-axis">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<style>
  .scroller {
    overflow: hidden;
    width: 100px;
    height: 100px;
  }
  .contents {
    height: 200px;
    width: 200px;
  }
  @keyframes expand {
    from { width: 100px; }
    to { width: 200px; }
  }
  #timeline_initial_axis {
    scroll-timeline: timeline_initial_axis;
  }
  #timeline_vertical {
    scroll-timeline: vertical timeline_vertical;
  }
  #timeline_horizontal {
    scroll-timeline: horizontal timeline_horizontal;
  }
  #timeline_block_in_horizontal {
    scroll-timeline: block timeline_block_in_horizontal;
  }
  #timeline_inline_in_horizontal {
    scroll-timeline: inline timeline_inline_in_horizontal;
  }
  #timeline_block_in_vertical {
    scroll-timeline: block timeline_block_in_vertical;
    writing-mode: vertical-lr;
  }
  #timeline_inline_in_vertical {
    scroll-timeline: inline timeline_inline_in_vertical;
    writing-mode: vertical-lr;
  }
  #container > div {
    width: 0px;
    animation-name: expand;
    animation-duration: 10s;
    animation-timing-function: linear;
  }
  /* Ensure stable expectations if feature is not supported */
  @supports not (animation-timeline:foo) {
    #container > div { animation-play-state: paused; }
  }
  #element_initial_axis { animation-timeline: timeline_initial_axis; }
  #element_vertical { animation-timeline: timeline_vertical; }
  #element_horizontal { animation-timeline: timeline_horizontal; }
  #element_block_in_horizontal { animation-timeline: timeline_block_in_horizontal; }
  #element_inline_in_horizontal { animation-timeline: timeline_inline_in_horizontal; }
  #element_block_in_vertical { animation-timeline: timeline_block_in_vertical; }
  #element_inline_in_vertical { animation-timeline: timeline_inline_in_vertical; }
</style>
<div class=scroller id=timeline_initial_axis><div class=contents></div></div>
<div class=scroller id=timeline_vertical><div class=contents></div></div>
<div class=scroller id=timeline_horizontal><div class=contents></div></div>
<div class=scroller id=timeline_block_in_horizontal><div class=contents></div></div>
<div class=scroller id=timeline_inline_in_horizontal><div class=contents></div></div>
<div class=scroller id=timeline_block_in_vertical><div class=contents></div></div>
<div class=scroller id=timeline_inline_in_vertical><div class=contents></div></div>
<div id=container>
  <div id=element_initial_axis></div>
  <div id=element_vertical></div>
  <div id=element_horizontal></div>
  <div id=element_block_in_horizontal></div>
  <div id=element_inline_in_horizontal></div>
  <div id=element_block_in_vertical></div>
  <div id=element_inline_in_vertical></div>
</div>
<script>
  // Animations linked to vertical scroll-timelines are at 75% progress.
  timeline_initial_axis.scrollTop = 75;
  timeline_vertical.scrollTop = 75;
  timeline_block_in_horizontal.scrollTop = 75;
  timeline_inline_in_vertical.scrollTop = 75;
  // Animations linked to horizontal scroll-timelines are at 25% progress.
  timeline_horizontal.scrollLeft = 25;
  timeline_block_in_vertical.scrollLeft = 25;
  timeline_inline_in_horizontal.scrollLeft = 25;

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(element_initial_axis).width, '175px');
  }, 'Initial axis');

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(element_vertical).width, '175px');
  }, 'Vertical axis');

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(element_horizontal).width, '125px');
  }, 'Horizontal axis');

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(element_block_in_horizontal).width, '175px');
  }, 'Block axis in horizontal writing-mode');

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(element_inline_in_horizontal).width, '125px');
  }, 'Inline axis in horizontal writing-mode');

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(timeline_block_in_vertical).writingMode, 'vertical-lr');
    assert_equals(getComputedStyle(element_block_in_vertical).width, '125px');
  }, 'Block axis in vertical writing-mode');

  promise_test(async (t) => {
    await waitForNextFrame();
    assert_equals(getComputedStyle(timeline_inline_in_vertical).writingMode, 'vertical-lr');
    assert_equals(getComputedStyle(element_inline_in_vertical).width, '175px');
  }, 'Inline axis in vertical writing-mode');

</script>