[css-grid] Scroll reset position when updating inner html on content
[WebKit-https.git] / LayoutTests / resources / basic-gestures.js
1 function didShowKeyboard()
2 {
3     return new Promise(resolve => {
4         testRunner.runUIScript(`
5             (function() {
6                 uiController.didShowKeyboardCallback = function() {
7                     uiController.uiScriptComplete();
8                 }
9             })();`, resolve);
10     });
11 }
12
13 function doubleTapToZoomAtPoint(x, y)
14 {
15     return new Promise(resolve => {
16         testRunner.runUIScript(`
17             (function() {
18                 let completionCount = 0;
19                 const checkDone = () => {
20                     if (++completionCount == 3)
21                         uiController.uiScriptComplete();
22                 };
23                 uiController.didEndZoomingCallback = checkDone;
24                 uiController.singleTapAtPoint(${x}, ${y}, checkDone);
25                 uiController.singleTapAtPoint(${x}, ${y}, checkDone);
26             })();`, resolve);
27     });
28 }
29
30 function doubleTapAtPoint(x, y)
31 {
32     return new Promise(resolve => {
33         testRunner.runUIScript(`
34             (function() {
35                 uiController.doubleTapAtPoint(${x}, ${y}, function() {
36                     uiController.uiScriptComplete();
37                 });
38             })();`, resolve);
39     });
40 }
41
42 function longPressAtPoint(x, y)
43 {
44     return new Promise(resolve => {
45         testRunner.runUIScript(`
46             (function() {
47                 uiController.longPressAtPoint(${x}, ${y}, function() {
48                     uiController.uiScriptComplete();
49                 });
50             })();`, resolve);
51     });
52 }
53
54 function liftUpAtPoint(x, y)
55 {
56     return new Promise(resolve => {
57         testRunner.runUIScript(`
58             (function() {
59                 uiController.liftUpAtPoint(${x}, ${y}, 1, function() {
60                     uiController.uiScriptComplete();
61                 });
62             })();`, resolve);
63     });
64 }
65
66 function longPressAndHoldAtPoint(x, y)
67 {
68     return new Promise(resolve => {
69         testRunner.runUIScript(`
70             (function() {
71             var eventStream = {
72             events : [
73                 {
74                     interpolate : "linear",
75                     timestep: 0.1,
76                     coordinateSpace : "content",
77                     startEvent : {
78                         inputType : "hand",
79                         timeOffset : 0,
80                         touches : [
81                             {
82                                 inputType : "finger",
83                                 phase : "began",
84                                 id : 1,
85                                 x : ${x},
86                                 y : ${y},
87                                 pressure : 0
88                             }
89                         ]
90                     },
91                     endEvent : {
92                         inputType : "hand",
93                         timeOffset : 2.0,
94                         touches : [
95                             {
96                                 inputType : "finger",
97                                 phase : "moved",
98                                 id : 1,
99                                 x : ${x},
100                                 y : ${y},
101                                 pressure : 0
102                             }
103                         ]
104                     }
105             }]};
106
107             uiController.sendEventStream(JSON.stringify(eventStream), function() {});
108                 uiController.uiScriptComplete();
109             })();`, resolve);
110     });
111 }
112
113 function tapAtPoint(x, y)
114 {
115     return new Promise(resolve => {
116         testRunner.runUIScript(`
117             (function() {
118                 uiController.singleTapAtPoint(${x}, ${y}, function() {
119                     uiController.uiScriptComplete();
120                 });
121             })();`, resolve);
122     });
123 }
124
125 function touchAndDragFromPointToPoint(startX, startY, endX, endY)
126 {
127     return new Promise(resolve => {
128         testRunner.runUIScript(`
129             (function() {
130             var eventStream = {
131             events : [
132                 {
133                     interpolate : "linear",
134                     timestep: 0.1,
135                     coordinateSpace : "content",
136                     startEvent : {
137                         inputType : "hand",
138                         timeOffset : 0,
139                         touches : [
140                             {
141                                 inputType : "finger",
142                                 phase : "began",
143                                 id : 1,
144                                 x : ${startX},
145                                 y : ${startY},
146                                 pressure : 0
147                             }
148                         ]
149                     },
150                     endEvent : {
151                         inputType : "hand",
152                         timeOffset : 0.5,
153                         touches : [
154                             {
155                                 inputType : "finger",
156                                 phase : "moved",
157                                 id : 1,
158                                 x : ${endX},
159                                 y : ${endY},
160                                 pressure : 0
161                             }
162                         ]
163                     }
164             }]};
165
166             uiController.sendEventStream(JSON.stringify(eventStream), function() {});
167                 uiController.uiScriptComplete();
168             })();`, resolve);
169     });
170 }
171
172 function holdAtPoint(x, y)
173 {
174     return new Promise(resolve => {
175         testRunner.runUIScript(`
176             (function() {
177             var eventStream = {
178             events : [
179                 {
180                     interpolate : "linear",
181                     timestep: 0.1,
182                     coordinateSpace : "content",
183                     startEvent : {
184                         inputType : "hand",
185                         timeOffset : 0,
186                         touches : [
187                             {
188                                 inputType : "finger",
189                                 phase : "moved",
190                                 id : 1,
191                                 x : ${x},
192                                 y : ${y},
193                                 pressure : 0
194                             }
195                         ]
196                     },
197                     endEvent : {
198                         inputType : "hand",
199                         timeOffset : 5.0,
200                         touches : [
201                             {
202                                 inputType : "finger",
203                                 phase : "moved",
204                                 id : 1,
205                                 x : ${x},
206                                 y : ${y},
207                                 pressure : 0
208                             }
209                         ]
210                     }
211             }]};
212
213             uiController.sendEventStream(JSON.stringify(eventStream), function() {});
214                 uiController.uiScriptComplete();
215             })();`, resolve);
216     });
217 }
218
219 function continueTouchAndDragFromPointToPoint(startX, startY, endX, endY)
220 {
221     return new Promise(resolve => {
222         testRunner.runUIScript(`
223             (function() {
224              var eventStream = {
225              events : [
226                        {
227                        interpolate : "linear",
228                        timestep: 0.1,
229                        coordinateSpace : "content",
230                        startEvent : {
231                            inputType : "hand",
232                            timeOffset : 0,
233                            touches : [
234                                {
235                                    inputType : "finger",
236                                    phase : "moved",
237                                    id : 1,
238                                    x : ${startX},
239                                    y : ${startY},
240                                    pressure : 0
241                                }
242                            ]
243                        },
244                        endEvent : {
245                            inputType : "hand",
246                            timeOffset : 0.5,
247                            touches : [
248                                {
249                                    inputType : "finger",
250                                    phase : "moved",
251                                    id : 1,
252                                    x : ${endX},
253                                    y : ${endY},
254                                    pressure : 0
255                                }
256                            ]
257                        }
258              }]};
259
260              uiController.sendEventStream(JSON.stringify(eventStream), function() {});
261                  uiController.uiScriptComplete();
262              })();`, resolve);
263     });
264 }