diff --git a/browser/components/extensions/parent/ext-sidebarAction.js b/browser/components/extensions/parent/ext-sidebarAction.js index 27e65a15b3c5..a16d33267c9c 100644 --- a/browser/components/extensions/parent/ext-sidebarAction.js +++ b/browser/components/extensions/parent/ext-sidebarAction.js @@ -108,6 +108,10 @@ this.sidebarAction = class extends ExtensionAPI { if (SidebarUI.currentID === this.id) { SidebarUI.hide(); } + if (SidebarUI.lastOpenedId === this.id && + reason === "ADDON_UNINSTALL") { + SidebarUI.lastOpenedId = null; + } let menu = document.getElementById(this.menuId); if (menu) { menu.remove(); @@ -135,7 +139,8 @@ this.sidebarAction = class extends ExtensionAPI { for (let window of windowTracker.browserWindows()) { this.updateWindow(window); let {SidebarUI} = window; - if (install || SidebarUI.lastOpenedId == this.id) { + if ((install && this.extension.manifest.sidebar_action.open_at_install) || + SidebarUI.lastOpenedId == this.id) { SidebarUI.show(this.id); } } diff --git a/browser/components/extensions/schemas/sidebar_action.json b/browser/components/extensions/schemas/sidebar_action.json index ae13737bda38..24ade0b0af33 100644 --- a/browser/components/extensions/schemas/sidebar_action.json +++ b/browser/components/extensions/schemas/sidebar_action.json @@ -30,6 +30,12 @@ "type": "string", "format": "strictRelativeUrl", "preprocess": "localize" + }, + "open_at_install": { + "type": "boolean", + "optional": true, + "default": true, + "description": "Whether or not the sidebar is opened at install. Default is true." } }, "optional": true diff --git a/browser/components/extensions/test/browser/browser_ext_sidebarAction.js b/browser/components/extensions/test/browser/browser_ext_sidebarAction.js index 0375533adfa9..280360e917d8 100644 --- a/browser/components/extensions/test/browser/browser_ext_sidebarAction.js +++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction.js @@ -70,8 +70,8 @@ add_task(async function sidebar_initial_install() { ok(document.getElementById("sidebar-box").hidden, "sidebar box is not visible"); let extension = ExtensionTestUtils.loadExtension(getExtData()); await extension.startup(); + // Test sidebar is opened on install - await extension.awaitMessage("sidebar"); ok(!document.getElementById("sidebar-box").hidden, "sidebar box is visible"); await extension.unload(); @@ -79,6 +79,20 @@ add_task(async function sidebar_initial_install() { ok(document.getElementById("sidebar-box").hidden, "sidebar box is not visible"); }); +add_task(async function sidebar__install_closed() { + ok(document.getElementById("sidebar-box").hidden, "sidebar box is not visible"); + let tempExtData = getExtData(); + tempExtData.manifest.sidebar_action.open_at_install = false; + let extension = ExtensionTestUtils.loadExtension(tempExtData); + await extension.startup(); + + // Test sidebar is closed on install + ok(document.getElementById("sidebar-box").hidden, "sidebar box is hidden"); + + await extension.unload(); + // This is the default value + tempExtData.manifest.sidebar_action.open_at_install = true; +}); add_task(async function sidebar_two_sidebar_addons() { let extension2 = ExtensionTestUtils.loadExtension(getExtData());