Skip to content

Commit 7aef9e4

Browse files
committed
Merge branch 'feature/other-connections' of https://github.com/rpl/rdp-inspector into rpl-feature/other-connections
2 parents a032f20 + 6d4eaa7 commit 7aef9e4

File tree

2 files changed

+41
-16
lines changed

2 files changed

+41
-16
lines changed

lib/inspector-service.js

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const { Rdp } = require("firebug.sdk/lib/core/rdp.js");
2222

2323
// DevTools
2424
// See also: https://bugzilla.mozilla.org/show_bug.cgi?id=912121
25-
const { devtools } = require("firebug.sdk/lib/core/devtools.js");
25+
const { devtools, gDevTools } = require("firebug.sdk/lib/core/devtools.js");
26+
2627
var DebuggerClient;
2728
try {
2829
DebuggerClient = devtools["require"]("devtools/shared/client/main").DebuggerClient;
@@ -82,23 +83,24 @@ const InspectorService =
8283
getConnectionsInfo() {
8384
let localTabsConnections = [];
8485
let webideConnections = [];
86+
let otherConnections = [];
8587

8688
for (let conn of this.clientsMap.values()) {
87-
// filter out incomplete connections
88-
if (!conn.toolbox) {
89-
continue;
90-
}
91-
9289
let connDesc = { uuid: conn.uuid };
9390

9491
if (conn.webide) {
9592
connDesc.name = conn.webide.selectedRuntime.name;
9693

9794
webideConnections.push(connDesc);
98-
} else if (conn.toolbox.target.isLocalTab) {
95+
} else if (conn.toolbox && conn.toolbox.target.isLocalTab) {
9996
connDesc.name = conn.toolbox.target.tab.label;
10097

10198
localTabsConnections.push(connDesc);
99+
} else {
100+
otherConnections.push({
101+
uuid: conn.uuid,
102+
name: conn.uuid,
103+
});
102104
}
103105
}
104106

@@ -110,6 +112,10 @@ const InspectorService =
110112
"webide": {
111113
label: Locale.$STR("rdpConnections.tab.WebIDE"),
112114
connections: webideConnections
115+
},
116+
"other": {
117+
label: "Other",
118+
connections: otherConnections
113119
}
114120
};
115121

@@ -118,9 +124,20 @@ const InspectorService =
118124

119125
openRDPInspectorWindow(uuidConn) {
120126
if (this.clientsByUUID.has(uuidConn)) {
121-
let { toolbox } = this.clientsByUUID.get(uuidConn);
122-
123-
Dispatcher.emit("onToggleRDPInspector", [{ toolbox }]);
127+
let conn = this.clientsByUUID.get(uuidConn);
128+
let { toolbox } = conn;
129+
130+
if (toolbox) {
131+
Dispatcher.emit("onToggleRDPInspector", [{ toolbox }]);
132+
} else {
133+
toolbox = new devtools.Toolbox({
134+
makeRemote: function() {},
135+
client: conn.client,
136+
on: () => {}
137+
}, null, devtools.Toolbox.HostType.WINDOW);
138+
toolbox.isFakeToolbox = true;
139+
gDevTools.emit("toolbox-created", toolbox);
140+
}
124141
}
125142
},
126143

@@ -129,7 +146,8 @@ const InspectorService =
129146
return;
130147
}
131148
let clientInfo = this.clientsMap.get(client) || {
132-
uuid: uuid().toString()
149+
uuid: uuid().toString(),
150+
client
133151
};
134152

135153
delete moreInfo["uuid"];
@@ -149,7 +167,7 @@ const InspectorService =
149167

150168
let autoOpenInspectorConsole = false;
151169

152-
if (clientInfo && clientInfo.webide && prefs.autoOpenOnWebIDEConnection) {
170+
if (toolbox.isFakeToolbox || (clientInfo && clientInfo.webide && prefs.autoOpenOnWebIDEConnection)) {
153171
autoOpenInspectorConsole = true;
154172
}
155173

@@ -170,7 +188,7 @@ const InspectorService =
170188

171189
// WebIDE Connections Events
172190

173-
onWebIDEConnectionCreated: function(/*{ connection }*/) {
191+
onWebIDEConnectionCreated: function(/*{ connection, selectedRuntime }*/) {
174192
Trace.sysout("InspectorService.onWebIDEConnectionCreated");
175193
},
176194

@@ -180,6 +198,8 @@ const InspectorService =
180198
this._setClientInfo(connection.client, {
181199
webide: { selectedRuntime, connection }
182200
});
201+
202+
Dispatcher.emit("onRDPConnectionsUpdated", []);
183203
},
184204

185205
// Start button events
@@ -191,7 +211,9 @@ const InspectorService =
191211

192212
let clientInfo = this.clientsMap.get(toolbox.target.client);
193213

194-
if (clientInfo && clientInfo.webide) {
214+
if (toolbox.isFakeToolbox) {
215+
inspectorWindowName = `Other: ${clientInfo.uuid}`;
216+
} else if (clientInfo && clientInfo.webide) {
195217
inspectorWindowName = `WebIDE: ${clientInfo.webide.selectedRuntime.name}`;
196218
} else if (toolbox.target.isLocalTab) {
197219
inspectorWindowName = `Tab: ${toolbox.target.tab.label}`;
@@ -210,6 +232,9 @@ const InspectorService =
210232
client.addOneTimeListener("closed", () => {
211233
this.onDebuggerClientClosed(client);
212234
});
235+
236+
this._setClientInfo(client, {});
237+
Dispatcher.emit("onRDPConnectionsUpdated", []);
213238
},
214239

215240
onDebuggerClientClosed: function(client) {

lib/webide-connections-monitor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ const WebIDEConnectionsMonitor =
4848
onNewConnection: function(type, connection) {
4949
Trace.sysout("WebIDEConnectionsMonitor.onNewConnection;", arguments);
5050

51-
Dispatcher.emit("onWebIDEConnectionCreated", [{ connection }]);
51+
Dispatcher.emit("onWebIDEConnectionCreated", [{ connection, selectedRuntime: AppManager.selectedRuntime }]);
5252

53-
connection.on(Connection.Events.CONNECTED, () => {
53+
connection.once(Connection.Events.CONNECTED, () => {
5454
if (AppManager.connection == connection) {
5555

5656
Dispatcher.emit("onWebIDEConnectionReady", [{ connection, selectedRuntime: AppManager.selectedRuntime }]);

0 commit comments

Comments
 (0)