browser/components/customizableui/test/browser_878452_drag_to_panel.js

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 // Dragging an item from the palette to another button in the panel should work.
michael@0 8 add_task(function() {
michael@0 9 yield startCustomizing();
michael@0 10 let btn = document.getElementById("feed-button");
michael@0 11 let panel = document.getElementById(CustomizableUI.AREA_PANEL);
michael@0 12 let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
michael@0 13
michael@0 14 let lastButtonIndex = placements.length - 1;
michael@0 15 let lastButton = placements[lastButtonIndex];
michael@0 16 let placementsAfterInsert = placements.slice(0, lastButtonIndex).concat(["feed-button", lastButton]);
michael@0 17 let lastButtonNode = document.getElementById(lastButton);
michael@0 18 simulateItemDrag(btn, lastButtonNode);
michael@0 19 assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
michael@0 20 ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
michael@0 21 let palette = document.getElementById("customization-palette");
michael@0 22 simulateItemDrag(btn, palette);
michael@0 23 ok(CustomizableUI.inDefaultState, "Should be in default state again.");
michael@0 24 });
michael@0 25
michael@0 26 // Dragging an item from the palette to the panel itself should also work.
michael@0 27 add_task(function() {
michael@0 28 yield startCustomizing();
michael@0 29 let btn = document.getElementById("feed-button");
michael@0 30 let panel = document.getElementById(CustomizableUI.AREA_PANEL);
michael@0 31 let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
michael@0 32
michael@0 33 let placementsAfterAppend = placements.concat(["feed-button"]);
michael@0 34 simulateItemDrag(btn, panel);
michael@0 35 assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
michael@0 36 ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
michael@0 37 let palette = document.getElementById("customization-palette");
michael@0 38 simulateItemDrag(btn, palette);
michael@0 39 ok(CustomizableUI.inDefaultState, "Should be in default state again.");
michael@0 40 });
michael@0 41
michael@0 42 // Dragging an item from the palette to an empty panel should also work.
michael@0 43 add_task(function() {
michael@0 44 let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
michael@0 45 while (widgetIds.length) {
michael@0 46 CustomizableUI.removeWidgetFromArea(widgetIds.shift());
michael@0 47 }
michael@0 48 yield startCustomizing();
michael@0 49 let btn = document.getElementById("feed-button");
michael@0 50 let panel = document.getElementById(CustomizableUI.AREA_PANEL);
michael@0 51
michael@0 52 assertAreaPlacements(panel.id, []);
michael@0 53
michael@0 54 let placementsAfterAppend = ["feed-button"];
michael@0 55 simulateItemDrag(btn, panel);
michael@0 56 assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
michael@0 57 ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
michael@0 58 let palette = document.getElementById("customization-palette");
michael@0 59 simulateItemDrag(btn, palette);
michael@0 60 assertAreaPlacements(panel.id, []);
michael@0 61 });
michael@0 62
michael@0 63 add_task(function asyncCleanup() {
michael@0 64 yield endCustomizing();
michael@0 65 yield resetCustomization();
michael@0 66 });

mercurial