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>
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>
34 <p id='description'
></p>
35 <div id='console'
></div>
38 // Set up shortcut access to elements
40 ['sandbox', 'a0', 'span0', 'img0', 'p0', 'p1', 'p2'].forEach(function(a
) {
41 e
[a
] = document
.getElementById(a
);
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));
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
);
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');
84 testAdjustedTouches();
85 e
.sandbox
.style
.display
= 'none';