Bug 986853: Add-on Debugger title is always 'Debugger - (null)'. r=past

This commit is contained in:
Dave Townsend 2014-03-27 10:29:03 -07:00
parent 076c60cd55
commit 7f27cc8269
6 changed files with 39 additions and 6 deletions

View File

@ -5,7 +5,18 @@
const ADDON4_URL = EXAMPLE_URL + "addon4.xpi";
let gAddon, gClient, gThreadClient, gDebugger, gSources;
let gAddon, gClient, gThreadClient, gDebugger, gSources, gTitle;
function onMessage(event) {
try {
let json = JSON.parse(event.data);
switch (json.name) {
case "toolbox-title":
gTitle = json.data.value;
break;
}
} catch(e) { Cu.reportError(e); }
}
function test() {
Task.spawn(function () {
@ -18,6 +29,8 @@ function test() {
let iframe = document.createElement("iframe");
document.documentElement.appendChild(iframe);
window.addEventListener("message", onMessage);
let transport = DebuggerServer.connectPipe();
gClient = new DebuggerClient(transport);
@ -43,6 +56,7 @@ function test() {
yield closeConnection();
yield debuggerPanel._toolbox.destroy();
iframe.remove();
window.removeEventListener("message", onMessage);
finish();
});
}
@ -87,6 +101,8 @@ function testSources(expectSecondModule) {
is(foundAddonModule2, expectSecondModule, "saw the second addon module");
ok(foundAddonBootstrap, "found bootstrap script for the addon in the list");
is(gTitle, "Debugger - Test add-on with JS Modules", "Saw the right toolbox title.");
deferred.resolve();
});

View File

@ -6,7 +6,18 @@
const ADDON3_URL = EXAMPLE_URL + "addon3.xpi";
let gAddon, gClient, gThreadClient, gDebugger, gSources;
let gAddon, gClient, gThreadClient, gDebugger, gSources, gTitle;
function onMessage(event) {
try {
let json = JSON.parse(event.data);
switch (json.name) {
case "toolbox-title":
gTitle = json.data.value;
break;
}
} catch(e) { Cu.reportError(e); }
}
function test() {
Task.spawn(function () {
@ -19,6 +30,8 @@ function test() {
let iframe = document.createElement("iframe");
document.documentElement.appendChild(iframe);
window.addEventListener("message", onMessage);
let transport = DebuggerServer.connectPipe();
gClient = new DebuggerClient(transport);
@ -37,6 +50,7 @@ function test() {
yield closeConnection();
yield debuggerPanel._toolbox.destroy();
iframe.remove();
window.removeEventListener("message", onMessage);
finish();
});
}
@ -88,6 +102,8 @@ function testSources() {
// built-in browser SDK modules
ok(foundSDKModule > 10, "SDK modules are listed");
is(gTitle, "Debugger - browser_dbg_addon3", "Saw the right toolbox title.");
deferred.resolve();
});

View File

@ -503,9 +503,9 @@ function initDebugger(aTarget, aWindow) {
function initAddonDebugger(aClient, aUrl, aFrame) {
info("Initializing an addon debugger panel.");
return getAddonActorForUrl(aClient, aUrl).then(({actor}) => {
return getAddonActorForUrl(aClient, aUrl).then((addonActor) => {
let targetOptions = {
form: { addonActor: actor },
form: { addonActor: addonActor.actor, title: addonActor.name },
client: aClient,
chrome: true
};

View File

@ -37,7 +37,7 @@ function connect() {
if (addonID) {
gClient.listAddons(({addons}) => {
let addonActor = addons.filter(addon => addon.id === addonID).pop();
openToolbox({ addonActor: addonActor.actor });
openToolbox({ addonActor: addonActor.actor, title: addonActor.name });
});
} else {
gClient.listTabs(openToolbox);

View File

@ -966,7 +966,7 @@ Toolbox.prototype = {
toolName = toolboxStrings("toolbox.defaultTitle");
}
let title = toolboxStrings("toolbox.titleTemplate",
toolName, this.target.url);
toolName, this.target.url || this.target.name);
this._host.setTitle(title);
},

View File

@ -1125,6 +1125,7 @@ BrowserAddonActor.prototype = {
return {
actor: this.actorID,
id: this.id,
name: this._addon.name,
url: this.url
};
},