Commit 277d1221 authored by Gijs Kruitbosch's avatar Gijs Kruitbosch
Browse files

Bug 1354117 - fix or remove tests that drag items to the panel, r=adw

The new panel doesn't have placeholders, or a distinction between wide and
narrow widgets, so those tests can just be removed.

MozReview-Commit-ID: D61AjwMbabG

--HG--
extra : rebase_source : 662a74e50ea05c5a4c5fdee476cae10fc9862775
parent 8216336e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@ support-files =
[browser_877447_skip_missing_ids.js]
[browser_878452_drag_to_panel.js]
[browser_880164_customization_context_menus.js]
[browser_880382_drag_wide_widgets_in_panel.js]
[browser_884402_customize_from_overflow.js]
skip-if = os == "linux"
[browser_885052_customize_mode_observers_disabed.js]
@@ -26,7 +25,6 @@ skip-if = os == "mac"
[browser_886323_buildArea_removable_nodes.js]
[browser_887438_currentset_shim.js]
[browser_888817_currentset_updating.js]
[browser_890140_orphaned_placeholders.js]
[browser_890262_destroyWidget_after_add_to_panel.js]
[browser_892955_isWidgetRemovable_for_removed_widgets.js]
[browser_892956_destroyWidget_defaultPlacements.js]
+13 −2
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@

const kXULWidgetId = "a-test-button"; // we'll create a button with this ID.
const kAPIWidgetId = "feed-button";
const kPanel = CustomizableUI.AREA_PANEL;
const kPanel = CustomizableUI.AREA_FIXED_OVERFLOW_PANEL;
const kToolbar = CustomizableUI.AREA_NAVBAR;
const kVisiblePalette = "customization-palette";
const kPlaceholderClass = "panel-customization-placeholder";
@@ -155,7 +155,10 @@ var otherWin;

// Moving widgets in two windows, one with customize mode and one without, should work.
add_task(async function MoveWidgetsInTwoWindows() {
  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]});
  CustomizableUI.createWidget({
    id: "cui-mode-wrapping-some-panel-item",
    label: "Test panel wrapping",
  });
  await startCustomizing();
  otherWin = await openAndLoadWindow(null, true);
  await otherWin.PanelUI.ensureReady();
