File: view-timeline-subject-size-changes.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (81 lines) | stat: -rw-r--r-- 2,603 bytes parent folder | download | duplicates (14)
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
<!DOCTYPE html>
<html id="top">
<meta charset="utf-8">
<title>View timeline Subject size changes after creation of Animation</title>
<link rel="help" href="https://drafts.csswg.org/scroll-animations-1/#viewtimeline-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/web-animations/testcommon.js"></script>
<script src="/scroll-animations/scroll-timelines/testcommon.js"></script>
<script src="/scroll-animations/view-timelines/testcommon.js"></script>
<style>
  #container {
    border:  10px solid lightgray;
    overflow-y: scroll;
    height:  400px;
    width: 400px;
  }
  .spacer {
    height:  500px;
  }
  #target {
    background-color:  green;
    height:  100px;
    width:  100px;
  }
</style>
<body>
  <div id="container">
    <div class="spacer"></div>
    <div id="target"></div>
    <div class="spacer"></div>
  </div>
</body>

<script type="text/javascript">
promise_test(async t => {
  const options = {
    timeline: { axis: 'y' },
    animation: {
      rangeStart: { rangeName: 'entry', offset: CSS.percent(0) },
      rangeEnd: { rangeName: 'entry', offset: CSS.percent(100) },
      // Set fill to accommodate floating point precision errors at the
      // endpoints.
      fill: 'both'
    }
  };

  container.scrollTop = 0;
  await waitForNextFrame();

  const anim = CreateViewTimelineOpacityAnimation(t, target, options);
  const timeline = anim.timeline;
  anim.effect.updateTiming(options.timing);
  await anim.ready;

  // Advance to the start offset, which triggers entry to the active phase.
  container.scrollTop = 100;
  await waitForNextFrame();
  assert_equals(getComputedStyle(target).opacity, '0.3',
                `Effect at the start of the active phase`);

  // Advance to the midpoint of the animation.
  container.scrollTop = 150;
  await waitForNextFrame();
  assert_equals(getComputedStyle(target).opacity,'0.5',
                `Effect at the midpoint of the active range`);

  // Since the height of the target is cut in half, the animation should be at the end now.
  target.style.height = '50px';
  await waitForNextFrame();
  assert_equals(getComputedStyle(target).opacity, '0.7',
                `Effect at the end of the active range`);

  // Advance to the midpoint of the animation again.
  container.scrollTop = 125;
  await waitForNextFrame();
  assert_equals(getComputedStyle(target).opacity,'0.5',
                `Effect at the midpoint of the active range again`);

  }, 'View timeline with subject size change after the creation of the animation');
</script>