зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1917996 - Disable Shopping sidebar when integrated sidebar pref is set. r=shopping-reviewers,kpatenio
Differential Revision: https://phabricator.services.mozilla.com/D221871
This commit is contained in:
Родитель
5a4253191f
Коммит
c961670a08
|
@ -198,6 +198,13 @@ class ShoppingSidebarManagerClass {
|
|||
true,
|
||||
this.updateSidebarVisibility
|
||||
);
|
||||
XPCOMUtils.defineLazyPreferenceGetter(
|
||||
this,
|
||||
"isIntegratedSidebarPanel",
|
||||
"browser.shopping.experience2023.integratedSidebar",
|
||||
false,
|
||||
this.updateSidebarVisibility
|
||||
);
|
||||
this.updateSidebarVisibility();
|
||||
|
||||
lazy.EveryWindow.registerCallback(
|
||||
|
@ -226,8 +233,9 @@ class ShoppingSidebarManagerClass {
|
|||
}
|
||||
|
||||
updateSidebarVisibility() {
|
||||
this.enabled = lazy.NimbusFeatures.shopping2023.getVariable("enabled");
|
||||
|
||||
this.enabled =
|
||||
lazy.NimbusFeatures.shopping2023.getVariable("enabled") &&
|
||||
!this.isIntegratedSidebarPanel;
|
||||
for (let window of lazy.BrowserWindowTracker.orderedWindows) {
|
||||
let isPBM = lazy.PrivateBrowsingUtils.isWindowPrivate(window);
|
||||
if (isPBM) {
|
||||
|
@ -275,6 +283,13 @@ class ShoppingSidebarManagerClass {
|
|||
.forEach(splitter => {
|
||||
splitter.remove();
|
||||
});
|
||||
let button = document.getElementById("shopping-sidebar-button");
|
||||
if (button) {
|
||||
button.hidden = true;
|
||||
// Reset attributes to defaults.
|
||||
button.setAttribute("shoppingsidebaropen", false);
|
||||
document.l10n.setAttributes(button, "shopping-sidebar-open-button2");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,11 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const CONTENT_PAGE = "https://example.com";
|
||||
const SHOPPING_SIDEBAR_WIDTH_PREF =
|
||||
"browser.shopping.experience2023.sidebarWidth";
|
||||
const SHOPPING_INTEGRATED_SIDEBAR_PREF =
|
||||
"browser.shopping.experience2023.integratedSidebar";
|
||||
|
||||
add_task(async function test_sidebar_opens_correct_size() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
|
@ -64,3 +67,63 @@ add_task(async function test_sidebar_opens_correct_size() {
|
|||
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
add_task(async function test_sidebar_and_button_not_present_if_integrated() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["toolkit.shopping.ohttpRelayURL", ""],
|
||||
["toolkit.shopping.ohttpConfigURL", ""],
|
||||
[SHOPPING_INTEGRATED_SIDEBAR_PREF, false],
|
||||
],
|
||||
});
|
||||
|
||||
await BrowserTestUtils.withNewTab(CONTENT_PAGE, async function (browser) {
|
||||
let browserPanel = gBrowser.getPanel(browser);
|
||||
|
||||
BrowserTestUtils.startLoadingURIString(browser, PRODUCT_TEST_URL);
|
||||
await BrowserTestUtils.browserLoaded(browser);
|
||||
|
||||
let sidebar = browserPanel.querySelector("shopping-sidebar");
|
||||
|
||||
ok(BrowserTestUtils.isVisible(sidebar), "Shopping sidebar should be open");
|
||||
|
||||
let shoppingButton = document.getElementById("shopping-sidebar-button");
|
||||
ok(
|
||||
BrowserTestUtils.isVisible(shoppingButton),
|
||||
"Shopping Button should be visible"
|
||||
);
|
||||
|
||||
let prefChangedPromise = TestUtils.waitForPrefChange(
|
||||
SHOPPING_INTEGRATED_SIDEBAR_PREF
|
||||
);
|
||||
Services.prefs.setBoolPref(SHOPPING_INTEGRATED_SIDEBAR_PREF, true);
|
||||
await prefChangedPromise;
|
||||
|
||||
sidebar = browserPanel.querySelector("shopping-sidebar");
|
||||
is(sidebar, null, "Shopping Sidebar should be removed");
|
||||
|
||||
shoppingButton = document.getElementById("shopping-sidebar-button");
|
||||
ok(
|
||||
BrowserTestUtils.isHidden(shoppingButton),
|
||||
"Shopping Button should be hidden"
|
||||
);
|
||||
|
||||
prefChangedPromise = TestUtils.waitForPrefChange(
|
||||
SHOPPING_INTEGRATED_SIDEBAR_PREF
|
||||
);
|
||||
Services.prefs.setBoolPref(SHOPPING_INTEGRATED_SIDEBAR_PREF, false);
|
||||
await prefChangedPromise;
|
||||
|
||||
sidebar = browserPanel.querySelector("shopping-sidebar");
|
||||
ok(BrowserTestUtils.isVisible(sidebar), "Shopping sidebar should be open");
|
||||
|
||||
shoppingButton = document.getElementById("shopping-sidebar-button");
|
||||
ok(
|
||||
BrowserTestUtils.isVisible(shoppingButton),
|
||||
"Shopping Button should be visible"
|
||||
);
|
||||
});
|
||||
|
||||
Services.prefs.clearUserPref(SHOPPING_INTEGRATED_SIDEBAR_PREF);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче