Bug 781797 - dbg open and dbg close commands; r=past
authorAnton Kovalyov <anton@mozilla.com>
Tue, 02 Oct 2012 19:03:59 -0700
changeset 109256 7b61da6b47ded1ded2b6070c38ed6d0f58a7af26
parent 109255 1332149e38af81f3a9ad7c814eda46dd8cab79d4
child 109257 f06d47c564b43f5840098cf9071e56e1a0255c69
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewerspast
bugs781797
milestone18.0a1
Bug 781797 - dbg open and dbg close commands; r=past
browser/devtools/commandline/CmdDbg.jsm
browser/devtools/commandline/test/browser_dbg_cmd.js
browser/locales/en-US/chrome/browser/devtools/gclicommands.properties
--- a/browser/devtools/commandline/CmdDbg.jsm
+++ b/browser/devtools/commandline/CmdDbg.jsm
@@ -13,16 +13,57 @@ Cu.import("resource://gre/modules/XPCOMU
  * 'dbg' command
  */
 gcli.addCommand({
   name: "dbg",
   description: gcli.lookup("dbgDesc"),
   manual: gcli.lookup("dbgManual")
 });
 
+/**
+ * 'dbg open' command
+ */
+gcli.addCommand({
+  name: "dbg open",
+  description: gcli.lookup("dbgOpen"),
+  params: [],
+  exec: function (args, context) {
+    let win = context.environment.chromeDocument.defaultView;
+    let tab = win.gBrowser.selectedTab;
+    let dbg = win.DebuggerUI.findDebugger();
+
+    if (dbg) {
+      if (dbg.ownerTab !== tab) {
+        win.DebuggerUI.toggleDebugger();
+      }
+
+      return;
+    }
+
+    win.DebuggerUI.toggleDebugger();
+  }
+});
+
+/**
+ * 'dbg close' command
+ */
+gcli.addCommand({
+  name: "dbg close",
+  description: gcli.lookup("dbgClose"),
+  params: [],
+  exec: function (args, context) {
+    let win = context.environment.chromeDocument.defaultView;
+    let tab = win.gBrowser.selectedTab;
+    let dbg = win.DebuggerUI.findDebugger();
+
+    if (dbg) {
+      dbg.close();
+    }
+  }
+});
 
 /**
  * 'dbg interrupt' command
  */
 gcli.addCommand({
   name: "dbg interrupt",
   description: gcli.lookup("dbgInterrupt"),
   params: [],
--- a/browser/devtools/commandline/test/browser_dbg_cmd.js
+++ b/browser/devtools/commandline/test/browser_dbg_cmd.js
@@ -3,18 +3,23 @@ function test() {
                    "test/browser_dbg_cmd.html";
 
   DeveloperToolbarTest.test(TEST_URI, function() {
     testDbgCmd();
   });
 }
 
 function testDbgCmd() {
-  let pane = DebuggerUI.toggleDebugger();
-  ok(pane, "toggleDebugger() should return a pane.");
+  DeveloperToolbarTest.exec({
+    typed: "dbg open",
+    blankOutput: true
+  });
+
+  let pane = DebuggerUI.findDebugger();
+  ok(pane, "Debugger was opened.");
   let frame = pane._frame;
 
   frame.addEventListener("Debugger:Connecting", function dbgConnected(aEvent) {
     frame.removeEventListener("Debugger:Connecting", dbgConnected, true);
 
     // Wait for the initial resume...
     aEvent.target.ownerDocument.defaultView.gClient
         .addOneTimeListener("resumed", function() {
@@ -36,19 +41,24 @@ function testDbgCmd() {
                   is(output.value, "step in", "debugger stepped in");
                   cmd("dbg step over", function() {
                     is(output.value, "step over", "debugger stepped over");
                     cmd("dbg step out", function() {
                       is(output.value, "step out", "debugger stepped out");
                       cmd("dbg continue", function() {
                         cmd("dbg continue", function() {
                           is(output.value, "dbg continue", "debugger continued");
-                          pane.contentWindow.gClient.close(function() {
-                            finish();
+                          DeveloperToolbarTest.exec({
+                            typed: "dbg close",
+                            blankOutput: true
                           });
+
+                          let dbg = DebuggerUI.findDebugger();
+                          ok(!dbg, "Debugger was closed.");
+                          finish();
                         });
                       });
                     });
                   });
                 });
               });
             });
           });
--- a/browser/locales/en-US/chrome/browser/devtools/gclicommands.properties
+++ b/browser/locales/en-US/chrome/browser/devtools/gclicommands.properties
@@ -375,16 +375,24 @@ breakNotFound=Breakpoint was not found
 # LOCALIZATION NOTE (dbgDesc) A very short string used to describe the
 # function of the dbg command.
 dbgDesc=Manage debugger
 
 # LOCALIZATION NOTE (dbgManual) A longer description describing the
 # set of commands that control the debugger.
 dbgManual=Commands to interrupt or resume the main thread, step in, out and over lines of code
 
+# LOCALIZATION NOTE (dbgOpen) A very short string used to describe the function
+# of the dbg open command.
+dbgOpen=Open the debugger
+
+# LOCALIZATION NOTE (dbgClose) A very short string used to describe the function
+# of the dbg close command.
+dbgClose=Close the debugger
+
 # LOCALIZATION NOTE (dbgInterrupt) A very short string used to describe the
 # function of the dbg interrupt command.
 dbgInterrupt=Pauses the main thread
 
 # LOCALIZATION NOTE (dbgContinue) A very short string used to describe the
 # function of the dbg continue command.
 dbgContinue=Resumes the main thread, and continues execution following a breakpoint, until the next breakpoint or the termination of the script.