1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/sourceeditor/test/browser_editor_cursor.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,40 @@ 1.4 +/* vim: set ts=2 et sw=2 tw=80: */ 1.5 +/* Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +function test() { 1.11 + waitForExplicitFinish(); 1.12 + setup((ed, win) => { 1.13 + ch(ed.getCursor(), { line: 0, ch: 0 }, "default cursor position is ok"); 1.14 + ed.setText("Hello.\nHow are you?"); 1.15 + 1.16 + ed.setCursor({ line: 1, ch: 5 }); 1.17 + ch(ed.getCursor(), { line: 1, ch: 5 }, "setCursor({ line, ch })"); 1.18 + 1.19 + ch(ed.getPosition(7), { line: 1, ch: 0}, "getPosition(num)"); 1.20 + ch(ed.getPosition(7, 1)[0], { line: 1, ch: 0}, "getPosition(num, num)[0]"); 1.21 + ch(ed.getPosition(7, 1)[1], { line: 0, ch: 1}, "getPosition(num, num)[1]"); 1.22 + 1.23 + ch(ed.getOffset({ line: 1, ch: 0 }), 7, "getOffset(num)"); 1.24 + ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 7, "getOffset(num, num)[0]"); 1.25 + ch(ed.getOffset({ line: 1, ch: 0 }, { line: 0, ch: 1 })[0], 2, "getOffset(num, num)[1]"); 1.26 + 1.27 + is(ed.getSelection(), "", "nothing is selected"); 1.28 + ed.setSelection({ line: 0, ch: 0 }, { line: 0, ch: 5 }); 1.29 + is(ed.getSelection(), "Hello", "setSelection"); 1.30 + 1.31 + ed.dropSelection(); 1.32 + is(ed.getSelection(), "", "dropSelection"); 1.33 + 1.34 + // Check that shift-click on a gutter selects the whole line (bug 919707) 1.35 + let iframe = win.document.querySelector("iframe"); 1.36 + let gutter = iframe.contentWindow.document.querySelector(".CodeMirror-gutters"); 1.37 + 1.38 + EventUtils.sendMouseEvent({ type: "mousedown", shiftKey: true }, gutter, iframe.contentWindow); 1.39 + is(ed.getSelection(), "Hello.", "shift-click"); 1.40 + 1.41 + teardown(ed, win); 1.42 + }); 1.43 +} 1.44 \ No newline at end of file