michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: let Toolbox = devtools.Toolbox; michael@0: let temp = {}; michael@0: Cu.import("resource://gre/modules/Services.jsm", temp); michael@0: let Services = temp.Services; michael@0: temp = null; michael@0: let toolbox = null; michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: const URL = "data:text/plain;charset=UTF-8,Nothing to see here, move along"; michael@0: michael@0: const TOOL_ID_1 = "jsdebugger"; michael@0: const TOOL_ID_2 = "webconsole"; michael@0: michael@0: addTab(URL, () => { michael@0: let target = TargetFactory.forTab(gBrowser.selectedTab); michael@0: gDevTools.showToolbox(target, TOOL_ID_1, Toolbox.HostType.BOTTOM) michael@0: .then(aToolbox => { michael@0: toolbox = aToolbox; michael@0: // select tool 2 michael@0: toolbox.selectTool(TOOL_ID_2) michael@0: // and highlight the first one michael@0: .then(highlightTab.bind(null, TOOL_ID_1)) michael@0: // to see if it has the proper class. michael@0: .then(checkHighlighted.bind(null, TOOL_ID_1)) michael@0: // Now switch back to first tool michael@0: .then(() => toolbox.selectTool(TOOL_ID_1)) michael@0: // to check again. But there is no easy way to test if michael@0: // it is showing orange or not. michael@0: .then(checkNoHighlightWhenSelected.bind(null, TOOL_ID_1)) michael@0: // Switch to tool 2 again michael@0: .then(() => toolbox.selectTool(TOOL_ID_2)) michael@0: // and check again. michael@0: .then(checkHighlighted.bind(null, TOOL_ID_1)) michael@0: // Now unhighlight the tool michael@0: .then(unhighlightTab.bind(null, TOOL_ID_1)) michael@0: // to see the classes gone. michael@0: .then(checkNoHighlight.bind(null, TOOL_ID_1)) michael@0: // Now close the toolbox and exit. michael@0: .then(() => executeSoon(() => { michael@0: toolbox.destroy() michael@0: .then(() => { michael@0: toolbox = null; michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: }); michael@0: })); michael@0: }); michael@0: }); michael@0: } michael@0: michael@0: function highlightTab(toolId) { michael@0: info("Highlighting tool " + toolId + "'s tab."); michael@0: toolbox.highlightTool(toolId); michael@0: } michael@0: michael@0: function unhighlightTab(toolId) { michael@0: info("Unhighlighting tool " + toolId + "'s tab."); michael@0: toolbox.unhighlightTool(toolId); michael@0: } michael@0: michael@0: function checkHighlighted(toolId) { michael@0: let tab = toolbox.doc.getElementById("toolbox-tab-" + toolId); michael@0: ok(tab.hasAttribute("highlighted"), "The highlighted attribute is present"); michael@0: ok(!tab.hasAttribute("selected") || tab.getAttribute("selected") != "true", michael@0: "The tab is not selected"); michael@0: } michael@0: michael@0: function checkNoHighlightWhenSelected(toolId) { michael@0: let tab = toolbox.doc.getElementById("toolbox-tab-" + toolId); michael@0: ok(tab.hasAttribute("highlighted"), "The highlighted attribute is present"); michael@0: ok(tab.hasAttribute("selected") && tab.getAttribute("selected") == "true", michael@0: "and the tab is selected, so the orange glow will not be present."); michael@0: } michael@0: michael@0: function checkNoHighlight(toolId) { michael@0: let tab = toolbox.doc.getElementById("toolbox-tab-" + toolId); michael@0: ok(!tab.hasAttribute("highlighted"), michael@0: "The highlighted attribute is not present"); michael@0: }