browser/devtools/scratchpad/test/browser_scratchpad_goto_line_ui.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:5d7bb0688311
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 714942 */
5
6 function test()
7 {
8 waitForExplicitFinish();
9
10 gBrowser.selectedTab = gBrowser.addTab();
11 gBrowser.selectedBrowser.addEventListener("load", function browserLoad() {
12 gBrowser.selectedBrowser.removeEventListener("load", browserLoad, true);
13 openScratchpad(runTests);
14 }, true);
15
16 content.location = "data:text/html,<p>test the 'Jump to line' feature in Scratchpad";
17 }
18
19 function runTests(aWindow, aScratchpad)
20 {
21 let editor = aScratchpad.editor;
22 let text = "foobar bug650345\nBug650345 bazbaz\nfoobar omg\ntest";
23 editor.setText(text);
24 editor.setCursor({ line: 0, ch: 0 });
25
26 let oldPrompt = editor.openDialog;
27 let desiredValue;
28
29 editor.openDialog = function (text, cb) {
30 cb(desiredValue);
31 };
32
33 desiredValue = 3;
34 EventUtils.synthesizeKey("J", {accelKey: true}, aWindow);
35 is(editor.getCursor().line, 2, "line is correct");
36
37 desiredValue = 2;
38 aWindow.goDoCommand("cmd_gotoLine")
39 is(editor.getCursor().line, 1, "line is correct (again)");
40
41 editor.openDialog = oldPrompt;
42 finish();
43 }

mercurial