зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648017 - Disable console text-selection only evaluation in in-line mode. r=Honza.
This feature is great in editor mode, but can be confusing in in-line mode. In inline mode, the input is cleared when you evaluate, so if you wrongfully evaluated only a text selection, you may lose the whole input, and have to type it again. This patch disable the feature in inline mode, and modifies the existing test so we make sure that this work as expected in both editor and inline mode. Differential Revision: https://phabricator.services.mozilla.com/D81333
This commit is contained in:
Родитель
6fb11b8325
Коммит
b4e71553af
|
@ -654,7 +654,13 @@ class JSTerm extends Component {
|
|||
* Execute a string. Execution happens asynchronously in the content process.
|
||||
*/
|
||||
_execute() {
|
||||
const executeString = this.getSelectedText() || this._getValue();
|
||||
const value = this._getValue();
|
||||
// In editor mode, we only evaluate the text selection if there's one. The feature isn't
|
||||
// enabled in inline mode as it can be confusing since input is cleared when evaluating.
|
||||
const executeString = this.props.editorMode
|
||||
? this.getSelectedText() || value
|
||||
: value;
|
||||
|
||||
if (!executeString) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,13 @@ add_task(async function() {
|
|||
await pushPref("devtools.webconsole.input.editor", true);
|
||||
const hud = await openNewTabAndConsole(TEST_URI);
|
||||
|
||||
const expression = `x = 10;x;
|
||||
x = 20;x;`;
|
||||
const expression = `x = "first assignment";x;
|
||||
x = "second assignment";x;`;
|
||||
|
||||
info("Evaluate the whole expression");
|
||||
setInputValue(hud, expression);
|
||||
|
||||
let onResultMessage = waitForMessage(hud, "20", ".result");
|
||||
let onResultMessage = waitForMessage(hud, "second assignment", ".result");
|
||||
synthesizeKeyboardEvaluation();
|
||||
await onResultMessage;
|
||||
ok(true, "The whole expression is evaluated when there's no selection");
|
||||
|
@ -30,13 +30,13 @@ add_task(async function() {
|
|||
{ line: 0, ch: 0 },
|
||||
{ line: 0, ch: expression.split("\n")[0].length }
|
||||
);
|
||||
onResultMessage = waitForMessage(hud, "10", ".result");
|
||||
onResultMessage = waitForMessage(hud, "first assignment", ".result");
|
||||
synthesizeKeyboardEvaluation();
|
||||
await onResultMessage;
|
||||
ok(true, "Only the expression on the first line was evaluated");
|
||||
|
||||
info("Check that it also works when clicking on the Run button");
|
||||
onResultMessage = waitForMessage(hud, "10", ".result");
|
||||
onResultMessage = waitForMessage(hud, "first assignment", ".result");
|
||||
hud.ui.outputNode
|
||||
.querySelector(".webconsole-editor-toolbar-executeButton")
|
||||
.click();
|
||||
|
@ -46,19 +46,16 @@ add_task(async function() {
|
|||
"Only the expression on the first line was evaluated when clicking the Run button"
|
||||
);
|
||||
|
||||
info("Check that this works in inline mode as well");
|
||||
info("Check that this is disabled in inline mode");
|
||||
await toggleLayout(hud);
|
||||
hud.ui.jsterm.editor.setSelection(
|
||||
{ line: 0, ch: 0 },
|
||||
{ line: 0, ch: expression.split("\n")[0].length }
|
||||
);
|
||||
onResultMessage = waitForMessage(hud, "10", ".result");
|
||||
onResultMessage = waitForMessage(hud, "second assignment", ".result");
|
||||
synthesizeKeyboardEvaluation();
|
||||
await onResultMessage;
|
||||
ok(
|
||||
true,
|
||||
"Only the expression on the first line was evaluated in inline mode"
|
||||
);
|
||||
ok(true, "The whole expression was evaluated in inline mode");
|
||||
});
|
||||
|
||||
function synthesizeKeyboardEvaluation() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче