browser/devtools/scratchpad/test/browser_scratchpad_tab.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial