diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index 531d0d64cb87..067d2645088b 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -1003,11 +1003,16 @@ pref("devtools.toolbar.visible", false); pref("devtools.gcli.allowSet", false); pref("devtools.commands.dir", ""); +// Toolbox preferences +pref("devtools.toolbox.footer.height", 250); +pref("devtools.toolbox.sidebar.width", 500); +pref("devtools.toolbox.host", "bottom"); +pref("devtools.toolbox.selectedTool", "webconsole"); +pref("devtools.toolbox.toolbarSpec", '["tilt toggle","scratchpad","resize toggle"]'); +pref("devtools.toolbox.sideEnabled", false); + // Enable the Inspector pref("devtools.inspector.enabled", true); -pref("devtools.inspector.htmlHeight", 112); -pref("devtools.inspector.htmlPanelOpen", false); -pref("devtools.inspector.sidebarOpen", false); pref("devtools.inspector.activeSidebar", "ruleview"); pref("devtools.inspector.markupPreview", false); @@ -1039,17 +1044,11 @@ pref("devtools.debugger.ui.variables-sorting-enabled", true); pref("devtools.debugger.ui.variables-non-enum-visible", true); pref("devtools.debugger.ui.variables-searchbox-visible", false); -// Enable the style inspector -pref("devtools.styleinspector.enabled", true); - // Enable the Tilt inspector pref("devtools.tilt.enabled", true); pref("devtools.tilt.intro_transition", true); pref("devtools.tilt.outro_transition", true); -// Enable the rules view -pref("devtools.ruleview.enabled", true); - // Enable the Scratchpad tool. pref("devtools.scratchpad.enabled", true); @@ -1074,17 +1073,6 @@ pref("devtools.gcli.eagerHelper", 2); // Do we allow the 'pref set' command pref("devtools.gcli.allowSet", false); -// The last Web Console height. This is initially 0 which means that the Web -// Console will use the default height next time it shows. -// Change to -1 if you do not want the Web Console to remember its last height. -pref("devtools.hud.height", 0); - -// Remember the Web Console position. Possible values: -// above - above the web page, -// below - below the web page, -// window - in a separate window/popup panel. -pref("devtools.webconsole.position", "below"); - // Remember the Web Console filters pref("devtools.webconsole.filter.network", true); pref("devtools.webconsole.filter.networkinfo", true); diff --git a/browser/base/content/browser-appmenu.inc b/browser/base/content/browser-appmenu.inc index a195f1808381..215c19ce29d6 100644 --- a/browser/base/content/browser-appmenu.inc +++ b/browser/base/content/browser-appmenu.inc @@ -150,20 +150,27 @@
+
+&availability;
+&connecting;
+ +1
"; + const tab2URL = "data:text/html;charset=utf8,2
"; + const tab3URL = "data:text/html;charset=utf8,3
"; + + let panelDoc; + + let registeredTabs = {}; + let readyTabs = {}; + + let toolDefinition = { + id: "fakeTool4242", + killswitch: "devtools.fakeTool4242.enabled", + url: toolURL, + label: "FAKE TOOL!!!", + isTargetSupported: function() true, + build: function(iframeWindow, toolbox) { + let panel = { + target: toolbox.target, + toolbox: toolbox, + isReady: true, + destroy: function(){}, + panelDoc: iframeWindow.document, + } + return panel; + }, + }; + + gDevTools.registerTool(toolDefinition); + + addTab("about:blank", function(aBrowser, aTab) { + let target = TargetFactory.forTab(gBrowser.selectedTab); + let toolbox = gDevTools.openToolbox(target, "bottom", "fakeTool4242"); + toolbox.once("fakeTool4242-ready", function(event, panel) { + ok(true, "Tool open"); + + let tabbox = panel.panelDoc.getElementById("sidebar"); + panel.sidebar = new ToolSidebar(tabbox, panel, true); + + panel.sidebar.on("new-tab-registered", function(event, id) { + registeredTabs[id] = true; + }); + + panel.sidebar.once("tab1-ready", function(event) { + readyTabs.tab1 = true; + if (readyTabs.tab1 && readyTabs.tab2 && readyTabs.tab3) { + allTabsReady(panel); + } + }); + + panel.sidebar.once("tab2-ready", function(event) { + readyTabs.tab2 = true; + if (readyTabs.tab1 && readyTabs.tab2 && readyTabs.tab3) { + allTabsReady(panel); + } + }); + + panel.sidebar.once("tab3-ready", function(event) { + readyTabs.tab3 = true; + if (readyTabs.tab1 && readyTabs.tab2 && readyTabs.tab3) { + allTabsReady(panel); + } + }); + + panel.sidebar.addTab("tab1", tab1URL, true); + panel.sidebar.addTab("tab2", tab2URL); + panel.sidebar.addTab("tab3", tab3URL); + + panel.sidebar.show(); + }); + }); + + function allTabsReady(panel) { + ok(registeredTabs.tab1, "tab1 registered"); + ok(registeredTabs.tab2, "tab2 registered"); + ok(registeredTabs.tab3, "tab3 registered"); + ok(readyTabs.tab1, "tab1 ready"); + ok(readyTabs.tab2, "tab2 ready"); + ok(readyTabs.tab3, "tab3 ready"); + + let tabs = panel.sidebar._tabbox.querySelectorAll("tab"); + let panels = panel.sidebar._tabbox.querySelectorAll("tabpanel"); + let label = 1; + for (let tab of tabs) { + is(tab.getAttribute("label"), label++, "Tab has the right title"); + } + is(label, 4, "Found the right amount of tabs."); + is(panel.sidebar._tabbox.selectedPanel, panels[0], "First tab is selected"); + ok(panel.sidebar.getCurrentTabID(), "tab1", "getCurrentTabID() is correct"); + + panel.sidebar.once("tab1-unselected", function() { + ok(true, "received 'unselected' event"); + panel.sidebar.once("tab2-selected", function() { + ok(true, "received 'selected' event"); + panel.sidebar.hide(); + is(panel.sidebar._tabbox.getAttribute("hidden"), "true", "Sidebar hidden"); + is(panel.sidebar.getWindowForTab("tab1").location.href, tab1URL, "Window is accessible"); + finishUp(panel); + }); + }); + + panel.sidebar.select("tab2"); + } + + function finishUp(panel) { + panel.sidebar.destroy(); + gDevTools.unregisterTool(toolDefinition.id); + + executeSoon(function() { + gBrowser.removeCurrentTab(); + finish(); + }); + } +} diff --git a/browser/devtools/framework/test/browser_toolbox_tool_ready.js b/browser/devtools/framework/test/browser_toolbox_tool_ready.js new file mode 100644 index 000000000000..98a537f03ca6 --- /dev/null +++ b/browser/devtools/framework/test/browser_toolbox_tool_ready.js @@ -0,0 +1,72 @@ +/* vim: set ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +let temp = []; +Cu.import("resource:///modules/devtools/Target.jsm", temp); +let TargetFactory = temp.TargetFactory; + +function test() { + waitForExplicitFinish(); + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) { + gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true); + openAllTools(); + }, true); + + function openAllTools() { + let target = TargetFactory.forTab(gBrowser.selectedTab); + + let tools = gDevTools.getToolDefinitions(); + let expectedCallbacksCount = tools.size; + + let firstTool = null; + // we transform the map to a [id, eventHasBeenFiredYet] map + for (let [id] of tools) { + if (!firstTool) + firstTool = id; + tools.set(id, false); + } + + let toolbox = gDevTools.openToolbox(target, undefined, firstTool); + + // We add the event listeners + for (let [toolId] of tools) { + let id = toolId; + info("Registering listener for " + id); + tools.set(id, false); + toolbox.on(id + "-ready", function(event, panel) { + expectedCallbacksCount--; + info("Got event " + event); + is(toolbox.getToolPanels().get(id), panel, "Got the right tool panel for " + id); + tools.set(id, true); + if (expectedCallbacksCount == 0) { + // "executeSoon" because we want to let a chance + // to falsy code to fire unexpected ready events. + executeSoon(theEnd); + } + if (expectedCallbacksCount < 0) { + ok(false, "we are receiving too many events"); + } + }); + } + + toolbox.once("ready", function() { + // We open all the + for (let [id] of tools) { + if (id != firstTool) { + toolbox.selectTool(id); + } + } + }); + + function theEnd() { + for (let [id, called] of tools) { + ok(called, "Tool " + id + " has fired its ready event"); + } + toolbox.destroy(); + gBrowser.removeCurrentTab(); + finish(); + } + } +} diff --git a/browser/devtools/framework/test/head.js b/browser/devtools/framework/test/head.js new file mode 100644 index 000000000000..796a7946c2d0 --- /dev/null +++ b/browser/devtools/framework/test/head.js @@ -0,0 +1,36 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +let tempScope = {}; +Components.utils.import("resource:///modules/devtools/Target.jsm", tempScope); +let TargetFactory = tempScope.TargetFactory; +Components.utils.import("resource:///modules/devtools/Console.jsm", tempScope); +let console = tempScope.console; + +/** + * Open a new tab at a URL and call a callback on load + */ +function addTab(aURL, aCallback) +{ + waitForExplicitFinish(); + + gBrowser.selectedTab = gBrowser.addTab(); + content.location = aURL; + + let tab = gBrowser.selectedTab; + let browser = gBrowser.getBrowserForTab(tab); + + function onTabLoad() { + browser.removeEventListener("load", onTabLoad, true); + aCallback(browser, tab, browser.contentDocument); + } + + browser.addEventListener("load", onTabLoad, true); +} + +registerCleanupFunction(function tearDown() { + while (gBrowser.tabs.length > 1) { + gBrowser.removeCurrentTab(); + } +}); diff --git a/browser/devtools/framework/toolbox-window.xul b/browser/devtools/framework/toolbox-window.xul new file mode 100644 index 000000000000..774747b531d9 --- /dev/null +++ b/browser/devtools/framework/toolbox-window.xul @@ -0,0 +1,33 @@ + + + + %toolboxDTD; +]> + + + +