diff --git a/browser/components/customizableui/CustomizableWidgets.jsm b/browser/components/customizableui/CustomizableWidgets.jsm index ad2b69fddbee..76efb06ed6ec 100644 --- a/browser/components/customizableui/CustomizableWidgets.jsm +++ b/browser/components/customizableui/CustomizableWidgets.jsm @@ -957,9 +957,8 @@ const CustomizableWidgets = [ type: "custom", label: "loop-call-button3.label", tooltiptext: "loop-call-button3.tooltiptext", + privateBrowsingTooltiptext: "loop-call-button3-pb.tooltiptext", defaultArea: CustomizableUI.AREA_NAVBAR, - // Not in private browsing, see bug 1108187. - showInPrivateBrowsing: false, introducedInVersion: 4, onBuild: function(aDocument) { // If we're not supposed to see the button, return zip. @@ -967,13 +966,21 @@ const CustomizableWidgets = [ return null; } + let isWindowPrivate = PrivateBrowsingUtils.isWindowPrivate(aDocument.defaultView); + let node = aDocument.createElementNS(kNSXUL, "toolbarbutton"); node.setAttribute("id", this.id); node.classList.add("toolbarbutton-1"); node.classList.add("chromeclass-toolbar-additional"); node.classList.add("badged-button"); node.setAttribute("label", CustomizableUI.getLocalizedProperty(this, "label")); - node.setAttribute("tooltiptext", CustomizableUI.getLocalizedProperty(this, "tooltiptext")); + if (isWindowPrivate) + node.setAttribute("disabled", "true"); + let tooltiptext = isWindowPrivate ? + CustomizableUI.getLocalizedProperty(this, "privateBrowsingTooltiptext", + [CustomizableUI.getLocalizedProperty(this, "label")]) : + CustomizableUI.getLocalizedProperty(this, "tooltiptext"); + node.setAttribute("tooltiptext", tooltiptext); node.setAttribute("removable", "true"); node.addEventListener("command", function(event) { aDocument.defaultView.LoopUI.togglePanel(event); diff --git a/browser/components/loop/test/mochitest/.eslintrc b/browser/components/loop/test/mochitest/.eslintrc index 7a196541186a..5833aeeb7f89 100644 --- a/browser/components/loop/test/mochitest/.eslintrc +++ b/browser/components/loop/test/mochitest/.eslintrc @@ -21,6 +21,7 @@ "gMozLoopAPI": true, "mockDb": true, "mockPushHandler": true, + "OpenBrowserWindow": true, "promiseDeletedOAuthParams": false, "promiseOAuthGetRegistration": false, "promiseOAuthParamsSetup": false, diff --git a/browser/components/loop/test/mochitest/browser_toolbarbutton.js b/browser/components/loop/test/mochitest/browser_toolbarbutton.js index 95b8ed32560e..1bb2285c12da 100644 --- a/browser/components/loop/test/mochitest/browser_toolbarbutton.js +++ b/browser/components/loop/test/mochitest/browser_toolbarbutton.js @@ -167,3 +167,19 @@ add_task(function* test_screen_share() { MozLoopService.setScreenShareState("1", false); Assert.strictEqual(LoopUI.toolbarButton.node.getAttribute("state"), "", "Check button is in default state"); }); + +add_task(function* test_private_browsing_window() { + let win = OpenBrowserWindow({ private: true }); + yield new Promise(resolve => { + win.addEventListener("load", function listener() { + win.removeEventListener("load", listener); + resolve(); + }); + }); + + let button = win.LoopUI.toolbarButton.node; + Assert.ok(button, "Loop button should be present"); + Assert.ok(button.getAttribute("disabled"), "Disabled attribute should be set"); + + win.close(); +}); diff --git a/browser/locales/en-US/chrome/browser/customizableui/customizableWidgets.properties b/browser/locales/en-US/chrome/browser/customizableui/customizableWidgets.properties index f61b20c17d89..f0ca0b10826b 100644 --- a/browser/locales/en-US/chrome/browser/customizableui/customizableWidgets.properties +++ b/browser/locales/en-US/chrome/browser/customizableui/customizableWidgets.properties @@ -97,6 +97,9 @@ quit-button.tooltiptext.mac = Quit %1$S (%2$S) # approval before you change it. loop-call-button3.label = Hello loop-call-button3.tooltiptext = Start a conversation +# LOCALIZATION NOTE(loop-call-button3-pb.tooltiptext): Shown when the button is +# placed inside a Private Browsing window. %S is the value of loop-call-button3.label. +loop-call-button3-pb.tooltiptext = %S is not available in Private Browsing social-share-button.label = Share This Page social-share-button.tooltiptext = Share this page