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:
Nicolas Chevobbe 2020-01-15 13:30:40 +00:00
Родитель dd51441012
Коммит 86284a357d
2 изменённых файлов: 29 добавлений и 10 удалений

Просмотреть файл

@ -25,6 +25,14 @@ add_task(async function() {
await pushPref(EAGER_EVALUATION_PREF, true);
const hud = await openNewTabAndConsole(TEST_URI);
// Do an evaluation to populate $_
await executeAndWaitForMessage(
hud,
"'result: ' + (x + y)",
"result: 7",
".result"
);
setInputValue(hud, "x + y");
await waitForEagerEvaluationResult(hud, "7");
@ -72,6 +80,13 @@ add_task(async function() {
setInputValue(hud, "Math.round(3.2)");
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.

Просмотреть файл

@ -1298,16 +1298,20 @@ const WebConsoleActor = ActorClassWithSpec(webconsoleSpec, {
}
}
if (!awaitResult) {
this._lastConsoleInputEvaluation = result;
} else {
// If we evaluated a top-level await expression, we want to assign its result to the
// _lastConsoleInputEvaluation only when the promise resolves, and only if it
// 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);
});
// Don't update _lastConsoleInputEvaluation in eager evaluation, as it would interfere
// with the $_ command.
if (!request.eager) {
if (!awaitResult) {
this._lastConsoleInputEvaluation = result;
} else {
// If we evaluated a top-level await expression, we want to assign its result to the
// _lastConsoleInputEvaluation only when the promise resolves, and only if it
// 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 {