diff --git a/devtools/client/debugger/src/client/firefox/commands.js b/devtools/client/debugger/src/client/firefox/commands.js index 0c522e066e60..c62d8e407ad3 100644 --- a/devtools/client/debugger/src/client/firefox/commands.js +++ b/devtools/client/debugger/src/client/firefox/commands.js @@ -268,21 +268,39 @@ async function removeBreakpoint(location) { }); } -async function evaluateExpressions(scripts, options) { - return Promise.all(scripts.map(script => evaluate(script, options))); +async function evaluateExpressions(expressions, options) { + return Promise.all( + expressions.map(expression => evaluate(expression, options)) + ); } -async function evaluate(script, { frameId, threadId } = {}) { - if (!currentTarget() || !script) { +/** + * Evaluate some JS expression in a given thread. + * + * @param {String} expression + * @param {Object} options + * @param {String} options.frameId + * Optional frame actor ID into which the expression should be evaluated. + * @param {String} options.threadId + * Optional thread actor ID into which the expression should be evaluated. + * @param {Boolean} options.evalInTracer + * To be set to true, if the object actors created during the evaluation + * should be registered in the tracer actor Pool. + * @return {Object} + * See ScriptCommand.execute JS Doc. + */ +async function evaluate(expression, { frameId, threadId, evalInTracer } = {}) { + if (!currentTarget() || !expression) { return { result: null }; } const selectedTargetFront = threadId ? lookupTarget(threadId) : null; - return commands.scriptCommand.execute(script, { + return commands.scriptCommand.execute(expression, { frameActor: frameId, selectedTargetFront, disableBreaks: true, + evalInTracer, }); } diff --git a/devtools/server/actors/webconsole.js b/devtools/server/actors/webconsole.js index c8e78ccdc3fa..0740269be8c6 100644 --- a/devtools/server/actors/webconsole.js +++ b/devtools/server/actors/webconsole.js @@ -908,7 +908,8 @@ class WebConsoleActor extends Actor { evalInfo, input, request.eager, - mapped + mapped, + request.evalInTracer ); resolve(result); } catch (err) { @@ -919,7 +920,7 @@ class WebConsoleActor extends Actor { } // eslint-disable-next-line complexity - prepareEvaluationResult(evalInfo, input, eager, mapped) { + prepareEvaluationResult(evalInfo, input, eager, mapped, evalInTracer) { const evalResult = evalInfo.result; const helperResult = evalInfo.helperResult; @@ -1039,7 +1040,6 @@ class WebConsoleActor extends Actor { } } } - // If a value is encountered that the devtools server doesn't support yet, // the console should remain functional. let resultGrip; @@ -1047,7 +1047,10 @@ class WebConsoleActor extends Actor { try { const objectActor = this.targetActor.threadActor.getThreadLifetimeObject(result); - if (objectActor) { + if (evalInTracer) { + const tracerActor = this.targetActor.getTargetScopedActor("tracer"); + resultGrip = tracerActor.createValueGrip(result); + } else if (objectActor) { resultGrip = this.targetActor.threadActor.createValueGrip(result); } else { resultGrip = this.createValueGrip(result); diff --git a/devtools/shared/commands/script/script-command.js b/devtools/shared/commands/script/script-command.js index cf5a7e263e8d..57fb533f40ec 100644 --- a/devtools/shared/commands/script/script-command.js +++ b/devtools/shared/commands/script/script-command.js @@ -43,6 +43,11 @@ class ScriptCommand { * visible in the debugger UI. * @param {boolean} options.preferConsoleCommandsOverLocalSymbols: Set to true to force * overriding local symbols defined by the page with same-name console commands. + * @param {boolean} options.evalInTracer: Set to true to store the evaluation result object + * actors within the Tracer Object Actor Pool. + * So that if the evaluation result object has already been processed by the JS Tracer, + * we will receive the same Object Actor. + * This helps later match the object when doing a search per value. * * @return {Promise}: A promise that resolves with the response. */ @@ -111,6 +116,7 @@ class ScriptCommand { disableBreaks: options.disableBreaks, preferConsoleCommandsOverLocalSymbols: options.preferConsoleCommandsOverLocalSymbols, + evalInTracer: options.evalInTracer, }) .then(packet => { resultID = packet.resultID; diff --git a/devtools/shared/specs/webconsole.js b/devtools/shared/specs/webconsole.js index 36c6d3595ed2..10d9b0e1d197 100644 --- a/devtools/shared/specs/webconsole.js +++ b/devtools/shared/specs/webconsole.js @@ -158,6 +158,7 @@ const webconsoleSpecPrototype = { eager: Option(0, "nullable:boolean"), disableBreaks: Option(0, "nullable:boolean"), preferConsoleCommandsOverLocalSymbols: Option(0, "nullable:boolean"), + evalInTracer: Option(0, "nullable:boolean"), }, response: RetVal("console.evaluatejsasync"), },