browser/devtools/sourceeditor/test/browser_editor_cursor.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     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/ */
     5 "use strict";
     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?");
    13     ed.setCursor({ line: 1, ch: 5 });
    14     ch(ed.getCursor(), { line: 1, ch: 5 }, "setCursor({ line, ch })");
    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]");
    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]");
    24     is(ed.getSelection(), "", "nothing is selected");
    25     ed.setSelection({ line: 0, ch: 0 }, { line: 0, ch: 5 });
    26     is(ed.getSelection(), "Hello", "setSelection");
    28     ed.dropSelection();
    29     is(ed.getSelection(), "", "dropSelection");
    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");
    35     EventUtils.sendMouseEvent({ type: "mousedown", shiftKey: true }, gutter, iframe.contentWindow);
    36     is(ed.getSelection(), "Hello.", "shift-click");
    38     teardown(ed, win);
    39   });
    40 }

mercurial