4 <title>Touch Adjustment : Adjust context-menu to text-node subtargets - bug
94449</title>
5 <script src=
"../resources/ahem.js"></script>
6 <script src=
"../resources/js-test.js"></script>
7 <script src=
"resources/touchadjustment.js"></script>
19 white-space: pre-wrap;
26 <!-- The layout of the two words should be: (10,10)x(80,20) and (170,10)x(80,20). -->
27 <div id=div1
><span id=span1
>Text text
</span></div>
30 <p id='description'
></p>
31 <div id='console'
></div>
34 // Set up shortcut access to elements
36 ['sandbox', 'div1', 'span1'].forEach(function(a
) {
37 e
[a
] = document
.getElementById(a
);
40 function testAdjustedTouches()
43 var word1Bounds
= { left
: 10, top
: 10, width
: 80, height
: 20 };
44 var word2Bounds
= { left
: 170, top
: 10, width
: 80, height
: 20 };
46 // Set editing-behaviour mac, so context-menu gesture triggers selections.
47 internals
.settings
.setEditingBehavior('mac');
48 // Check the context-menu is adjusted to the individual words.
49 adjustedPoint
= adjustTouchPointContextMenu(touchPoint(5, 5, 20, 10));
50 shouldBeWithin(adjustedPoint
, word1Bounds
);
51 adjustedPoint
= adjustTouchPointContextMenu(touchPoint(100, 15, 20, 10));
52 shouldBeWithin(adjustedPoint
, word1Bounds
);
54 adjustedPoint
= adjustTouchPointContextMenu(touchPoint(150, 15, 30, 10));
55 shouldBeWithin(adjustedPoint
, word2Bounds
);
56 adjustedPoint
= adjustTouchPointContextMenu(touchPoint(260, 35, 20, 10));
57 shouldBeWithin(adjustedPoint
, word2Bounds
);
59 // Set editing-behaviour to win, so context-menu gesture does not trigger selections.
60 internals
.settings
.setEditingBehavior('win');
61 var range
= document
.createRange();
62 range
.setStart(e
.span1
.firstChild
, 2);
63 range
.setEnd(e
.span1
.firstChild
, 6);
64 window
.getSelection().addRange(range
);
65 var selectionBounds
= { left
: 50, top
: 10, width
: 80, height
: 20 };
66 adjustedPoint
= adjustTouchPointContextMenu(touchPoint(25, 5, 30, 20));
67 shouldBeWithin(adjustedPoint
, selectionBounds
);
68 adjustedPoint
= adjustTouchPointContextMenu(touchPoint(140, 10, 20, 10));
69 shouldBeWithin(adjustedPoint
, selectionBounds
);
74 if (window
.testRunner
&& window
.internals
&& internals
.touchNodeAdjustedToBestContextMenuNode
) {
75 description('Test touch-adjustment to individual words or active selection.');
76 testAdjustedTouches();
77 e
.sandbox
.style
.display
= 'none';