зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 8b94363b10f1 (bug 984455) for debug OSX mochitest-bc failures.
This commit is contained in:
Родитель
71d30a9090
Коммит
75f1da8e39
|
@ -884,10 +884,6 @@ let PlacesToolbarHelper = {
|
|||
if (!viewElt || viewElt._placesView)
|
||||
return;
|
||||
|
||||
// CustomizableUI.addListener is idempotent, so we can safely
|
||||
// call this multiple times.
|
||||
CustomizableUI.addListener(this);
|
||||
|
||||
// If the bookmarks toolbar item is:
|
||||
// - not in a toolbar, or;
|
||||
// - the toolbar is collapsed, or;
|
||||
|
@ -903,11 +899,7 @@ let PlacesToolbarHelper = {
|
|||
if (forceToolbarOverflowCheck) {
|
||||
viewElt._placesView.updateOverflowStatus();
|
||||
}
|
||||
this._setupPlaceholder();
|
||||
},
|
||||
|
||||
uninit: function PTH_uninit() {
|
||||
CustomizableUI.removeListener(this);
|
||||
this.customizeChange();
|
||||
},
|
||||
|
||||
customizeStart: function PTH_customizeStart() {
|
||||
|
@ -922,15 +914,10 @@ let PlacesToolbarHelper = {
|
|||
},
|
||||
|
||||
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) {
|
||||
|
@ -971,40 +958,7 @@ let PlacesToolbarHelper = {
|
|||
element = element.parentNode;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
onWidgetUnderflow: function(aNode, aContainer) {
|
||||
// The view gets broken by being removed and reinserted by the overflowable
|
||||
// toolbar, so we have to force an uninit and reinit.
|
||||
let win = aNode.ownerDocument.defaultView;
|
||||
if (aNode.id == "personal-bookmarks" && win == window) {
|
||||
this._resetView();
|
||||
}
|
||||
},
|
||||
|
||||
onWidgetAdded: function(aWidgetId, aArea, aPosition) {
|
||||
if (aWidgetId == "personal-bookmarks" && !this._isCustomizing) {
|
||||
// It's possible (with the "Add to Menu", "Add to Toolbar" context
|
||||
// options) that the Places Toolbar Items have been moved without
|
||||
// letting us prepare and handle it with with customizeStart and
|
||||
// customizeDone. If that's the case, we need to reset the views
|
||||
// since they're probably broken from the DOM reparenting.
|
||||
this._resetView();
|
||||
}
|
||||
},
|
||||
|
||||
_resetView: function() {
|
||||
if (this._viewElt) {
|
||||
// It's possible that the placesView might not exist, and we need to
|
||||
// do a full init. This could happen if the Bookmarks Toolbar Items are
|
||||
// moved to the Menu Panel, and then to the toolbar with the "Add to Toolbar"
|
||||
// context menu option, outside of customize mode.
|
||||
if (this._viewElt._placesView) {
|
||||
this._viewElt._placesView.uninit();
|
||||
}
|
||||
this.init(true);
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1210,16 +1164,6 @@ let BookmarkingUI = {
|
|||
// so kill current view and let popupshowing generate a new one.
|
||||
if (this.button._placesView)
|
||||
this.button._placesView.uninit();
|
||||
|
||||
// We have to do the same thing for the "special" views underneath the
|
||||
// the bookmarks menu.
|
||||
const kSpecialViewNodeIDs = ["BMB_bookmarksToolbar", "BMB_unsortedBookmarks"];
|
||||
for (let viewNodeID of kSpecialViewNodeIDs) {
|
||||
let elem = document.getElementById(viewNodeID);
|
||||
if (elem && elem._placesView) {
|
||||
elem._placesView.uninit();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onCustomizeStart: function BUI_customizeStart(aWindow) {
|
||||
|
|
|
@ -1289,8 +1289,6 @@ var gBrowserInit = {
|
|||
} catch (ex) {
|
||||
}
|
||||
|
||||
PlacesToolbarHelper.uninit();
|
||||
|
||||
BookmarkingUI.uninit();
|
||||
|
||||
TabsInTitlebar.uninit();
|
||||
|
|
|
@ -93,10 +93,6 @@ skip-if = os == "linux"
|
|||
[browser_978084_dragEnd_after_move.js]
|
||||
[browser_980155_add_overflow_toolbar.js]
|
||||
[browser_981418-widget-onbeforecreated-handler.js]
|
||||
|
||||
[browser_984455_bookmarks_items_reparenting.js]
|
||||
skip-if = os == "linux"
|
||||
|
||||
[browser_985815_propagate_setToolbarVisibility.js]
|
||||
[browser_981305_separator_insertion.js]
|
||||
[browser_987177_destroyWidget_xul.js]
|
||||
|
|
|
@ -10,7 +10,7 @@ const isOSX = (Services.appinfo.OS === "Darwin");
|
|||
// show a context menu with options to move it.
|
||||
add_task(function() {
|
||||
let contextMenu = document.getElementById("toolbar-context-menu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let homeButton = document.getElementById("home-button");
|
||||
EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2 });
|
||||
yield shownPromise;
|
||||
|
@ -30,7 +30,7 @@ add_task(function() {
|
|||
);
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenPromise = popupHidden(contextMenu);
|
||||
let hiddenPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenPromise;
|
||||
});
|
||||
|
@ -40,7 +40,7 @@ add_task(function() {
|
|||
// and a toggle option for the extra toolbar
|
||||
add_task(function() {
|
||||
let contextMenu = document.getElementById("toolbar-context-menu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let toolbar = createToolbarWithPlacements("880164_empty_toolbar", []);
|
||||
toolbar.setAttribute("context", "toolbar-context-menu");
|
||||
toolbar.setAttribute("toolbarname", "Fancy Toolbar for Context Menu");
|
||||
|
@ -63,7 +63,7 @@ add_task(function() {
|
|||
);
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenPromise = popupHidden(contextMenu);
|
||||
let hiddenPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenPromise;
|
||||
removeCustomToolbars();
|
||||
|
@ -74,7 +74,7 @@ add_task(function() {
|
|||
// show a context menu with disabled options to move it.
|
||||
add_task(function() {
|
||||
let contextMenu = document.getElementById("toolbar-context-menu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let urlBarContainer = document.getElementById("urlbar-container");
|
||||
// Need to make sure not to click within an edit field.
|
||||
let urlbarRect = urlBarContainer.getBoundingClientRect();
|
||||
|
@ -96,7 +96,7 @@ add_task(function() {
|
|||
);
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenPromise = popupHidden(contextMenu);
|
||||
let hiddenPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenPromise;
|
||||
});
|
||||
|
@ -135,7 +135,7 @@ add_task(function() {
|
|||
yield shownPanelPromise;
|
||||
|
||||
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
|
||||
let shownContextPromise = popupShown(contextMenu);
|
||||
let shownContextPromise = contextMenuShown(contextMenu);
|
||||
let newWindowButton = document.getElementById("new-window-button");
|
||||
ok(newWindowButton, "new-window-button was found");
|
||||
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
|
||||
|
@ -151,7 +151,7 @@ add_task(function() {
|
|||
];
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenContextPromise;
|
||||
|
||||
|
@ -165,7 +165,7 @@ add_task(function() {
|
|||
add_task(function() {
|
||||
yield startCustomizing();
|
||||
let contextMenu = document.getElementById("toolbar-context-menu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let homeButton = document.getElementById("wrapper-home-button");
|
||||
EventUtils.synthesizeMouse(homeButton, 2, 2, {type: "contextmenu", button: 2});
|
||||
yield shownPromise;
|
||||
|
@ -185,7 +185,7 @@ add_task(function() {
|
|||
);
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenContextPromise;
|
||||
});
|
||||
|
@ -194,7 +194,7 @@ add_task(function() {
|
|||
// show a context menu with options to move it.
|
||||
add_task(function() {
|
||||
let contextMenu = document.getElementById("customizationPaletteItemContextMenu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let openFileButton = document.getElementById("wrapper-open-file-button");
|
||||
EventUtils.synthesizeMouse(openFileButton, 2, 2, {type: "contextmenu", button: 2});
|
||||
yield shownPromise;
|
||||
|
@ -205,7 +205,7 @@ add_task(function() {
|
|||
];
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenContextPromise;
|
||||
});
|
||||
|
@ -214,7 +214,7 @@ add_task(function() {
|
|||
// should show a context menu with options to move it.
|
||||
add_task(function() {
|
||||
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let newWindowButton = document.getElementById("wrapper-new-window-button");
|
||||
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
|
||||
yield shownPromise;
|
||||
|
@ -227,7 +227,7 @@ add_task(function() {
|
|||
];
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenContextPromise;
|
||||
yield endCustomizing();
|
||||
|
@ -241,7 +241,7 @@ add_task(function() {
|
|||
yield startCustomizing(this.otherWin);
|
||||
|
||||
let contextMenu = this.otherWin.document.getElementById("customizationPanelItemContextMenu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let newWindowButton = this.otherWin.document.getElementById("wrapper-new-window-button");
|
||||
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2}, this.otherWin);
|
||||
yield shownPromise;
|
||||
|
@ -254,7 +254,7 @@ add_task(function() {
|
|||
];
|
||||
checkContextMenu(contextMenu, expectedEntries, this.otherWin);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenContextPromise;
|
||||
yield endCustomizing(this.otherWin);
|
||||
|
@ -267,13 +267,13 @@ add_task(function() {
|
|||
add_task(function() {
|
||||
yield startCustomizing();
|
||||
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
let shownPromise = contextMenuShown(contextMenu);
|
||||
let zoomControls = document.getElementById("wrapper-zoom-controls");
|
||||
EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
|
||||
yield shownPromise;
|
||||
// Execute the command to move the item from the panel to the toolbar.
|
||||
contextMenu.childNodes[0].doCommand();
|
||||
let hiddenPromise = popupHidden(contextMenu);
|
||||
let hiddenPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenPromise;
|
||||
yield endCustomizing();
|
||||
|
@ -282,7 +282,7 @@ add_task(function() {
|
|||
is(zoomControls.parentNode.id, "nav-bar-customization-target", "Zoom-controls should be on the nav-bar");
|
||||
|
||||
contextMenu = document.getElementById("toolbar-context-menu");
|
||||
shownPromise = popupShown(contextMenu);
|
||||
shownPromise = contextMenuShown(contextMenu);
|
||||
EventUtils.synthesizeMouse(zoomControls, 2, 2, {type: "contextmenu", button: 2});
|
||||
yield shownPromise;
|
||||
|
||||
|
@ -301,7 +301,7 @@ add_task(function() {
|
|||
);
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
hiddenPromise = popupHidden(contextMenu);
|
||||
hiddenPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenPromise;
|
||||
yield resetCustomization();
|
||||
|
@ -315,7 +315,7 @@ add_task(function() {
|
|||
yield PanelUI.show();
|
||||
|
||||
let contextMenu = document.getElementById("customizationPanelItemContextMenu");
|
||||
let shownContextPromise = popupShown(contextMenu);
|
||||
let shownContextPromise = contextMenuShown(contextMenu);
|
||||
let newWindowButton = document.getElementById("new-window-button");
|
||||
ok(newWindowButton, "new-window-button was found");
|
||||
EventUtils.synthesizeMouse(newWindowButton, 2, 2, {type: "contextmenu", button: 2});
|
||||
|
@ -331,7 +331,7 @@ add_task(function() {
|
|||
];
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
contextMenu.hidePopup();
|
||||
yield hiddenContextPromise;
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ add_task(function() {
|
|||
yield shownPanelPromise;
|
||||
|
||||
let contextMenu = document.getElementById("toolbar-context-menu");
|
||||
let shownContextPromise = popupShown(contextMenu);
|
||||
let shownContextPromise = contextMenuShown(contextMenu);
|
||||
let homeButton = document.getElementById("home-button");
|
||||
ok(homeButton, "home-button was found");
|
||||
is(homeButton.getAttribute("overflowedItem"), "true", "Home button is overflowing");
|
||||
|
@ -51,7 +51,7 @@ add_task(function() {
|
|||
);
|
||||
checkContextMenu(contextMenu, expectedEntries);
|
||||
|
||||
let hiddenContextPromise = popupHidden(contextMenu);
|
||||
let hiddenContextPromise = contextMenuHidden(contextMenu);
|
||||
let hiddenPromise = promisePanelElementHidden(window, overflowPanel);
|
||||
let moveToPanel = contextMenu.querySelector(".customize-context-moveToPanel");
|
||||
if (moveToPanel) {
|
||||
|
|
|
@ -1,251 +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";
|
||||
|
||||
let gNavBar = document.getElementById(CustomizableUI.AREA_NAVBAR);
|
||||
let gOverflowList = document.getElementById(gNavBar.getAttribute("overflowtarget"));
|
||||
|
||||
const kBookmarksButton = "bookmarks-menu-button";
|
||||
const kBookmarksItems = "personal-bookmarks";
|
||||
const kOriginalWindowWidth = window.outerWidth;
|
||||
const kSmallWidth = 400;
|
||||
|
||||
/**
|
||||
* Helper function that opens the bookmarks menu, and returns a Promise that
|
||||
* resolves as soon as the menu is ready for interaction.
|
||||
*/
|
||||
function bookmarksMenuPanelShown() {
|
||||
let deferred = Promise.defer();
|
||||
let bookmarksMenuPopup = document.getElementById("BMB_bookmarksPopup");
|
||||
let onTransitionEnd = (e) => {
|
||||
if (e.target == bookmarksMenuPopup) {
|
||||
bookmarksMenuPopup.removeEventListener("transitionend", onTransitionEnd);
|
||||
deferred.resolve();
|
||||
}
|
||||
}
|
||||
bookmarksMenuPopup.addEventListener("transitionend", onTransitionEnd);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the placesContext menu is correctly attached to the
|
||||
* controller of some view. Returns a Promise that resolves as soon
|
||||
* as the context menu is closed.
|
||||
*
|
||||
* @param aItemWithContextMenu the item that we need to synthesize hte
|
||||
* right click on in order to open the context menu.
|
||||
*/
|
||||
function checkContextMenu(aItemWithContextMenu) {
|
||||
return Task.spawn(function* () {
|
||||
let contextMenu = document.getElementById("placesContext");
|
||||
let newBookmarkItem = document.getElementById("placesContext_new:bookmark");
|
||||
let shownPromise = popupShown(contextMenu);
|
||||
EventUtils.synthesizeMouseAtCenter(aItemWithContextMenu,
|
||||
{type: "contextmenu", button: 2});
|
||||
yield shownPromise;
|
||||
|
||||
ok(!newBookmarkItem.hasAttribute("disabled"),
|
||||
"New bookmark item shouldn't be disabled");
|
||||
|
||||
yield closePopup(contextMenu);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the bookmarks menu panel, and then opens each of the "special"
|
||||
* submenus in that list. Then it checks that those submenu's context menus
|
||||
* are properly hooked up to a controller.
|
||||
*/
|
||||
function checkSpecialContextMenus() {
|
||||
return Task.spawn(function* () {
|
||||
let contextMenu = document.getElementById("placesContext");
|
||||
let bookmarksMenuButton = document.getElementById(kBookmarksButton);
|
||||
let bookmarksMenuPopup = document.getElementById("BMB_bookmarksPopup");
|
||||
|
||||
const kSpecialItemIDs = {
|
||||
"BMB_bookmarksToolbar": "BMB_bookmarksToolbarPopup",
|
||||
"BMB_unsortedBookmarks": "BMB_unsortedBookmarksPopup",
|
||||
};
|
||||
|
||||
// Open the bookmarks menu button context menus and ensure that
|
||||
// they have the proper views attached.
|
||||
let shownPromise = bookmarksMenuPanelShown();
|
||||
let dropmarker = document.getAnonymousElementByAttribute(bookmarksMenuButton,
|
||||
"anonid", "dropmarker");
|
||||
EventUtils.synthesizeMouseAtCenter(dropmarker, {});
|
||||
info("Waiting for bookmarks menu popup to show after clicking dropmarker.")
|
||||
yield shownPromise;
|
||||
|
||||
for (let menuID in kSpecialItemIDs) {
|
||||
let menuItem = document.getElementById(menuID);
|
||||
let menuPopup = document.getElementById(kSpecialItemIDs[menuID]);
|
||||
let shownPromise = popupShown(menuPopup);
|
||||
EventUtils.synthesizeMouseAtCenter(menuItem, {});
|
||||
yield shownPromise;
|
||||
|
||||
yield checkContextMenu(menuPopup);
|
||||
yield closePopup(menuPopup);
|
||||
}
|
||||
|
||||
yield closePopup(bookmarksMenuPopup);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes a focused popup by simulating pressing the Escape key,
|
||||
* and returns a Promise that resolves as soon as the popup is closed.
|
||||
*
|
||||
* @param aPopup the popup node to close.
|
||||
*/
|
||||
function closePopup(aPopup) {
|
||||
let hiddenPromise = popupHidden(aPopup);
|
||||
EventUtils.synthesizeKey("VK_ESCAPE", {});
|
||||
return hiddenPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function that checks that the context menu of the
|
||||
* bookmark toolbar items chevron popup is correctly hooked up
|
||||
* to the controller of a view.
|
||||
*/
|
||||
function checkBookmarksItemsChevronContextMenu() {
|
||||
return Task.spawn(function*() {
|
||||
let chevronPopup = document.getElementById("PlacesChevronPopup");
|
||||
let shownPromise = popupShown(chevronPopup);
|
||||
let chevron = document.getElementById("PlacesChevron");
|
||||
EventUtils.synthesizeMouseAtCenter(chevron, {});
|
||||
yield shownPromise;
|
||||
|
||||
yield checkContextMenu(chevronPopup);
|
||||
yield closePopup(chevronPopup);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces the window to a width that causes the nav-bar to overflow
|
||||
* its contents. Returns a Promise that resolves as soon as the
|
||||
* overflowable nav-bar is showing its chevron.
|
||||
*/
|
||||
function overflowEverything() {
|
||||
window.resizeTo(kSmallWidth, window.outerHeight);
|
||||
return waitForCondition(() => gNavBar.hasAttribute("overflowing"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the window to its original size from the start of the test,
|
||||
* and returns a Promise that resolves when the nav-bar is no longer
|
||||
* overflowing.
|
||||
*/
|
||||
function stopOverflowing() {
|
||||
window.resizeTo(kOriginalWindowWidth, window.outerHeight);
|
||||
return waitForCondition(() => !gNavBar.hasAttribute("overflowing"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that an item with ID aID is overflowing in the nav-bar.
|
||||
*
|
||||
* @param aID the ID of the node to check for overflowingness.
|
||||
*/
|
||||
function checkOverflowing(aID) {
|
||||
ok(!gNavBar.querySelector("#" + aID),
|
||||
"Item with ID " + aID + " should no longer be in the gNavBar");
|
||||
let item = gOverflowList.querySelector("#" + aID);
|
||||
ok(item, "Item with ID " + aID + " should be overflowing");
|
||||
is(item.getAttribute("overflowedItem"), "true",
|
||||
"Item with ID " + aID + " should have overflowedItem attribute");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that an item with ID aID is not overflowing in the nav-bar.
|
||||
*
|
||||
* @param aID the ID of hte node to check for non-overflowingness.
|
||||
*/
|
||||
function checkNotOverflowing(aID) {
|
||||
ok(!gOverflowList.querySelector("#" + aID),
|
||||
"Item with ID " + aID + " should no longer be overflowing");
|
||||
let item = gNavBar.querySelector("#" + aID);
|
||||
ok(item, "Item with ID " + aID + " should be in the nav bar");
|
||||
ok(!item.hasAttribute("overflowedItem"),
|
||||
"Item with ID " + aID + " should not have overflowedItem attribute");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that overflowing the bookmarks menu button doesn't break the
|
||||
* context menus for the Unsorted and Bookmarks Toolbar menu items.
|
||||
*/
|
||||
add_task(function* testOverflowingBookmarksButtonContextMenu() {
|
||||
ok(!gNavBar.hasAttribute("overflowing"), "Should start with a non-overflowing toolbar.");
|
||||
ok(CustomizableUI.inDefaultState, "Should start in default state.");
|
||||
|
||||
// Open the Unsorted and Bookmarks Toolbar context menus and ensure
|
||||
// that they have views attached.
|
||||
yield checkSpecialContextMenus();
|
||||
|
||||
yield overflowEverything();
|
||||
checkOverflowing(kBookmarksButton);
|
||||
|
||||
yield stopOverflowing();
|
||||
checkNotOverflowing(kBookmarksButton);
|
||||
|
||||
yield checkSpecialContextMenus();
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that the bookmarks toolbar items context menu still works if moved
|
||||
* to the menu from the overflow panel, and then back to the toolbar.
|
||||
*/
|
||||
add_task(function* testOverflowingBookmarksItemsContextMenu() {
|
||||
yield PanelUI.ensureReady();
|
||||
|
||||
let bookmarksToolbarItems = document.getElementById(kBookmarksItems);
|
||||
gCustomizeMode.addToToolbar(bookmarksToolbarItems);
|
||||
yield checkContextMenu(bookmarksToolbarItems);
|
||||
|
||||
yield overflowEverything();
|
||||
checkOverflowing(kBookmarksItems)
|
||||
|
||||
gCustomizeMode.addToPanel(bookmarksToolbarItems);
|
||||
|
||||
yield stopOverflowing();
|
||||
|
||||
gCustomizeMode.addToToolbar(bookmarksToolbarItems);
|
||||
yield checkContextMenu(bookmarksToolbarItems);
|
||||
});
|
||||
|
||||
/**
|
||||
* Test that overflowing the bookmarks toolbar items doesn't cause the
|
||||
* context menu in the bookmarks toolbar items chevron to stop working.
|
||||
*/
|
||||
add_task(function* testOverflowingBookmarksItemsChevronContextMenu() {
|
||||
// If it's not already there, let's move the bookmarks toolbar items to
|
||||
// the nav-bar.
|
||||
let bookmarksToolbarItems = document.getElementById(kBookmarksItems);
|
||||
gCustomizeMode.addToToolbar(bookmarksToolbarItems);
|
||||
|
||||
// We make the PlacesToolbarItems element be super tiny in order to force
|
||||
// the bookmarks toolbar items into overflowing and making the chevron
|
||||
// show itself.
|
||||
let placesToolbarItems = document.getElementById("PlacesToolbarItems");
|
||||
let placesChevron = document.getElementById("PlacesChevron");
|
||||
placesToolbarItems.style.maxWidth = "10px";
|
||||
yield waitForCondition(() => !placesChevron.collapsed);
|
||||
|
||||
yield checkBookmarksItemsChevronContextMenu();
|
||||
|
||||
yield overflowEverything();
|
||||
checkOverflowing(kBookmarksItems);
|
||||
|
||||
yield stopOverflowing();
|
||||
checkNotOverflowing(kBookmarksItems);
|
||||
|
||||
yield checkBookmarksItemsChevronContextMenu();
|
||||
|
||||
placesToolbarItems.style.removeProperty("max-width");
|
||||
});
|
||||
|
||||
add_task(function* asyncCleanup() {
|
||||
window.resizeTo(kOriginalWindowWidth, window.outerHeight);
|
||||
yield resetCustomization();
|
||||
});
|
|
@ -428,50 +428,37 @@ function promiseTabHistoryNavigation(aDirection = -1, aConditionFn) {
|
|||
return deferred.promise;
|
||||
}
|
||||
|
||||
function popupShown(aPopup) {
|
||||
return promisePopupEvent(aPopup, "shown");
|
||||
}
|
||||
|
||||
function popupHidden(aPopup) {
|
||||
return promisePopupEvent(aPopup, "hidden");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Promise that resolves when aPopup fires an event of type
|
||||
* aEventType. Times out and rejects after 20 seconds.
|
||||
*
|
||||
* @param aPopup the popup to monitor for events.
|
||||
* @param aEventSuffix the _suffix_ for the popup event type to watch for.
|
||||
*
|
||||
* Example usage:
|
||||
* let popupShownPromise = promisePopupEvent(somePopup, "shown");
|
||||
* // ... something that opens a popup
|
||||
* yield popupShownPromise;
|
||||
*
|
||||
* let popupHiddenPromise = promisePopupEvent(somePopup, "hidden");
|
||||
* // ... something that hides a popup
|
||||
* yield popupHiddenPromise;
|
||||
*/
|
||||
function promisePopupEvent(aPopup, aEventSuffix) {
|
||||
function contextMenuShown(aContextMenu) {
|
||||
let deferred = Promise.defer();
|
||||
let win = aPopup.ownerDocument.defaultView;
|
||||
let eventType = "popup" + aEventSuffix;
|
||||
|
||||
let win = aContextMenu.ownerDocument.defaultView;
|
||||
let timeoutId = win.setTimeout(() => {
|
||||
deferred.reject("Context menu (" + aPopup.id + ") did not fire "
|
||||
+ eventType + " within 20 seconds.");
|
||||
deferred.reject("Context menu (" + aContextMenu.id + ") did not show within 20 seconds.");
|
||||
}, 20000);
|
||||
|
||||
function onPopupEvent(e) {
|
||||
function onPopupShown(e) {
|
||||
aContextMenu.removeEventListener("popupshown", onPopupShown);
|
||||
win.clearTimeout(timeoutId);
|
||||
aPopup.removeEventListener(eventType, onPopupEvent);
|
||||
deferred.resolve();
|
||||
};
|
||||
|
||||
aPopup.addEventListener(eventType, onPopupEvent);
|
||||
aContextMenu.addEventListener("popupshown", onPopupShown);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function contextMenuHidden(aContextMenu) {
|
||||
let deferred = Promise.defer();
|
||||
let win = aContextMenu.ownerDocument.defaultView;
|
||||
let timeoutId = win.setTimeout(() => {
|
||||
deferred.reject("Context menu (" + aContextMenu.id + ") did not hide within 20 seconds.");
|
||||
}, 20000);
|
||||
function onPopupHidden(e) {
|
||||
win.clearTimeout(timeoutId);
|
||||
aContextMenu.removeEventListener("popuphidden", onPopupHidden);
|
||||
deferred.resolve();
|
||||
};
|
||||
aContextMenu.addEventListener("popuphidden", onPopupHidden);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
// This is a simpler version of the context menu check that
|
||||
// exists in contextmenu_common.js.
|
||||
function checkContextMenu(aContextMenu, aExpectedEntries, aWindow=window) {
|
||||
|
|
|
@ -960,10 +960,6 @@ PlacesToolbar.prototype = {
|
|||
this._removeEventListeners(window, ["resize", "unload"], false);
|
||||
this._removeEventListeners(gBrowser.tabContainer, ["TabOpen", "TabClose"], false);
|
||||
|
||||
if (this._chevron._placesView) {
|
||||
this._chevron._placesView.uninit();
|
||||
}
|
||||
|
||||
PlacesViewBase.prototype.uninit.apply(this, arguments);
|
||||
},
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче