10 <script src=
"../editing.js"></script>
11 <script src=
"../../resources/js-test.js"></script>
12 <script src=
"resources/js-test-selection-shared.js"></script>
16 function editingTest(editingBehavior
) {
19 internals
.settings
.setEditingBehavior(editingBehavior
);
21 var startTarget
= document
.getElementById('start');
22 var endTarget
= document
.getElementById('end');
24 eventSender
.mouseMoveTo(startTarget
.offsetLeft
, startTarget
.offsetTop
+ 10);
25 // Double-click to select at word-granularity to workaround eventSender bug with selecting text at
26 // character granularity (i.e. that it just doesn't work).
27 eventSender
.mouseDown();
28 eventSender
.mouseUp();
29 eventSender
.mouseDown();
30 eventSender
.mouseMoveTo(endTarget
.offsetLeft
, endTarget
.offsetTop
+ 10);
31 eventSender
.mouseUp();
33 assertSelectionAt(startTarget
.firstChild
, 0, endTarget
.firstChild
, 2);
35 extendSelectionBackwardByCharacterCommand();
37 // On Win/Linux the anchor is be fixed after the mouse-selection and never changes.
38 // On Mac, the first character-granularity selection after a mouse-selection resets the anchor/focus.
39 if (editingBehavior
== "mac")
40 assertSelectionAt(endTarget
.firstChild
, 2, startTarget
.previousSibling
, 1);
42 assertSelectionAt(startTarget
.firstChild
, 0, endTarget
.firstChild
, 1);
44 extendSelectionForwardByCharacterCommand();
45 if (editingBehavior
== "mac")
46 assertSelectionAt(endTarget
.firstChild
, 2, startTarget
.firstChild
, 0);
48 assertSelectionAt(startTarget
.firstChild
, 0, endTarget
.firstChild
, 2);
50 extendSelectionForwardByLineBoundaryCommand();
52 if (editingBehavior
== "mac")
53 assertSelectionAt(endTarget
.nextSibling
, 1, startTarget
.firstChild
, 0);
55 assertSelectionAt(startTarget
.firstChild
, 0, endTarget
.nextSibling
, 1);
57 extendSelectionBackwardByLineBoundaryCommand();
59 if (editingBehavior
== "mac")
60 assertSelectionAt(endTarget
.nextSibling
, 1, startTarget
.previousSibling
, 0);
62 assertSelectionAt(startTarget
.firstChild
, 0, document
.getElementById('test'), 4);
67 <title>Editing Test
</title>
70 <div contenteditable
id=
"root" class=
"editing">
71 <span id=
"test">a
<span id=
"start">bc
</span> <br>d
<span id=
"end">ef
</span> <br>ghi
</span>
74 <div id=
"console"></div>
80 editingTest("android");