Bug 1701883 - Fix Pocket button default placement if pref is false. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D112653
This commit is contained in:
Scott 2021-04-27 00:21:34 +00:00
parent 7318dd5ba0
commit 0b3971d7a5
3 changed files with 35 additions and 2 deletions

View File

@ -2342,7 +2342,9 @@ var CustomizableUIInternal = {
}
// Destroyed API widgets are in gSeenWidgets, but not in gPalette:
if (gSeenWidgets.has(aWidgetId)) {
// The Pocket button is a default API widget that acts like a custom widget.
// If it's not in gPalette, it doesn't exist.
if (gSeenWidgets.has(aWidgetId) || aWidgetId === "save-to-pocket-button") {
return false;
}
@ -3417,7 +3419,9 @@ var CustomizableUIInternal = {
get inDefaultState() {
for (let [areaId, props] of gAreas) {
let defaultPlacements = props.get("defaultPlacements");
let defaultPlacements = props
.get("defaultPlacements")
.filter(item => this.widgetExists(item));
let currentPlacements = gPlacements.get(areaId);
// We're excluding all of the placement IDs for items that do not exist,
// and items that have removable="false",

View File

@ -134,6 +134,7 @@ skip-if = os == "mac"
[browser_1161838_inserted_new_default_buttons.js]
skip-if = verify
[browser_1484275_PanelMultiView_toggle_with_other_popup.js]
[browser_1701883_restore_defaults_pocket_pref.js]
[browser_allow_dragging_removable_false.js]
[browser_bookmarks_toolbar_collapsed_restore_default.js]
[browser_bookmarks_toolbar_shown_newtab.js]

View File

@ -0,0 +1,28 @@
/* 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";
// Turning off Pocket pref should still be considered default state.
add_task(async function() {
ok(CustomizableUI.inDefaultState, "Default state to begin");
Assert.ok(
Services.prefs.getBoolPref("extensions.pocket.enabled"),
"Pocket feature is enabled by default"
);
Services.prefs.setBoolPref("extensions.pocket.enabled", false);
ok(CustomizableUI.inDefaultState, "Should still be default state");
await resetCustomization();
Assert.ok(
!Services.prefs.getBoolPref("extensions.pocket.enabled"),
"Pocket feature is still off"
);
ok(CustomizableUI.inDefaultState, "Should still be default state");
Services.prefs.setBoolPref("extensions.pocket.enabled", true);
});