michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: "use strict"; michael@0: michael@0: michael@0: add_task(function* checkNoAddingToPanel() { michael@0: let area = CustomizableUI.AREA_PANEL; michael@0: let previousPlacements = getAreaWidgetIds(area); michael@0: CustomizableUI.addWidgetToArea("separator", area); michael@0: CustomizableUI.addWidgetToArea("spring", area); michael@0: CustomizableUI.addWidgetToArea("spacer", area); michael@0: assertAreaPlacements(area, previousPlacements); michael@0: michael@0: let oldNumberOfItems = previousPlacements.length; michael@0: if (getAreaWidgetIds(area).length != oldNumberOfItems) { michael@0: CustomizableUI.reset(); michael@0: } michael@0: }); michael@0: michael@0: add_task(function* checkAddingToToolbar() { michael@0: let area = CustomizableUI.AREA_NAVBAR; michael@0: let previousPlacements = getAreaWidgetIds(area); michael@0: CustomizableUI.addWidgetToArea("separator", area); michael@0: CustomizableUI.addWidgetToArea("spring", area); michael@0: CustomizableUI.addWidgetToArea("spacer", area); michael@0: let expectedPlacements = [...previousPlacements].concat([ michael@0: /separator/, michael@0: /spring/, michael@0: /spacer/ michael@0: ]); michael@0: assertAreaPlacements(area, expectedPlacements); michael@0: michael@0: let newlyAddedElements = getAreaWidgetIds(area).slice(-3); michael@0: while (newlyAddedElements.length) { michael@0: CustomizableUI.removeWidgetFromArea(newlyAddedElements.shift()); michael@0: } michael@0: michael@0: assertAreaPlacements(area, previousPlacements); michael@0: michael@0: let oldNumberOfItems = previousPlacements.length; michael@0: if (getAreaWidgetIds(area).length != oldNumberOfItems) { michael@0: CustomizableUI.reset(); michael@0: } michael@0: }); michael@0: michael@0: michael@0: add_task(function* checkDragging() { michael@0: let startArea = CustomizableUI.AREA_NAVBAR; michael@0: let targetArea = CustomizableUI.AREA_PANEL; michael@0: let startingToolbarPlacements = getAreaWidgetIds(startArea); michael@0: let startingTargetPlacements = getAreaWidgetIds(targetArea); michael@0: michael@0: CustomizableUI.addWidgetToArea("separator", startArea); michael@0: CustomizableUI.addWidgetToArea("spring", startArea); michael@0: CustomizableUI.addWidgetToArea("spacer", startArea); michael@0: michael@0: let placementsWithSpecials = getAreaWidgetIds(startArea); michael@0: let elementsToMove = []; michael@0: for (let id of placementsWithSpecials) { michael@0: if (CustomizableUI.isSpecialWidget(id)) { michael@0: elementsToMove.push(id); michael@0: } michael@0: } michael@0: is(elementsToMove.length, 3, "Should have 3 elements to try and drag."); michael@0: michael@0: yield startCustomizing(); michael@0: for (let id of elementsToMove) { michael@0: simulateItemDrag(document.getElementById(id), PanelUI.contents); michael@0: } michael@0: michael@0: assertAreaPlacements(startArea, placementsWithSpecials); michael@0: assertAreaPlacements(targetArea, startingTargetPlacements); michael@0: michael@0: for (let id of elementsToMove) { michael@0: simulateItemDrag(document.getElementById(id), gCustomizeMode.visiblePalette); michael@0: } michael@0: michael@0: assertAreaPlacements(startArea, startingToolbarPlacements); michael@0: assertAreaPlacements(targetArea, startingTargetPlacements); michael@0: michael@0: ok(!gCustomizeMode.visiblePalette.querySelector("toolbarspring,toolbarseparator,toolbarspacer"), michael@0: "No specials should make it to the palette alive."); michael@0: yield endCustomizing(); michael@0: }); michael@0: michael@0: michael@0: add_task(function* asyncCleanup() { michael@0: yield endCustomizing(); michael@0: CustomizableUI.reset(); michael@0: }); michael@0: