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