bug 856772 fix japanese/chinese/etc text in social manifests. r=gavin

This commit is contained in:
Shane Caraveo 2013-04-01 16:27:13 -07:00
parent aac5f73ef0
commit d746becc66
5 changed files with 23 additions and 8 deletions

View File

@ -26,7 +26,7 @@ let manifest2 = { // used for testing install
function test() {
waitForExplicitFinish();
Services.prefs.setCharPref("social.manifest.good", JSON.stringify(manifest));
setManifestPref("social.manifest.good", manifest);
Services.prefs.setBoolPref("social.remote-install.enabled", true);
runSocialTests(tests, undefined, undefined, function () {
Services.prefs.clearUserPref("social.remote-install.enabled");

View File

@ -54,7 +54,7 @@ var tests = {
Services.prefs.clearUserPref("social.manifest.good");
setAndUpdateBlocklist(blocklistEmpty, next);
}
Services.prefs.setCharPref("social.manifest.good", JSON.stringify(manifest));
setManifestPref("social.manifest.good", manifest);
setAndUpdateBlocklist(blocklistURL, function() {
try {
SocialService.addProvider(manifest, function(provider) {
@ -79,7 +79,7 @@ var tests = {
Services.prefs.clearUserPref("social.manifest.blocked");
setAndUpdateBlocklist(blocklistEmpty, next);
}
Services.prefs.setCharPref("social.manifest.blocked", JSON.stringify(manifest_bad));
setManifestPref("social.manifest.blocked", manifest_bad);
setAndUpdateBlocklist(blocklistURL, function() {
try {
SocialService.addProvider(manifest_bad, function(provider) {
@ -136,7 +136,7 @@ var tests = {
Services.prefs.clearUserPref("social.manifest.blocked");
setAndUpdateBlocklist(blocklistEmpty, next);
}
Services.prefs.setCharPref("social.manifest.blocked", JSON.stringify(manifest_bad));
setManifestPref("social.manifest.blocked", manifest_bad);
SocialService.addProvider(manifest_bad, function(provider) {
if (provider) {
setAndUpdateBlocklist(blocklistURL, function() {

View File

@ -42,7 +42,7 @@ function postTestCleanup(callback) {
}
function addBuiltinManifest(manifest) {
Services.prefs.setCharPref("social.manifest." + manifest.origin, JSON.stringify(manifest));
setManifestPref("social.manifest."+manifest.origin, manifest);
}
function addTab(url, callback) {

View File

@ -232,6 +232,13 @@ function resetBlocklist() {
Services.prefs.setCharPref("extensions.blocklist.url", _originalTestBlocklistURL);
}
function setManifestPref(name, manifest) {
let string = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
string.data = JSON.stringify(manifest);
Services.prefs.setComplexValue(name, Ci.nsISupportsString, string);
}
function addWindowListener(aURL, aCallback) {
Services.wm.addListener({
onOpenWindow: function(aXULWindow) {

View File

@ -42,7 +42,7 @@ let SocialServiceInternal = {
let prefs = MANIFEST_PREFS.getChildList("", []);
for (let pref of prefs) {
try {
var manifest = JSON.parse(MANIFEST_PREFS.getCharPref(pref));
var manifest = JSON.parse(MANIFEST_PREFS.getComplexValue(pref, Ci.nsISupportsString).data);
if (manifest && typeof(manifest) == "object" && manifest.origin)
yield manifest;
} catch (err) {
@ -759,7 +759,12 @@ function AddonInstaller(sourceURI, aManifest, installCallback) {
let addon = this.addon;
AddonManagerPrivate.callInstallListeners("onExternalInstall", null, addon, null, false);
AddonManagerPrivate.callAddonListeners("onInstalling", addon, false);
Services.prefs.setCharPref(getPrefnameFromOrigin(aManifest.origin), JSON.stringify(aManifest));
let string = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
string.data = JSON.stringify(aManifest);
Services.prefs.setComplexValue(getPrefnameFromOrigin(aManifest.origin), Ci.nsISupportsString, string);
AddonManagerPrivate.callAddonListeners("onInstalled", addon);
installCallback(aManifest);
};
@ -1000,7 +1005,10 @@ AddonWrapper.prototype = {
if (Services.prefs.prefHasUserValue(prefName))
throw new Error(this.manifest.name + " is not marked to be uninstalled");
// ensure we're set into prefs
Services.prefs.setCharPref(prefName, JSON.stringify(this.manifest));
let string = Cc["@mozilla.org/supports-string;1"].
createInstance(Ci.nsISupportsString);
string.data = JSON.stringify(this.manifest);
Services.prefs.setComplexValue(prefName, Ci.nsISupportsString, string);
this._pending -= AddonManager.PENDING_UNINSTALL;
AddonManagerPrivate.callAddonListeners("onOperationCancelled", this);
}