Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / extend-after-mouse-selection.html
blob8a05b2741a06ad99137bbaabe30e1f477543ab69
1 <html>
2 <head>
4 <style>
5 .editing {
6 border: 2px solid red;
7 font-size: 24px;
9 </style>
10 <script src="../editing.js"></script>
11 <script src="../../resources/js-test.js"></script>
12 <script src="resources/js-test-selection-shared.js"></script>
14 <script>
16 function editingTest(editingBehavior) {
18 if (window.internals)
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);
41 else
42 assertSelectionAt(startTarget.firstChild, 0, endTarget.firstChild, 1);
44 extendSelectionForwardByCharacterCommand();
45 if (editingBehavior == "mac")
46 assertSelectionAt(endTarget.firstChild, 2, startTarget.firstChild, 0);
47 else
48 assertSelectionAt(startTarget.firstChild, 0, endTarget.firstChild, 2);
50 extendSelectionForwardByLineBoundaryCommand();
52 if (editingBehavior == "mac")
53 assertSelectionAt(endTarget.nextSibling, 1, startTarget.firstChild, 0);
54 else
55 assertSelectionAt(startTarget.firstChild, 0, endTarget.nextSibling, 1);
57 extendSelectionBackwardByLineBoundaryCommand();
59 if (editingBehavior == "mac")
60 assertSelectionAt(endTarget.nextSibling, 1, startTarget.previousSibling, 0);
61 else
62 assertSelectionAt(startTarget.firstChild, 0, document.getElementById('test'), 4);
65 </script>
67 <title>Editing Test</title>
68 </head>
69 <body>
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>
72 </div>
74 <div id="console"></div>
76 <script>
77 editingTest("mac");
78 editingTest("win");
79 editingTest("unix");
80 editingTest("android");
81 </script>
83 </body>
84 </html>