fune/browser/components/customizableui/test/browser_currentset_post_reset.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

25 lines
954 B
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
function checkSpacers() {
let navbarWidgets = CustomizableUI.getWidgetIdsInArea("nav-bar");
let currentSetWidgets = document.getElementById("nav-bar").currentSet.split(",");
navbarWidgets = navbarWidgets.filter(w => CustomizableUI.isSpecialWidget(w));
currentSetWidgets = currentSetWidgets.filter(w => CustomizableUI.isSpecialWidget(w));
Assert.deepEqual(navbarWidgets, currentSetWidgets, "Should have the same 'special' widgets in currentset and placements");
}
/**
* Check that after a reset, the currentset property correctly deals with flexible spacers.
*/
add_task(async function() {
await startCustomizing();
checkSpacers();
CustomizableUI.addWidgetToArea("spring", "nav-bar", 4 /* Insert before the last extant spacer */);
await gCustomizeMode.reset();
checkSpacers();
await endCustomizing();
});