Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / touchadjustment / context-menu.html
blobc7e1ddd822bd60a84e1df70e1fdb5d6f5c528031
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Touch Adjustment : Adjust to context menu providers - bug 94101</title>
5 <script src="../resources/ahem.js"></script>
6 <script src="../resources/js-test.js"></script>
7 <script src="resources/touchadjustment.js"></script>
8 <style>
9 #sandbox {
10 position: absolute;
11 top: 0px;
12 left: 0px;
13 width: 400px;
14 height: 200px;
16 #sandbox p {
17 padding: 5px;
18 font: 20px Ahem;
20 </style>
21 </head>
22 <body>
24 <script>
25 function onClick() {}
26 </script>
28 <div id=sandbox>
29 <p id=p0><a id=a0 href="#a0">Link with URL.</a>
30 <p id=p1><span id=span0 onclick=onClick>Text with onclick handler.</span>
31 <p id=p2><img id=img0 height=20 width=100 src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPAQMAAAABGAcJAAAAA1BMVEUAgACc+aWRAAAADElEQVR42mNgIAEAAAAtAAH7KhMqAAAAAElFTkSuQmCC"></img>
32 </div>
34 <p id='description'></p>
35 <div id='console'></div>
37 <script>
38 // Set up shortcut access to elements
39 var e = {};
40 ['sandbox', 'a0', 'span0', 'img0', 'p0', 'p1', 'p2'].forEach(function(a) {
41 e[a] = document.getElementById(a);
42 });
44 function testDirectTouches()
46 // Check links can be targeted with context menu gesture.
47 testTouchPointContextMenu(touchPoint(100, 35, 10), e.a0);
48 // Check onclick can be targeted with activate gesture.
49 testTouchPoint(touchPoint(100, 100, 10), e.span0);
50 // Check onclick can not be targeted with context menu.
51 testTouchPointContextMenu(touchPoint(100, 100, 10), null);
52 // But that the adjusted point still hits it, if no better target is available
53 var adjustedPoint = adjustTouchPointContextMenu(touchPoint(100, 100, 10));
54 if (adjustedPoint) {
55 shouldBeNode(document.elementFromPoint(adjustedPoint.x, adjustedPoint.y), e.span0);
57 // Check images can be targeted with context menu.
58 testTouchPointContextMenu(offsetTouchPoint(findAbsoluteBounds(e.img0), 'center', 0, 5, 5), e.img0);
61 function testAdjustedTouches()
63 // Check we if we adjust the context menu onto the link.
64 testTouchPointContextMenu(touchPoint(100, 50, 10), e.a0);
65 // Check we if we do not adjust the context menu onto the onclick element.
66 testTouchPointContextMenu(touchPoint(100, 70, 10), null);
67 // Check the link is strongly preferred.
68 testTouchPointContextMenu(touchPoint(100, 60, 20), e.a0);
69 // Check adjustment onto the image.
70 testTouchPointContextMenu(touchPoint(20, 140, 10), e.img0);
71 // Check the image is strongly preferred for context menu gestures.
72 testTouchPointContextMenu(touchPoint(20, 120, 30), e.img0);
73 // But the onclick handler would be preferred for activate gestures.
74 testTouchPoint(touchPoint(20, 120, 30), e.span0);
77 function runTests()
79 if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestContextMenuNode) {
80 description('Test touch adjustment for context-menu gestures.');
81 // Set editing-behaviour to win, so context-menu gesture does not trigger selections.
82 internals.settings.setEditingBehavior('win');
83 testDirectTouches();
84 testAdjustedTouches();
85 e.sandbox.style.display = 'none';
88 runTests();
89 </script>
92 </body>
93 </html>