Bug 1442531 - Part 2. Check tool tab in tools menu as well. r?jdescottes
Currently, browser_toolbox_options check only toolbox's tab.
If tool tabs is bigger than toolbox width, this mechanism will not work
correctly. So this patch will check target tool tab from toolbox tabs and
tools menu (in chevron).
MozReview-Commit-ID: D3kaOwHvHni
--- a/devtools/client/framework/test/browser_toolbox_options.js
+++ b/devtools/client/framework/test/browser_toolbox_options.js
@@ -16,38 +16,30 @@ const {PrefObserver} = require("devtools
add_task(async function() {
const URL = "data:text/html;charset=utf8,test for dynamically registering " +
"and unregistering tools";
registerNewTool();
let tab = await addTab(URL);
let target = TargetFactory.forTab(tab);
toolbox = await gDevTools.showToolbox(target);
- info("In order to ensure display the chevron menu, increase the width of " +
- "the toolbox");
- let hostWindow = toolbox.win.parent;
- let originalWidth = hostWindow.outerWidth;
- let onResize = once(hostWindow, "resize");
- hostWindow.resizeTo(1350, hostWindow.outerHeight);
- await onResize;
-
doc = toolbox.doc;
await registerNewPerToolboxTool();
await testSelectTool();
await testOptionsShortcut();
await testOptions();
await testToggleTools();
// Test that registered WebExtensions becomes entries in the
// options panel and toggling their checkbox toggle the related
// preference.
await registerNewWebExtensions();
await testToggleWebExtensions();
- await cleanup(hostWindow, originalWidth);
+ await cleanup();
});
function registerNewTool() {
let toolDefinition = {
id: "test-tool",
isTargetSupported: () => true,
visibilityswitch: "devtools.test-tool.enabled",
url: "about:blank",
@@ -433,21 +425,21 @@ function checkUnregistered(toolId, defer
ok(!doc.getElementById("toolbox-tab-" + toolId),
"Tab removed for " + toolId);
} else {
ok(false, "Something went wrong, " + toolId + " was not unregistered");
}
deferred.resolve();
}
-function checkRegistered(toolId, deferred, data) {
+async function checkRegistered(toolId, deferred, data) {
if (data == toolId) {
ok(true, "Correct tool added back");
// checking tab on the toolbox
- let button = doc.getElementById("toolbox-tab-" + toolId);
+ let button = await lookupButtonForToolId(toolId);
ok(button, "Tab added back for " + toolId);
} else {
ok(false, "Something went wrong, " + toolId + " was not registered");
}
deferred.resolve();
}
function GetPref(name) {
@@ -459,18 +451,37 @@ function GetPref(name) {
return Services.prefs.getIntPref(name);
case Services.prefs.PREF_BOOL:
return Services.prefs.getBoolPref(name);
default:
throw new Error("Unknown type");
}
}
-async function cleanup(win, winWidth) {
+/**
+ * Find the button from specified toolId.
+ * Generally, button which access to the tool panel is in toolbox or
+ * tools menu(in the Chevron menu).
+ */
+async function lookupButtonForToolId(toolId) {
+ let button = doc.getElementById("toolbox-tab-" + toolId);
+ if (!button) {
+ // search from the tools menu.
+ let menuPopup = await openChevronMenu(toolbox);
+ button = doc.querySelector("#tools-chevron-menupopup-" + toolId);
+
+ info("Closing the tools-chevron-menupopup popup");
+ let onPopupHidden = once(menuPopup, "popuphidden");
+ menuPopup.hidePopup();
+ await onPopupHidden;
+ }
+ return button;
+}
+
+async function cleanup() {
gDevTools.unregisterTool("test-tool");
await toolbox.destroy();
gBrowser.removeCurrentTab();
for (let pref of modifiedPrefs) {
Services.prefs.clearUserPref(pref);
}
toolbox = doc = panelWin = modifiedPrefs = null;
- win.resizeTo(winWidth, win.outerHeight);
}
--- a/devtools/client/themes/toolbox.css
+++ b/devtools/client/themes/toolbox.css
@@ -122,30 +122,34 @@
flex-shrink: 0;
}
.devtools-tab > label {
white-space: nowrap;
margin: 0 4px;
}
-.devtools-tab > img,
-.tools-chevron-menu > img {
+.devtools-tab > img {
-moz-context-properties: fill;
- fill: var(--theme-toolbar-photon-icon-color);
+ fill: var(--theme-toolbar-color);
}
.devtools-tab.selected > img {
fill: var(--theme-toolbar-selected-color);
}
.devtools-tab.highlighted > img {
fill: var(--theme-toolbar-highlighted-color);
}
+#devtools-chevron-menu-button::before {
+ -moz-context-properties: fill;
+ fill: var(--theme-toolbar-photon-icon-color);
+}
+
/* Toolbox controls */
#tools-chevron-menu-button::before {
top: 0;
offset-inline-end: 0;
background-image: var(--command-chevron-image);
background-position: center;
}