Bug 1067337 - Provide an icon for the toolbar to activate/deactivate the devtools panel. r=paul, r=gijs

This commit is contained in:
Victor Porof 2014-10-27 12:26:07 -04:00
Родитель 700f51942f
Коммит e2f1ba1b83
6 изменённых файлов: 120 добавлений и 15 удалений

Просмотреть файл

@ -678,7 +678,11 @@
aria-label="&navbarCmd.label;"
fullscreentoolbar="true" mode="icons" customizable="true"
iconsize="small"
#ifdef MOZ_DEV_EDITION
defaultset="urlbar-container,search-container,developer-button,bookmarks-menu-button,downloads-button,home-button,loop-call-button"
#else
defaultset="urlbar-container,search-container,bookmarks-menu-button,downloads-button,home-button,loop-call-button"
#endif
customizationtarget="nav-bar-customization-target"
overflowable="true"
overflowbutton="nav-bar-overflow-button"

Просмотреть файл

@ -175,7 +175,9 @@ let CustomizableUIInternal = {
"find-button",
"preferences-button",
"add-ons-button",
#ifndef MOZ_DEV_EDITION
"developer-button",
#endif
];
if (gPalette.has("switch-to-metro-button")) {
@ -209,6 +211,9 @@ let CustomizableUIInternal = {
let navbarPlacements = [
"urlbar-container",
"search-container",
#ifdef MOZ_DEV_EDITION
"developer-button",
#endif
"bookmarks-menu-button",
"downloads-button",
"home-button",

Просмотреть файл

@ -343,7 +343,11 @@ const CustomizableWidgets = [
viewId: "PanelUI-developer",
shortcutId: "key_devToolboxMenuItem",
tooltiptext: "developer-button.tooltiptext2",
#ifdef MOZ_DEV_EDITION
defaultArea: CustomizableUI.AREA_NAVBAR,
#else
defaultArea: CustomizableUI.AREA_PANEL,
#endif
onViewShowing: function(aEvent) {
// Populate the subview with whatever menuitems are in the developer
// menu. We skip menu elements, because the menu panel has no way

Просмотреть файл

@ -23,6 +23,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, printButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -49,6 +50,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -73,6 +75,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -96,6 +99,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, historyPanelMenu);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -123,6 +127,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(zoomControls, preferencesButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -150,6 +155,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterInsert);
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(openFileButton, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
@ -189,6 +195,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterInsert);
addSwitchToMetroButtonInWindows8(placementsAfterInsert);
simulateItemDrag(openFileButton, editControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
@ -225,6 +232,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, zoomControls);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -249,6 +257,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, newWindowButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -276,6 +285,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, privateBrowsingButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -303,6 +313,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, savePageButton);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -329,6 +340,7 @@ add_task(function() {
"add-ons-button",
"edit-controls",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, panel);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -354,6 +366,7 @@ add_task(function() {
"preferences-button",
"add-ons-button",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
let paletteChildElementCount = palette.childElementCount;
simulateItemDrag(editControls, palette);
@ -394,6 +407,7 @@ add_task(function() {
"add-ons-button",
"edit-controls",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, placeholder);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
@ -436,6 +450,7 @@ add_task(function() {
"add-ons-button",
"edit-controls",
"developer-button"];
removeDeveloperButtonIfDevEdition(placementsAfterMove);
addSwitchToMetroButtonInWindows8(placementsAfterMove);
simulateItemDrag(editControls, target);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);

Просмотреть файл

@ -9,17 +9,24 @@ requestLongerTimeout(2);
// One orphaned item should have two placeholders next to it.
add_task(function() {
yield startCustomizing();
let btn = document.getElementById("open-file-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
if (isInWin8()) {
CustomizableUI.removeWidgetFromArea("switch-to-metro-button");
placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
} else {
ok(CustomizableUI.inDefaultState, "Should be in default state.");
}
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
}
if (!isInWin8() && !isInDevEdition()) {
ok(CustomizableUI.inDefaultState, "Should be in default state.");
} else {
ok(!CustomizableUI.inDefaultState, "Should not be in default state if on Win8 or DevEdition.");
}
let btn = document.getElementById("open-file-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
is(getVisiblePlaceholderCount(panel), 2, "Should only have 2 visible placeholders before exiting");
@ -31,16 +38,24 @@ add_task(function() {
if (isInWin8()) {
CustomizableUI.addWidgetToArea("switch-to-metro-button", CustomizableUI.AREA_PANEL);
}
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Two orphaned items should have one placeholder next to them (case 1).
add_task(function() {
yield startCustomizing();
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL);
}
let btn = document.getElementById("open-file-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
let placementsAfterAppend = placements;
if (!isInWin8()) {
@ -49,7 +64,13 @@ add_task(function() {
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
is(CustomizableUI.inDefaultState, isInWin8(), "Should only be in default state if on Win8");
if (isInWin8() && !isInDevEdition()) {
ok(CustomizableUI.inDefaultState, "Should be in default state if on Win8 and not on DevEdition.");
} else {
ok(!CustomizableUI.inDefaultState, "Should not be in default state if not Win8 or on DevEdition.");
}
is(getVisiblePlaceholderCount(panel), 1, "Should only have 1 visible placeholder before exiting");
yield endCustomizing();
@ -63,12 +84,21 @@ add_task(function() {
btn = document.getElementById("open-file-button");
simulateItemDrag(btn, palette);
}
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// Two orphaned items should have one placeholder next to them (case 2).
add_task(function() {
yield startCustomizing();
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL);
}
let btn = document.getElementById("add-ons-button");
let btn2 = document.getElementById("developer-button");
let btn3 = document.getElementById("switch-to-metro-button");
@ -101,25 +131,36 @@ add_task(function() {
}
assertAreaPlacements(CustomizableUI.AREA_PANEL, placements);
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// A wide widget at the bottom of the panel should have three placeholders after it.
add_task(function() {
yield startCustomizing();
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_PANEL);
}
let btn = document.getElementById("edit-controls");
let developerButton = document.getElementById("developer-button");
let metroBtn = document.getElementById("switch-to-metro-button");
let btn2 = document.getElementById("developer-button");
let btn3 = document.getElementById("switch-to-metro-button");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let palette = document.getElementById("customization-palette");
let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
placements.pop();
simulateItemDrag(developerButton, palette);
simulateItemDrag(btn2, palette);
if (isInWin8()) {
// Remove switch-to-metro-button
placements.pop();
simulateItemDrag(metroBtn, palette);
simulateItemDrag(btn3, palette);
}
let placementsAfterAppend = placements.concat([placements.shift()]);
@ -132,19 +173,41 @@ add_task(function() {
yield startCustomizing();
is(getVisiblePlaceholderCount(panel), 3, "Should have 3 visible placeholders after re-entering");
simulateItemDrag(developerButton, panel);
simulateItemDrag(btn2, panel);
if (isInWin8()) {
simulateItemDrag(metroBtn, panel);
simulateItemDrag(btn3, panel);
}
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(btn, zoomControls);
if (isInDevEdition()) {
CustomizableUI.addWidgetToArea("developer-button", CustomizableUI.AREA_NAVBAR, 2);
}
ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});
// The default placements should have two placeholders at the bottom (or 1 in win8).
add_task(function() {
yield startCustomizing();
let numPlaceholders = isInWin8() ? 1 : 2;
let numPlaceholders = -1;
if (isInWin8()) {
if (isInDevEdition()) {
numPlaceholders = 2;
} else {
numPlaceholders = 1;
}
} else {
if (isInDevEdition()) {
numPlaceholders = 3;
} else {
numPlaceholders = 2;
}
}
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
ok(CustomizableUI.inDefaultState, "Should be in default state.");
is(getVisiblePlaceholderCount(panel), numPlaceholders, "Should have " + numPlaceholders + " visible placeholders before exiting");

Просмотреть файл

@ -113,6 +113,20 @@ function resetCustomization() {
return CustomizableUI.reset();
}
XPCOMUtils.defineLazyGetter(this, 'gDeveloperButtonInNavbar', function() {
return getAreaWidgetIds(CustomizableUI.AREA_NAVBAR).indexOf("developer-button") != -1;
});
function isInDevEdition() {
return gDeveloperButtonInNavbar;
}
function removeDeveloperButtonIfDevEdition(areaPanelPlacements) {
if (isInDevEdition()) {
areaPanelPlacements.splice(areaPanelPlacements.indexOf("developer-button"), 1);
}
}
function isInWin8() {
if (!Services.metro)
return false;