diff --git a/devtools/client/inspector/markup/markup-context-menu.js b/devtools/client/inspector/markup/markup-context-menu.js index 46e6f3077c11..dbc9af9d60db 100644 --- a/devtools/client/inspector/markup/markup-context-menu.js +++ b/devtools/client/inspector/markup/markup-context-menu.js @@ -345,7 +345,7 @@ class MarkupContextMenu { _showDOMProperties() { this.toolbox.openSplitConsole().then(() => { const { hud } = this.toolbox.getPanel("webconsole"); - hud.ui.wrapper.dispatchEvaluateExpression("inspect($0)"); + hud.ui.wrapper.dispatchEvaluateExpression("inspect($0, true)"); }); } diff --git a/devtools/client/inspector/test/browser_inspector_menu-06-other.js b/devtools/client/inspector/test/browser_inspector_menu-06-other.js index 8bbe324c979a..fdd25a490db3 100644 --- a/devtools/client/inspector/test/browser_inspector_menu-06-other.js +++ b/devtools/client/inspector/test/browser_inspector_menu-06-other.js @@ -2,22 +2,16 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; -const { - getHistoryEntries, -} = require("devtools/client/webconsole/selectors/history"); - // Tests for menuitem functionality that doesn't fit into any specific category const TEST_URL = URL_ROOT + "doc_inspector_menu.html"; add_task(async function() { const { inspector, toolbox, testActor } = await openInspectorForURL(TEST_URL); + await testShowDOMProperties(); await testDuplicateNode(); await testDeleteNode(); await testDeleteTextNode(); await testDeleteRootNode(); await testScrollIntoView(); - // This needs to be last as the webconsole `inspect` command impact the selected node in - // the inspector. - await testShowDOMProperties(); async function testDuplicateNode() { info("Testing 'Duplicate Node' menu item for normal elements."); @@ -135,12 +129,25 @@ add_task(async function() { await consoleOpened; const webconsoleUI = toolbox.getPanel("webconsole").hud.ui; - const messagesAdded = webconsoleUI.once("new-messages"); - await messagesAdded; - info("Checking if 'inspect($0)' was evaluated"); - const state = webconsoleUI.wrapper.getStore().getState(); - ok(getHistoryEntries(state)[0] === "inspect($0)"); + await poll( + () => { + const messages = [ + ...webconsoleUI.outputNode.querySelectorAll(".message"), + ]; + const nodeMessage = messages.find(m => m.textContent.includes("body")); + // wait for the object to be expanded + return ( + nodeMessage && + nodeMessage.querySelectorAll(".object-inspector .node").length > 10 + ); + }, + "Waiting for the element node to be expanded", + 10, + 1000 + ); + + info("Close split console"); await toolbox.toggleSplitConsole(); } diff --git a/devtools/client/webconsole/actions/input.js b/devtools/client/webconsole/actions/input.js index 9a3c6f629bb0..62b283dd1090 100644 --- a/devtools/client/webconsole/actions/input.js +++ b/devtools/client/webconsole/actions/input.js @@ -148,7 +148,7 @@ function handleHelperResult(response) { break; case "inspectObject": { const objectActor = helperResult.object; - if (hud.toolbox) { + if (hud.toolbox && !helperResult.forceExpandInConsole) { hud.toolbox.inspectObjectActor(objectActor); } else { webConsoleUI.inspectObjectActor(objectActor); diff --git a/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js b/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js index 24d0260c8952..f31bb037e0d7 100644 --- a/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js +++ b/devtools/client/webconsole/test/node/fixtures/stubs/evaluationResult.js @@ -155,7 +155,8 @@ rawPackets.set(`inspect({a: 1})`, { } }, "actorID": "server0.conn0.child1/obj28" - } + }, + "forceExpandInConsole": false }, "input": "inspect({a: 1})", "result": { diff --git a/devtools/server/actors/webconsole/utils.js b/devtools/server/actors/webconsole/utils.js index c2a56bdf17b4..1ce1e3142c06 100644 --- a/devtools/server/actors/webconsole/utils.js +++ b/devtools/server/actors/webconsole/utils.js @@ -629,7 +629,11 @@ WebConsoleCommands._registerOriginal("cd", function(owner, window) { * @param object object * Object to inspect. */ -WebConsoleCommands._registerOriginal("inspect", function(owner, object) { +WebConsoleCommands._registerOriginal("inspect", function( + owner, + object, + forceExpandInConsole = false +) { const dbgObj = owner.preprocessDebuggerObject( owner.makeDebuggeeValue(object) ); @@ -639,6 +643,7 @@ WebConsoleCommands._registerOriginal("inspect", function(owner, object) { type: "inspectObject", input: owner.evalInput, object: grip, + forceExpandInConsole, }; });