Bug 1673403 - Show the Bookmarks Toolbar in customize mode as long as it's not set to Never show. r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D95777
This commit is contained in:
Jared Wein 2020-11-04 17:11:26 +00:00
Родитель 2678e67f38
Коммит 06a8a7870b
4 изменённых файлов: 66 добавлений и 0 удалений

Просмотреть файл

@ -1696,6 +1696,24 @@ var BookmarkingUI = {
if (aWindow == window) {
this._uninitView();
this._isCustomizing = true;
if (
!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020", false)
) {
return;
}
let isVisible =
Services.prefs.getCharPref(
"browser.toolbars.bookmarks.visibility",
"newtab"
) != "never";
// Temporarily show the bookmarks toolbar in Customize mode if
// the toolbar isn't set to Never. We don't have to worry about
// hiding when leaving customize mode since the toolbar will
// hide itself on location change.
let toolbar = document.getElementById("PersonalToolbar");
setToolbarVisibility(toolbar, isVisible, false);
}
},

Просмотреть файл

@ -12,6 +12,7 @@ const kDragDataTypePrefix = "text/toolbarwrapper-id/";
const kSkipSourceNodePref = "browser.uiCustomization.skipSourceNodeCheck";
const kDrawInTitlebarPref = "browser.tabs.drawInTitlebar";
const kExtraDragSpacePref = "browser.tabs.extraDragSpace";
const kBookmarksToolbarPref = "browser.toolbars.bookmarks.visibility";
const kKeepBroadcastAttributes = "keepbroadcastattributeswhencustomizing";
const kPanelItemContextMenu = "customizationPanelItemContextMenu";
@ -178,6 +179,12 @@ function CustomizeMode(aWindow) {
this.$("customization-extra-drag-space-checkbox").hidden = true;
}
// Observe pref changes to the bookmarks toolbar visibility,
// since we won't get a toolbarvisibilitychange event if the
// toolbar is changing from 'newtab' to 'always' in Customize mode
// since the toolbar is shown with the 'newtab' setting.
Services.prefs.addObserver(kBookmarksToolbarPref, this);
this.window.addEventListener("unload", this);
}
@ -229,6 +236,7 @@ CustomizeMode.prototype = {
Services.prefs.removeObserver(kDrawInTitlebarPref, this);
Services.prefs.removeObserver(kExtraDragSpacePref, this);
}
Services.prefs.removeObserver(kBookmarksToolbarPref, this);
},
$(id) {

Просмотреть файл

@ -136,6 +136,7 @@ skip-if = verify
[browser_1484275_PanelMultiView_toggle_with_other_popup.js]
[browser_allow_dragging_removable_false.js]
[browser_bookmarks_toolbar_collapsed_restore_default.js]
[browser_bookmarks_toolbar_shown_newtab.js]
[browser_bootstrapped_custom_toolbar.js]
[browser_character_encoding_ctrl_click.js]
[browser_ctrl_click_panel_opening.js]

Просмотреть файл

@ -0,0 +1,39 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
"use strict";
// Entering customize mode should show the toolbar as long as it's not set to "never"
add_task(async function() {
if (!Services.prefs.getBoolPref("browser.toolbars.bookmarks.2h2020", false)) {
ok(true, "Skip as behavior only changes when the feature is enabled");
return;
}
await resetCustomization();
ok(CustomizableUI.inDefaultState, "Default state to begin");
let toolbar = document.querySelector("#PersonalToolbar");
for (let state of ["always", "never", "newtab"]) {
info(`Testing setting toolbar state to '${state}'`);
setToolbarVisibility(toolbar, state, true, false);
await startCustomizing();
let expected = state != "never";
await TestUtils.waitForCondition(
() => !toolbar.collapsed == expected,
`Waiting for toolbar visibility, state=${state}, visible=${!toolbar.collapsed}, expected=${expected}`
);
is(
!toolbar.collapsed,
expected,
"The toolbar should be visible when state isn't 'never'"
);
await endCustomizing();
}
await resetCustomization();
});