@@ -168,10 +171,17 @@ add_task(async function MoveWidgetsInTwoWindows() {
    for (let method of ["API", "drag", "dragToItem"]) {
      info("Moving widget " + widgetId + " using " + method);
      checkToolbar(widgetId, method);
      // We add an item to the panel because otherwise we can't test dragging
      // to items that are already there. We remove it because
      // 'checkPalette' checks that we leave the browser in the default state.
      CustomizableUI.addWidgetToArea("cui-mode-wrapping-some-panel-item", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
      checkPanel(widgetId, method);
      CustomizableUI.removeWidgetFromArea("cui-mode-wrapping-some-panel-item");
      checkPalette(widgetId, method);
      CustomizableUI.addWidgetToArea("cui-mode-wrapping-some-panel-item", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
      checkPanel(widgetId, method);
      checkToolbar(widgetId, method);
      CustomizableUI.removeWidgetFromArea("cui-mode-wrapping-some-panel-item");
      checkPalette(widgetId, method);
    }
  }
@@ -182,5 +192,6 @@ add_task(async function MoveWidgetsInTwoWindows() {
});

add_task(async function asyncCleanup() {
  CustomizableUI.destroyWidget("cui-mode-wrapping-some-panel-item");
  await resetCustomization();
});
+0 −33
Original line number Diff line number Diff line
@@ -5,11 +5,9 @@
"use strict";

const kTestWidget1 = "test-customize-mode-create-destroy1";
const kTestWidget2 = "test-customize-mode-create-destroy2";

// Creating and destroying a widget should correctly wrap/unwrap stuff
add_task(async function testWrapUnwrap() {
  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]});
  await startCustomizing();
  CustomizableUI.createWidget({id: kTestWidget1, label: "Pretty label", tooltiptext: "Pretty tooltip"});
  let elem = document.getElementById(kTestWidget1);
@@ -25,41 +23,10 @@ add_task(async function testWrapUnwrap() {
  ok(!item, "There should no longer be an item");
});

// Creating and destroying a widget should correctly deal with panel placeholders
add_task(async function testPanelPlaceholders() {
  let panel = document.getElementById(CustomizableUI.AREA_PANEL);
  // The value of expectedPlaceholders depends on the default palette layout.
  // Bug 1229236 is for these tests to be smarter so the test doesn't need to
  // change when the default placements change.
  let expectedPlaceholders = 1;
  if (isInNightly()) {
    expectedPlaceholders += 2;
  }
  is(panel.querySelectorAll(".panel-customization-placeholder").length, expectedPlaceholders, "The number of placeholders should be correct.");
  CustomizableUI.createWidget({id: kTestWidget2, label: "Pretty label", tooltiptext: "Pretty tooltip", defaultArea: CustomizableUI.AREA_PANEL});
  let elem = document.getElementById(kTestWidget2);
  let wrapper = document.getElementById("wrapper-" + kTestWidget2);
  ok(elem, "There should be an item");
  ok(wrapper, "There should be a wrapper");
  is(wrapper.firstChild.id, kTestWidget2, "Wrapper should have test widget");
  is(wrapper.parentNode, panel, "Wrapper should be in panel");
  expectedPlaceholders = (expectedPlaceholders - 1) || 3;
  is(panel.querySelectorAll(".panel-customization-placeholder").length, expectedPlaceholders, "The number of placeholders should be correct.");
  CustomizableUI.destroyWidget(kTestWidget2);
  wrapper = document.getElementById("wrapper-" + kTestWidget2);
  ok(!wrapper, "There should be a wrapper");
  let item = document.getElementById(kTestWidget2);
  ok(!item, "There should no longer be an item");
  await endCustomizing();
});

add_task(async function asyncCleanup() {
  await endCustomizing();
  try {
    CustomizableUI.destroyWidget(kTestWidget1);
  } catch (ex) {}
  try {
    CustomizableUI.destroyWidget(kTestWidget2);
  } catch (ex) {}
  await resetCustomization();
});
+12 −9
Original line number Diff line number Diff line
@@ -3,57 +3,60 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";
CustomizableUI.createWidget({id: "cui-panel-item-to-drag-to", defaultArea: CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, label: "Item in panel to drag to"});

// Dragging an item from the palette to another button in the panel should work.
add_task(async function() {
  await SpecialPowers.pushPrefEnv({set: [["browser.photon.structure.enabled", false]]});
  await startCustomizing();
  let btn = document.getElementById("feed-button");
  let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
  let placements = getAreaWidgetIds(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);

  let lastButtonIndex = placements.length - 1;
  let lastButton = placements[lastButtonIndex];
  let placementsAfterInsert = placements.slice(0, lastButtonIndex).concat(["feed-button", lastButton]);
  let lastButtonNode = document.getElementById(lastButton);
  simulateItemDrag(btn, lastButtonNode);
  assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterInsert);
  assertAreaPlacements(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, placementsAfterInsert);
  ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
  let palette = document.getElementById("customization-palette");
  simulateItemDrag(btn, palette);
  CustomizableUI.removeWidgetFromArea("cui-panel-item-to-drag-to");
  ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});

// Dragging an item from the palette to the panel itself should also work.
add_task(async function() {
  CustomizableUI.addWidgetToArea("cui-panel-item-to-drag-to", CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
  await startCustomizing();
  let btn = document.getElementById("feed-button");
  let panel = document.getElementById(CustomizableUI.AREA_PANEL);
  let placements = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
  let panel = document.getElementById(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
  let placements = getAreaWidgetIds(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);

  let placementsAfterAppend = placements.concat(["feed-button"]);
  simulateItemDrag(btn, panel);
  assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
  assertAreaPlacements(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, placementsAfterAppend);
  ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
  let palette = document.getElementById("customization-palette");
  simulateItemDrag(btn, palette);
  CustomizableUI.removeWidgetFromArea("cui-panel-item-to-drag-to");
  ok(CustomizableUI.inDefaultState, "Should be in default state again.");
});

// Dragging an item from the palette to an empty panel should also work.
add_task(async function() {
  let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_PANEL);
  let widgetIds = getAreaWidgetIds(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);
  while (widgetIds.length) {
    CustomizableUI.removeWidgetFromArea(widgetIds.shift());
  }
  await startCustomizing();
  let btn = document.getElementById("feed-button");
  let panel = document.getElementById(CustomizableUI.AREA_PANEL);
  let panel = document.getElementById(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL);

  assertAreaPlacements(panel.id, []);

  let placementsAfterAppend = ["feed-button"];
  simulateItemDrag(btn, panel);
  assertAreaPlacements(CustomizableUI.AREA_PANEL, placementsAfterAppend);
  assertAreaPlacements(CustomizableUI.AREA_FIXED_OVERFLOW_PANEL, placementsAfterAppend);
  ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");
  let palette = document.getElementById("customization-palette");
  simulateItemDrag(btn, palette);
+0 −520

File deleted.

Preview size limit exceeded, changes collapsed.

Loading