Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / touchadjustment / touch-links-longpress.html
blob4d6c5d7b92ab6ad02cb106678812cb0b6ed1e5ba
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.js"></script>
6 <script src="resources/touchadjustment.js"></script>
7 <style>
8 #sandbox {
9 position: absolute;
10 left: 0px;
11 top: 0px;
13 </style>
14 </head>
16 <body>
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>
22 <p id='description'></p>
23 <div id='console'></div>
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 });
34 document.ondragstart = function(e) { debug("PASS"); e.preventDefault();}
36 function testLongPress(touchpoint)
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.");
44 function testDirectTouch(element)
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);
53 function testIndirectTouch(element)
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);
62 function isDescendantOf(parent, child)
64 var n = child;
65 while(n) {
66 if(n==parent)
67 return true;
68 n = n.parentNode;
70 return false;
73 function testDirectTouches()
75 debug('Testing direct hits.');
76 testDirectTouch(e.link1);
77 testDirectTouch(e.link2);
78 testDirectTouch(e.link3);
81 function testIndirectTouches()
83 debug('Testing indirect hits.');
84 testIndirectTouch(e.link1);
85 testIndirectTouch(e.link2);
86 testIndirectTouch(e.link3);
89 function runTests()
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';
99 runTests();
100 </script>
101 </body>
102 </html>