Change fast/e* files to use pre and post js files in LayoutTests/resources.
[WebKit-https.git] / LayoutTests / fast / events / touch / gesture / touch-gesture-scroll-shy-target.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <link rel="stylesheet" href="../../../js/resources/js-test-style.css">
5 <script src="../../../../resources/js-test-pre.js"></script>
6 <script src="resources/gesture-helpers.js"></script>
7 <style type="text/css">
8 ::-webkit-scrollbar {
9     width: 0px;
10     height: 0px;
11 }
12
13 #touchtarget {
14   width: 100px;
15   height: 100px;
16   position: absolute;
17   background: white;
18   top: 100px;
19   left: 100px;
20 }
21
22 #movingbox {
23   width: 100%;
24   height: 100%;
25   position: absolute;
26   word-wrap: break-word;
27   overflow-y: scroll;
28   overflow-x: scroll;
29   display: block;
30 }
31
32 .greenbox {
33   width: 100px;
34   height: 100px;
35   background: green;
36   padding: 0px;
37   margin: 0px;
38 }
39
40 .redbox {
41   width: 100px;
42   height: 100px;
43   background: red;
44   padding: 0px;
45   margin: 0px;
46 }
47
48 td {
49   padding: 0px;
50 }
51 </style>
52 </head>
53 <body style="margin:0" onload="runTest();">
54 <div id="touchtarget">
55   <div id="movingbox">
56     <table border="0" cellspacing="0px" id="table">
57       <tr>
58         <td><div class="redbox" id="redbox"></div></td>
59         <td><div class="greenbox" id="greenbox_1"></div></td>
60       </tr>
61       <tr>
62         <td><div class="greenbox" id="greenbox_2"></div></td>
63         <td><div class="greenbox" id="greenbox_3"></div></td>
64       </tr>
65     </table>
66   </div>
67 </div>
68
69 <p id="description"></p>
70 <div id="console"></div>
71 <script type="text/javascript">
72
73 var movingdiv;
74 var expectedGesturesTotal = 2;
75 var gesturesOccurred = 0;
76 var scrollAmountX = ['63', '0'];
77 var scrollAmountY = ['62', '0'];
78 var wheelEventsOccurred = 0;
79 var expectedWheelEventsOccurred = ['0', '0'];
80 var scrollEventsOccurred = 0;
81 var expectedScrollEventsOccurred = '1';
82 var scrolledElement = 'movingdiv'
83
84 document.onkeypress = function()
85 {
86     debug('received element removing keypress');
87     var parent = document.getElementById('touchtarget');
88     movingdiv = document.getElementById('movingbox');
89     parent.removeChild(movingdiv);
90     return false;
91 }
92
93 function firstGestureScroll()
94 {
95     debug("first gesture");
96     eventSender.gestureScrollBegin(195, 195);
97     eventSender.gestureScrollUpdate(-20, -28);
98     eventSender.gestureScrollUpdate(-14, -4);
99     eventSender.gestureScrollUpdate(-29, -30);
100     eventSender.gestureScrollEnd(0, 0);
101
102     // Wait for layout.
103     checkScrollOffset();
104 }
105
106 function secondGestureScroll()
107 {
108     movingdiv.scrollTop = 0;
109     movingdiv.scrollLeft = 0;
110
111     debug("second gesture");
112     eventSender.gestureScrollBegin(195, 195);
113     eventSender.gestureScrollUpdate(-20, -28);
114     eventSender.gestureScrollUpdate(-14, -4);
115
116     // Send a key to delete the target Element.
117     eventSender.keyDown("d", []);
118
119     eventSender.gestureScrollUpdate(-29, -30);
120     eventSender.gestureScrollEnd(0, 0);
121
122     // By getting here successfully, the test demonstrates that the implementation
123     // does not crash when a latched Element is removed from the DOM.
124     checkScrollOffset();
125 }
126
127 if (window.testRunner)
128     testRunner.waitUntilDone();
129
130 function runTest()
131 {
132     movingdiv = document.getElementById('movingbox');
133     movingdiv.addEventListener("scroll", recordScroll);
134     window.addEventListener("mousewheel", recordWheel);
135
136     if (window.eventSender) {
137         description('This tests gesture scrolling div which is deleted while latched, ' +
138             'Square is (mostly) green on pass');
139         if (checkTestDependencies())
140             firstGestureScroll();
141         else
142             exitIfNecessary();
143     } else {
144         debug("This test requires DumpRenderTree.  Touch-scroll the red rect to log.");
145     }
146 }
147 </script>
148 </body>
149 </html>