Bug 1568492 - Add default parameter to RPMGetIntPref. r=nhnt11

Differential Revision: https://phabricator.services.mozilla.com/D39173
This commit is contained in:
Johann Hofmann
2019-07-24 22:07:12 +00:00
parent da087c13df
commit 7348622a88
2 changed files with 19 additions and 7 deletions

View File

@@ -402,7 +402,8 @@ function initPageCertError() {
checkbox.checked = !!errorReportingAutomatic;
}
let hideAddExceptionButton = RPMGetBoolPref(
"security.certerror.hideAddException"
"security.certerror.hideAddException",
false
);
if (hideAddExceptionButton) {
document.querySelector(".exceptionDialogButtonContainer").hidden = true;
@@ -577,7 +578,8 @@ async function setCertErrorDetails(event) {
case "MOZILLA_PKIX_ERROR_MITM_DETECTED":
let autoEnabledEnterpriseRoots = RPMGetBoolPref(
"security.enterprise_roots.auto-enabled"
"security.enterprise_roots.auto-enabled",
false
);
if (mitmPrimingEnabled && autoEnabledEnterpriseRoots) {
RPMSendAsyncMessage("Browser:ResetEnterpriseRootsPref");
@@ -623,9 +625,9 @@ async function setCertErrorDetails(event) {
learnMoreLink.href = baseURL + "time-errors";
// We check against the remote-settings server time first if available, because that allows us
// to give the user an approximation of what the correct time is.
let difference = RPMGetIntPref("services.settings.clock_skew_seconds");
let difference = RPMGetIntPref("services.settings.clock_skew_seconds", 0);
let lastFetched =
RPMGetIntPref("services.settings.last_update_seconds") * 1000;
RPMGetIntPref("services.settings.last_update_seconds", 0) * 1000;
let now = Date.now();
let certRange = {

View File

@@ -383,11 +383,16 @@ class MessagePort {
return Services.appinfo.appBuildID;
}
getIntPref(aPref) {
getIntPref(aPref, defaultValue) {
let principal = this.window.document.nodePrincipal;
if (!RPMAccessManager.checkAllowAccess(principal, "getIntPref", aPref)) {
throw new Error("RPMAccessManager does not allow access to getIntPref");
}
// Only call with a default value if it's defined, to be able to throw
// errors for non-existent prefs.
if (defaultValue !== undefined) {
return Services.prefs.getIntPref(aPref, defaultValue);
}
return Services.prefs.getIntPref(aPref);
}
@@ -401,12 +406,17 @@ class MessagePort {
return Services.prefs.getStringPref(aPref);
}
getBoolPref(aPref, defaultValue = false) {
getBoolPref(aPref, defaultValue) {
let principal = this.window.document.nodePrincipal;
if (!RPMAccessManager.checkAllowAccess(principal, "getBoolPref", aPref)) {
throw new Error("RPMAccessManager does not allow access to getBoolPref");
}
return Services.prefs.getBoolPref(aPref, defaultValue);
// Only call with a default value if it's defined, to be able to throw
// errors for non-existent prefs.
if (defaultValue !== undefined) {
return Services.prefs.getBoolPref(aPref, defaultValue);
}
return Services.prefs.getBoolPref(aPref);
}
setBoolPref(aPref, aVal) {