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 | /* Bug 660560 */ |
michael@0 | 5 | |
michael@0 | 6 | function test() |
michael@0 | 7 | { |
michael@0 | 8 | waitForExplicitFinish(); |
michael@0 | 9 | |
michael@0 | 10 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 11 | gBrowser.selectedBrowser.addEventListener("load", function onTabLoad() { |
michael@0 | 12 | gBrowser.selectedBrowser.removeEventListener("load", onTabLoad, true); |
michael@0 | 13 | |
michael@0 | 14 | ok(window.Scratchpad, "Scratchpad variable exists"); |
michael@0 | 15 | |
michael@0 | 16 | Services.prefs.setIntPref("devtools.editor.tabsize", 5); |
michael@0 | 17 | |
michael@0 | 18 | openScratchpad(runTests); |
michael@0 | 19 | }, true); |
michael@0 | 20 | |
michael@0 | 21 | content.location = "data:text/html,Scratchpad test for the Tab key, bug 660560"; |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | function runTests() |
michael@0 | 25 | { |
michael@0 | 26 | let sp = gScratchpadWindow.Scratchpad; |
michael@0 | 27 | ok(sp, "Scratchpad object exists in new window"); |
michael@0 | 28 | |
michael@0 | 29 | ok(sp.editor.hasFocus(), "the editor has focus"); |
michael@0 | 30 | |
michael@0 | 31 | sp.setText("window.foo;"); |
michael@0 | 32 | sp.editor.setCursor({ line: 0, ch: 0 }); |
michael@0 | 33 | |
michael@0 | 34 | EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow); |
michael@0 | 35 | |
michael@0 | 36 | is(sp.getText(), " window.foo;", "Tab key added 5 spaces"); |
michael@0 | 37 | |
michael@0 | 38 | is(sp.editor.getCursor().line, 0, "line is correct"); |
michael@0 | 39 | is(sp.editor.getCursor().ch, 5, "character is correct"); |
michael@0 | 40 | |
michael@0 | 41 | sp.editor.setCursor({ line: 0, ch: 6 }); |
michael@0 | 42 | |
michael@0 | 43 | EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow); |
michael@0 | 44 | |
michael@0 | 45 | is(sp.getText(), " w indow.foo;", |
michael@0 | 46 | "Tab key added 4 spaces"); |
michael@0 | 47 | |
michael@0 | 48 | is(sp.editor.getCursor().line, 0, "line is correct"); |
michael@0 | 49 | is(sp.editor.getCursor().ch, 10, "character is correct"); |
michael@0 | 50 | |
michael@0 | 51 | gScratchpadWindow.close(); |
michael@0 | 52 | |
michael@0 | 53 | Services.prefs.setIntPref("devtools.editor.tabsize", 6); |
michael@0 | 54 | Services.prefs.setBoolPref("devtools.editor.expandtab", false); |
michael@0 | 55 | |
michael@0 | 56 | openScratchpad(runTests2); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | function runTests2() |
michael@0 | 60 | { |
michael@0 | 61 | let sp = gScratchpadWindow.Scratchpad; |
michael@0 | 62 | |
michael@0 | 63 | sp.setText("window.foo;"); |
michael@0 | 64 | sp.editor.setCursor({ line: 0, ch: 0 }); |
michael@0 | 65 | |
michael@0 | 66 | EventUtils.synthesizeKey("VK_TAB", {}, gScratchpadWindow); |
michael@0 | 67 | |
michael@0 | 68 | is(sp.getText(), "\twindow.foo;", "Tab key added the tab character"); |
michael@0 | 69 | |
michael@0 | 70 | is(sp.editor.getCursor().line, 0, "line is correct"); |
michael@0 | 71 | is(sp.editor.getCursor().ch, 1, "character is correct"); |
michael@0 | 72 | |
michael@0 | 73 | Services.prefs.clearUserPref("devtools.editor.tabsize"); |
michael@0 | 74 | Services.prefs.clearUserPref("devtools.editor.expandtab"); |
michael@0 | 75 | |
michael@0 | 76 | finish(); |
michael@0 | 77 | } |