Bug 1059308 - Add Target.isTabActor to tell if the remote tab actor supports attach/detach requests. r=jryans

This commit is contained in:
Alexandre Poirot 2015-02-26 03:55:00 +01:00
Родитель a5270da9e8
Коммит 9ddabe8061
10 изменённых файлов: 46 добавлений и 33 удалений

Просмотреть файл

@ -206,7 +206,9 @@ let DebuggerController = {
if (target.isAddon) {
yield this._startAddonDebugging(actor);
} else if (target.chrome) {
} else if (!target.isTabActor) {
// Some actors like AddonActor or RootActor for chrome debugging
// do not support attach/detach and can be used directly
yield this._startChromeDebugging(chromeDebugger);
} else {
yield this._startDebuggingTab();

Просмотреть файл

@ -581,7 +581,8 @@ AddonDebugger.prototype = {
let targetOptions = {
form: addonActor,
client: this.client,
chrome: true
chrome: true,
isTabActor: false
};
let toolboxOptions = {

Просмотреть файл

@ -162,7 +162,7 @@ let onConnectionReady = Task.async(function*(aType, aTraits) {
function buildAddonLink(addon, parent) {
let a = document.createElement("a");
a.onclick = function() {
openToolbox(addon, true, "jsdebugger");
openToolbox(addon, true, "jsdebugger", false);
}
a.textContent = addon.name;
@ -221,11 +221,12 @@ function handleConnectionTimeout() {
* The user clicked on one of the buttons.
* Opens the toolbox.
*/
function openToolbox(form, chrome=false, tool="webconsole") {
function openToolbox(form, chrome=false, tool="webconsole", isTabActor) {
let options = {
form: form,
client: gClient,
chrome: chrome
chrome: chrome,
isTabActor: isTabActor
};
devtools.TargetFactory.forRemoteTab(options).then((target) => {
let hostType = devtools.Toolbox.HostType.WINDOW;
@ -233,7 +234,7 @@ function openToolbox(form, chrome=false, tool="webconsole") {
toolbox.once("destroyed", function() {
gClient.close();
});
});
}, console.error.bind(console));
window.close();
});
}, console.error.bind(console));
}

Просмотреть файл

@ -718,7 +718,8 @@ let gDevToolsBrowser = {
let options = {
form: response.form,
client: client,
chrome: true
chrome: true,
isTabActor: false
};
return devtools.TargetFactory.forRemoteTab(options);
})

Просмотреть файл

@ -175,6 +175,8 @@ function TabTarget(tab) {
this._client = tab.client;
this._chrome = tab.chrome;
}
// Default isTabActor to true if not explicitely specified
this._isTabActor = typeof(tab.isTabActor) == "boolean" ? tab.isTabActor : true;
}
TabTarget.prototype = {
@ -315,10 +317,21 @@ TabTarget.prototype = {
return this._client;
},
// Tells us if we are debugging content document
// or if we are debugging chrome stuff.
// Allows to controls which features are available against
// a chrome or a content document.
get chrome() {
return this._chrome;
},
// Tells us if the related actor implements TabActor interface
// and requires to call `attach` request before being used
// and `detach` during cleanup
get isTabActor() {
return this._isTabActor;
},
get window() {
// XXX - this is a footgun for e10s - there .contentWindow will be null,
// and even though .contentWindowAsCPOW *might* work, it will not work
@ -436,12 +449,13 @@ TabTarget.prototype = {
attachTab();
});
});
} else if (!this.chrome) {
} else if (this.isTabActor) {
// In the remote debugging case, the protocol connection will have been
// already initialized in the connection screen code.
attachTab();
} else {
// Remote chrome debugging doesn't need anything at this point.
// AddonActor and chrome debugging on RootActor doesn't inherits from TabActor and
// doesn't need to be attached.
this._remote.resolve(null);
}

Просмотреть файл

@ -38,7 +38,7 @@ let connect = Task.async(function*() {
if (addonID) {
gClient.listAddons(({addons}) => {
let addonActor = addons.filter(addon => addon.id === addonID).pop();
openToolbox(addonActor);
openToolbox({ form: addonActor, chrome: true, isTabActor: false });
});
} else {
gClient.listTabs(openToolbox);
@ -65,11 +65,12 @@ function onCloseCommand(event) {
window.close();
}
function openToolbox(form) {
function openToolbox({ form, chrome, isTabActor }) {
let options = {
form: form,
client: gClient,
chrome: true
chrome: chrome,
isTabActor: isTabActor
};
devtools.TargetFactory.forRemoteTab(options).then(target => {
let frame = document.getElementById("toolbox-iframe");

Просмотреть файл

@ -211,7 +211,9 @@ let NetMonitorController = {
let target = this._target;
let { client, form } = target;
if (target.chrome) {
// Some actors like AddonActor or RootActor for chrome debugging
// do not support attach/detach and can be used directly
if (!target.isTabActor) {
this._startChromeMonitoring(client, form.consoleActor, deferred.resolve);
} else {
this._startMonitoringTab(client, form, deferred.resolve);

Просмотреть файл

@ -121,14 +121,9 @@ PerformanceActorsConnection.prototype = {
* Initializes a connection to the profiler actor.
*/
_connectProfilerActor: Task.async(function*() {
// Chrome debugging targets have already obtained a reference
// to the profiler actor.
if (this._target.chrome) {
this._profiler = this._target.form.profilerActor;
}
// When we are debugging content processes, we already have the tab
// specific one. Use it immediately.
else if (this._target.form && this._target.form.profilerActor) {
// Chrome and content process targets already have obtained a reference
// to the profiler tab actor. Use it immediately.
if (this._target.form && this._target.form.profilerActor) {
this._profiler = this._target.form.profilerActor;
}
// Check if we already have a grip to the `listTabs` response object

Просмотреть файл

@ -83,14 +83,9 @@ ProfilerConnection.prototype = {
// Local debugging needs to make the target remote.
yield this._target.makeRemote();
// Chrome debugging targets have already obtained a reference
// to the profiler actor.
if (this._target.chrome) {
this._profiler = this._target.form.profilerActor;
}
// Or when we are debugging content processes, we already have the tab
// specific one. Use it immediately.
else if (this._target.form && this._target.form.profilerActor) {
// Chrome and content process targets already have obtained a reference
// to the profiler tab actor. Use it immediately.
if (this._target.form && this._target.form.profilerActor) {
this._profiler = this._target.form.profilerActor;
yield this._registerEventNotifications();
}
@ -100,8 +95,9 @@ ProfilerConnection.prototype = {
this._profiler = this._target.root.profilerActor;
yield this._registerEventNotifications();
}
// Otherwise, call `listTabs`.
else {
// Otherwise, call `listTabs`, but ensure not trying to fetch tab actors
// for AddonTarget that are chrome, but do not expose profile at all.
else if (!this._target.chrome) {
this._profiler = (yield listTabs(this._client)).profilerActor;
yield this._registerEventNotifications();
}

Просмотреть файл

@ -5095,7 +5095,7 @@ WebConsoleConnectionProxy.prototype = {
this.target.on("navigate", this._onTabNavigated);
this._consoleActor = this.target.form.consoleActor;
if (!this.target.chrome) {
if (this.target.isTabActor) {
let tab = this.target.form;
this.owner.onLocationChange(tab.url, tab.title);
}