Bug 935014 - Allows to specify the devtool debuggger port via the command line. r=fabrice
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 24 Mar 2014 08:15:00 -0700
changeset 175336 8b1a3307065af36d8c2f8ed8995e540b75a0eb34
parent 175335 9c128455092caad1d93a0734c046b7fe66e1fa5e
child 175340 e7be0c42c2c4bd4a945ea4c9ab1e485495085127
push id5925
push usermozilla@noorenberghe.ca
push dateWed, 26 Mar 2014 10:00:56 +0000
treeherderfx-team@8b1a3307065a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs935014
milestone31.0a1
Bug 935014 - Allows to specify the devtool debuggger port via the command line. r=fabrice
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;
   },
 });