From eaf8d3696359dcea0edaa2fd9bc1e4cf5d985014 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 17 Mar 2017 17:08:03 -0400 Subject: [PATCH] Adds a -debugger command-line flag to start the devtools server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Follow-up to https://github.com/zotero/zotero-standalone-build/commit/22cfe2404 The devtools must be included in the build by passing the -t flag to build.sh in zotero-standalone-build. After starting Zotero with the flag, connect from a Firefox instance with remote debugging enabled by choosing "Connect…" from the Web Developer menu and connecting to port 6100. --- components/zotero-service.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/components/zotero-service.js b/components/zotero-service.js index 315f215dc..5879dc386 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -559,6 +559,33 @@ ZoteroCommandLineHandler.prototype = { } } + param = cmdLine.handleFlag("debugger", false); + if (param) { + try { + let portOrPath = Services.prefs.getBranch('').getIntPref('devtools.debugger.remote-port'); + + const { devtools } = Components.utils.import("resource://devtools/shared/Loader.jsm", {}); + const { DebuggerServer } = devtools.require("devtools/server/main"); + + if (!DebuggerServer.initialized) { + dump("Initializing devtools server\n"); + DebuggerServer.init(); + DebuggerServer.allowChromeProcess = true; + DebuggerServer.addBrowserActors(); + } + + let listener = DebuggerServer.createListener(); + listener.portOrPath = portOrPath; + listener.open(); + + dump("Debugger server started on " + portOrPath + "\n\n"); + } + catch (e) { + dump(e + "\n\n"); + Components.utils.reportError(e); + } + } + // In Fx49-based Mac Standalone, if Zotero is closed, an associated file is launched, and // Zotero hasn't been opened before, a -file parameter is passed and two main windows open. // Subsequent file openings when closed result in -url with file:// URLs (converted above)