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 draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 24 Jan 2017 09:55:51 +0000
changeset 465576 b3143e5fff9ab8240dc2349baeffc5e2349d761f
parent 464978 f80dc9fc34680105b714a49b4704bb843f5f7004
child 543176 bf0fd1f1e06e82276f35218c3cb3307885fba1f4
push id42630
push usergijskruitbosch@gmail.com
push dateTue, 24 Jan 2017 10:08:44 +0000
reviewersmikedeboer
bugs1333305
milestone53.0a1
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
browser/components/customizableui/test/browser_880382_drag_wide_widgets_in_panel.js
browser/components/customizableui/test/head.js
--- 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) {