Bug 969427 - recreating a destroyed widget after a CustomizableUI.reset() call causes the new widget to go in the customize palette, r=Gijs.

--HG--
extra : rebase_source : e9d4d232d98f3dca3602a74d97017af1418d6474
This commit is contained in:
Florian Quèze 2014-02-11 00:09:19 +01:00
parent 68626411cd
commit 9d972bdedb
3 changed files with 36 additions and 0 deletions

View File

@ -2055,6 +2055,7 @@ let CustomizableUIInternal = {
// Reset placements to make restoring default placements possible.
gPlacements = new Map();
gDirtyAreaCache = new Set();
gSeenWidgets = new Set();
// Clear the saved state to ensure that defaults will be used.
gSavedState = null;
// Restore the state for each area to its defaults

View File

@ -63,5 +63,6 @@ skip-if = os == "linux"
[browser_948985_non_removable_defaultArea.js]
[browser_952963_areaType_getter_no_area.js]
[browser_956602_remove_special_widget.js]
[browser_969427_recreate_destroyed_widget_after_reset.js]
[browser_969661_character_encoding_navbar_disabled.js]
[browser_panel_toggle.js]

View File

@ -0,0 +1,34 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
function getPlacementArea(id) {
let placement = CustomizableUI.getPlacementOfWidget(id);
return placement && placement.area;
}
// Check that a destroyed widget recreated after a reset call goes to
// the navigation bar.
add_task(function() {
const kWidgetId = "test-recreate-after-reset";
let spec = {id: kWidgetId, label: "Test re-create after reset.",
removable: true, defaultArea: CustomizableUI.AREA_NAVBAR};
CustomizableUI.createWidget(spec);
is(getPlacementArea(kWidgetId), CustomizableUI.AREA_NAVBAR,
"widget is in the navigation bar");
CustomizableUI.destroyWidget(kWidgetId);
isnot(getPlacementArea(kWidgetId), CustomizableUI.AREA_NAVBAR,
"widget removed from the navigation bar");
CustomizableUI.reset();
CustomizableUI.createWidget(spec);
is(getPlacementArea(kWidgetId), CustomizableUI.AREA_NAVBAR,
"widget recreated and added back to the nav bar");
CustomizableUI.destroyWidget(kWidgetId);
});