browser/devtools/scratchpad/test/browser_scratchpad_goto_line_ui.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/scratchpad/test/browser_scratchpad_goto_line_ui.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,43 @@
     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 +/* Bug 714942 */
     1.8 +
     1.9 +function test()
    1.10 +{
    1.11 +  waitForExplicitFinish();
    1.12 +
    1.13 +  gBrowser.selectedTab = gBrowser.addTab();
    1.14 +  gBrowser.selectedBrowser.addEventListener("load", function browserLoad() {
    1.15 +    gBrowser.selectedBrowser.removeEventListener("load", browserLoad, true);
    1.16 +    openScratchpad(runTests);
    1.17 +  }, true);
    1.18 +
    1.19 +  content.location = "data:text/html,<p>test the 'Jump to line' feature in Scratchpad";
    1.20 +}
    1.21 +
    1.22 +function runTests(aWindow, aScratchpad)
    1.23 +{
    1.24 +  let editor = aScratchpad.editor;
    1.25 +  let text = "foobar bug650345\nBug650345 bazbaz\nfoobar omg\ntest";
    1.26 +  editor.setText(text);
    1.27 +  editor.setCursor({ line: 0, ch: 0 });
    1.28 +
    1.29 +  let oldPrompt = editor.openDialog;
    1.30 +  let desiredValue;
    1.31 +
    1.32 +  editor.openDialog = function (text, cb) {
    1.33 +    cb(desiredValue);
    1.34 +  };
    1.35 +
    1.36 +  desiredValue = 3;
    1.37 +  EventUtils.synthesizeKey("J", {accelKey: true}, aWindow);
    1.38 +  is(editor.getCursor().line, 2, "line is correct");
    1.39 +
    1.40 +  desiredValue = 2;
    1.41 +  aWindow.goDoCommand("cmd_gotoLine")
    1.42 +  is(editor.getCursor().line, 1, "line is correct (again)");
    1.43 +
    1.44 +  editor.openDialog = oldPrompt;
    1.45 +  finish();
    1.46 +}

mercurial