|
1 /* vim: set ts=2 et sw=2 tw=80: */ |
|
2 /* Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 function test() { |
|
8 waitForExplicitFinish(); |
|
9 setup((ed, win) => { |
|
10 ch(ed.getCursor(), { line: 0, ch: 0 }, "default cursor position is ok"); |
|
11 ed.setText("Hello.\nHow are you?"); |
|
12 |
|
13 ed.setCursor({ line: 1, ch: 5 }); |
|
14 ch(ed.getCursor(), { line: 1, ch: 5 }, "setCursor({ line, ch })"); |
|
15 |
|
16 ch(ed.getPosition(7), { line: 1, ch: 0}, "getPosition(num)"); |
|
17 ch(ed.getPosition(7, 1)[0], { line: 1, ch: 0}, "getPosition(num, num)[0]"); |
|
18 ch(ed.getPosition(7, 1)[1], { line: 0, ch: 1}, "getPosition(num, num)[1]"); |
|
19 |
|
20 ch(ed.getOffset({ line: 1, ch: 0 }), 7, "getOffset(num)"); |
|
21 ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 7, "getOffset(num, num)[0]"); |
|
22 ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 2, "getOffset(num, num)[1]"); |
|
23 |
|
24 is(ed.getSelection(), "", "nothing is selected"); |
|
25 ed.setSelection({ line: 0, ch: 0 }, { line: 0, ch: 5 }); |
|
26 is(ed.getSelection(), "Hello", "setSelection"); |
|
27 |
|
28 ed.dropSelection(); |
|
29 is(ed.getSelection(), "", "dropSelection"); |
|
30 |
|
31 // Check that shift-click on a gutter selects the whole line (bug 919707) |
|
32 let iframe = win.document.querySelector("iframe"); |
|
33 let gutter = iframe.contentWindow.document.querySelector(".CodeMirror-gutters"); |
|
34 |
|
35 EventUtils.sendMouseEvent({ type: "mousedown", shiftKey: true }, gutter, iframe.contentWindow); |
|
36 is(ed.getSelection(), "Hello.", "shift-click"); |
|
37 |
|
38 teardown(ed, win); |
|
39 }); |
|
40 } |