michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: /* Bug 714942 */ michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function browserLoad() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", browserLoad, true); michael@0: openScratchpad(runTests); michael@0: }, true); michael@0: michael@0: content.location = "data:text/html,
test the 'Jump to line' feature in Scratchpad"; michael@0: } michael@0: michael@0: function runTests(aWindow, aScratchpad) michael@0: { michael@0: let editor = aScratchpad.editor; michael@0: let text = "foobar bug650345\nBug650345 bazbaz\nfoobar omg\ntest"; michael@0: editor.setText(text); michael@0: editor.setCursor({ line: 0, ch: 0 }); michael@0: michael@0: let oldPrompt = editor.openDialog; michael@0: let desiredValue; michael@0: michael@0: editor.openDialog = function (text, cb) { michael@0: cb(desiredValue); michael@0: }; michael@0: michael@0: desiredValue = 3; michael@0: EventUtils.synthesizeKey("J", {accelKey: true}, aWindow); michael@0: is(editor.getCursor().line, 2, "line is correct"); michael@0: michael@0: desiredValue = 2; michael@0: aWindow.goDoCommand("cmd_gotoLine") michael@0: is(editor.getCursor().line, 1, "line is correct (again)"); michael@0: michael@0: editor.openDialog = oldPrompt; michael@0: finish(); michael@0: }