Bug 1333305 - fix perma-orange by only removing buttons if they're present (splice(-1, 1) removes the last element of an array), r?mikedeboer
MozReview-Commit-ID: INCwigBboL1
--- a/browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
+++ b/browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
@@ -341,17 +341,17 @@ add_task(function*() {
assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterMove);
let zoomControls = document.getElementById("zoom-controls");
simulateItemDrag(editControls, zoomControls);
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to the panel itself should append
// the edit controls to the bottom of the panel.
-add_task(function*() {
+add_task(function* editControlsToPanelEmptySpace() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let placementsAfterMove = ["zoom-controls",
"new-window-button",
"privatebrowsing-button",
"save-page-button",
"print-button",
@@ -412,17 +412,17 @@ add_task(function*() {
simulateItemDrag(editControls, zoomControls);
is(paletteChildElementCount, palette.childElementCount,
"The palette child count should have returned to its prior value.");
ok(CustomizableUI.inDefaultState, "Should still be in default state.");
});
// Dragging the edit-controls to each of the panel placeholders
// should append the edit-controls to the bottom of the panel.
-add_task(function*() {
+add_task(function* editControlsToPanelPlaceholders() {
yield startCustomizing();
let editControls = document.getElementById("edit-controls");
let panel = document.getElementById(CustomizableUI.AREA_PANEL);
let numPlaceholders = 2;
for (let i = 0; i < numPlaceholders; i++) {
// This test relies on there being a specific number of widgets in the
// panel. The addition of sync-button and webcompat-reporter-button screwed
// this up, so we remove them here. We should either fix the tests to not
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -118,21 +118,21 @@ function isInDevEdition() {
return AppConstants.MOZ_DEV_EDITION;
}
function isInNightly() {
return AppConstants.NIGHTLY_BUILD;
}
function removeNonReleaseButtons(areaPanelPlacements) {
- if (isInDevEdition()) {
+ if (isInDevEdition() && areaPanelPlacements.includes("developer-button")) {
areaPanelPlacements.splice(areaPanelPlacements.indexOf("developer-button"), 1);
}
- if (!isInNightly()) {
+ if (!isInNightly() && areaPanelPlacements.includes("webcompat-reporter-button")) {
areaPanelPlacements.splice(areaPanelPlacements.indexOf("webcompat-reporter-button"), 1);
}
}
function removeNonOriginalButtons() {
CustomizableUI.removeWidgetFromArea("sync-button");
if (isInNightly()) {
CustomizableUI.removeWidgetFromArea("webcompat-reporter-button");
@@ -147,16 +147,18 @@ function restoreNonOriginalButtons() {
}
function assertAreaPlacements(areaId, expectedPlacements) {
let actualPlacements = getAreaWidgetIds(areaId);
placementArraysEqual(areaId, actualPlacements, expectedPlacements);
}
function placementArraysEqual(areaId, actualPlacements, expectedPlacements) {
+ info("Actual placements: " + actualPlacements.join(", "));
+ info("Expected placements: " + expectedPlacements.join(", "));
is(actualPlacements.length, expectedPlacements.length,
"Area " + areaId + " should have " + expectedPlacements.length + " items.");
let minItems = Math.min(expectedPlacements.length, actualPlacements.length);
for (let i = 0; i < minItems; i++) {
if (typeof expectedPlacements[i] == "string") {
is(actualPlacements[i], expectedPlacements[i],
"Item " + i + " in " + areaId + " should match expectations.");
} else if (expectedPlacements[i] instanceof RegExp) {