Bug 770156 - Added the QSA command to find the CSS selector matches. r=mratcliffe
☠☠ backed out by d9813cc43ecc ☠ ☠
authorPablo <pablo_lm1@hotmail.com>
Tue, 10 Nov 2015 15:24:00 +0100
changeset 308685 d3c2323985132f5858b36d923749c325b100def3
parent 308624 4b2ec935bc99bc505776190210b11dfe552bd041
child 308686 ea102921641595c8cf67c3296580ecb6700529ef
push id7514
push users.kaspari@gmail.com
push dateFri, 13 Nov 2015 14:12:41 +0000
reviewersmratcliffe
bugs770156
milestone45.0a1
Bug 770156 - Added the QSA command to find the CSS selector matches. r=mratcliffe
devtools/client/commandline/test/browser.ini
devtools/client/commandline/test/browser_cmd_qsa.js
devtools/shared/gcli/commands/index.js
devtools/shared/gcli/commands/moz.build
devtools/shared/gcli/commands/qsa.js
devtools/shared/locales/en-US/gclicommands.properties
--- a/devtools/client/commandline/test/browser.ini
+++ b/devtools/client/commandline/test/browser.ini
@@ -70,16 +70,17 @@ support-files =
   browser_cmd_media.html
 [browser_cmd_pagemod_export.js]
 support-files =
   browser_cmd_pagemod_export.html
 [browser_cmd_paintflashing.js]
 [browser_cmd_pref1.js]
 [browser_cmd_pref2.js]
 [browser_cmd_pref3.js]
+[browser_cmd_qsa.js]
 [browser_cmd_restart.js]
 [browser_cmd_rulers.js]
 [browser_cmd_screenshot.js]
 support-files =
   browser_cmd_screenshot.html
 [browser_cmd_settings.js]
 [browser_gcli_async.js]
 [browser_gcli_canon.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/commandline/test/browser_cmd_qsa.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+* http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Tests that the qsa commands work as they should.
+
+const TEST_URI = "data:text/html;charset=utf-8,<body></body>";
+
+function test() {
+ helpers.addTabWithToolbar(TEST_URI, function(options) {
+   return helpers.audit(options, [
+     {
+       setup: 'qsa',
+       check: {
+         input:  'qsa',
+         hints:  ' [query]',
+         markup: 'VVV',
+         status: 'VALID'
+       }
+     },
+     {
+       setup: 'qsa body',
+       check: {
+         input:  'qsa body',
+         hints:  '',
+         markup: 'VVVVVVVV',
+         status: 'VALID'
+       }
+     }
+   ]);
+ }).then(finish, helpers.handleError);
+}
--- a/devtools/shared/gcli/commands/index.js
+++ b/devtools/shared/gcli/commands/index.js
@@ -64,16 +64,17 @@ exports.devtoolsModules = [
   "devtools/shared/gcli/commands/highlight",
   "devtools/shared/gcli/commands/inject",
   "devtools/shared/gcli/commands/jsb",
   "devtools/shared/gcli/commands/listen",
   "devtools/shared/gcli/commands/measure",
   "devtools/shared/gcli/commands/media",
   "devtools/shared/gcli/commands/pagemod",
   "devtools/shared/gcli/commands/paintflashing",
+  "devtools/shared/gcli/commands/qsa",
   "devtools/shared/gcli/commands/restart",
   "devtools/shared/gcli/commands/rulers",
   "devtools/shared/gcli/commands/screenshot",
   "devtools/shared/gcli/commands/security",
   "devtools/shared/gcli/commands/tools",
 ];
 
 /**
--- a/devtools/shared/gcli/commands/moz.build
+++ b/devtools/shared/gcli/commands/moz.build
@@ -16,14 +16,15 @@ DevToolsModules(
     'index.js',
     'inject.js',
     'jsb.js',
     'listen.js',
     'measure.js',
     'media.js',
     'pagemod.js',
     'paintflashing.js',
+    'qsa.js',
     'restart.js',
     'rulers.js',
     'screenshot.js',
     'security.js',
     'tools.js',
 )
new file mode 100644
--- /dev/null
+++ b/devtools/shared/gcli/commands/qsa.js
@@ -0,0 +1,24 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const l10n = require("gcli/l10n");
+
+exports.items = [
+  {
+    item: "command",
+    runAt: "server",
+    name: "qsa",
+    description: l10n.lookup("qsaDesc"),
+    params: [{
+      name: "query",
+      type: nodelist,
+      description: l10n.lookup("qsaQueryDesc")
+    }],
+    exec: function(args, context) {
+      return args.query.length;
+    }
+  }
+];
--- a/devtools/shared/locales/en-US/gclicommands.properties
+++ b/devtools/shared/locales/en-US/gclicommands.properties
@@ -1552,16 +1552,21 @@ unlistenOutput=All TCP ports closed
 # mediaEmulateType, mediaResetDesc, mediaResetManual) These strings describe
 # the 'media' commands and all available parameters.
 mediaDesc=CSS media type emulation
 mediaEmulateDesc=Emulate a specified CSS media type
 mediaEmulateManual=View the document as if rendered on a device supporting the given media type, with the relevant CSS rules applied.
 mediaEmulateType=The media type to emulate
 mediaResetDesc=Stop emulating a CSS media type
 
+# LOCALIZATION NOTE (qsaDesc, qsaQueryDesc)
+# These strings describe the 'qsa' commands and all available parameters.
+qsaDesc=Perform querySelectorAll on the current document and return number of matches
+qsaQueryDesc=CSS selectors separated by comma
+
 # LOCALIZATION NOTE (injectDesc, injectManual, injectLibraryDesc, injectLoaded,
 # injectFailed) These strings describe the 'inject' commands and all available
 # parameters.
 injectDesc=Inject common libraries into the page
 injectManual2=Inject common libraries into the content of the page which can also be accessed from the console.
 injectLibraryDesc=Select the library to inject or enter a valid script URI to inject
 injectLoaded=%1$S loaded
 injectFailed=Failed to load %1$S - Invalid URI