browser/devtools/scratchpad/test/browser_scratchpad_goto_line_ui.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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

mercurial