Bug 813834 - Character corruption on Facebook messenger with Social API. r=jaws

This commit is contained in:
Makoto Kato 2012-11-29 15:14:48 +09:00
parent 630d3b8360
commit b46c440e1e
2 changed files with 14 additions and 7 deletions

View File

@ -715,7 +715,7 @@ var SocialToolbar = {
let command = document.getElementById("Social:ToggleNotifications");
command.setAttribute("checked", Services.prefs.getBoolPref("social.toast-notifications.enabled"));
const CACHE_PREF_NAME = "social.cached.notificationIcons";
const CACHE_PREF_NAME = "social.cached.ambientNotificationIcons";
// provider.profile == undefined means no response yet from the provider
// to tell us whether the user is logged in or not.
if (!Social.provider || !Social.provider.enabled ||
@ -732,7 +732,8 @@ var SocialToolbar = {
// a cached version for this provider.
let cached;
try {
cached = JSON.parse(Services.prefs.getCharPref(CACHE_PREF_NAME));
cached = JSON.parse(Services.prefs.getComplexValue(CACHE_PREF_NAME,
Ci.nsISupportsString).data);
} catch (ex) {}
if (cached && cached.provider == Social.provider.origin && cached.data) {
icons = cached.data;
@ -745,9 +746,11 @@ var SocialToolbar = {
} else {
// We have a logged in user - save the current set of icons back to the
// "cache" so we can use them next startup.
Services.prefs.setCharPref(CACHE_PREF_NAME,
JSON.stringify({provider: Social.provider.origin,
data: icons}));
let str = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
str.data = JSON.stringify({provider: Social.provider.origin, data: icons});
Services.prefs.setComplexValue(CACHE_PREF_NAME,
Ci.nsISupportsString,
str);
}
let notificationFrames = document.createDocumentFragment();

View File

@ -59,7 +59,7 @@ var tests = {
iconURL: "https://example.com/browser/browser/base/content/test/moz.png",
contentPanel: "about:blank",
counter: 42,
label: "Test Ambient 1",
label: "Test Ambient 1 \u2046",
menuURL: "https://example.com/testAmbient1"
};
let ambience2 = {
@ -79,6 +79,10 @@ var tests = {
menuURL: "https://example.com/testAmbient3"
};
Social.provider.setAmbientNotification(ambience);
// for Bug 813834. Check preference whether stored data is correct.
is(JSON.parse(Services.prefs.getComplexValue("social.cached.ambientNotificationIcons", Ci.nsISupportsString).data).data.testIcon.label, "Test Ambient 1 \u2046", "label is stored into preference correctly");
Social.provider.setAmbientNotification(ambience2);
Social.provider.setAmbientNotification(ambience3);
@ -107,7 +111,7 @@ var tests = {
is(socialToggleMore.querySelectorAll("menuitem").length, 9, "The number of menuitems is minimum plus three ambient notification menuitems.");
is(socialToggleMore.hidden, false, "Menu is visible when ambient notifications have label & menuURL");
let menuitem = socialToggleMore.querySelector(".ambient-menuitem");
is(menuitem.getAttribute("label"), "Test Ambient 1", "Keyboard accessible ambient menuitem should have specified label");
is(menuitem.getAttribute("label"), "Test Ambient 1 \u2046", "Keyboard accessible ambient menuitem should have specified label");
toolsPopup.hidePopup();
next();
}, false);