Bug 987890 - Hide unused tools when using addon debugger. r=jryans

This commit is contained in:
Jordan Santell 2014-03-27 12:32:00 +01:00
parent fc8d68521b
commit 906440ab37
4 changed files with 92 additions and 7 deletions

View File

@ -85,6 +85,7 @@ support-files =
[browser_dbg_addonactor.js]
[browser_dbg_addon-sources.js]
[browser_dbg_addon-modules.js]
[browser_dbg_addon-panels.js]
[browser_dbg_auto-pretty-print-01.js]
[browser_dbg_auto-pretty-print-02.js]
[browser_dbg_bfcache.js]

View File

@ -0,0 +1,80 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Ensure that only panels that are relevant to the addon debugger
// display in the toolbox
const ADDON3_URL = EXAMPLE_URL + "addon3.xpi";
let gAddon, gClient, gThreadClient, gDebugger, gSources;
function test() {
Task.spawn(function () {
if (!DebuggerServer.initialized) {
DebuggerServer.init(() => true);
DebuggerServer.addBrowserActors();
}
gBrowser.selectedTab = gBrowser.addTab();
let iframe = document.createElement("iframe");
document.documentElement.appendChild(iframe);
let transport = DebuggerServer.connectPipe();
gClient = new DebuggerClient(transport);
let connected = promise.defer();
gClient.connect(connected.resolve);
yield connected.promise;
yield installAddon();
let debuggerPanel = yield initAddonDebugger(gClient, ADDON3_URL, iframe);
gDebugger = debuggerPanel.panelWin;
gThreadClient = gDebugger.gThreadClient;
gSources = gDebugger.DebuggerView.Sources;
testPanels(iframe);
yield uninstallAddon();
yield closeConnection();
yield debuggerPanel._toolbox.destroy();
iframe.remove();
finish();
});
}
function installAddon () {
return addAddon(ADDON3_URL).then(aAddon => {
gAddon = aAddon;
});
}
function testPanels(frame) {
let tabs = frame.contentDocument.getElementById("toolbox-tabs").children;
let expectedTabs = ["options", "jsdebugger"];
is(tabs.length, 2, "displaying only 2 tabs in addon debugger");
Array.forEach(tabs, (tab, i) => {
let toolName = expectedTabs[i];
is(tab.getAttribute("toolid"), toolName, "displaying " + toolName);
});
}
function uninstallAddon() {
return removeAddon(gAddon);
}
function closeConnection () {
let deferred = promise.defer();
gClient.close(deferred.resolve);
return deferred.promise;
}
registerCleanupFunction(function() {
gClient = null;
gAddon = null;
gThreadClient = null;
gDebugger = null;
gSources = null;
while (gBrowser.tabs.length > 1) {
gBrowser.removeCurrentTab();
}
});

View File

@ -242,6 +242,10 @@ TabTarget.prototype = {
return !this.isLocalTab;
},
get isAddon() {
return !!(this._form && this._form.addonActor);
},
get isLocalTab() {
return !!this._tab;
},

View File

@ -97,7 +97,7 @@ Tools.webConsole = {
},
isTargetSupported: function(target) {
return true;
return !target.isAddon;
},
build: function(iframeWindow, toolbox) {
let panel = new WebConsolePanel(iframeWindow, toolbox);
@ -124,7 +124,7 @@ Tools.inspector = {
},
isTargetSupported: function(target) {
return true;
return !target.isAddon;
},
build: function(iframeWindow, toolbox) {
@ -171,7 +171,7 @@ Tools.styleEditor = {
inMenu: true,
isTargetSupported: function(target) {
return true;
return !target.isAddon;
},
build: function(iframeWindow, toolbox) {
@ -191,7 +191,7 @@ Tools.shaderEditor = {
tooltip: l10n("ToolboxShaderEditor.tooltip", shaderEditorStrings),
isTargetSupported: function(target) {
return true;
return !target.isAddon;
},
build: function(iframeWindow, toolbox) {
@ -215,7 +215,7 @@ Tools.jsprofiler = {
inMenu: true,
isTargetSupported: function (target) {
return true;
return !target.isAddon;
},
build: function (frame, target) {
@ -240,7 +240,7 @@ Tools.netMonitor = {
isTargetSupported: function(target) {
let root = target.client.mainRoot;
return root.traits.networkMonitor || !target.isApp;
return !target.isAddon && (root.traits.networkMonitor || !target.isApp);
},
build: function(iframeWindow, toolbox) {
@ -261,7 +261,7 @@ Tools.scratchpad = {
inMenu: false,
isTargetSupported: function(target) {
return target.isRemote;
return !target.isAddon && target.isRemote;
},
build: function(iframeWindow, toolbox) {