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 | var simpleProg = "function foo() {\n let i = 1;\n let j = 2;\n return bar;\n}"; |
michael@0 | 11 | ed.setText(simpleProg); |
michael@0 | 12 | |
michael@0 | 13 | // Move first line up |
michael@0 | 14 | ed.setCursor({ line: 0, ch: 0 }); |
michael@0 | 15 | ed.moveLineUp(); |
michael@0 | 16 | is(ed.getText(0), "function foo() {", "getText(num)"); |
michael@0 | 17 | ch(ed.getCursor(), { line: 0, ch: 0 }, "getCursor"); |
michael@0 | 18 | |
michael@0 | 19 | // Move last line down |
michael@0 | 20 | ed.setCursor({ line: 4, ch: 0 }); |
michael@0 | 21 | ed.moveLineDown(); |
michael@0 | 22 | is(ed.getText(4), "}", "getText(num)"); |
michael@0 | 23 | ch(ed.getCursor(), { line: 4, ch: 0 }, "getCursor"); |
michael@0 | 24 | |
michael@0 | 25 | // Move line 2 up |
michael@0 | 26 | ed.setCursor({ line: 1, ch: 5}); |
michael@0 | 27 | ed.moveLineUp(); |
michael@0 | 28 | is(ed.getText(0), " let i = 1;", "getText(num)"); |
michael@0 | 29 | is(ed.getText(1), "function foo() {", "getText(num)"); |
michael@0 | 30 | ch(ed.getCursor(), { line: 0, ch: 5 }, "getCursor"); |
michael@0 | 31 | |
michael@0 | 32 | // Undo previous move by moving line 1 down |
michael@0 | 33 | ed.moveLineDown(); |
michael@0 | 34 | is(ed.getText(0), "function foo() {", "getText(num)"); |
michael@0 | 35 | is(ed.getText(1), " let i = 1;", "getText(num)"); |
michael@0 | 36 | ch(ed.getCursor(), { line: 1, ch: 5 }, "getCursor"); |
michael@0 | 37 | |
michael@0 | 38 | // Move line 2 and 3 up |
michael@0 | 39 | ed.setSelection({ line: 1, ch: 0 }, { line: 2, ch: 0 }); |
michael@0 | 40 | ed.moveLineUp(); |
michael@0 | 41 | is(ed.getText(0), " let i = 1;", "getText(num)"); |
michael@0 | 42 | is(ed.getText(1), " let j = 2;", "getText(num)"); |
michael@0 | 43 | is(ed.getText(2), "function foo() {", "getText(num)"); |
michael@0 | 44 | ch(ed.getCursor("start"), { line: 0, ch: 0 }, "getCursor(string)"); |
michael@0 | 45 | ch(ed.getCursor("end"), { line: 1, ch: 0 }, "getCursor(string)"); |
michael@0 | 46 | |
michael@0 | 47 | // Move line 1 to 3 down twice |
michael@0 | 48 | ed.dropSelection(); |
michael@0 | 49 | ed.setSelection({ line: 0, ch: 7 }, { line: 2, ch: 5 }); |
michael@0 | 50 | ed.moveLineDown(); |
michael@0 | 51 | ed.moveLineDown(); |
michael@0 | 52 | is(ed.getText(0), " return bar;", "getText(num)"); |
michael@0 | 53 | is(ed.getText(1), "}", "getText(num)"); |
michael@0 | 54 | is(ed.getText(2), " let i = 1;", "getText(num)"); |
michael@0 | 55 | is(ed.getText(3), " let j = 2;", "getText(num)"); |
michael@0 | 56 | is(ed.getText(4), "function foo() {", "getText(num)"); |
michael@0 | 57 | ch(ed.getCursor("start"), { line: 2, ch: 7 }, "getCursor(string)"); |
michael@0 | 58 | ch(ed.getCursor("end"), { line: 4, ch: 5 }, "getCursor(string)"); |
michael@0 | 59 | |
michael@0 | 60 | teardown(ed, win); |
michael@0 | 61 | }); |
michael@0 | 62 | } |