fune/browser/components/customizableui/test/browser_remove_customized_specials.js
Gijs Kruitbosch 8ec70a2c1b Bug 1393574 - fix flexible spacers not being removable in some circumstances, r=jaws
The goal of this patch is to ensure that:
- in default placements, specials have no unique ids
- in actual placements as stored by CUI, they do
- we reset the counter for those unique ids on reset.
- we re-number specials when building an area (like on startup, or when resetting),
  ensuring that the actual nodes always match the placements for a given area.
- we force saves after resetting, to ensure that the gNewElementCount is always persisted correctly.

This last part will also fix bug 1393661

MozReview-Commit-ID: HAS5J5ZSgB5

--HG--
extra : rebase_source : df62441169e07fb94e39f68a2b3e43f6ed7f464c
2017-09-06 10:02:44 +01:00

28 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check that after a reset, we can still drag special nodes in customize mode
*/
add_task(async function() {
await startCustomizing();
CustomizableUI.addWidgetToArea("spring", "nav-bar", 5);
await gCustomizeMode.reset();
let springs = document.querySelectorAll("#nav-bar toolbarspring");
let lastSpring = springs[springs.length - 1];
let expectedPlacements = CustomizableUI.getWidgetIdsInArea("nav-bar");
info("Placements before drag: " + expectedPlacements.join(","));
let lastItem = document.getElementById(expectedPlacements[expectedPlacements.length - 1]);
simulateItemDrag(lastSpring, lastItem);
expectedPlacements.splice(expectedPlacements.indexOf(lastSpring.id), 1);
expectedPlacements.splice(expectedPlacements.length - 1, 0, lastSpring.id);
let actualPlacements = CustomizableUI.getWidgetIdsInArea("nav-bar");
// Log these separately because Assert.deepEqual truncates the stringified versions...
info("Actual placements: " + actualPlacements.join(","));
info("Expected placements: " + expectedPlacements.join(","));
Assert.deepEqual(expectedPlacements, actualPlacements, "Should be able to move spring");
await gCustomizeMode.reset();
await endCustomizing();
});