From ddef712d8f2488264af9c26ce612207dbd4a2761 Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Tue, 29 Oct 2019 00:36:23 +0000 Subject: [PATCH] Bug 1580165 - fix selected node for console; r=nchevobbe Differential Revision: https://phabricator.services.mozilla.com/D50126 --HG-- extra : moz-landing-system : lando --- devtools/client/webconsole/actions/input.js | 7 ++++--- devtools/client/webconsole/commands.js | 16 +++++++++++++++- devtools/client/webconsole/webconsole-ui.js | 10 ++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/devtools/client/webconsole/actions/input.js b/devtools/client/webconsole/actions/input.js index b499dbdbed05..117c5fc8c680 100644 --- a/devtools/client/webconsole/actions/input.js +++ b/devtools/client/webconsole/actions/input.js @@ -37,7 +37,7 @@ loader.lazyRequireGetter( const HELP_URL = "https://developer.mozilla.org/docs/Tools/Web_Console/Helpers"; function evaluateExpression(expression) { - return async ({ dispatch, webConsoleUI, hud }) => { + return async ({ dispatch, webConsoleUI, hud, client }) => { if (!expression) { expression = hud.getInputSelection() || hud.getInputValue(); } @@ -78,10 +78,11 @@ function evaluateExpression(expression) { // we still need to pass the error response to onExpressionEvaluated. const onSettled = res => res; - const response = await webConsoleFront + const response = await client .evaluateJSAsync(expression, { frameActor, - selectedNodeActor: webConsoleUI.getSelectedNodeActor(), + selectedNodeFront: webConsoleUI.getSelectedNodeFront(), + webConsoleFront, mapped: mappedExpressionRes ? mappedExpressionRes.mapped : null, }) .then(onSettled, onSettled); diff --git a/devtools/client/webconsole/commands.js b/devtools/client/webconsole/commands.js index b34ea9921aa7..7b3eb6982cca 100644 --- a/devtools/client/webconsole/commands.js +++ b/devtools/client/webconsole/commands.js @@ -15,7 +15,21 @@ class ConsoleCommands { } evaluateJSAsync(expression, options) { - return this.proxy.webConsoleFront.evaluateJSAsync(expression, options); + const { selectedNodeFront, webConsoleFront } = options; + let front = this.proxy.webConsoleFront; + + // Defer to the selected paused thread front + if (webConsoleFront) { + front = webConsoleFront; + } + + // Defer to the selected node's thread console front + if (selectedNodeFront) { + front = selectedNodeFront.targetFront.activeConsole; + options.selectedNodeActor = selectedNodeFront.actorID; + } + + return front.evaluateJSAsync(expression, options); } createObjectFront(object) { diff --git a/devtools/client/webconsole/webconsole-ui.js b/devtools/client/webconsole/webconsole-ui.js index cc4c9d2ba78b..337e9196fd74 100644 --- a/devtools/client/webconsole/webconsole-ui.js +++ b/devtools/client/webconsole/webconsole-ui.js @@ -594,11 +594,13 @@ class WebConsoleUI { } getSelectedNodeActor() { + const front = this.getSelectedNodeFront(); + return front ? front.actorID : null; + } + + getSelectedNodeFront() { const inspectorSelection = this.hud.getInspectorSelection(); - if (inspectorSelection && inspectorSelection.nodeFront) { - return inspectorSelection.nodeFront.actorID; - } - return null; + return inspectorSelection ? inspectorSelection.nodeFront : null; } onMessageHover(type, message) {