Bug 822508 - allow social providers to specify null as the profile. r=gavin
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 19 Dec 2012 11:05:37 +1100
changeset 125569 57adbfadcc853a62020b638ea6eadf8a217b1c5f
parent 125568 3c01cb463c00d038be3cbf8bdf8e9b8867029dbb
child 125570 67900b58b4f85cba4fc8eccf26bf5db936d13e4f
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs822508
milestone20.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 822508 - allow social providers to specify null as the profile. r=gavin
browser/base/content/test/social/browser_social_toolbar.js
toolkit/components/social/SocialService.jsm
--- a/browser/base/content/test/social/browser_social_toolbar.js
+++ b/browser/base/content/test/social/browser_social_toolbar.js
@@ -12,16 +12,33 @@ function test() {
     iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
   };
   runSocialTestWithProvider(manifest, function (finishcb) {
     runSocialTests(tests, undefined, undefined, finishcb);
   });
 }
 
 var tests = {
+  testProfileNone: function(next, useNull) {
+    let profile = useNull ? null : {};
+    Social.provider.updateUserProfile(profile);
+    // check dom values
+    let portrait = document.getElementsByClassName("social-statusarea-user-portrait")[0].getAttribute("src");
+    // this is the default image for the profile area when not logged in.
+    is(portrait, "chrome://global/skin/icons/information-32.png", "portrait is empty");
+    let userDetailsBroadcaster = document.getElementById("socialBroadcaster_userDetails");
+    let notLoggedInStatusValue = userDetailsBroadcaster.getAttribute("notLoggedInLabel");
+    let userButton = document.getElementsByClassName("social-statusarea-loggedInStatus")[0];
+    ok(!userButton.hidden, "username is visible");
+    is(userButton.getAttribute("label"), notLoggedInStatusValue, "label reflects not being logged in");
+    next();
+  },
+  testProfileNull: function(next) {
+    this.testProfileNone(next, true);
+  },
   testProfileSet: function(next) {
     let profile = {
       portrait: "https://example.com/portrait.jpg",
       userName: "trickster",
       displayName: "Kuma Lisa",
       profileURL: "http://en.wikipedia.org/wiki/Kuma_Lisa"
     }
     Social.provider.updateUserProfile(profile);
--- a/toolkit/components/social/SocialService.jsm
+++ b/toolkit/components/social/SocialService.jsm
@@ -363,16 +363,18 @@ SocialProvider.prototype = {
   // Map of objects describing the provider's notification icons, whose
   // properties include:
   //   name, iconURL, counter, contentPanel
   // See https://developer.mozilla.org/en-US/docs/Social_API
   ambientNotificationIcons: null,
 
   // Called by the workerAPI to update our profile information.
   updateUserProfile: function(profile) {
+    if (!profile)
+      profile = {};
     this.profile = profile;
 
     // Sanitize the portrait from any potential script-injection.
     if (profile.portrait) {
       try {
         let portraitUri = Services.io.newURI(profile.portrait, null, null);
 
         let scheme = portraitUri ? portraitUri.scheme : "";