author | Julian Descottes <jdescottes@mozilla.com> |
Mon, 04 Dec 2017 18:55:55 +0100 | |
changeset 395747 | b871e0db43a1cbe71e400aa6794bfa13afe7b00c |
parent 395746 | c780082475a2740c217e9c976eb6df75f08718cb |
child 395748 | e5986b2cc92b2602ec2388ac23760501fd9c12d2 |
push id | 33054 |
push user | rgurzau@mozilla.com |
push date | Fri, 08 Dec 2017 21:57:23 +0000 |
treeherder | mozilla-central@6e2181b6137c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bgrins |
bugs | 1408933 |
milestone | 59.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser.ini @@ -208,16 +208,18 @@ skip-if = true # Bug 1403188 [browser_jsterm_autocomplete_inside_text.js] [browser_jsterm_autocomplete_native_getters.js] [browser_jsterm_autocomplete_nav_and_tab_key.js] [browser_jsterm_autocomplete_return_key_no_selection.js] [browser_jsterm_autocomplete_return_key.js] [browser_jsterm_autocomplete-properties-with-non-alphanumeric-names.js] [browser_jsterm_completion.js] [browser_jsterm_copy_command.js] +[browser_jsterm_ctrl_key_nav.js] +skip-if = os != 'mac' # The tested ctrl+key shortcuts are OSX only [browser_jsterm_dollar.js] [browser_jsterm_history.js] [browser_jsterm_history_persist.js] [browser_jsterm_history_nav.js] [browser_jsterm_inspect.js] [browser_jsterm_multiline.js] [browser_jsterm_no_autocompletion_on_defined_variables.js] [browser_jsterm_no_input_and_tab_key_pressed.js] @@ -260,19 +262,16 @@ skip-if = (os == 'linux' && bits == 32 & subsuite = clipboard [browser_webconsole_context_menu_open_url.js] [browser_webconsole_context_menu_store_as_global.js] [browser_webconsole_csp_ignore_reflected_xss_message.js] skip-if = (e10s && debug) || (e10s && os == 'win') # Bug 1221499 enabled these on windows [browser_webconsole_cspro.js] skip-if = true # Bug 1408932 # old console skip-if = e10s && (os == 'win' || os == 'mac') # Bug 1243967 -[browser_webconsole_ctrl_key_nav.js] -skip-if = true # Bug 1408933 -# old console skip-if = os != "mac" [browser_webconsole_document_focus.js] skip-if = true # Bug 1404368 [browser_webconsole_duplicate_errors.js] skip-if = true # Bug 1403907 [browser_webconsole_errors_after_page_reload.js] [browser_webconsole_eval_in_debugger_stackframe.js] [browser_webconsole_eval_in_debugger_stackframe2.js] skip-if = true # Bug 1408893
rename from devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_ctrl_key_nav.js rename to devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js --- a/devtools/client/webconsole/new-console-output/test/mochitest/browser_webconsole_ctrl_key_nav.js +++ b/devtools/client/webconsole/new-console-output/test/mochitest/browser_jsterm_ctrl_key_nav.js @@ -1,96 +1,90 @@ /* -*- 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/ */ // Test navigation of webconsole contents via ctrl-a, ctrl-e, ctrl-p, ctrl-n // see https://bugzilla.mozilla.org/show_bug.cgi?id=804845 +// +// The shortcuts tested here have platform limitations: +// - ctrl-e does not work on windows, +// - ctrl-a, ctrl-p and ctrl-n only work on OSX "use strict"; const TEST_URI = "data:text/html;charset=utf-8,Web Console test for " + "bug 804845 and bug 619598"; -var jsterm, inputNode; - -add_task(function* () { - yield loadTab(TEST_URI); - - let hud = yield openConsole(); +add_task(async function () { + const {jsterm} = await openNewTabAndConsole(TEST_URI); - doTests(hud); - - jsterm = inputNode = null; -}); - -function doTests(HUD) { - jsterm = HUD.jsterm; - inputNode = jsterm.inputNode; ok(!jsterm.getInputValue(), "jsterm.getInputValue() is empty"); is(jsterm.inputNode.selectionStart, 0); is(jsterm.inputNode.selectionEnd, 0); - testSingleLineInputNavNoHistory(); - testMultiLineInputNavNoHistory(); - testNavWithHistory(); -} + testSingleLineInputNavNoHistory(jsterm); + testMultiLineInputNavNoHistory(jsterm); + testNavWithHistory(jsterm); +}); -function testSingleLineInputNavNoHistory() { +function testSingleLineInputNavNoHistory(jsterm) { + let inputNode = jsterm.inputNode; // Single char input EventUtils.synthesizeKey("1", {}); is(inputNode.selectionStart, 1, "caret location after single char input"); // nav to start/end with ctrl-a and ctrl-e; - EventUtils.synthesizeKey("a", { ctrlKey: true }); + synthesizeLineStartKey(); is(inputNode.selectionStart, 0, "caret location after single char input and ctrl-a"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + synthesizeLineEndKey(); is(inputNode.selectionStart, 1, "caret location after single char input and ctrl-e"); // Second char input EventUtils.synthesizeKey("2", {}); // nav to start/end with up/down keys; verify behaviour using ctrl-p/ctrl-n EventUtils.synthesizeKey("VK_UP", {}); is(inputNode.selectionStart, 0, "caret location after two char input and VK_UP"); EventUtils.synthesizeKey("VK_DOWN", {}); is(inputNode.selectionStart, 2, "caret location after two char input and VK_DOWN"); - EventUtils.synthesizeKey("a", { ctrlKey: true }); + synthesizeLineStartKey(); is(inputNode.selectionStart, 0, "move caret to beginning of 2 char input with ctrl-a"); - EventUtils.synthesizeKey("a", { ctrlKey: true }); + synthesizeLineStartKey(); is(inputNode.selectionStart, 0, "no change of caret location on repeat ctrl-a"); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(inputNode.selectionStart, 0, "no change of caret location on ctrl-p from beginning of line"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + synthesizeLineEndKey(); is(inputNode.selectionStart, 2, "move caret to end of 2 char input with ctrl-e"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + synthesizeLineEndKey(); is(inputNode.selectionStart, 2, "no change of caret location on repeat ctrl-e"); - EventUtils.synthesizeKey("n", { ctrlKey: true }); + synthesizeLineDownKey(); is(inputNode.selectionStart, 2, "no change of caret location on ctrl-n from end of line"); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(inputNode.selectionStart, 0, "ctrl-p moves to start of line"); - EventUtils.synthesizeKey("n", { ctrlKey: true }); + synthesizeLineDownKey(); is(inputNode.selectionStart, 2, "ctrl-n moves to end of line"); } -function testMultiLineInputNavNoHistory() { +function testMultiLineInputNavNoHistory(jsterm) { + let inputNode = jsterm.inputNode; let lineValues = ["one", "2", "something longer", "", "", "three!"]; jsterm.setInputValue(""); // simulate shift-return for (let i = 0; i < lineValues.length; i++) { jsterm.setInputValue(jsterm.getInputValue() + lineValues[i]); EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); } let inputValue = jsterm.getInputValue(); @@ -108,120 +102,141 @@ function testMultiLineInputNavNoHistory( is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "up arrow from end of multiline"); EventUtils.synthesizeKey("VK_DOWN", {}); is(jsterm.getInputValue().slice(inputNode.selectionStart), "", "down arrow from within multiline"); // navigate up through input lines - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "ctrl-p from end of multiline"); for (let i = 4; i >= 0; i--) { - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); expectedStringAfterCarat = lineValues[i] + newlineString + expectedStringAfterCarat; is(jsterm.getInputValue().slice(inputNode.selectionStart), expectedStringAfterCarat, "ctrl-p from within line " + i + " of multiline input"); } - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(inputNode.selectionStart, 0, "reached start of input"); is(jsterm.getInputValue(), inputValue, "no change to multiline input on ctrl-p from beginning of multiline"); // navigate to end of first line - EventUtils.synthesizeKey("e", { ctrlKey: true }); + synthesizeLineEndKey(); let caretPos = inputNode.selectionStart; let expectedStringBeforeCarat = lineValues[0]; is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat, "ctrl-e into multiline input"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + synthesizeLineEndKey(); is(inputNode.selectionStart, caretPos, "repeat ctrl-e doesn't change caret position in multiline input"); // navigate down one line; ctrl-a to the beginning; ctrl-e to end for (let i = 1; i < lineValues.length; i++) { - EventUtils.synthesizeKey("n", { ctrlKey: true }); - EventUtils.synthesizeKey("a", { ctrlKey: true }); + synthesizeLineDownKey(); + synthesizeLineStartKey(); caretPos = inputNode.selectionStart; expectedStringBeforeCarat += newlineString; is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat, "ctrl-a to beginning of line " + (i + 1) + " in multiline input"); - EventUtils.synthesizeKey("e", { ctrlKey: true }); + synthesizeLineEndKey(); caretPos = inputNode.selectionStart; expectedStringBeforeCarat += lineValues[i]; is(jsterm.getInputValue().slice(0, caretPos), expectedStringBeforeCarat, "ctrl-e to end of line " + (i + 1) + "in multiline input"); } } -function testNavWithHistory() { +function testNavWithHistory(jsterm) { + let inputNode = jsterm.inputNode; + // NOTE: Tests does NOT currently define behaviour for ctrl-p/ctrl-n with // caret placed _within_ single line input - let values = ['"single line input"', - '"a longer single-line input to check caret repositioning"', - ['"multi-line"', '"input"', '"here!"'].join("\n"), - ]; + let values = [ + '"single line input"', + '"a longer single-line input to check caret repositioning"', + '"multi-line"\n"input"\n"here!"', + ]; + // submit to history for (let i = 0; i < values.length; i++) { jsterm.setInputValue(values[i]); jsterm.execute(); } is(inputNode.selectionStart, 0, "caret location at start of empty line"); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(inputNode.selectionStart, values[values.length - 1].length, "caret location correct at end of last history input"); // Navigate backwards history with ctrl-p for (let i = values.length - 1; i > 0; i--) { let match = values[i].match(/(\n)/g); if (match) { // multi-line inputs won't update from history unless caret at beginning - EventUtils.synthesizeKey("a", { ctrlKey: true }); + synthesizeLineStartKey(); for (let j = 0; j < match.length; j++) { - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); } - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); } else { // single-line inputs will update from history from end of line - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); } is(jsterm.getInputValue(), values[i - 1], "ctrl-p updates inputNode from backwards history values[" + i - 1 + "]"); } + let inputValue = jsterm.getInputValue(); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(inputNode.selectionStart, 0, "ctrl-p at beginning of history moves caret location to beginning " + "of line"); is(jsterm.getInputValue(), inputValue, "no change to input value on ctrl-p from beginning of line"); // Navigate forwards history with ctrl-n for (let i = 1; i < values.length; i++) { - EventUtils.synthesizeKey("n", { ctrlKey: true }); + synthesizeLineDownKey(); is(jsterm.getInputValue(), values[i], "ctrl-n updates inputNode from forwards history values[" + i + "]"); is(inputNode.selectionStart, values[i].length, "caret location correct at end of history input for values[" + i + "]"); } - EventUtils.synthesizeKey("n", { ctrlKey: true }); + synthesizeLineDownKey(); ok(!jsterm.getInputValue(), "ctrl-n at end of history updates to empty input"); // Simulate editing multi-line inputValue = "one\nlinebreak"; jsterm.setInputValue(inputValue); // Attempt nav within input - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineUpKey(); is(jsterm.getInputValue(), inputValue, "ctrl-p from end of multi-line does not trigger history"); - EventUtils.synthesizeKey("a", { ctrlKey: true }); - EventUtils.synthesizeKey("p", { ctrlKey: true }); + synthesizeLineStartKey(); + synthesizeLineUpKey(); is(jsterm.getInputValue(), values[values.length - 1], "ctrl-p from start of multi-line triggers history"); } + +function synthesizeLineStartKey() { + EventUtils.synthesizeKey("a", { ctrlKey: true }); +} + +function synthesizeLineEndKey() { + EventUtils.synthesizeKey("e", { ctrlKey: true }); +} + +function synthesizeLineUpKey() { + EventUtils.synthesizeKey("p", { ctrlKey: true }); +} + +function synthesizeLineDownKey() { + EventUtils.synthesizeKey("n", { ctrlKey: true }); +}