Bug 935014 - Allows to specify the devtool debuggger port via the command line. r=fabrice, a=lsblakk
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 24 Mar 2014 08:15:00 -0700
changeset 191957 7904ad4a140fb9416c8c4029f48e10cfee114dc5
parent 191956 73252b6d1598039a1405e369fe430e1401ec7fb6
child 191958 f9793983f4f5f601f1ddaebad99157515cc3ddb4
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, lsblakk
bugs935014
milestone30.0a2
Bug 935014 - Allows to specify the devtool debuggger port via the command line. r=fabrice, a=lsblakk
b2g/chrome/content/desktop.js
b2g/simulator/lib/simulator-process.js
--- a/b2g/chrome/content/desktop.js
+++ b/b2g/chrome/content/desktop.js
@@ -41,12 +41,35 @@ function setupButtons() {
     rotateButton.classList.add('active');
   });
   rotateButton.addEventListener('touchend', function() {
     GlobalSimulatorScreen.flipScreen();
     rotateButton.classList.remove('active');
   });
 }
 
+function checkDebuggerPort() {
+  // XXX: To be removed once bug 942756 lands.
+  // We are hacking 'unix-domain-socket' pref by setting a tcp port (number).
+  // DebuggerServer.openListener detects that it isn't a file path (string),
+  // and starts listening on the tcp port given here as command line argument.
+
+  // Get the command line arguments that were passed to the b2g client
+  let args = window.arguments[0].QueryInterface(Ci.nsICommandLine);
+
+  let dbgport;
+  try {
+    dbgport = args.handleFlagWithParam('start-debugger-server', false);
+  } catch(e) {}
+
+  if (dbgport) {
+    dump('Opening debugger server on ' + dbgport + '\n');
+    Services.prefs.setCharPref('devtools.debugger.unix-domain-socket', dbgport);
+    navigator.mozSettings.createLock().set(
+      {'debugger.remote-mode': 'adb-devtools'});
+  }
+}
+
 window.addEventListener('ContentStart', function() {
   enableTouch();
   setupButtons();
+  checkDebuggerPort();
 });
--- a/b2g/simulator/lib/simulator-process.js
+++ b/b2g/simulator/lib/simulator-process.js
@@ -166,17 +166,17 @@ exports.SimulatorProcess = Class({
   get b2gArguments() {
     let args = [];
 
     let profile = URL.toFilename(PROFILE_URL);
     args.push("-profile", profile);
     Cu.reportError(profile);
 
     // NOTE: push dbgport option on the b2g-desktop commandline
-    args.push("-dbgport", "" + this.remoteDebuggerPort);
+    args.push("-start-debugger-server", "" + this.remoteDebuggerPort);
 
     // Ignore eventual zombie instances of b2g that are left over
     args.push("-no-remote");
 
     return args;
   },
 });