summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/animations/negative-delay-events.html
blob: 93815138e8d6fd2c09d7a3c83e95af00ac411899 (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
<!DOCTYPE html>

<html>
<head>
  <style type="text/css">
    .box {
      position: relative;
      height: 25px;
      width: 25px;
      background-color: blue;
      margin: 10px;
    }
    .animation {
      -webkit-animation-duration: 0.1s;
      -webkit-animation-name: animation;
    }
    #animation1 {
      -webkit-animation-delay: 0.05s;
    }
    #animation2 {
      -webkit-animation-delay: -0.05s;
    }
    #animation3 {
      -webkit-animation-delay: -0.15s;
    }
    @-webkit-keyframes animation {
        from { left: 0; }
        to   { left: 500px; }
    }
  </style>
  <script type="text/javascript">
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }
    function log(text) {
        var div = document.createElement('div');
        div.innerText = text;
        document.getElementById('log').appendChild(div);
    }

    var count = 0;
    document.addEventListener('webkitAnimationStart', function(event) {
        var pass = event.elapsedTime === [0, 0.05, 0.15][count++];
        log((pass ? 'PASS' : 'FAIL') + ': ' + event.target.id + ': Start event: elapsedTime=' + event.elapsedTime);
    }, false);

    document.addEventListener('webkitAnimationEnd', function(event) {
        var pass = event.elapsedTime === 0.1;
        log((pass ? 'PASS' : 'FAIL') + ': ' + event.target.id + ': End event: elapsedTime=' + event.elapsedTime);
        switch (count) {
        case 1:
            document.getElementById('animation2').classList.add('animation');
            break;
        case 2:
            document.getElementById('animation3').classList.add('animation');
            break;
        case 3:
            if (window.testRunner)
                testRunner.notifyDone();
        }
    }, false);
  </script>
</head>
<body>
  <p>Tests animation events with a negative delay.
  <div id="animation1" class="box animation"></div>
  <div id="animation2" class="box"></div>
  <div id="animation3" class="box"></div>
  <div id="log"></div>
</body>
</html>