michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: setup((ed, win) => { michael@0: ch(ed.getCursor(), { line: 0, ch: 0 }, "default cursor position is ok"); michael@0: ed.setText("Hello.\nHow are you?"); michael@0: michael@0: ed.setCursor({ line: 1, ch: 5 }); michael@0: ch(ed.getCursor(), { line: 1, ch: 5 }, "setCursor({ line, ch })"); michael@0: michael@0: ch(ed.getPosition(7), { line: 1, ch: 0}, "getPosition(num)"); michael@0: ch(ed.getPosition(7, 1)[0], { line: 1, ch: 0}, "getPosition(num, num)[0]"); michael@0: ch(ed.getPosition(7, 1)[1], { line: 0, ch: 1}, "getPosition(num, num)[1]"); michael@0: michael@0: ch(ed.getOffset({ line: 1, ch: 0 }), 7, "getOffset(num)"); michael@0: ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 7, "getOffset(num, num)[0]"); michael@0: ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 2, "getOffset(num, num)[1]"); michael@0: michael@0: is(ed.getSelection(), "", "nothing is selected"); michael@0: ed.setSelection({ line: 0, ch: 0 }, { line: 0, ch: 5 }); michael@0: is(ed.getSelection(), "Hello", "setSelection"); michael@0: michael@0: ed.dropSelection(); michael@0: is(ed.getSelection(), "", "dropSelection"); michael@0: michael@0: // Check that shift-click on a gutter selects the whole line (bug 919707) michael@0: let iframe = win.document.querySelector("iframe"); michael@0: let gutter = iframe.contentWindow.document.querySelector(".CodeMirror-gutters"); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown", shiftKey: true }, gutter, iframe.contentWindow); michael@0: is(ed.getSelection(), "Hello.", "shift-click"); michael@0: michael@0: teardown(ed, win); michael@0: }); michael@0: }