Bug 1616524 - [devtools] Allow console commands override from the page in eager evaluations. r=devtools-reviewers,nchevobbe

It was wrong to both:
* reuse disableBreaks options to add the useInnerBindings as it would prevent overrides for eager evaluation,
* use disableBreaks for eager evaluation.

It sounds safer to let the server control all the server side details and only pass eager attribute
when evaluating js via the console actor.

Differential Revision: https://phabricator.services.mozilla.com/D195097
This commit is contained in:
Alexandre Poirot 2023-12-02 08:07:15 +00:00
parent b1595e7177
commit 3a9ec9747c
3 changed files with 8 additions and 3 deletions

View file

@ -481,7 +481,6 @@ function terminalInputChanged(expression, force = false) {
), ),
mapped, mapped,
eager: true, eager: true,
disableBreaks: true,
}); });
return dispatch({ return dispatch({

View file

@ -15,6 +15,7 @@ function zzyzx2() {
} }
var obj = {propA: "A", propB: "B"}; var obj = {propA: "A", propB: "B"};
var array = [1, 2, 3]; var array = [1, 2, 3];
var $$ = 42;
</script> </script>
<h1>title</h1> <h1>title</h1>
`; `;
@ -109,6 +110,9 @@ add_task(async function () {
setInputValue(hud, "$('html')"); setInputValue(hud, "$('html')");
await waitForEagerEvaluationResult(hud, `<html>`); await waitForEagerEvaluationResult(hud, `<html>`);
setInputValue(hud, "$$");
await waitForEagerEvaluationResult(hud, `42`);
info("Check that $_ wasn't polluted by eager evaluations"); info("Check that $_ wasn't polluted by eager evaluations");
setInputValue(hud, "$_"); setInputValue(hud, "$_");
await waitForEagerEvaluationResult(hud, `"result: 7"`); await waitForEagerEvaluationResult(hud, `"result: 7"`);

View file

@ -193,12 +193,14 @@ function evalWithDebugger(string, options = {}, webConsole) {
evalOptions.lineNumber = options.lineNumber; evalOptions.lineNumber = options.lineNumber;
} }
if (options.disableBreaks) { if (options.disableBreaks || options.eager) {
// When we are disabling breakpoints for a given evaluation, // When we are disabling breakpoints for a given evaluation, or when we are doing an eager evaluation,
// also prevent spawning related Debugger.Source object to avoid showing it // also prevent spawning related Debugger.Source object to avoid showing it
// in the debugger UI // in the debugger UI
evalOptions.hideFromDebugger = true; evalOptions.hideFromDebugger = true;
}
if (options.disableBreaks) {
// disableBreaks is used for all non-user-provided code, and in this case // disableBreaks is used for all non-user-provided code, and in this case
// extra bindings shouldn't be shadowed. // extra bindings shouldn't be shadowed.
evalOptions.useInnerBindings = true; evalOptions.useInnerBindings = true;