Add an unlisten command for stopping any active debugger server instaces (bug 976977). r=jwalker
authorPanos Astithas <past@mozilla.com>
Wed, 27 May 2015 19:48:24 +0300
changeset 246021 a6325318d1c6b958bb0d3dc4251cc753cf1b41ed
parent 246020 c9c55b1fb120561aba4690e15737d0e9eb715c25
child 246022 707f94ce1881bb69fdb03f53c08500eee0db97ca
push id60333
push userryanvm@gmail.com
push dateThu, 28 May 2015 14:20:47 +0000
treeherdermozilla-inbound@8225a3b75df6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwalker
bugs976977
milestone41.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
Add an unlisten command for stopping any active debugger server instaces (bug 976977). r=jwalker
browser/devtools/commandline/test/browser.ini
browser/devtools/commandline/test/browser_cmd_listen.js
toolkit/devtools/gcli/commands/listen.js
toolkit/locales/en-US/chrome/global/devtools/gclicommands.properties
--- a/browser/devtools/commandline/test/browser.ini
+++ b/browser/devtools/commandline/test/browser.ini
@@ -58,16 +58,17 @@ support-files =
 [browser_cmd_highlight_02.js]
 [browser_cmd_inject.js]
 support-files =
  browser_cmd_inject.html
 [browser_cmd_csscoverage_util.js]
 [browser_cmd_jsb.js]
 support-files =
   browser_cmd_jsb_script.jsi
+[browser_cmd_listen.js]
 [browser_cmd_media.js]
 support-files =
   browser_cmd_media.html
 [browser_cmd_pagemod_export.js]
 support-files =
   browser_cmd_pagemod_export.html
 [browser_cmd_pref1.js]
 [browser_cmd_pref2.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/commandline/test/browser_cmd_listen.js
@@ -0,0 +1,79 @@
+/* Any copyright is dedicated to the Public Domain.
+* http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// Tests that the listen/unlisten commands work as they should.
+
+const TEST_URI = "http://example.com/browser/browser/devtools/commandline/"+
+                 "test/browser_cmd_cookie.html";
+
+function test() {
+  return Task.spawn(testTask).then(finish, helpers.handleError);
+}
+
+let tests = {
+  testInput: function(options) {
+    return helpers.audit(options, [
+      {
+        setup:    'listen',
+        check: {
+          input:  'listen',
+          markup: 'VVVVVV',
+          status: 'VALID'
+        },
+      },
+      {
+        setup:    'unlisten',
+        check: {
+          input:  'unlisten',
+          markup: 'VVVVVVVV',
+          status: 'VALID'
+        },
+        exec: {
+          output: 'All TCP ports closed'
+        }
+      },
+      {
+        setup: function() {
+          return helpers.setInput(options, 'listen');
+        },
+        check: {
+          input:  'listen',
+          hints:        ' [port]',
+          markup: 'VVVVVV',
+          status: 'VALID'
+        },
+        exec: {
+          output: 'Listening on port 6080'
+        }
+      },
+      {
+        setup: function() {
+          return helpers.setInput(options, 'listen 8000');
+        },
+        exec: {
+          output: 'Listening on port 8000'
+        }
+      },
+      {
+        setup: function() {
+          return helpers.setInput(options, 'unlisten');
+        },
+        exec: {
+          output: 'All TCP ports closed'
+        }
+      }
+    ]);
+  },
+};
+
+function* testTask() {
+    Services.prefs.setBoolPref('devtools.debugger.remote-enabled', true);
+    let options = yield helpers.openTab(TEST_URI);
+    yield helpers.openToolbar(options);
+
+    yield helpers.runTests(options, tests);
+
+    yield helpers.closeToolbar(options);
+    yield helpers.closeTab(options);
+    Services.prefs.clearUserPref('devtools.debugger.remote-enabled');
+}
--- a/toolkit/devtools/gcli/commands/listen.js
+++ b/toolkit/devtools/gcli/commands/listen.js
@@ -59,10 +59,21 @@ exports.items = [
       listener.open();
 
       if (debuggerServer.initialized) {
         return l10n.lookupFormat("listenInitOutput", [ "" + args.port ]);
       }
 
       return l10n.lookup("listenNoInitOutput");
     },
+  },
+  {
+    item: "command",
+    runAt: "client",
+    name: "unlisten",
+    description: l10n.lookup("unlistenDesc"),
+    manual: l10n.lookup("unlistenManual"),
+    exec: function(args, context) {
+      debuggerServer.closeAllListeners();
+      return l10n.lookup("unlistenOutput");
+    }
   }
 ];
--- a/toolkit/locales/en-US/chrome/global/devtools/gclicommands.properties
+++ b/toolkit/locales/en-US/chrome/global/devtools/gclicommands.properties
@@ -1512,16 +1512,28 @@ listenDisabledOutput=Listen is disabled 
 # LOCALIZATION NOTE (listenInitOutput) Text of a message output during the
 # execution of the 'listen' command. %1$S is a port number
 listenInitOutput=Listening on port %1$S
 
 # LOCALIZATION NOTE (listenNoInitOutput) Text of a message output during the
 # execution of the 'listen' command.
 listenNoInitOutput=DebuggerServer not initialized
 
+# LOCALIZATION NOTE (unlistenDesc) A very short string used to describe the
+# function of the 'unlisten' command.
+unlistenDesc=Close all remote debug ports
+
+# LOCALIZATION NOTE (unlistenManual) A longer description of the 'unlisten'
+# command.
+unlistenManual=Closes all the open ports for remote debugging.
+
+# LOCALIZATION NOTE (unlistenOutput) Text of a message output during the
+# execution of the 'unlisten' command.
+unlistenOutput=All TCP ports closed
+
 # LOCALIZATION NOTE (mediaDesc, mediaEmulateDesc, mediaEmulateManual,
 # 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