From b54247414cea4b7688044ccd9cf5f77302a070f8 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Sun, 13 Apr 2014 19:49:07 -0400 Subject: [PATCH] Bug 995161 - Customize mode can still break after bootstrapped add-on with custom legacy:true toolbar restarts. r=Gijs. --HG-- rename : browser/components/customizableui/test/browser_989609_bootstrapped_custom_toolbar.js => browser/components/customizableui/test/browser_bootstrapped_custom_toolbar.js --- .../customizableui/src/CustomizableUI.jsm | 2 +- .../customizableui/test/browser.ini | 2 +- ...=> browser_bootstrapped_custom_toolbar.js} | 28 +++++++++++-------- 3 files changed, 18 insertions(+), 14 deletions(-) rename browser/components/customizableui/test/{browser_989609_bootstrapped_custom_toolbar.js => browser_bootstrapped_custom_toolbar.js} (74%) diff --git a/browser/components/customizableui/src/CustomizableUI.jsm b/browser/components/customizableui/src/CustomizableUI.jsm index 51c6b93af0e..b1b98af700e 100644 --- a/browser/components/customizableui/src/CustomizableUI.jsm +++ b/browser/components/customizableui/src/CustomizableUI.jsm @@ -338,7 +338,7 @@ let CustomizableUIInternal = { if (!areaIsKnown) { gAreas.set(aName, props); - if (props.get("legacy")) { + if (props.get("legacy") && !gPlacements.has(aName)) { // Guarantee this area exists in gFuturePlacements, to avoid checking it in // various places elsewhere. gFuturePlacements.set(aName, new Set()); diff --git a/browser/components/customizableui/test/browser.ini b/browser/components/customizableui/test/browser.ini index f0210cc5779..d4c28e79516 100644 --- a/browser/components/customizableui/test/browser.ini +++ b/browser/components/customizableui/test/browser.ini @@ -99,10 +99,10 @@ skip-if = os == "linux" [browser_985815_propagate_setToolbarVisibility.js] [browser_981305_separator_insertion.js] -[browser_989609_bootstrapped_custom_toolbar.js] [browser_987177_destroyWidget_xul.js] [browser_987177_xul_wrapper_updating.js] [browser_987492_window_api.js] [browser_992747_toggle_noncustomizable_toolbar.js] [browser_993322_widget_notoolbar.js] +[browser_bootstrapped_custom_toolbar.js] [browser_panel_toggle.js] diff --git a/browser/components/customizableui/test/browser_989609_bootstrapped_custom_toolbar.js b/browser/components/customizableui/test/browser_bootstrapped_custom_toolbar.js similarity index 74% rename from browser/components/customizableui/test/browser_989609_bootstrapped_custom_toolbar.js rename to browser/components/customizableui/test/browser_bootstrapped_custom_toolbar.js index 18d038accf5..b565ac6194e 100644 --- a/browser/components/customizableui/test/browser_989609_bootstrapped_custom_toolbar.js +++ b/browser/components/customizableui/test/browser_bootstrapped_custom_toolbar.js @@ -7,13 +7,14 @@ const kTestBarID = "testBar"; const kWidgetID = "characterencoding-button"; -function createTestBar() { +function createTestBar(aLegacy) { let testBar = document.createElement("toolbar"); testBar.id = kTestBarID; testBar.setAttribute("customizable", "true"); - CustomizableUI.registerArea(kTestBarID, - { type: CustomizableUI.TYPE_TOOLBAR, legacy: false } - ); + CustomizableUI.registerArea(kTestBarID, { + type: CustomizableUI.TYPE_TOOLBAR, + legacy: aLegacy, + }); gNavToolbox.appendChild(testBar); return testBar; } @@ -22,7 +23,8 @@ function createTestBar() { * Helper function that does the following: * * 1) Creates a custom toolbar and registers it - * with CustomizableUI. + * with CustomizableUI. Sets the legacy attribute + * of the object passed to registerArea to aLegacy. * 2) Adds the widget with ID aWidgetID to that new * toolbar. * 3) Enters customize mode and makes sure that the @@ -31,15 +33,15 @@ function createTestBar() { * the custom toolbar. * 5) Checks that the widget has no placement. * 6) Re-adds and re-registers a custom toolbar with the same - * ID as the first one. + * ID and options as the first one. * 7) Enters customize mode and checks that the widget is * properly back in the toolbar. * 8) Exits customize mode, removes and de-registers the * toolbar, and resets the toolbars to default. */ -function checkRestoredPresence(aWidgetID) { +function checkRestoredPresence(aWidgetID, aLegacy) { return Task.spawn(function* () { - let testBar = createTestBar(); + let testBar = createTestBar(aLegacy); CustomizableUI.addWidgetToArea(aWidgetID, kTestBarID); let placement = CustomizableUI.getPlacementOfWidget(aWidgetID); is(placement.area, kTestBarID, @@ -51,7 +53,7 @@ function checkRestoredPresence(aWidgetID) { let placement = CustomizableUI.getPlacementOfWidget(aWidgetID); is(placement, null, "Expected " + aWidgetID + " to be in the palette"); - testBar = createTestBar(); + testBar = createTestBar(aLegacy); yield startCustomizing(); let placement = CustomizableUI.getPlacementOfWidget(aWidgetID); @@ -67,9 +69,11 @@ function checkRestoredPresence(aWidgetID) { } add_task(function* () { - yield checkRestoredPresence("downloads-button") + yield checkRestoredPresence("downloads-button", false); + yield checkRestoredPresence("downloads-button", true); }); add_task(function* () { - yield checkRestoredPresence("characterencoding-button") -}); \ No newline at end of file + yield checkRestoredPresence("characterencoding-button", false); + yield checkRestoredPresence("characterencoding-button", true); +});