summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/animations/animation-hit-test-transform.html
blob: c96ff4d286f029009f7840affc75d8860c094e45 (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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
  <title>Test hit testing of -webkit-transform property while animating</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <style>
    #target {
      position: absolute;
      left: 0px;
      height: 200px;
      width: 200px;
      background-color: red;
      -webkit-animation-duration: 4s;
      -webkit-animation-timing-function: linear;
    }
    @-webkit-keyframes "anim" {
        from { -webkit-transform: translate(100px); }
        to { -webkit-transform: translate(300px); }
    }
    
    .dot {
        width: 10px;
        height: 10px;
        top: 100px;
        background-color: yellow;
        position:absolute;
    }
   </style>

   <script src="animation-test-helpers.js" type="text/javascript" charset="utf-8"></script>
   <script type="text/javascript" charset="utf-8">
        function checkResult(pos, isIn)
        {
            var elt = document.elementFromPoint(pos, 150);
            var good = isIn ? "inside" : "outside";
            var bad = isIn ? "outside" : "inside";
            return (isIn == (elt.id == "target")) ?
                "<span style='color:green'>PASS</span> - " + pos + "px was " + good + " as it should be" + "<br>" :
                "<span style='color:red'>FAIL</span> - " + pos + "px was " + bad + " and should have been " + good + "<br>";
        }
        
        function checkResults()
        {
            // Test before (150), in (300) and after (450)
            var result = "";
            result += checkResult(150, false);
            result += checkResult(300, true);
            result += checkResult(450, false);
            document.getElementById('result').innerHTML = result;
        }
     
        function doTest()
        {
            if (window.layoutTestController) {
                if (!layoutTestController.pauseAnimationAtTimeOnElementWithId("anim", 2.0, "target"))
                    throw("Transition is not running");
        
                checkResults();
                layoutTestController.notifyDone();
            }
            else {
                window.setTimeout("checkResults()", 2000);
            }
        }
    
        function startTest()
        {
            if (window.layoutTestController) {
                layoutTestController.dumpAsText();
                layoutTestController.waitUntilDone();
            }
      
            document.getElementById("target").style.webkitAnimationName = "anim";
            waitForAnimationToStart(document.getElementById('target'), doTest);
        }
   </script>
</head>
<body onload="startTest()">
    <div>
        This test starts an animation of the '-webkit-transform' property and then does elementFromPoint calls
        at the shown yellow dots to see if hit testing works
    </div>
    <div id="target"></div>
    <div class="dot" style="left:150px"></div>
    <div class="dot" style="left:300px"></div>
    <div class="dot" style="left:450px"></div>
    <div id="result" style="position:absolute; top:250px"></div>
</body>
</html>