Bug 945739 - Australis' non-private-browsing-widget breaks customize mode, r=Unfocused

This commit is contained in:
Gijs Kruitbosch 2013-12-11 23:45:20 +01:00
parent 571c060e57
commit 07e9b8ba2f
4 changed files with 49 additions and 2 deletions

View File

@ -1253,6 +1253,8 @@ let CustomizableUIInternal = {
},
getUnusedWidgets: function(aWindowPalette) {
let window = aWindowPalette.ownerDocument.defaultView;
let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(window);
// We use a Set because there can be overlap between the widgets in
// gPalette and the items in the palette, especially after the first
// customization, since programmatically generated widgets will remain
@ -1264,7 +1266,9 @@ let CustomizableUIInternal = {
// gPalette.
for (let [id, widget] of gPalette) {
if (!widget.currentArea) {
widgets.add(id);
if (widget.showInPrivateBrowsing || !isWindowPrivate) {
widgets.add(id);
}
}
}

View File

@ -45,5 +45,6 @@ skip-if = os == "mac"
[browser_942581_unregisterArea_keeps_placements.js]
[browser_943683_migration_test.js]
[browser_944887_destroyWidget_should_destroy_in_palette.js]
[browser_945739_showInPrivateBrowsing_customize_mode.js]
[browser_947987_removable_default.js]
[browser_panel_toggle.js]

View File

@ -17,7 +17,7 @@ function assertWidgetExists(aWindow, aExists) {
let gTests = [
{
desc: "A widget that is created with showInPrivateBrowsing undefined should " +
"have that value default to false.",
"have that value default to true.",
run: function() {
let wrapper = CustomizableUI.createWidget({
id: kWidgetId

View File

@ -0,0 +1,42 @@
/* 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/. */
const kWidgetId = "test-private-browsing-customize-mode-widget";
let gTests = [
{
desc: "Add a widget via the API with showInPrivateBrowsing set to false " +
"and ensure it does not appear in the list of unused widgets in private windows",
run: function() {
CustomizableUI.createWidget({
id: kWidgetId,
showInPrivateBrowsing: false
});
let normalWidgetArray = CustomizableUI.getUnusedWidgets(gNavToolbox.palette);
normalWidgetArray = normalWidgetArray.map((w) => w.id);
ok(normalWidgetArray.indexOf(kWidgetId) > -1,
"Widget should appear as unused in non-private window");
let privateWindow = yield openAndLoadWindow({private: true});
let privateWidgetArray = CustomizableUI.getUnusedWidgets(privateWindow.gNavToolbox.palette);
privateWidgetArray = privateWidgetArray.map((w) => w.id);
is(privateWidgetArray.indexOf(kWidgetId), -1,
"Widget should not appear as unused in private window");
privateWindow.close();
CustomizableUI.destroyWidget(kWidgetId);
},
},
];
function asyncCleanup() {
yield resetCustomization();
}
function test() {
waitForExplicitFinish();
runTests(gTests, asyncCleanup);
}