Bug 1274303 - fix gcli "inspect" command; r=jwalker
authorTom Tromey <tom@tromey.com>
Wed, 27 Jul 2016 13:08:47 -0600
changeset 347432 6284dacc7718052ba6e7d91f45a48110be7c49af
parent 347431 474c03c87e8c80a313be0af14c56049b298027bb
child 347433 d65a4acc9227e75c8dc1ab664108fa2d84c1c400
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalker
bugs1274303
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1274303 - fix gcli "inspect" command; r=jwalker MozReview-Commit-ID: GeTUvJqvrKx
devtools/client/inspector/inspector-commands.js
devtools/client/inspector/test/browser_inspector_gcli-inspect-command.js
--- 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"),
       },
     ]);
-  });
+  }));
 });