diff --git a/browser/base/content/test/social/browser_social_perwindowPB.js b/browser/base/content/test/social/browser_social_perwindowPB.js index e12d64197afc..7def78f21b27 100644 --- a/browser/base/content/test/social/browser_social_perwindowPB.js +++ b/browser/base/content/test/social/browser_social_perwindowPB.js @@ -38,7 +38,9 @@ function test() { name: "provider 1", origin: "https://example.com", sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", + statusURL: "https://example.com/browser/browser/base/content/test/social/social_panel.html", workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js", + markURL: "https://example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}", iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png" }; runSocialTestWithProvider(manifest, function (finishcb) { @@ -68,10 +70,26 @@ var tests = { info("checking private window ui"); ok(!pbwin.SocialUI.enabled, "social is disabled in a PB window"); checkSocialUI(pbwin); + // but they should all remain enabled in the initial window info("checking main window ui"); ok(window.SocialUI.enabled, "social is still enabled in normal window"); checkSocialUI(window); + + // Check that the status button is disabled on the private + // browsing window and not on the normal window. + let id = SocialStatus._toolbarHelper.idFromOrigin("https://example.com"); + let widget = CustomizableUI.getWidget(id); + ok(widget.forWindow(pbwin).node.disabled, "status button disabled on private window"); + ok(!widget.forWindow(window).node.disabled, "status button enabled on normal window"); + + // Check that the mark button is disabled on the private + // browsing window and not on the normal window. + id = SocialMarks._toolbarHelper.idFromOrigin("https://example.com"); + widget = CustomizableUI.getWidget(id); + ok(widget.forWindow(pbwin).node.disabled, "mark button disabled on private window"); + ok(!widget.forWindow(window).node.disabled, "mark button enabled on normal window"); + // that's all folks... pbwin.close(); next(); diff --git a/browser/modules/Social.jsm b/browser/modules/Social.jsm index ce886c2145b0..cc5d2879b676 100644 --- a/browser/modules/Social.jsm +++ b/browser/modules/Social.jsm @@ -25,6 +25,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "SocialService", "resource://gre/modules/SocialService.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", + "resource://gre/modules/PrivateBrowsingUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "Promise", "resource://gre/modules/Promise.jsm"); @@ -398,6 +400,9 @@ function CreateSocialStatusWidget(aId, aProvider) { node.setAttribute("tooltiptext", aProvider.name); node.setAttribute("oncommand", "SocialStatus.showPopup(this);"); + if (PrivateBrowsingUtils.isWindowPrivate(aDocument.defaultView)) + node.setAttribute("disabled", "true"); + return node; } });