Bug 1001158 - Handle an invalid distribution.ini gracefully, r=gijs

This commit is contained in:
Mike Kaply 2015-04-08 14:18:31 -05:00
parent 4fa6befb85
commit 2b9cdb8c78
2 changed files with 14 additions and 6 deletions

View File

@ -43,9 +43,17 @@ DistributionCustomizer.prototype = {
_iniFile: null,
get _ini() {
let ini = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
let ini = null;
try {
if (this._iniFile) {
ini = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
getService(Ci.nsIINIParserFactory).
createINIParser(this._iniFile);
}
} catch (e) {
// Unable to parse INI.
Cu.reportError("Unable to parse distribution.ini");
}
this.__defineGetter__("_ini", function() ini);
return this._ini;
},
@ -202,7 +210,7 @@ DistributionCustomizer.prototype = {
_customizationsApplied: false,
applyCustomizations: function DIST_applyCustomizations() {
this._customizationsApplied = true;
if (!this._iniFile)
if (!this._ini)
return this._checkCustomizationComplete();
// nsPrefService loads very early. Reload prefs so we can set
@ -220,7 +228,7 @@ DistributionCustomizer.prototype = {
}),
_doApplyBookmarks: Task.async(function* () {
if (!this._iniFile)
if (!this._ini)
return;
let sections = enumToObject(this._ini.getSections());
@ -264,7 +272,7 @@ DistributionCustomizer.prototype = {
_prefDefaultsApplied: false,
applyPrefDefaults: function DIST_applyPrefDefaults() {
this._prefDefaultsApplied = true;
if (!this._iniFile)
if (!this._ini)
return this._checkCustomizationComplete();
let sections = enumToObject(this._ini.getSections());
@ -354,7 +362,7 @@ DistributionCustomizer.prototype = {
},
_checkCustomizationComplete: function DIST__checkCustomizationComplete() {
let prefDefaultsApplied = this._prefDefaultsApplied || !this._iniFile;
let prefDefaultsApplied = this._prefDefaultsApplied || !this._ini;
if (this._customizationsApplied && this._bookmarksApplied &&
prefDefaultsApplied) {
let os = Cc["@mozilla.org/observer-service;1"].

View File

@ -753,7 +753,7 @@ nsXPConnect::EvalInSandboxObject(const nsAString& source, const char* filename,
filenameStr = NS_LITERAL_CSTRING("x-bogus://XPConnect/Sandbox");
}
return EvalInSandbox(cx, sandbox, source, filenameStr, 1,
JSVERSION_DEFAULT, rval);
JSVERSION_LATEST, rval);
}
/* nsIXPConnectJSObjectHolder getWrappedNativePrototype (in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsIClassInfo aClassInfo); */