summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui/test/browser_978084_dragEnd_after_move.js
blob: c818a1b4685e284004d4e0419c5ab4de673ded27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

var draggedItem;

/**
 * Check that customizing-movingItem gets removed on a drop when the item is moved.
 */

// Drop on the palette
add_task(async function () {
  draggedItem = document.createXULElement("toolbarbutton");
  draggedItem.id = "test-dragEnd-after-move1";
  draggedItem.setAttribute("label", "Test");
  draggedItem.setAttribute("removable", "true");
  let navbar = document.getElementById("nav-bar");
  CustomizableUI.getCustomizationTarget(navbar).appendChild(draggedItem);
  await startCustomizing();
  simulateItemDrag(draggedItem, gCustomizeMode.visiblePalette);
  is(
    document.documentElement.hasAttribute("customizing-movingItem"),
    false,
    "Make sure customizing-movingItem is removed after dragging to the palette"
  );
  await endCustomizing();
});

// Drop on a customization target itself
add_task(async function () {
  draggedItem = document.createXULElement("toolbarbutton");
  draggedItem.id = "test-dragEnd-after-move2";
  draggedItem.setAttribute("label", "Test");
  draggedItem.setAttribute("removable", "true");
  let dest = createToolbarWithPlacements("test-dragEnd");
  let navbar = document.getElementById("nav-bar");
  CustomizableUI.getCustomizationTarget(navbar).appendChild(draggedItem);
  await startCustomizing();
  simulateItemDrag(draggedItem, CustomizableUI.getCustomizationTarget(dest));
  is(
    document.documentElement.hasAttribute("customizing-movingItem"),
    false,
    "Make sure customizing-movingItem is removed"
  );
  await endCustomizing();
});

registerCleanupFunction(async function asyncCleanup() {
  await endCustomizing();
  removeCustomToolbars();
});