From 3d501e4ccf359c6c31a70b9f2a58fd6dbc648d62 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Mon, 1 Aug 2016 08:00:00 -0700 Subject: [PATCH] Bug 1286281 - Part 7: Add WebSocket transport option to chrome debugger server r=jryans MozReview-Commit-ID: 3gkcU2Zl8Pq --- devtools/client/framework/ToolboxProcess.jsm | 3 ++ .../framework/toolbox-process-window.js | 42 ++++++++++--------- devtools/client/preferences/devtools.js | 1 + 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/devtools/client/framework/ToolboxProcess.jsm b/devtools/client/framework/ToolboxProcess.jsm index e381f9f08abc..cd12e92cd727 100644 --- a/devtools/client/framework/ToolboxProcess.jsm +++ b/devtools/client/framework/ToolboxProcess.jsm @@ -141,8 +141,11 @@ BrowserToolboxProcess.prototype = { 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."); diff --git a/devtools/client/framework/toolbox-process-window.js b/devtools/client/framework/toolbox-process-window.js index 34ba8e99ddd1..be65c55bba02 100644 --- a/devtools/client/framework/toolbox-process-window.js +++ b/devtools/client/framework/toolbox-process-window.js @@ -25,7 +25,8 @@ var { Task } = require("devtools/shared/task"); */ 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; @@ -35,27 +36,28 @@ var connect = Task.async(function*() { // 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 @@ -77,7 +79,7 @@ window.addEventListener("load", function() { 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); }); diff --git a/devtools/client/preferences/devtools.js b/devtools/client/preferences/devtools.js index 4d310dc52d43..822b7f256764 100644 --- a/devtools/client/preferences/devtools.js +++ b/devtools/client/preferences/devtools.js @@ -81,6 +81,7 @@ pref("devtools.responsiveUI.no-reload-notification", false); 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);