summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/scroll-animations/view-timelines/view-timeline-missing-subject.html
blob: 01ca0215246bb59e8c7976f68801fb00837869f5 (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
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
<title>ViewTimeline with missing subject</title>
<link rel="help" href="https://www.w3.org/TR/scroll-animations-1/#viewtimeline-interface">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<style type="text/css">
  #target {
    background:  blue;
    height:  100px;
    width:  100px;
  }
  #scroller {
    overflow:  scroll;
  }
  #filler {
    height:  300vh;
  }
</style>
<body onload="runTests()">
  <div id="scroller">
    <div id="target"></div>
    <div id="filler"></div>
  </div>
</body>
<script type="text/javascript">
  function raf() {
    return new Promise(resolve => {
      requestAnimationFrame(() => {
        requestAnimationFrame(resolve);
      })
    });
  }
  function runTests() {
    promise_test(async t => {
      const timeline = new ViewTimeline();
      const anim =
          target.animate(
              { backgroundColor: ['green', 'red' ] },
              { duration: 100,
                timeline: timeline });
      await raf();
      scroller.scrollTop = 50;
      await raf();
      assert_equals(timeline.currentTime, null,
                    'ViewTimeline with missing subject is inactive');
    });
  }

</script>
</html>