Bug 965265 - Opening a new private window shows social provider buttons which don't do anything, r=mixedpuppy.
authorFlorian Quèze <florian@queze.net>
Tue, 11 Feb 2014 08:28:25 +0100
changeset 167923 f98c5c2d6bba
parent 167922 c530339e8155
child 167945 8bb30e0e4ddd
child 168082 643c706bc2ef
push id26192
push userryanvm@gmail.com
push date2014-02-11 12:55 +0000
treeherdermozilla-central@f98c5c2d6bba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs965265
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 965265 - Opening a new private window shows social provider buttons which don't do anything, r=mixedpuppy.
browser/base/content/test/social/browser_social_perwindowPB.js
browser/modules/Social.jsm
--- a/browser/base/content/test/social/browser_social_perwindowPB.js
+++ b/browser/base/content/test/social/browser_social_perwindowPB.js
@@ -33,17 +33,19 @@ function postAndReceive(port, postTopic,
 
 function test() {
   waitForExplicitFinish();
 
   let manifest = { // normal provider
     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) {
     openTab(window, "http://example.com", function(newTab) {
       runSocialTests(tests, undefined, undefined, function() {
         window.gBrowser.removeTab(newTab);
         finishcb();
       });
@@ -63,20 +65,36 @@ var tests = {
       // open a new private-window
       openPBWindow(function(pbwin) {
         // The provider should remain alive.
         postAndReceive(port, "ping", "pong", function() {
           // the new window should have no social features at all.
           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();
         })
       });
     });
   },
 }
--- a/browser/modules/Social.jsm
+++ b/browser/modules/Social.jsm
@@ -20,16 +20,18 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "CustomizableUI",
   "resource:///modules/CustomizableUI.jsm");
 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");
 
 XPCOMUtils.defineLazyServiceGetter(this, "unescapeService",
                                    "@mozilla.org/feed-unescapehtml;1",
                                    "nsIScriptableUnescapeHTML");
 
 // Add a pref observer for the enabled state
@@ -393,16 +395,19 @@ function CreateSocialStatusWidget(aId, a
       node.setAttribute('class', 'toolbarbutton-1 chromeclass-toolbar-additional social-status-button');
       node.setAttribute('type', "badged");
       node.style.listStyleImage = "url(" + (aProvider.icon32URL || aProvider.iconURL) + ")";
       node.setAttribute("origin", aProvider.origin);
       node.setAttribute("label", aProvider.name);
       node.setAttribute("tooltiptext", aProvider.name);
       node.setAttribute("oncommand", "SocialStatus.showPopup(this);");
 
+      if (PrivateBrowsingUtils.isWindowPrivate(aDocument.defaultView))
+        node.setAttribute("disabled", "true");
+
       return node;
     }
   });
 };
 
 function CreateSocialMarkWidget(aId, aProvider) {
   if (!aProvider.markURL)
     return;