diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/framework/test/browser_toolbox_split_console.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/framework/test/browser_toolbox_split_console.js')
-rw-r--r-- | devtools/client/framework/test/browser_toolbox_split_console.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/devtools/client/framework/test/browser_toolbox_split_console.js b/devtools/client/framework/test/browser_toolbox_split_console.js new file mode 100644 index 000000000..8e1fecd15 --- /dev/null +++ b/devtools/client/framework/test/browser_toolbox_split_console.js @@ -0,0 +1,85 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Tests that these toolbox split console APIs work: +// * toolbox.useKeyWithSplitConsole() +// * toolbox.isSplitConsoleFocused + +let gToolbox = null; +let panelWin = null; + +const URL = "data:text/html;charset=utf8,test split console key delegation"; + +// Force the old debugger UI since it's directly used (see Bug 1301705) +Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false); +registerCleanupFunction(function* () { + Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend"); +}); + +add_task(function* () { + let tab = yield addTab(URL); + let target = TargetFactory.forTab(tab); + gToolbox = yield gDevTools.showToolbox(target, "jsdebugger"); + panelWin = gToolbox.getPanel("jsdebugger").panelWin; + + yield gToolbox.openSplitConsole(); + yield testIsSplitConsoleFocused(); + yield testUseKeyWithSplitConsole(); + yield testUseKeyWithSplitConsoleWrongTool(); + + yield cleanup(); +}); + +function* testIsSplitConsoleFocused() { + yield gToolbox.openSplitConsole(); + // The newly opened split console should have focus + ok(gToolbox.isSplitConsoleFocused(), "Split console is focused"); + panelWin.focus(); + ok(!gToolbox.isSplitConsoleFocused(), "Split console is no longer focused"); +} + +// A key bound to the selected tool should trigger it's command +function* testUseKeyWithSplitConsole() { + let commandCalled = false; + + info("useKeyWithSplitConsole on debugger while debugger is focused"); + gToolbox.useKeyWithSplitConsole("F3", () => { + commandCalled = true; + }, "jsdebugger"); + + info("synthesizeKey with the console focused"); + let consoleInput = gToolbox.getPanel("webconsole").hud.jsterm.inputNode; + consoleInput.focus(); + synthesizeKeyShortcut("F3", panelWin); + + ok(commandCalled, "Shortcut key should trigger the command"); +} + +// A key bound to a *different* tool should not trigger it's command +function* testUseKeyWithSplitConsoleWrongTool() { + let commandCalled = false; + + info("useKeyWithSplitConsole on inspector while debugger is focused"); + gToolbox.useKeyWithSplitConsole("F4", () => { + commandCalled = true; + }, "inspector"); + + info("synthesizeKey with the console focused"); + let consoleInput = gToolbox.getPanel("webconsole").hud.jsterm.inputNode; + consoleInput.focus(); + synthesizeKeyShortcut("F4", panelWin); + + ok(!commandCalled, "Shortcut key shouldn't trigger the command"); +} + +function* cleanup() { + // We don't want the open split console to confuse other tests.. + Services.prefs.clearUserPref("devtools.toolbox.splitconsoleEnabled"); + yield gToolbox.destroy(); + gBrowser.removeCurrentTab(); + gToolbox = panelWin = null; +} |