зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1609264 - Don't populate _lastConsoleInputEvaluation when doing an eager evaluation. r=bhackett.
This was messing up with the $_ command. A webconsole test case is added to ensure this works as expected now. Differential Revision: https://phabricator.services.mozilla.com/D59990 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
dd51441012
Коммит
86284a357d
|
@ -25,6 +25,14 @@ add_task(async function() {
|
||||||
await pushPref(EAGER_EVALUATION_PREF, true);
|
await pushPref(EAGER_EVALUATION_PREF, true);
|
||||||
const hud = await openNewTabAndConsole(TEST_URI);
|
const hud = await openNewTabAndConsole(TEST_URI);
|
||||||
|
|
||||||
|
// Do an evaluation to populate $_
|
||||||
|
await executeAndWaitForMessage(
|
||||||
|
hud,
|
||||||
|
"'result: ' + (x + y)",
|
||||||
|
"result: 7",
|
||||||
|
".result"
|
||||||
|
);
|
||||||
|
|
||||||
setInputValue(hud, "x + y");
|
setInputValue(hud, "x + y");
|
||||||
await waitForEagerEvaluationResult(hud, "7");
|
await waitForEagerEvaluationResult(hud, "7");
|
||||||
|
|
||||||
|
@ -72,6 +80,13 @@ add_task(async function() {
|
||||||
|
|
||||||
setInputValue(hud, "Math.round(3.2)");
|
setInputValue(hud, "Math.round(3.2)");
|
||||||
await waitForEagerEvaluationResult(hud, "3");
|
await waitForEagerEvaluationResult(hud, "3");
|
||||||
|
|
||||||
|
info("Check that $_ wasn't polluted by eager evaluations");
|
||||||
|
setInputValue(hud, "$_");
|
||||||
|
await waitForEagerEvaluationResult(hud, `"result: 7"`);
|
||||||
|
|
||||||
|
setInputValue(hud, "'> ' + $_");
|
||||||
|
await waitForEagerEvaluationResult(hud, `"> result: 7"`);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Test that the currently selected autocomplete result is eagerly evaluated.
|
// Test that the currently selected autocomplete result is eagerly evaluated.
|
||||||
|
|
|
@ -1298,16 +1298,20 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!awaitResult) {
|
// Don't update _lastConsoleInputEvaluation in eager evaluation, as it would interfere
|
||||||
this._lastConsoleInputEvaluation = result;
|
// with the $_ command.
|
||||||
} else {
|
if (!request.eager) {
|
||||||
// If we evaluated a top-level await expression, we want to assign its result to the
|
if (!awaitResult) {
|
||||||
// _lastConsoleInputEvaluation only when the promise resolves, and only if it
|
this._lastConsoleInputEvaluation = result;
|
||||||
// resolves. If the promise rejects, we don't re-assign _lastConsoleInputEvaluation,
|
} else {
|
||||||
// it will keep its previous value.
|
// If we evaluated a top-level await expression, we want to assign its result to the
|
||||||
awaitResult.then(res => {
|
// _lastConsoleInputEvaluation only when the promise resolves, and only if it
|
||||||
this._lastConsoleInputEvaluation = this.makeDebuggeeValue(res);
|
// resolves. If the promise rejects, we don't re-assign _lastConsoleInputEvaluation,
|
||||||
});
|
// it will keep its previous value.
|
||||||
|
awaitResult.then(res => {
|
||||||
|
this._lastConsoleInputEvaluation = this.makeDebuggeeValue(res);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче