Add first-letter assert exception in RenderButton::setupInnerStyle().
[WebKit-https.git] / LayoutTests / touchadjustment / touch-links-longpress.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4     <title>Touch Adjustment : Testing that a drag/drop will start on a long press - bug 92914</title>
5     <script src="../resources/js-test-pre.js"></script>
6     <script src="resources/touchadjustment.js"></script>
7     <style>
8         #sandbox {
9             position: absolute;
10             left: 0px;
11             top: 0px;
12         }
13     </style>
14 </head>
15
16 <body>
17
18 <div id="sandbox">
19 <p><a href="" id="link1">I</a> propose to consider <a href="" id="link2">the question</a>, "Can machines think?"<br>This should begin with definitions of the meaning of the terms "machine" and <a href="" id="link3">"think."</a></p>
20 </div>
21
22 <p id='description'></p>
23 <div id='console'></div>
24
25 <script>
26     var element;
27     var adjustedNode;
28     // Set up shortcut access to elements
29     var e = {};
30     ['sandbox', 'link1', 'link2', 'link3'].forEach(function(a) {
31         e[a] = document.getElementById(a);
32     });
33
34     document.ondragstart = function(e) { debug("PASS"); e.preventDefault();}
35
36     function testLongPress(touchpoint)
37     {
38         if (eventSender.gestureLongPress)
39             eventSender.gestureLongPress(touchpoint.x, touchpoint.y, touchpoint.width, touchpoint.height);
40         else
41             debug("gestureLongPress not implemented by this platform.");
42     }
43
44     function testDirectTouch(element)
45     {
46         // Touch directly in the center of the element.
47         var touchpoint = offsetTouchPoint(findAbsoluteBounds(element), 'center', 0, 20, 30);
48         if (document.elementFromPoint(touchpoint.x, touchpoint.y) != element)
49             testFailed('Direct touch ended up on some other element');
50         testLongPress(touchpoint);
51     }
52
53     function testIndirectTouch(element)
54     {
55         // Touch just right of the element.
56         var touchpoint = offsetTouchPoint(findAbsoluteBounds(element), 'right', 10, 30, 20);
57         if (isDescendantOf(element, document.elementFromPoint(touchpoint.x, touchpoint.y)))
58             testFailed('Indirect touch ended up still on top of the element');
59         testLongPress(touchpoint);
60     }
61
62     function isDescendantOf(parent, child)
63     {
64         var n = child;
65         while(n) {
66             if(n==parent)
67                 return true;
68             n = n.parentNode;
69         }
70         return false;
71     }
72
73     function testDirectTouches()
74     {
75         debug('Testing direct hits.');
76         testDirectTouch(e.link1);
77         testDirectTouch(e.link2);
78         testDirectTouch(e.link3);
79     }
80
81     function testIndirectTouches()
82     {
83         debug('Testing indirect hits.');
84         testIndirectTouch(e.link1);
85         testIndirectTouch(e.link2);
86         testIndirectTouch(e.link3);
87     }
88
89     function runTests()
90     {
91         if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
92             internals.settings.setTouchDragDropEnabled(true);
93             description('Tests if a long press gesture on links will trigger a drag/drop when touch adjustment is used.');
94             testDirectTouches();
95             testIndirectTouches();
96             e.sandbox.style.display = 'none';
97         }
98     }
99     runTests();
100 </script>
101 <script src="../resources/js-test-post.js"></script>
102 </body>
103 </html>