Bug 859569 - Target.makeRemote should attachTab; r=dcamp
This commit is contained in:
@@ -137,7 +137,7 @@ let DebuggerController = {
|
||||
|
||||
if (!window._isChromeDebugger) {
|
||||
let target = this._target;
|
||||
let { client, form } = target;
|
||||
let { client, form, threadActor } = target;
|
||||
target.on("close", this._onTabDetached);
|
||||
target.on("navigate", this._onTabNavigated);
|
||||
target.on("will-navigate", this._onTabNavigated);
|
||||
@@ -145,7 +145,7 @@ let DebuggerController = {
|
||||
if (target.chrome) {
|
||||
this._startChromeDebugging(client, form.chromeDebugger, deferred.resolve);
|
||||
} else {
|
||||
this._startDebuggingTab(client, form, deferred.resolve);
|
||||
this._startDebuggingTab(client, threadActor, deferred.resolve);
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
@@ -176,18 +176,17 @@ let DebuggerController = {
|
||||
if (!this.client) {
|
||||
return;
|
||||
}
|
||||
this.client.removeListener("tabNavigated", this._onTabNavigated);
|
||||
this.client.removeListener("tabDetached", this._onTabDetached);
|
||||
|
||||
// When debugging local or a remote instance, the connection is closed by
|
||||
// the RemoteTarget.
|
||||
if (window._isChromeDebugger) {
|
||||
this.client.removeListener("tabNavigated", this._onTabNavigated);
|
||||
this.client.removeListener("tabDetached", this._onTabDetached);
|
||||
this.client.close();
|
||||
}
|
||||
|
||||
this._connection = null;
|
||||
this.client = null;
|
||||
this.tabClient = null;
|
||||
this.activeThread = null;
|
||||
},
|
||||
|
||||
@@ -227,41 +226,33 @@ let DebuggerController = {
|
||||
*
|
||||
* @param DebuggerClient aClient
|
||||
* The debugger client.
|
||||
* @param object aTabGrip
|
||||
* @param string aThreadActor
|
||||
* The remote protocol grip of the tab.
|
||||
* @param function aCallback
|
||||
* A function to invoke once the client attached to the active thread.
|
||||
*/
|
||||
_startDebuggingTab: function DC__startDebuggingTab(aClient, aTabGrip, aCallback) {
|
||||
_startDebuggingTab: function DC__startDebuggingTab(aClient, aThreadActor, aCallback) {
|
||||
if (!aClient) {
|
||||
Cu.reportError("No client found!");
|
||||
return;
|
||||
}
|
||||
this.client = aClient;
|
||||
|
||||
aClient.attachTab(aTabGrip.actor, (aResponse, aTabClient) => {
|
||||
if (!aTabClient) {
|
||||
Cu.reportError("No tab client found!");
|
||||
aClient.attachThread(aThreadActor, (aResponse, aThreadClient) => {
|
||||
if (!aThreadClient) {
|
||||
Cu.reportError("Couldn't attach to thread: " + aResponse.error);
|
||||
return;
|
||||
}
|
||||
this.tabClient = aTabClient;
|
||||
this.activeThread = aThreadClient;
|
||||
|
||||
aClient.attachThread(aResponse.threadActor, (aResponse, aThreadClient) => {
|
||||
if (!aThreadClient) {
|
||||
Cu.reportError("Couldn't attach to thread: " + aResponse.error);
|
||||
return;
|
||||
}
|
||||
this.activeThread = aThreadClient;
|
||||
this.ThreadState.connect();
|
||||
this.StackFrames.connect();
|
||||
this.SourceScripts.connect();
|
||||
aThreadClient.resume(this._ensureResumptionOrder);
|
||||
|
||||
this.ThreadState.connect();
|
||||
this.StackFrames.connect();
|
||||
this.SourceScripts.connect();
|
||||
aThreadClient.resume(this._ensureResumptionOrder);
|
||||
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
}
|
||||
});
|
||||
if (aCallback) {
|
||||
aCallback();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -331,7 +322,6 @@ let DebuggerController = {
|
||||
_shutdown: null,
|
||||
_connection: null,
|
||||
client: null,
|
||||
tabClient: null,
|
||||
activeThread: null
|
||||
};
|
||||
|
||||
@@ -1720,9 +1710,6 @@ Object.defineProperties(window, {
|
||||
"gClient": {
|
||||
get: function() DebuggerController.client
|
||||
},
|
||||
"gTabClient": {
|
||||
get: function() DebuggerController.tabClient
|
||||
},
|
||||
"gThreadClient": {
|
||||
get: function() DebuggerController.activeThread
|
||||
},
|
||||
|
||||
@@ -280,12 +280,20 @@ TabTarget.prototype = {
|
||||
// already initialized in the connection screen code.
|
||||
this._remote.resolve(null);
|
||||
} else {
|
||||
this._client.connect(function(aType, aTraits) {
|
||||
this._client.listTabs(function(aResponse) {
|
||||
this._client.connect((aType, aTraits) => {
|
||||
this._client.listTabs(aResponse => {
|
||||
this._form = aResponse.tabs[aResponse.selected];
|
||||
this._remote.resolve(null);
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
this._client.attachTab(this._form.actor, (aResponse, aTabClient) => {
|
||||
if (!aTabClient) {
|
||||
this._remote.reject("Unable to attach to the tab");
|
||||
return;
|
||||
}
|
||||
this.threadActor = aResponse.threadActor;
|
||||
this._remote.resolve(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return this._remote.promise;
|
||||
|
||||
@@ -4386,7 +4386,6 @@ function WebConsoleConnectionProxy(aWebConsole, aTarget)
|
||||
this._onNetworkEventUpdate = this._onNetworkEventUpdate.bind(this);
|
||||
this._onFileActivity = this._onFileActivity.bind(this);
|
||||
this._onTabNavigated = this._onTabNavigated.bind(this);
|
||||
this._onAttachTab = this._onAttachTab.bind(this);
|
||||
this._onAttachConsole = this._onAttachConsole.bind(this);
|
||||
this._onCachedMessages = this._onCachedMessages.bind(this);
|
||||
this._connectionTimeout = this._connectionTimeout.bind(this);
|
||||
@@ -4423,12 +4422,6 @@ WebConsoleConnectionProxy.prototype = {
|
||||
*/
|
||||
webConsoleClient: null,
|
||||
|
||||
/**
|
||||
* The TabClient instance we use.
|
||||
* @type object
|
||||
*/
|
||||
tabClient: null,
|
||||
|
||||
/**
|
||||
* Tells if the connection is established.
|
||||
* @type boolean
|
||||
@@ -4453,14 +4446,6 @@ WebConsoleConnectionProxy.prototype = {
|
||||
*/
|
||||
_consoleActor: null,
|
||||
|
||||
/**
|
||||
* The TabActor ID.
|
||||
*
|
||||
* @private
|
||||
* @type string
|
||||
*/
|
||||
_tabActor: null,
|
||||
|
||||
/**
|
||||
* Tells if the window.console object of the remote web page is the native
|
||||
* object or not.
|
||||
@@ -4504,17 +4489,15 @@ WebConsoleConnectionProxy.prototype = {
|
||||
client.addListener("networkEvent", this._onNetworkEvent);
|
||||
client.addListener("networkEventUpdate", this._onNetworkEventUpdate);
|
||||
client.addListener("fileActivity", this._onFileActivity);
|
||||
client.addListener("tabNavigated", this._onTabNavigated);
|
||||
this.target.on("will-navigate", this._onTabNavigated);
|
||||
this.target.on("navigate", this._onTabNavigated);
|
||||
|
||||
this._consoleActor = this.target.form.consoleActor;
|
||||
if (!this.target.chrome) {
|
||||
// target.form is a TabActor grip
|
||||
this._attachTab(this.target.form);
|
||||
}
|
||||
else {
|
||||
// target.form is a RootActor grip
|
||||
this._consoleActor = this.target.form.consoleActor;
|
||||
this._attachConsole();
|
||||
let tab = this.target.form;
|
||||
this.owner.onLocationChange(tab.url, tab.title);
|
||||
}
|
||||
this._attachConsole();
|
||||
|
||||
return promise;
|
||||
},
|
||||
@@ -4533,43 +4516,6 @@ WebConsoleConnectionProxy.prototype = {
|
||||
this._connectDefer.reject(error);
|
||||
},
|
||||
|
||||
/**
|
||||
* Attach to the tab actor.
|
||||
*
|
||||
* @private
|
||||
* @param object aTab
|
||||
* Grip for the tab to attach to.
|
||||
*/
|
||||
_attachTab: function WCCP__attachTab(aTab)
|
||||
{
|
||||
this._consoleActor = aTab.consoleActor;
|
||||
this._tabActor = aTab.actor;
|
||||
this.owner.onLocationChange(aTab.url, aTab.title);
|
||||
this.client.attachTab(this._tabActor, this._onAttachTab);
|
||||
},
|
||||
|
||||
/**
|
||||
* The "attachTab" response handler.
|
||||
*
|
||||
* @private
|
||||
* @param object aResponse
|
||||
* The JSON response object received from the server.
|
||||
* @param object aTabClient
|
||||
* The TabClient instance for the attached tab.
|
||||
*/
|
||||
_onAttachTab: function WCCP__onAttachTab(aResponse, aTabClient)
|
||||
{
|
||||
if (aResponse.error) {
|
||||
Cu.reportError("attachTab failed: " + aResponse.error + " " +
|
||||
aResponse.message);
|
||||
this._connectDefer.reject(aResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
this.tabClient = aTabClient;
|
||||
this._attachConsole();
|
||||
},
|
||||
|
||||
/**
|
||||
* Attach to the Web Console actor.
|
||||
* @private
|
||||
@@ -4739,7 +4685,7 @@ WebConsoleConnectionProxy.prototype = {
|
||||
*/
|
||||
_onTabNavigated: function WCCP__onTabNavigated(aType, aPacket)
|
||||
{
|
||||
if (!this.owner || aPacket.from != this._tabActor) {
|
||||
if (!this.owner) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4747,7 +4693,7 @@ WebConsoleConnectionProxy.prototype = {
|
||||
this.owner.onLocationChange(aPacket.url, aPacket.title);
|
||||
}
|
||||
|
||||
if (aPacket.state == "stop" && !aPacket.nativeConsoleAPI) {
|
||||
if (aType == "navigate" && !aPacket.nativeConsoleAPI) {
|
||||
this.owner.logWarningAboutReplacedAPI();
|
||||
}
|
||||
},
|
||||
@@ -4793,7 +4739,6 @@ WebConsoleConnectionProxy.prototype = {
|
||||
|
||||
this.client = null;
|
||||
this.webConsoleClient = null;
|
||||
this.tabClient = null;
|
||||
this.target = null;
|
||||
this.connected = false;
|
||||
this.owner = null;
|
||||
|
||||
Reference in New Issue
Block a user