Bug 1354117 - remove wrap handling for the bookmarks toolbar button and tests verifying it, r=johannh
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Mon, 31 Jul 2017 21:52:06 +0100
changeset 422374 11a53e10db19204e6f4a33427ef8b02d0e7691ef
parent 422373 e6ba2424ca8c799134df7855a9f14309a359ea6c
child 422375 f6e7d68931d3e1cb00dd2b8e8e8ccf5ecc37b1e8
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjohannh
bugs1354117
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1354117 - remove wrap handling for the bookmarks toolbar button and tests verifying it, r=johannh MozReview-Commit-ID: CeSGIQrDPpw
browser/base/content/browser-customization.js
browser/base/content/browser-places.js
browser/base/content/browser.js
browser/components/customizableui/content/panelUI.js
browser/components/customizableui/test/browser.ini
browser/components/customizableui/test/browser_968447_bookmarks_toolbar_items_in_panel.js
browser/components/customizableui/test/head.js
--- a/browser/base/content/browser-customization.js
+++ b/browser/base/content/browser-customization.js
@@ -12,19 +12,16 @@
  * events.
  */
 var CustomizationHandler = {
   handleEvent(aEvent) {
     switch (aEvent.type) {
       case "customizationstarting":
         this._customizationStarting();
         break;
-      case "customizationchange":
-        this._customizationChange();
-        break;
       case "customizationending":
         this._customizationEnding(aEvent.detail);
         break;
     }
   },
 
   isCustomizing() {
     return document.documentElement.hasAttribute("customizing");
@@ -49,20 +46,16 @@ var CustomizationHandler = {
     // can cause the customize tab to get clipped.
     let tabContainer = gBrowser.tabContainer;
     if (tabContainer.getAttribute("overflow") == "true") {
       let tabstrip = tabContainer.mTabstrip;
       tabstrip.ensureElementIsVisible(gBrowser.selectedTab, true);
     }
   },
 
-  _customizationChange() {
-    PlacesToolbarHelper.customizeChange();
-  },
-
   _customizationEnding(aDetails) {
     // Update global UI elements that may have been added or removed
     if (aDetails.changed) {
       gURLBar = document.getElementById("urlbar");
 
       gHomeButton.updateTooltip();
 
       if (AppConstants.platform != "macosx")
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1190,68 +1190,37 @@ var PlacesToolbarHelper = {
     if (!toolbar || toolbar.collapsed || this._isCustomizing ||
         getComputedStyle(toolbar, "").display == "none")
       return;
 
     new PlacesToolbar(this._place);
     if (forceToolbarOverflowCheck) {
       viewElt._placesView.updateOverflowStatus();
     }
-    this._shouldWrap = false;
-    this._setupPlaceholder();
   },
 
   uninit: function PTH_uninit() {
     CustomizableUI.removeListener(this);
   },
 
   customizeStart: function PTH_customizeStart() {
     try {
       let viewElt = this._viewElt;
       if (viewElt && viewElt._placesView)
         viewElt._placesView.uninit();
     } finally {
       this._isCustomizing = true;
     }
-    this._shouldWrap = this._getShouldWrap();
-  },
-
-  customizeChange: function PTH_customizeChange() {
-    this._setupPlaceholder();
-  },
-
-  _setupPlaceholder: function PTH_setupPlaceholder() {
-    let placeholder = this._placeholder;
-    if (!placeholder) {
-      return;
-    }
-
-    let shouldWrapNow = this._getShouldWrap();
-    if (this._shouldWrap != shouldWrapNow) {
-      if (shouldWrapNow) {
-        placeholder.setAttribute("wrap", "true");
-      } else {
-        placeholder.removeAttribute("wrap");
-      }
-      this._shouldWrap = shouldWrapNow;
-    }
   },
 
   customizeDone: function PTH_customizeDone() {
     this._isCustomizing = false;
     this.init(true);
   },
 
-  _getShouldWrap: function PTH_getShouldWrap() {
-    let placement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
-    let area = placement && placement.area;
-    let areaType = area && CustomizableUI.getAreaType(area);
-    return !area || CustomizableUI.TYPE_MENU_PANEL == areaType;
-  },
-
   onPlaceholderCommand() {
     let widgetGroup = CustomizableUI.getWidget("personal-bookmarks");
     let widget = widgetGroup.forWindow(window);
     if (widget.overflowed ||
         widgetGroup.areaType == CustomizableUI.TYPE_MENU_PANEL) {
       PlacesCommandHook.showPlacesOrganizer("BookmarksToolbar");
     }
   },
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1706,17 +1706,16 @@ var gBrowserInit = {
         UpdatePopupNotificationsVisibility();
       }
     });
 
     window.addEventListener("mousemove", MousePosTracker);
     window.addEventListener("dragover", MousePosTracker);
 
     gNavToolbox.addEventListener("customizationstarting", CustomizationHandler);
-    gNavToolbox.addEventListener("customizationchange", CustomizationHandler);
     gNavToolbox.addEventListener("customizationending", CustomizationHandler);
 
     // End startup crash tracking after a delay to catch crashes while restoring
     // tabs and to postpone saving the pref to disk.
     try {
       const startupCrashEndDelay = 30 * 1000;
       setTimeout(Services.startup.trackStartupCrashEnd, startupCrashEndDelay);
     } catch (ex) {
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -252,22 +252,16 @@ const PanelUI = {
     return new Promise(resolve => {
       this.ensureReady().then(() => {
         if (this.panel.state == "open" ||
             document.documentElement.hasAttribute("customizing")) {
           resolve();
           return;
         }
 
-        let personalBookmarksPlacement = CustomizableUI.getPlacementOfWidget("personal-bookmarks");
-        if (personalBookmarksPlacement &&
-            personalBookmarksPlacement.area == CustomizableUI.AREA_PANEL) {
-          PlacesToolbarHelper.customizeChange();
-        }
-
         let anchor;
         let domEvent = null;
         if (!aEvent ||
             aEvent.type == "command") {
           anchor = this.menuButton;
         } else {
           domEvent = aEvent;
           anchor = aEvent.target;
--- a/browser/components/customizableui/test/browser.ini
+++ b/browser/components/customizableui/test/browser.ini
@@ -96,18 +96,16 @@ skip-if = os == "linux" # Intermittent f
 [browser_948985_non_removable_defaultArea.js]
 [browser_952963_areaType_getter_no_area.js]
 [browser_956602_remove_special_widget.js]
 [browser_962069_drag_to_overflow_chevron.js]
 [browser_962884_opt_in_disable_hyphens.js]
 [browser_963639_customizing_attribute_non_customizable_toolbar.js]
 [browser_967000_button_charEncoding.js]
 [browser_967000_button_feeds.js]
-[browser_968447_bookmarks_toolbar_items_in_panel.js]
-skip-if = os == "linux" # Intemittent failures - bug 979207
 [browser_968565_insert_before_hidden_items.js]
 [browser_969427_recreate_destroyed_widget_after_reset.js]
 [browser_969661_character_encoding_navbar_disabled.js]
 [browser_970511_undo_restore_default.js]
 [browser_972267_customizationchange_events.js]
 [browser_973641_button_addon.js]
 [browser_973932_addonbar_currentset.js]
 [browser_975719_customtoolbars_behaviour.js]
deleted file mode 100644
--- a/browser/components/customizableui/test/browser_968447_bookmarks_toolbar_items_in_panel.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-// Bug 968447 - The Bookmarks Toolbar Items doesn't appear as a
-// normal menu panel button in new windows.
-add_task(async function() {
-  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]});
-  const buttonId = "bookmarks-toolbar-placeholder";
-  await startCustomizing();
-  CustomizableUI.addWidgetToArea("personal-bookmarks", CustomizableUI.AREA_PANEL);
-  await endCustomizing();
-
-  await PanelUI.show();
-
-  let bookmarksToolbarPlaceholder = document.getElementById(buttonId);
-  ok(bookmarksToolbarPlaceholder.classList.contains("toolbarbutton-1"),
-     "Button should have toolbarbutton-1 class");
-  is(bookmarksToolbarPlaceholder.getAttribute("wrap"), "true",
-     "Button should have the 'wrap' attribute");
-
-  info("Waiting for panel to close");
-  let panelHiddenPromise = promisePanelHidden(window);
-  PanelUI.hide();
-  await panelHiddenPromise;
-
-  info("Waiting for window to open");
-  let newWin = await openAndLoadWindow({}, true);
-
-  info("Waiting for panel in new window to open");
-  let hideTrace = function() {
-    info(new Error().stack);
-    info("Panel was hidden.");
-  };
-  newWin.PanelUI.panel.addEventListener("popuphidden", hideTrace);
-
-  await newWin.PanelUI.show();
-  let newWinBookmarksToolbarPlaceholder = newWin.document.getElementById(buttonId);
-  ok(newWinBookmarksToolbarPlaceholder.classList.contains("toolbarbutton-1"),
-     "Button in new window should have toolbarbutton-1 class");
-  is(newWinBookmarksToolbarPlaceholder.getAttribute("wrap"), "true",
-     "Button in new window should have 'wrap' attribute");
-
-  newWin.PanelUI.panel.removeEventListener("popuphidden", hideTrace);
-  // XXXgijs on Linux, we're sometimes seeing the panel being hidden early
-  // in the newly created window, probably because something else steals focus.
-  if (newWin.PanelUI.panel.state != "closed") {
-    info("Panel is still open in new window, waiting for it to close");
-    panelHiddenPromise = promisePanelHidden(newWin);
-    newWin.PanelUI.hide();
-    await panelHiddenPromise;
-  } else {
-    info("panel was already closed");
-  }
-
-  info("Waiting for new window to close");
-  await promiseWindowClosed(newWin);
-});
-
-add_task(async function asyncCleanUp() {
-  await endCustomizing();
-  CustomizableUI.reset();
-});
-
--- a/browser/components/customizableui/test/head.js
+++ b/browser/components/customizableui/test/head.js
@@ -300,17 +300,17 @@ function promisePanelElementShown(win, a
 }
 
 function promisePanelHidden(win) {
   let panelEl = win.PanelUI.panel;
   return promisePanelElementHidden(win, panelEl);
 }
 
 function promiseOverflowHidden(win) {
-  let panelEl = document.getElementById("widget-overflow");
+  let panelEl = win.PanelUI.overflowPanel;
   return promisePanelElementHidden(win, panelEl);
 }
 
 function promisePanelElementHidden(win, aPanel) {
   return new Promise((resolve, reject) => {
     let timeoutId = win.setTimeout(() => {
       reject("Panel did not hide within 20 seconds.");
     }, 20000);