Bug 1286281 - Part 7: Add WebSocket transport option to chrome debugger server r=jryans
authorJarda Snajdr <jsnajdr@gmail.com>
Mon, 01 Aug 2016 08:00:00 -0700
changeset 308490 107fd4076b3cc891540c53c144c60d7225fef48f
parent 308489 0da07a12817c5785deef55e9b688724a19348dca
child 308491 bfb4f7467dd4b39005d61fbcb2872da14a29d66b
push id80347
push userkwierso@gmail.com
push dateSun, 07 Aug 2016 07:17:22 +0000
treeherdermozilla-inbound@d42aacfe34af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1286281
milestone51.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
Bug 1286281 - Part 7: Add WebSocket transport option to chrome debugger server r=jryans MozReview-Commit-ID: 3gkcU2Zl8Pq
devtools/client/framework/ToolboxProcess.jsm
devtools/client/framework/toolbox-process-window.js
devtools/client/preferences/devtools.js
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -136,18 +136,21 @@ BrowserToolboxProcess.prototype = {
 
     this.debuggerServer.init();
     this.debuggerServer.addBrowserActors();
     this.debuggerServer.allowChromeProcess = true;
     dumpn("initialized and added the browser actors for the DebuggerServer.");
 
     let chromeDebuggingPort =
       Services.prefs.getIntPref("devtools.debugger.chrome-debugging-port");
+    let chromeDebuggingWebSocket =
+      Services.prefs.getBoolPref("devtools.debugger.chrome-debugging-websocket");
     let listener = this.debuggerServer.createListener();
     listener.portOrPath = chromeDebuggingPort;
+    listener.webSocket = chromeDebuggingWebSocket;
     listener.open();
 
     dumpn("Finished initializing the chrome toolbox server.");
     dumpn("Started listening on port: " + chromeDebuggingPort);
   },
 
   /**
    * Initializes a profile for the remote debugger process.
--- a/devtools/client/framework/toolbox-process-window.js
+++ b/devtools/client/framework/toolbox-process-window.js
@@ -20,47 +20,49 @@ var { DebuggerClient } = require("devtoo
 var { PrefsHelper } = require("devtools/client/shared/prefs");
 var { Task } = require("devtools/shared/task");
 
 /**
  * Shortcuts for accessing various debugger preferences.
  */
 var Prefs = new PrefsHelper("devtools.debugger", {
   chromeDebuggingHost: ["Char", "chrome-debugging-host"],
-  chromeDebuggingPort: ["Int", "chrome-debugging-port"]
+  chromeDebuggingPort: ["Int", "chrome-debugging-port"],
+  chromeDebuggingWebSocket: ["Bool", "chrome-debugging-websocket"],
 });
 
 var gToolbox, gClient;
 
 var connect = Task.async(function*() {
   window.removeEventListener("load", connect);
   // Initiate the connection
   let transport = yield DebuggerClient.socketConnect({
     host: Prefs.chromeDebuggingHost,
-    port: Prefs.chromeDebuggingPort
+    port: Prefs.chromeDebuggingPort,
+    webSocket: Prefs.chromeDebuggingWebSocket,
   });
   gClient = new DebuggerClient(transport);
-  gClient.connect().then(() => {
-    let addonID = getParameterByName("addonID");
+  yield gClient.connect();
+  let addonID = getParameterByName("addonID");
 
-    if (addonID) {
-      gClient.listAddons(({addons}) => {
-        let addonActor = addons.filter(addon => addon.id === addonID).pop();
-        openToolbox({
-          form: addonActor,
-          chrome: true,
-          isTabActor: addonActor.isWebExtension ? true : false
-        });
-      });
-    } else {
-      gClient.getProcess().then(aResponse => {
-        openToolbox({ form: aResponse.form, chrome: true });
-      });
-    }
-  });
+  if (addonID) {
+    let { addons } = yield gClient.listAddons();
+    let addonActor = addons.filter(addon => addon.id === addonID).pop();
+    openToolbox({
+      form: addonActor,
+      chrome: true,
+      isTabActor: addonActor.isWebExtension ? true : false
+    });
+  } else {
+    let response = yield gClient.getProcess();
+    openToolbox({
+      form: response.form,
+      chrome: true
+    });
+  }
 });
 
 // Certain options should be toggled since we can assume chrome debugging here
 function setPrefDefaults() {
   Services.prefs.setBoolPref("devtools.inspector.showUserAgentStyles", true);
   Services.prefs.setBoolPref("devtools.performance.ui.show-platform-data", true);
   Services.prefs.setBoolPref("devtools.inspector.showAllAnonymousContent", true);
   Services.prefs.setBoolPref("browser.dom.window.dump.enabled", true);
@@ -72,17 +74,17 @@ function setPrefDefaults() {
 
 window.addEventListener("load", function() {
   let cmdClose = document.getElementById("toolbox-cmd-close");
   cmdClose.addEventListener("command", onCloseCommand);
   setPrefDefaults();
   connect().catch(e => {
     let errorMessageContainer = document.getElementById("error-message-container");
     let errorMessage = document.getElementById("error-message");
-    errorMessage.value = e;
+    errorMessage.value = e.message || e;
     errorMessageContainer.hidden = false;
     console.error(e);
   });
 });
 
 function onCloseCommand(event) {
   window.close();
 }
--- a/devtools/client/preferences/devtools.js
+++ b/devtools/client/preferences/devtools.js
@@ -76,16 +76,17 @@ pref("devtools.defaultColorUnit", "autho
 
 // Enable the Responsive UI tool
 pref("devtools.responsiveUI.no-reload-notification", false);
 
 // Enable the Debugger
 pref("devtools.debugger.enabled", true);
 pref("devtools.debugger.chrome-debugging-host", "localhost");
 pref("devtools.debugger.chrome-debugging-port", 6080);
+pref("devtools.debugger.chrome-debugging-websocket", false);
 pref("devtools.debugger.remote-host", "localhost");
 pref("devtools.debugger.remote-timeout", 20000);
 pref("devtools.debugger.pause-on-exceptions", false);
 pref("devtools.debugger.ignore-caught-exceptions", true);
 pref("devtools.debugger.source-maps-enabled", true);
 pref("devtools.debugger.pretty-print-enabled", true);
 pref("devtools.debugger.auto-pretty-print", false);
 pref("devtools.debugger.auto-black-box", true);