browser/components/customizableui/test/browser_878452_drag_to_panel.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/customizableui/test/browser_878452_drag_to_panel.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +"use strict";
     1.9 +
    1.10 +// Dragging an item from the palette to another button in the panel should work.
    1.11 +add_task(function() {
    1.12 +  yield startCustomizing();
    1.13 +  let btn = document.getElementById("feed-button");
    1.14 +  let panel = document.getElementById(CustomizableUI.AREA_PANEL);
    1.15 +  let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
    1.16 +
    1.17 +  let lastButtonIndex = placements.length - 1;
    1.18 +  let lastButton = placements[lastButtonIndex];
    1.19 +  let placementsAfterInsert = placements.slice(0, lastButtonIndex).concat(["feed-button", lastButton]);
    1.20 +  let lastButtonNode = document.getElementById(lastButton);
    1.21 +  simulateItemDrag(btn, lastButtonNode);
    1.22 +  assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
    1.23 +  ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
    1.24 +  let palette = document.getElementById("customization-palette");
    1.25 +  simulateItemDrag(btn, palette);
    1.26 +  ok(CustomizableUI.inDefaultState, "Should be in default state again.");
    1.27 +});
    1.28 +
    1.29 +// Dragging an item from the palette to the panel itself should also work.
    1.30 +add_task(function() {
    1.31 +  yield startCustomizing();
    1.32 +  let btn = document.getElementById("feed-button");
    1.33 +  let panel = document.getElementById(CustomizableUI.AREA_PANEL);
    1.34 +  let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
    1.35 +
    1.36 +  let placementsAfterAppend = placements.concat(["feed-button"]);
    1.37 +  simulateItemDrag(btn, panel);
    1.38 +  assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
    1.39 +  ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
    1.40 +  let palette = document.getElementById("customization-palette");
    1.41 +  simulateItemDrag(btn, palette);
    1.42 +  ok(CustomizableUI.inDefaultState, "Should be in default state again.");
    1.43 +});
    1.44 +
    1.45 +// Dragging an item from the palette to an empty panel should also work.
    1.46 +add_task(function() {
    1.47 +  let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
    1.48 +  while (widgetIds.length) {
    1.49 +    CustomizableUI.removeWidgetFromArea(widgetIds.shift());
    1.50 +  }
    1.51 +  yield startCustomizing();
    1.52 +  let btn = document.getElementById("feed-button");
    1.53 +  let panel = document.getElementById(CustomizableUI.AREA_PANEL);
    1.54 +
    1.55 +  assertAreaPlacements(panel.id, []);
    1.56 +
    1.57 +  let placementsAfterAppend = ["feed-button"];
    1.58 +  simulateItemDrag(btn, panel);
    1.59 +  assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
    1.60 +  ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
    1.61 +  let palette = document.getElementById("customization-palette");
    1.62 +  simulateItemDrag(btn, palette);
    1.63 +  assertAreaPlacements(panel.id, []);
    1.64 +});
    1.65 +
    1.66 +add_task(function asyncCleanup() {
    1.67 +  yield endCustomizing();
    1.68 +  yield resetCustomization();
    1.69 +});

mercurial