4 On Mac when word-selecting backwards starting with the
5 caret on the middle of a word and then word-selecting forward, the
6 caret is left in the same place where it was, instead of directly selecting to the end
7 of the word (which is windows/unix behavior).
10 <div id=
"test-div" contenteditable=true
>
17 function editingTest(behavior
) {
18 if (window
.testRunner
&& window
.internals
) {
19 testRunner
.dumpAsText();
20 internals
.settings
.setEditingBehavior(behavior
);
23 function getSetCaretFunction(node
, container
, offset
) {
25 var selection
= window
.getSelection();
28 var range
= document
.createRange();
29 range
.setStart(container
, offset
);
30 selection
.addRange(range
);
34 function runTest(firstDirection
, secondDirection
, granularity
, expectedText
, setCaret
) {
35 var selection
= window
.getSelection();
37 selection
.modify("extend", firstDirection
, granularity
);
38 selection
.modify("extend", secondDirection
, granularity
);
39 var s
= selection
.toString();
40 document
.write("Extend " + firstDirection
+ " and then " + secondDirection
+ " by " + granularity
+ ": ");
41 document
.write(s
=== expectedText
? "PASS" : 'FAIL: expected "' + escape(expectedText
) + '", got "' + escape(s
) + '"');
42 document
.write("<br>");
45 var node
= document
.getElementById("test-div");
46 var children
= node
.childNodes
;
48 var wordCaretFunction
= getSetCaretFunction(node
, children
[2], children
[2].data
.search("ne 2"));
50 document
.write(behavior
+ ":<br>");
51 runTest("backward", "forward", "word", behavior
== "mac" ? "" : behavior
== "win" ? "ne " : "ne", getSetCaretFunction(node
, children
[2], children
[2].data
.search("ne 2")));
52 runTest("forward", "backward", "word", behavior
== "mac" ? "" : "li", getSetCaretFunction(node
, children
[2], children
[2].data
.search("ne 2")));
53 runTest("backward", "forward", "line", behavior
== "mac" ? "" : "1\nline ", getSetCaretFunction(node
, children
[0], children
[0].data
.search("1")));
54 runTest("forward", "backward", "line", behavior
== "mac" ? "" : "2\nline ", getSetCaretFunction(node
, children
[4], children
[4].data
.search("3")));
55 runTest("backward", "forward", "paragraph", behavior
== "mac" ? "" : "1\nline ", getSetCaretFunction(node
, children
[0], children
[0].data
.search("1")));
56 runTest("forward", "backward", "paragraph", behavior
== "mac" ? "" : "2\nline ", getSetCaretFunction(node
, children
[4], children
[4].data
.search("3")));
62 editingTest("android");
64 var node
= document
.getElementById("test-div");
65 node
.parentNode
.removeChild(node
);