远程连接,如浏览器工具箱

时间:2014-07-17 20:35:49

标签: firefox-addon

我正在尝试与另一个开放的个人资料互动,这是一个单独的过程。浏览器工具箱执行此操作。我想知道如何重新模拟这种行为?没有提示要求“允许远程连接”?

我的目标是(1)找到所有打开的firefox进程,(2)访问其每个xpcom并找出配置文件名称,(3)如果它是我感兴趣的配置文件名称,则关注其最近的窗口

1 个答案:

答案 0 :(得分:1)

我不知道但是我通过在MXR中跟踪它来到达某个地方:

http://mxr.mozilla.org/mozilla-release/source/browser/devtools/framework/toolbox-process-window.js#11

11 let { debuggerSocketConnect, DebuggerClient } =
12   Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
13 let { ViewHelpers } =
14   Cu.import("resource:///modules/devtools/ViewHelpers.jsm", {});
15 
16 /**
17  * Shortcuts for accessing various debugger preferences.
18  */
19 let Prefs = new ViewHelpers.Prefs("devtools.debugger", {
20   chromeDebuggingHost: ["Char", "chrome-debugging-host"],
21   chromeDebuggingPort: ["Int", "chrome-debugging-port"]
22 });
23 
24 let gToolbox, gClient;
25 
26 function connect() {
27   window.removeEventListener("load", connect);
28   // Initiate the connection
29   let transport = debuggerSocketConnect(
30     Prefs.chromeDebuggingHost,
31     Prefs.chromeDebuggingPort
32   );
33   gClient = new DebuggerClient(transport);
34   gClient.connect(() => {
35     let addonID = getParameterByName("addonID");
36 
37     if (addonID) {
38       gClient.listAddons(({addons}) => {
39         let addonActor = addons.filter(addon => addon.id === addonID).pop();
40         openToolbox({ addonActor: addonActor.actor, title: addonActor.name });
41       });
42     } else {
43       gClient.listTabs(openToolbox);
44     }
45   });
46 }
47 

我运行了个人资料,看起来pref ..-hostlocalhost..-port6080。我不确定这有助于针对特定的个人资料。也许在浏览器工具箱启动时,它将端口6080打开到开启者配置文件。我不确定,但如果它是真的,那么你必须从目标配置文件中运行代码才能打开一个端口。

但完全不确定。

但是端口在这里打开:

http://mxr.mozilla.org/mozilla-release/source/browser/devtools/framework/ToolboxProcess.jsm#107

106 
107 BrowserToolboxProcess.prototype = {
108   /**
109    * Initializes the debugger server.
110    */
111   _initServer: function() {
112     dumpn("Initializing the chrome toolbox server.");
113 
114     if (!this.loader) {
115       // Create a separate loader instance, so that we can be sure to receive a
116       // separate instance of the DebuggingServer from the rest of the devtools.
117       // This allows us to safely use the tools against even the actors and
118       // DebuggingServer itself, especially since we can mark this loader as
119       // invisible to the debugger (unlike the usual loader settings).
120       this.loader = new DevToolsLoader();
121       this.loader.invisibleToDebugger = true;
122       this.loader.main("devtools/server/main");
123       this.debuggerServer = this.loader.DebuggerServer;
124       dumpn("Created a separate loader instance for the DebuggerServer.");
125 
126       // Forward interesting events.
127       this.debuggerServer.on("connectionchange", this.emit.bind(this));
128     }
129 
130     if (!this.debuggerServer.initialized) {
131       this.debuggerServer.init();
132       this.debuggerServer.addBrowserActors();
133       dumpn("initialized and added the browser actors for the DebuggerServer.");
134     }
135 
136     this.debuggerServer.openListener(Prefs.chromeDebuggingPort);
137 
138     dumpn("Finished initializing the chrome toolbox server.");
139     dumpn("Started listening on port: " + Prefs.chromeDebuggingPort);
140   },
141