bug 858321 update default state of toolbarbutton menu, r=markh
authorShane Caraveo <scaraveo@mozilla.com>
Mon, 06 May 2013 11:25:24 -0700
changeset 141992 b8f086ab97aa3dc3f10931e0295d237264456593
parent 141991 e64c20f04597d15322eac6516ff9f15f743a11c3
child 141993 b24fa214730b36e88cf247e1c4f90ecf7e018c26
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarkh
bugs858321
milestone23.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 858321 update default state of toolbarbutton menu, r=markh
browser/base/content/browser-social.js
browser/base/content/browser.xul
browser/base/content/test/social/browser_social_multiprovider.js
browser/base/content/test/social/head.js
browser/locales/en-US/chrome/browser/browser.properties
browser/themes/linux/browser.css
browser/themes/osx/browser.css
browser/themes/windows/browser.css
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -689,23 +689,27 @@ SocialToolbar = {
   update: function() {
     this._updateButtonHiddenState();
     this.updateProvider();
     this.populateProviderMenus();
   },
 
   // Called when the Social.provider changes
   updateProvider: function () {
-    let provider = Social.provider || Social.defaultProvider;
+    let provider = Social.provider;
     if (provider) {
       this.button.setAttribute("label", provider.name);
       this.button.setAttribute("tooltiptext", provider.name);
       this.button.style.listStyleImage = "url(" + provider.iconURL + ")";
 
       this.updateProfile();
+    } else {
+      this.button.setAttribute("label", gNavigatorBundle.getString("service.toolbarbutton.label"));
+      this.button.setAttribute("tooltiptext", gNavigatorBundle.getString("service.toolbarbutton.tooltiptext"));
+      this.button.style.removeProperty("list-style-image");
     }
     this.updateButton();
   },
 
   get button() {
     return document.getElementById("social-provider-button");
   },
 
@@ -989,17 +993,17 @@ SocialToolbar = {
   _populateProviderMenu: function SocialToolbar_renderProviderMenu(providerMenuSep) {
     let menu = providerMenuSep.parentNode;
     // selectable providers are inserted before the provider-menu seperator,
     // remove any menuitems in that area
     while (providerMenuSep.previousSibling.nodeName == "menuitem") {
       menu.removeChild(providerMenuSep.previousSibling);
     }
     // only show a selection if enabled and there is more than one
-    if (!SocialUI.enabled || Social.providers.length < 2) {
+    if (Social.providers.length < 2) {
       providerMenuSep.hidden = true;
       return;
     }
     for (let provider of Social.providers) {
       let menuitem = document.createElement("menuitem");
       menuitem.className = "menuitem-iconic social-provider-menuitem";
       menuitem.setAttribute("image", provider.iconURL);
       menuitem.setAttribute("label", provider.name);
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -736,17 +736,17 @@
                       accesskey="&social.toggleSidebar.accesskey;"/>
             <menuitem class="social-toggle-notifications-menuitem"
                       type="checkbox"
                       autocheck="false"
                       command="Social:ToggleNotifications"
                       label="&social.toggleNotifications.label;"
                       accesskey="&social.toggleNotifications.accesskey;"/>
             <menuitem class="social-toggle-menuitem" command="Social:Toggle"/>
-            <menuseparator class="social-statusarea-separator"/>
+            <menuseparator/>
             <menuseparator class="social-provider-menu" hidden="true"/>
             <menuitem class="social-addons-menuitem" command="Social:Addons"
                       label="&social.addons.label;"/>
             <menuitem label="&social.learnMore.label;"
                       accesskey="&social.learnMore.accesskey;"
                       oncommand="SocialUI.showLearnMore();"/>
           </menupopup>
         </toolbarbutton>
--- a/browser/base/content/test/social/browser_social_multiprovider.js
+++ b/browser/base/content/test/social/browser_social_multiprovider.js
@@ -44,17 +44,26 @@ var tests = {
     // Now wait for the initial provider profile to be set
     waitForProviderLoad(function() {
       checkUIStateMatchesProvider(gProviders[0]);
 
       // Now activate "provider 2"
       observeProviderSet(function () {
         waitForProviderLoad(function() {
           checkUIStateMatchesProvider(gProviders[1]);
-          next();
+          // disable social, click on the provider menuitem to switch providers
+          Social.enabled = false;
+          let menu = document.getElementById("social-statusarea-popup");
+          let el = menu.getElementsByAttribute("origin", gProviders[0].origin);
+          is(el.length, 1, "selected provider menu item exists");
+          el[0].click();
+          waitForProviderLoad(function() {
+            checkUIStateMatchesProvider(gProviders[0]);
+            next();
+          });
         });
       });
       Social.activateFromOrigin("https://test1.example.com");
     });
   }
 }
 
 function checkUIStateMatchesProvider(provider) {
--- a/browser/base/content/test/social/head.js
+++ b/browser/base/content/test/social/head.js
@@ -185,18 +185,23 @@ function checkSocialUI(win) {
   isbool(win.SocialChatBar.isAvailable, enabled && Social.haveLoggedInUser(), "chatbar available?");
   isbool(!win.SocialChatBar.chatbar.hidden, enabled && Social.haveLoggedInUser(), "chatbar visible?");
 
   let markVisible = enabled && provider.pageMarkInfo;
   let canMark = markVisible && win.SocialMark.canMarkPage(win.gBrowser.currentURI);
   isbool(!win.SocialMark.button.hidden, markVisible, "SocialMark button visible?");
   isbool(!win.SocialMark.button.disabled, canMark, "SocialMark button enabled?");
   isbool(!doc.getElementById("social-toolbar-item").hidden, active, "toolbar items visible?");
-  if (active)
-    is(win.SocialToolbar.button.style.listStyleImage, 'url("' + Social.defaultProvider.iconURL + '")', "toolbar button has provider icon");
+  if (active) {
+    if (!enabled) {
+      ok(!win.SocialToolbar.button.style.listStyleImage, "toolbar button is default icon");
+    } else {
+      is(win.SocialToolbar.button.style.listStyleImage, 'url("' + Social.defaultProvider.iconURL + '")', "toolbar button has provider icon");
+    }
+  }
   // the menus should always have the provider name
   if (provider) {
     for (let id of ["menu_socialSidebar", "menu_socialAmbientMenu"])
       is(document.getElementById(id).getAttribute("label"), Social.provider.name, "element has the provider name");
   }
 
   // and for good measure, check all the social commands.
   isbool(!doc.getElementById("Social:Toggle").hidden, active, "Social:Toggle visible?");
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -370,16 +370,19 @@ webapps.install.accesskey = I
 webapps.requestInstall = Do you want to install "%1$S" from this site (%2$S)?
 webapps.install.success = Application Installed
 
 # LOCALIZATION NOTE (fullscreen.entered): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
 fullscreen.entered=%S is now fullscreen.
 # LOCALIZATION NOTE (fullscreen.rememberDecision): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
 fullscreen.rememberDecision=Remember decision for %S
 
+service.toolbarbutton.label=Services
+service.toolbarbutton.tooltiptext=Services
+
 # LOCALIZATION NOTE (social.install.description): %1$S is the hostname of the social provider, %2$S is brandShortName (e.g. Firefox)
 service.install.description=Would you like to enable services from %1$S to display in your %2$S toolbar and sidebar?
 service.install.ok.label=Enable Services
 service.install.ok.accesskey=E
 service.install.learnmore=Learn Moreā€¦
 
 # LOCALIZATION NOTE (social.turnOff.label): %S is the name of the social provider
 social.turnOff.label=Turn off %S
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -2089,16 +2089,21 @@ toolbar[mode="text"] toolbarbutton.chevr
   color: #FDF3DE;
   min-width: 16px;
   text-shadow: none;
   background-image: linear-gradient(#B4211B, #8A1915);
   border-radius: 1px;
   -moz-margin-end: 2px;
 }
 
+#social-provider-button {
+  -moz-image-region: rect(0, 16px, 16px, 0);
+  list-style-image: url(chrome://browser/skin/social/services-16.png);
+}
+
 #social-provider-button > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
 .toolbarbutton-badge-container {
   margin: 5px 3px;
   position: relative;
 }
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -3625,16 +3625,23 @@ toolbarbutton.chevron > .toolbarbutton-m
 #social-toolbar-item > .toolbarbutton-1:-moz-locale-dir(ltr):last-child {
   margin-right: 4px;
   border-top-right-radius: 3px;
   border-bottom-right-radius: 3px;
 }
 
 #social-provider-button {
   -moz-image-region: rect(0, 16px, 16px, 0);
+  list-style-image: url(chrome://browser/skin/social/services-16.png);
+}
+
+@media (min-resolution: 2dppx) {
+  #social-provider-button {
+    list-style-image: url(chrome://browser/skin/social/services-16@2x.png);
+  }
 }
 
 #social-provider-button > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
 .toolbarbutton-badge-container {
   margin: 0;
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2760,16 +2760,17 @@ toolbarbutton.bookmark-item[dragover="tr
   border-radius: 1px;
   -moz-margin-end: 5px;
 }
 
 /* Social toolbar item */
 
 #social-provider-button {
   -moz-image-region: rect(0, 16px, 16px, 0);
+  list-style-image: url(chrome://browser/skin/social/services-16.png);
 }
 
 #social-provider-button > .toolbarbutton-menu-dropmarker {
   display: none;
 }
 
 .toolbarbutton-badge-container {
   margin: 0;