--- a/devtools/client/inspector/inspector-commands.js
+++ b/devtools/client/inspector/inspector-commands.js
@@ -8,34 +8,36 @@ const l10n = require("gcli/l10n");
loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
/* eslint-disable mozilla/reject-some-requires */
const {EyeDropper, HighlighterEnvironment} = require("devtools/server/actors/highlighters");
/* eslint-enable mozilla/reject-some-requires */
const Telemetry = require("devtools/client/shared/telemetry");
exports.items = [{
item: "command",
- runAt: "server",
+ runAt: "client",
name: "inspect",
description: l10n.lookup("inspectDesc"),
manual: l10n.lookup("inspectManual"),
params: [
{
name: "selector",
- type: "node",
+ type: "string",
description: l10n.lookup("inspectNodeDesc"),
manual: l10n.lookup("inspectNodeManual")
}
],
- exec: function (args, context) {
+ exec: function* (args, context) {
let target = context.environment.target;
- return gDevTools.showToolbox(target, "inspector").then(toolbox => {
- toolbox.getCurrentPanel().selection.setNode(args.selector, "gcli");
- });
- }
+ let toolbox = yield gDevTools.showToolbox(target, "inspector");
+ let walker = toolbox.getCurrentPanel().walker;
+ let rootNode = yield walker.getRootNode();
+ let nodeFront = yield walker.querySelector(rootNode, args.selector);
+ toolbox.getCurrentPanel().selection.setNodeFront(nodeFront, "gcli");
+ },
}, {
item: "command",
runAt: "client",
name: "eyedropper",
description: l10n.lookup("eyedropperDesc"),
manual: l10n.lookup("eyedropperManual"),
params: [{
// This hidden parameter is only set to true when the eyedropper browser menu item is
--- a/devtools/client/inspector/test/browser_inspector_gcli-inspect-command.js
+++ b/devtools/client/inspector/test/browser_inspector_gcli-inspect-command.js
@@ -4,132 +4,115 @@
/* eslint key-spacing: 0 */
"use strict";
// Testing that the gcli 'inspect' command works as it should.
const TEST_URI = URL_ROOT + "doc_inspector_gcli-inspect-command.html";
add_task(function* () {
- return helpers.addTabWithToolbar(TEST_URI, function (options) {
- return helpers.audit(options, [
+ return helpers.addTabWithToolbar(TEST_URI, Task.async(function* (options) {
+ let {inspector} = yield openInspector();
+
+ let checkSelection = Task.async(function* (selector) {
+ let node = yield getNodeFront(selector, inspector);
+ is(inspector.selection.nodeFront, node, "the current selection is correct");
+ });
+
+ yield helpers.audit(options, [
{
setup: "inspect",
check: {
input: "inspect",
hints: " <selector>",
markup: "VVVVVVV",
status: "ERROR",
args: {
selector: {
message: "Value required for \u2018selector\u2019."
},
}
},
},
{
- setup: "inspect h1",
- check: {
- input: "inspect h1",
- hints: "",
- markup: "VVVVVVVVII",
- status: "ERROR",
- args: {
- selector: { message: "No matches" },
- }
- },
- },
- {
- setup: "inspect span",
- check: {
- input: "inspect span",
- hints: "",
- markup: "VVVVVVVVEEEE",
- status: "ERROR",
- args: {
- selector: { message: "Too many matches (2)" },
- }
- },
- },
- {
setup: "inspect div",
check: {
input: "inspect div",
hints: "",
markup: "VVVVVVVVVVV",
status: "VALID",
args: {
selector: { message: "" },
}
},
- },
- {
- setup: "inspect .someclas",
- check: {
- input: "inspect .someclas",
- hints: "",
- markup: "VVVVVVVVIIIIIIIII",
- status: "ERROR",
- args: {
- selector: { message: "No matches" },
- }
- },
+ exec: {},
+ post: () => checkSelection("div"),
},
{
setup: "inspect .someclass",
check: {
input: "inspect .someclass",
hints: "",
markup: "VVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
selector: { message: "" },
}
},
+ exec: {},
+ post: () => checkSelection(".someclass"),
},
{
setup: "inspect #someid",
check: {
input: "inspect #someid",
hints: "",
markup: "VVVVVVVVVVVVVVV",
status: "VALID",
args: {
selector: { message: "" },
}
},
+ exec: {},
+ post: () => checkSelection("#someid"),
},
{
setup: "inspect button[disabled]",
check: {
input: "inspect button[disabled]",
hints: "",
markup: "VVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
selector: { message: "" },
}
},
+ exec: {},
+ post: () => checkSelection("button[disabled]"),
},
{
setup: "inspect p>strong",
check: {
input: "inspect p>strong",
hints: "",
markup: "VVVVVVVVVVVVVVVV",
status: "VALID",
args: {
selector: { message: "" },
}
},
+ exec: {},
+ post: () => checkSelection("p>strong"),
},
{
setup: "inspect :root",
check: {
input: "inspect :root",
hints: "",
markup: "VVVVVVVVVVVVV",
status: "VALID"
},
+ exec: {},
+ post: () => checkSelection(":root"),
},
]);
- });
+ }));
});