browser/components/customizableui/test/browser_1003588_no_specials_in_panel.js

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 "use strict";
michael@0 5
michael@0 6
michael@0 7 add_task(function* checkNoAddingToPanel() {
michael@0 8 let area = CustomizableUI.AREA_PANEL;
michael@0 9 let previousPlacements = getAreaWidgetIds(area);
michael@0 10 CustomizableUI.addWidgetToArea("separator", area);
michael@0 11 CustomizableUI.addWidgetToArea("spring", area);
michael@0 12 CustomizableUI.addWidgetToArea("spacer", area);
michael@0 13 assertAreaPlacements(area, previousPlacements);
michael@0 14
michael@0 15 let oldNumberOfItems = previousPlacements.length;
michael@0 16 if (getAreaWidgetIds(area).length != oldNumberOfItems) {
michael@0 17 CustomizableUI.reset();
michael@0 18 }
michael@0 19 });
michael@0 20
michael@0 21 add_task(function* checkAddingToToolbar() {
michael@0 22 let area = CustomizableUI.AREA_NAVBAR;
michael@0 23 let previousPlacements = getAreaWidgetIds(area);
michael@0 24 CustomizableUI.addWidgetToArea("separator", area);
michael@0 25 CustomizableUI.addWidgetToArea("spring", area);
michael@0 26 CustomizableUI.addWidgetToArea("spacer", area);
michael@0 27 let expectedPlacements = [...previousPlacements].concat([
michael@0 28 /separator/,
michael@0 29 /spring/,
michael@0 30 /spacer/
michael@0 31 ]);
michael@0 32 assertAreaPlacements(area, expectedPlacements);
michael@0 33
michael@0 34 let newlyAddedElements = getAreaWidgetIds(area).slice(-3);
michael@0 35 while (newlyAddedElements.length) {
michael@0 36 CustomizableUI.removeWidgetFromArea(newlyAddedElements.shift());
michael@0 37 }
michael@0 38
michael@0 39 assertAreaPlacements(area, previousPlacements);
michael@0 40
michael@0 41 let oldNumberOfItems = previousPlacements.length;
michael@0 42 if (getAreaWidgetIds(area).length != oldNumberOfItems) {
michael@0 43 CustomizableUI.reset();
michael@0 44 }
michael@0 45 });
michael@0 46
michael@0 47
michael@0 48 add_task(function* checkDragging() {
michael@0 49 let startArea = CustomizableUI.AREA_NAVBAR;
michael@0 50 let targetArea = CustomizableUI.AREA_PANEL;
michael@0 51 let startingToolbarPlacements = getAreaWidgetIds(startArea);
michael@0 52 let startingTargetPlacements = getAreaWidgetIds(targetArea);
michael@0 53
michael@0 54 CustomizableUI.addWidgetToArea("separator", startArea);
michael@0 55 CustomizableUI.addWidgetToArea("spring", startArea);
michael@0 56 CustomizableUI.addWidgetToArea("spacer", startArea);
michael@0 57
michael@0 58 let placementsWithSpecials = getAreaWidgetIds(startArea);
michael@0 59 let elementsToMove = [];
michael@0 60 for (let id of placementsWithSpecials) {
michael@0 61 if (CustomizableUI.isSpecialWidget(id)) {
michael@0 62 elementsToMove.push(id);
michael@0 63 }
michael@0 64 }
michael@0 65 is(elementsToMove.length, 3, "Should have 3 elements to try and drag.");
michael@0 66
michael@0 67 yield startCustomizing();
michael@0 68 for (let id of elementsToMove) {
michael@0 69 simulateItemDrag(document.getElementById(id), PanelUI.contents);
michael@0 70 }
michael@0 71
michael@0 72 assertAreaPlacements(startArea, placementsWithSpecials);
michael@0 73 assertAreaPlacements(targetArea, startingTargetPlacements);
michael@0 74
michael@0 75 for (let id of elementsToMove) {
michael@0 76 simulateItemDrag(document.getElementById(id), gCustomizeMode.visiblePalette);
michael@0 77 }
michael@0 78
michael@0 79 assertAreaPlacements(startArea, startingToolbarPlacements);
michael@0 80 assertAreaPlacements(targetArea, startingTargetPlacements);
michael@0 81
michael@0 82 ok(!gCustomizeMode.visiblePalette.querySelector("toolbarspring,toolbarseparator,toolbarspacer"),
michael@0 83 "No specials should make it to the palette alive.");
michael@0 84 yield endCustomizing();
michael@0 85 });
michael@0 86
michael@0 87
michael@0 88 add_task(function* asyncCleanup() {
michael@0 89 yield endCustomizing();
michael@0 90 CustomizableUI.reset();
michael@0 91 });
michael@0 92

mercurial