Bug 1344711 - script-generated patch to remove try blocks around get*Pref calls, r=jaws.

--HG--
extra : rebase_source : c6e20e6e79b0ca5de751c52712d96cbea9432d26
This commit is contained in:
Florian Quèze 2017-03-07 15:29:48 +01:00
parent e2b53c13ce
commit cd762cc83c
75 changed files with 152 additions and 665 deletions

View File

@ -113,13 +113,7 @@ DirectoryProvider.prototype = {
// path from the parent, and it is then used to build
// jar:remoteopenfile:// uris.
if (prop == "coreAppsDir") {
let coreAppsDirPref;
try {
coreAppsDirPref = Services.prefs.getCharPref(COREAPPSDIR_PREF);
} catch (e) {
// coreAppsDirPref may not exist if we're on an older version
// of gaia, so just fail silently.
}
let coreAppsDirPref = Services.prefs.getCharPref(COREAPPSDIR_PREF, "");
let appsDir;
// If pref doesn't exist or isn't set, default to old value
if (!coreAppsDirPref || coreAppsDirPref == "") {

View File

@ -157,10 +157,7 @@ var gFxAccounts = {
// Note that updateUI() returns a Promise that's only used by tests.
updateUI() {
let profileInfoEnabled = false;
try {
profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled");
} catch (e) { }
let profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled", false);
this.panelUIFooter.hidden = false;

View File

@ -297,10 +297,7 @@ var gSyncUI = {
*/
maybeMoveSyncedTabsButton() {
const prefName = "browser.migrated-sync-button";
let migrated = false;
try {
migrated = Services.prefs.getBoolPref(prefName);
} catch (_) {}
let migrated = Services.prefs.getBoolPref(prefName, false);
if (migrated) {
return;
}

View File

@ -2797,11 +2797,8 @@ var gMenuButtonUpdateBadge = {
this.enabled = Services.prefs.getBoolPref("app.update.badge");
} catch (e) {}
if (this.enabled) {
try {
this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime");
} catch (e) {
this.badgeWaitTime = 345600; // 4 days
}
this.badgeWaitTime = Services.prefs.getIntPref("app.update.badgeWaitTime",
345600); // 4 days
Services.obs.addObserver(this, "update-staged", false);
Services.obs.addObserver(this, "update-downloaded", false);
}

View File

@ -302,12 +302,7 @@ var RemoteTabViewer = {
_refetchTabs(force) {
if (!force) {
// Don't bother refetching tabs if we already did so recently
let lastFetch = 0;
try {
lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch");
} catch (e) {
/* Just use the default value of 0 */
}
let lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch", 0);
let now = Math.floor(Date.now() / 1000);
if (now - lastFetch < 30) {

View File

@ -4470,11 +4470,7 @@
return true;
if (this._logInit)
return this._shouldLog;
let result = false;
try {
result = Services.prefs.getBoolPref("browser.tabs.remote.logSwitchTiming");
} catch (ex) {
}
let result = Services.prefs.getBoolPref("browser.tabs.remote.logSwitchTiming", false);
this._shouldLog = result;
this._logInit = true;
return this._shouldLog;
@ -5647,11 +5643,7 @@
window.addEventListener("resize", this);
window.addEventListener("load", this);
try {
this._tabAnimationLoggingEnabled = Services.prefs.getBoolPref("browser.tabs.animationLogging.enabled");
} catch (ex) {
this._tabAnimationLoggingEnabled = false;
}
this._tabAnimationLoggingEnabled = Services.prefs.getBoolPref("browser.tabs.animationLogging.enabled", false);
this._browserNewtabpageEnabled = Services.prefs.getBoolPref("browser.newtabpage.enabled");
Services.prefs.addObserver("privacy.userContext", this, false);
this.observe(null, "nsPref:changed", "privacy.userContext.enabled");

View File

@ -2,11 +2,7 @@ var offlineByDefault = {
defaultValue: false,
prefBranch: SpecialPowers.Cc["@mozilla.org/preferences-service;1"].getService(SpecialPowers.Ci.nsIPrefBranch),
set(allow) {
try {
this.defaultValue = this.prefBranch.getBoolPref("offline-apps.allow_by_default");
} catch (e) {
this.defaultValue = false
}
this.defaultValue = this.prefBranch.getBoolPref("offline-apps.allow_by_default", false);
this.prefBranch.setBoolPref("offline-apps.allow_by_default", allow);
},
reset() {

View File

@ -158,10 +158,7 @@ var gUIStateBeforeReset = {
XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope);
let debug;
try {
debug = Services.prefs.getBoolPref(kPrefCustomizationDebug);
} catch (ex) {}
let debug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
let consoleOptions = {
maxLogLevel: debug ? "all" : "log",
prefix: "CustomizableUI",
@ -2220,10 +2217,7 @@ var CustomizableUIInternal = {
this.notifyListeners("onWidgetAdded", widget.id, widget.currentArea,
widget.currentPosition);
} else if (widgetMightNeedAutoAdding) {
let autoAdd = true;
try {
autoAdd = Services.prefs.getBoolPref(kPrefCustomizationAutoAdd);
} catch (e) {}
let autoAdd = Services.prefs.getBoolPref(kPrefCustomizationAutoAdd, true);
// If the widget doesn't have an existing placement, and it hasn't been
// seen before, then add it to its default area so it can be used.

View File

@ -46,10 +46,7 @@ const kWidePanelItemClass = "panel-wide-item";
XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope);
let debug;
try {
debug = Services.prefs.getBoolPref(kPrefCustomizationDebug);
} catch (ex) {}
let debug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
let consoleOptions = {
maxLogLevel: debug ? "all" : "log",
prefix: "CustomizableWidgets",

View File

@ -1502,10 +1502,7 @@ CustomizeMode.prototype = {
if (!AppConstants.CAN_DRAW_IN_TITLEBAR) {
return;
}
let drawInTitlebar = true;
try {
drawInTitlebar = Services.prefs.getBoolPref(kDrawInTitlebarPref);
} catch (ex) { }
let drawInTitlebar = Services.prefs.getBoolPref(kDrawInTitlebarPref, true);
let button = this.document.getElementById("customization-titlebar-visibility-button");
// Drawing in the titlebar means 'hiding' the titlebar:
if (drawInTitlebar) {

View File

@ -81,10 +81,7 @@ function test() {
continue;
}
let pref = "browser.toolbarbuttons.introduced." + placements[i];
let introduced = false;
try {
introduced = Services.prefs.getBoolPref(pref);
} catch (ex) {}
let introduced = Services.prefs.getBoolPref(pref, false);
if (!introduced) {
i++;
continue;

View File

@ -22,10 +22,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
this.DistributionCustomizer = function DistributionCustomizer() {
// For parallel xpcshell testing purposes allow loading the distribution.ini
// file from the profile folder through an hidden pref.
let loadFromProfile = false;
try {
loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile");
} catch (ex) {}
let loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile", false);
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
try {
@ -60,12 +57,7 @@ DistributionCustomizer.prototype = {
},
get _locale() {
let locale;
try {
locale = this._prefs.getCharPref("general.useragent.locale");
} catch (e) {
locale = "en-US";
}
let locale = this._prefs.getCharPref("general.useragent.locale", "en-US");
this.__defineGetter__("_locale", () => locale);
return this._locale;
},
@ -289,10 +281,7 @@ DistributionCustomizer.prototype = {
this._ini.getString("Global", "id") + ".bookmarksProcessed";
}
let bmProcessed = false;
try {
bmProcessed = this._prefs.getBoolPref(bmProcessedPref);
} catch (e) {}
let bmProcessed = this._prefs.getBoolPref(bmProcessedPref, false);
if (!bmProcessed) {
if (sections["BookmarksMenu"])

View File

@ -19,11 +19,7 @@ function LOG(str) {
let prefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
let shouldLog = false;
try {
shouldLog = prefB.getBoolPref("feeds.log");
} catch (ex) {
}
let shouldLog = prefB.getBoolPref("feeds.log", false);
if (shouldLog)
dump("*** Feeds: " + str + "\n");
@ -697,10 +693,7 @@ FeedWriter.prototype = {
_setSelectedHandler(feedType) {
let prefs = Services.prefs;
let handler = "bookmarks";
try {
handler = prefs.getCharPref(getPrefReaderForType(feedType));
} catch (ex) { }
let handler = prefs.getCharPref(getPrefReaderForType(feedType), "bookmarks");
switch (handler) {
case "web": {
@ -835,10 +828,7 @@ FeedWriter.prototype = {
.addEventListener("click", this);
// first-run ui
let showFirstRunUI = true;
try {
showFirstRunUI = Services.prefs.getBoolPref(PREF_SHOW_FIRST_RUN_UI);
} catch (ex) { }
let showFirstRunUI = Services.prefs.getBoolPref(PREF_SHOW_FIRST_RUN_UI, true);
if (showFirstRunUI) {
let textfeedinfo1, textfeedinfo2;
switch (feedType) {

View File

@ -98,20 +98,14 @@ const OVERRIDE_NEW_BUILD_ID = 3;
* OVERRIDE_NONE otherwise.
*/
function needHomepageOverride(prefb) {
var savedmstone = null;
try {
savedmstone = prefb.getCharPref("browser.startup.homepage_override.mstone");
} catch (e) {}
var savedmstone = prefb.getCharPref("browser.startup.homepage_override.mstone", "");
if (savedmstone == "ignore")
return OVERRIDE_NONE;
var mstone = Services.appinfo.platformVersion;
var savedBuildID = null;
try {
savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID");
} catch (e) {}
var savedBuildID = prefb.getCharPref("browser.startup.homepage_override.buildID", "");
var buildID = Services.appinfo.platformBuildID;
@ -484,10 +478,7 @@ nsBrowserContentHandler.prototype = {
// URL if we do end up showing an overridePage. This makes it possible
// to have the overridePage's content vary depending on the version we're
// upgrading from.
let old_mstone = "unknown";
try {
old_mstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
} catch (ex) {}
let old_mstone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone", "unknown");
override = needHomepageOverride(prefb);
if (override != OVERRIDE_NONE) {
switch (override) {

View File

@ -935,10 +935,7 @@ BrowserGlue.prototype = {
// Offer to reset a user's profile if it hasn't been used for 60 days.
const OFFER_PROFILE_RESET_INTERVAL_MS = 60 * 24 * 60 * 60 * 1000;
let lastUse = Services.appinfo.replacedLockTime;
let disableResetPrompt = false;
try {
disableResetPrompt = Services.prefs.getBoolPref("browser.disableResetPrompt");
} catch (e) {}
let disableResetPrompt = Services.prefs.getBoolPref("browser.disableResetPrompt", false);
if (!disableResetPrompt && lastUse &&
Date.now() - lastUse >= OFFER_PROFILE_RESET_INTERVAL_MS) {
@ -1456,10 +1453,7 @@ BrowserGlue.prototype = {
} catch (ex) {}
// Support legacy bookmarks.html format for apps that depend on that format.
let autoExportHTML = false;
try {
autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML");
} catch (ex) {} // Do not export.
let autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML", false); // Do not export.
if (autoExportHTML) {
// Sqlite.jsm and Places shutdown happen at profile-before-change, thus,
// to be on the safe side, this should run earlier.
@ -1526,10 +1520,7 @@ BrowserGlue.prototype = {
// An import operation is about to run.
// Don't try to recreate smart bookmarks if autoExportHTML is true or
// smart bookmarks are disabled.
let smartBookmarksVersion = 0;
try {
smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion");
} catch (ex) {}
let smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion", 0);
if (!autoExportHTML && smartBookmarksVersion != -1)
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
@ -1876,10 +1867,7 @@ BrowserGlue.prototype = {
// Refactor urlbar suggestion preferences to make it extendable and
// allow new suggestion types (e.g: search suggestions).
let types = ["history", "bookmark", "openpage"];
let defaultBehavior = 0;
try {
defaultBehavior = Services.prefs.getIntPref("browser.urlbar.default.behavior");
} catch (ex) {}
let defaultBehavior = Services.prefs.getIntPref("browser.urlbar.default.behavior", 0);
try {
let autocompleteEnabled = Services.prefs.getBoolPref("browser.urlbar.autocomplete.enabled");
if (!autocompleteEnabled) {
@ -2018,10 +2006,7 @@ BrowserGlue.prototype = {
}
if (currentUIVersion < 43) {
let currentTheme = null;
try {
currentTheme = Services.prefs.getCharPref("lightweightThemes.selectedThemeID");
} catch (e) {}
let currentTheme = Services.prefs.getCharPref("lightweightThemes.selectedThemeID", "");
if (currentTheme == "firefox-devedition@mozilla.org") {
let newTheme = Services.prefs.getCharPref("devtools.theme") == "dark" ?
"firefox-compact-dark@mozilla.org" : "firefox-compact-light@mozilla.org";
@ -2099,10 +2084,7 @@ BrowserGlue.prototype = {
const MAX_RESULTS = 10;
// Get current smart bookmarks version. If not set, create them.
let smartBookmarksCurrentVersion = 0;
try {
smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF);
} catch (ex) {}
let smartBookmarksCurrentVersion = Services.prefs.getIntPref(SMART_BOOKMARKS_PREF, 0);
// If version is current, or smart bookmarks are disabled, bail out.
if (smartBookmarksCurrentVersion == -1 ||

View File

@ -74,22 +74,14 @@ var gSyncPane = {
},
_showLoadPage(xps) {
let username;
try {
username = Services.prefs.getCharPref("services.sync.username");
} catch (e) {}
let username = Services.prefs.getCharPref("services.sync.username", "");
if (!username) {
this.page = FXA_PAGE_LOGGED_OUT;
return;
}
// Use cached values while we wait for the up-to-date values
let cachedComputerName;
try {
cachedComputerName = Services.prefs.getCharPref("services.sync.client.name");
} catch (e) {
cachedComputerName = "";
}
let cachedComputerName = Services.prefs.getCharPref("services.sync.client.name", "");
document.getElementById("fxaEmailAddress1").textContent = username;
this._populateComputerName(cachedComputerName);
this.page = FXA_PAGE_LOGGED_IN;
@ -251,10 +243,7 @@ var gSyncPane = {
fxaEmailAddress1Label.hidden = false;
displayNameLabel.hidden = true;
let profileInfoEnabled;
try {
profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled");
} catch (ex) {}
let profileInfoEnabled = Services.prefs.getBoolPref("identity.fxaccounts.profile_image.enabled", false);
// determine the fxa status...
this._showLoadPage(service);

View File

@ -600,10 +600,7 @@ this.BrowserUITelemetry = {
getSyncState() {
let result = {};
for (let sub of ["desktop", "mobile"]) {
let count = 0;
try {
count = Services.prefs.getIntPref("services.sync.clients.devices." + sub);
} catch (ex) {}
let count = Services.prefs.getIntPref("services.sync.clients.devices." + sub, 0);
result[sub] = count;
}
return result;

View File

@ -188,10 +188,7 @@ var DirectoryLinksProvider = {
* @return the selected locale or "en-US" if none is selected
*/
get locale() {
let matchOS;
try {
matchOS = Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE);
} catch (e) {}
let matchOS = Services.prefs.getBoolPref(PREF_MATCH_OS_LOCALE, false);
if (matchOS) {
return Cc["@mozilla.org/intl/ospreferences;1"].

View File

@ -284,10 +284,7 @@ function migrateSettings() {
}
// primary migration from pre-fx21
let active;
try {
active = Services.prefs.getBoolPref("social.active");
} catch (e) {}
let active = Services.prefs.getBoolPref("social.active", false);
if (!active)
return;

View File

@ -193,12 +193,7 @@ DevTools.prototype = {
return tool;
}
let enabled;
try {
enabled = Services.prefs.getBoolPref(tool.visibilityswitch);
} catch (e) {
enabled = true;
}
let enabled = Services.prefs.getBoolPref(tool.visibilityswitch, true);
return enabled ? tool : null;
},

View File

@ -100,17 +100,13 @@ function openToolbox({ form, chrome, isTabActor }) {
};
TargetFactory.forRemoteTab(options).then(target => {
let frame = document.getElementById("toolbox-iframe");
let selectedTool = "jsdebugger";
try {
// Remember the last panel that was used inside of this profile.
selectedTool = Services.prefs.getCharPref("devtools.toolbox.selectedTool");
} catch(e) {}
try {
// But if we are testing, then it should always open the debugger panel.
selectedTool = Services.prefs.getCharPref("devtools.browsertoolbox.panel");
} catch(e) {}
// Remember the last panel that was used inside of this profile.
// But if we are testing, then it should always open the debugger panel.
let selectedTool =
Services.prefs.getCharPref("devtools.browsertoolbox.panel",
Services.prefs.getCharPref("devtools.toolbox.selectedTool",
"jsdebugger"));
let options = { customIframe: frame };
gDevTools.showToolbox(target,

View File

@ -1226,12 +1226,7 @@ Toolbox.prototype = {
visibilityswitch
} = button;
let visible = true;
try {
visible = Services.prefs.getBoolPref(visibilityswitch);
} catch (ex) {
// Do nothing.
}
let visible = Services.prefs.getBoolPref(visibilityswitch, true);
if (isTargetSupported) {
return visible && isTargetSupported(this.target);

View File

@ -71,11 +71,8 @@ function MarkupView(inspector, frame, controllerWindow) {
this.doc = this._frame.contentDocument;
this._elt = this.doc.querySelector("#root");
try {
this.maxChildren = Services.prefs.getIntPref("devtools.markup.pagesize");
} catch (ex) {
this.maxChildren = DEFAULT_MAX_CHILDREN;
}
this.maxChildren = Services.prefs.getIntPref("devtools.markup.pagesize",
DEFAULT_MAX_CHILDREN);
this.collapseAttributes =
Services.prefs.getBoolPref(ATTR_COLLAPSE_ENABLED_PREF);

View File

@ -17,12 +17,7 @@ function getMaxContentParents(processType) {
maxContentParents = Services.prefs.getIntPref(PREF_BRANCH + processType);
} catch (e) {
// Pref probably didn't exist, get the default number of processes.
try {
maxContentParents = Services.prefs.getIntPref(BASE_PREF);
} catch (e) {
// No prefs? That's odd, use only one process.
maxContentParents = 1;
}
maxContentParents = Services.prefs.getIntPref(BASE_PREF, 1);
}
return maxContentParents;

View File

@ -964,11 +964,7 @@ BrowserElementChild.prototype = {
self._takeScreenshot(maxWidth, maxHeight, mimeType, domRequestID);
};
let maxDelayMS = 2000;
try {
maxDelayMS = Services.prefs.getIntPref('dom.browserElement.maxScreenshotDelayMS');
}
catch(e) {}
let maxDelayMS = Services.prefs.getIntPref('dom.browserElement.maxScreenshotDelayMS', 2000);
// Try to wait for the event loop to go idle before we take the screenshot,
// but once we've waited maxDelayMS milliseconds, go ahead and take it
@ -1649,10 +1645,7 @@ BrowserElementChild.prototype = {
// certerror? If yes, maybe we should add a property to the
// event to to indicate whether there is a custom page. That would
// let the embedder have more control over the desired behavior.
let errorPage = null;
try {
errorPage = Services.prefs.getCharPref(CERTIFICATE_ERROR_PAGE_PREF);
} catch (e) {}
let errorPage = Services.prefs.getCharPref(CERTIFICATE_ERROR_PAGE_PREF, "");
if (errorPage == 'certerror') {
sendAsyncMsg('error', { type: 'certerror' });

View File

@ -31,14 +31,8 @@
Cu.import("resource://gre/modules/Services.jsm");
for (var stage of [ "install", "startup", "shutdown", "uninstall" ]) {
for (var symbol of [ "IDBKeyRange", "indexedDB" ]) {
let pref;
try {
pref = Services.prefs.getBoolPref("indexeddbtest.bootstrap." + stage +
"." + symbol);
}
catch(ex) {
pref = false;
}
let pref = Services.prefs.getBoolPref("indexeddbtest.bootstrap." + stage +
"." + symbol, false);
ok(pref, "Symbol '" + symbol + "' present during '" + stage + "'");
}
}

View File

@ -109,13 +109,7 @@ PresentationTransportBuilder.prototype = {
// TODO bug 1228235 we should have a way to let device providers customize
// the time-out duration.
let timeout;
try {
timeout = Services.prefs.getIntPref("presentation.receiver.loading.timeout");
} catch (e) {
// This happens if the pref doesn't exist, so we have a default value.
timeout = 10000;
}
let timeout = Services.prefs.getIntPref("presentation.receiver.loading.timeout", 10000);
// The timer is to check if the negotiation finishes on time.
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);

View File

@ -39,12 +39,7 @@ var DEBUG = RIL.DEBUG_RIL;
function updateDebugFlag() {
// Read debug setting from pref
let debugPref;
try {
debugPref = Services.prefs.getBoolPref(PREF_RIL_DEBUG_ENABLED);
} catch (e) {
debugPref = false;
}
let debugPref = Services.prefs.getBoolPref(PREF_RIL_DEBUG_ENABLED, false);
DEBUG = debugPref || RIL.DEBUG_RIL;
}
updateDebugFlag();

View File

@ -85,12 +85,7 @@ var DEBUG = RIL.DEBUG_RIL;
function updateDebugFlag() {
// Read debug setting from pref
let debugPref;
try {
debugPref = Services.prefs.getBoolPref(PREF_RIL_DEBUG_ENABLED);
} catch (e) {
debugPref = false;
}
let debugPref = Services.prefs.getBoolPref(PREF_RIL_DEBUG_ENABLED, false);
DEBUG = debugPref || RIL.DEBUG_RIL;
}
updateDebugFlag();

View File

@ -68,12 +68,7 @@ var DEBUG = RIL.DEBUG_RIL;
function updateDebugFlag() {
// Read debug setting from pref
let debugPref;
try {
debugPref = Services.prefs.getBoolPref(kPrefRilDebuggingEnabled);
} catch (e) {
debugPref = false;
}
let debugPref = Services.prefs.getBoolPref(kPrefRilDebuggingEnabled, false);
DEBUG = RIL.DEBUG_RIL || debugPref;
}
updateDebugFlag();

View File

@ -277,23 +277,11 @@ this.OnRefTestLoad = function OnRefTestLoad(win)
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
getService(Components.interfaces.nsIPrefBranch);
try {
gBrowserIsRemote = prefs.getBoolPref("browser.tabs.remote.autostart");
} catch (e) {
gBrowserIsRemote = false;
}
gBrowserIsRemote = prefs.getBoolPref("browser.tabs.remote.autostart", false);
try {
gBrowserIsIframe = prefs.getBoolPref("reftest.browser.iframe.enabled");
} catch (e) {
gBrowserIsIframe = false;
}
gBrowserIsIframe = prefs.getBoolPref("reftest.browser.iframe.enabled", false);
try {
gLogLevel = prefs.getCharPref("reftest.logLevel");
} catch (e) {
gLogLevel ='info';
}
gLogLevel = prefs.getCharPref("reftest.logLevel", "info");
if (win === undefined || win == null) {
win = window;
@ -375,17 +363,9 @@ function InitAndStartRefTests()
}
} catch(e) {}
try {
gRemote = prefs.getBoolPref("reftest.remote");
} catch(e) {
gRemote = false;
}
gRemote = prefs.getBoolPref("reftest.remote", false);
try {
gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize");
} catch(e) {
gIgnoreWindowSize = false;
}
gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize", false);
/* Support for running a chunk (subset) of tests. In separate try as this is optional */
try {
@ -473,39 +453,19 @@ function StartTests()
logger.error("EXCEPTION: " + e);
}
try {
gNoCanvasCache = prefs.getIntPref("reftest.nocache");
} catch(e) {
gNoCanvasCache = false;
}
gNoCanvasCache = prefs.getIntPref("reftest.nocache", false);
try {
gShuffle = prefs.getBoolPref("reftest.shuffle");
} catch (e) {
gShuffle = false;
}
gShuffle = prefs.getBoolPref("reftest.shuffle", false);
try {
gRunUntilFailure = prefs.getBoolPref("reftest.runUntilFailure");
} catch (e) {
gRunUntilFailure = false;
}
gRunUntilFailure = prefs.getBoolPref("reftest.runUntilFailure", false);
// When we repeat this function is called again, so really only want to set
// gRepeat once.
if (gRepeat == null) {
try {
gRepeat = prefs.getIntPref("reftest.repeat");
} catch (e) {
gRepeat = 0;
}
gRepeat = prefs.getIntPref("reftest.repeat", 0);
}
try {
gRunSlowTests = prefs.getIntPref("reftest.skipslowtests");
} catch(e) {
gRunSlowTests = false;
}
gRunSlowTests = prefs.getIntPref("reftest.skipslowtests", false);
if (gShuffle) {
gNoCanvasCache = true;
@ -754,11 +714,7 @@ function BuildConditionSandbox(aURL) {
} catch (e) {
sandbox.nativeThemePref = true;
}
try {
sandbox.gpuProcessForceEnabled = prefs.getBoolPref("layers.gpu-process.force-enabled");
} catch (e) {
sandbox.gpuProcessForceEnabled = false;
}
sandbox.gpuProcessForceEnabled = prefs.getBoolPref("layers.gpu-process.force-enabled", false);
sandbox.prefs = CU.cloneInto({
getBoolPref: function(p) { return prefs.getBoolPref(p); },

View File

@ -563,11 +563,7 @@ var BrowserApp = {
get _startupStatus() {
delete this._startupStatus;
let savedMilestone = null;
try {
savedMilestone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone");
} catch (e) {
}
let savedMilestone = Services.prefs.getCharPref("browser.startup.homepage_override.mstone", "");
let ourMilestone = AppConstants.MOZ_APP_VERSION;
this._startupStatus = "";
if (ourMilestone != savedMilestone) {
@ -987,10 +983,7 @@ var BrowserApp = {
_migrateUI: function() {
const UI_VERSION = 3;
let currentUIVersion = 0;
try {
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
} catch(ex) {}
let currentUIVersion = Services.prefs.getIntPref("browser.migration.version", 0);
if (currentUIVersion >= UI_VERSION) {
return;
}
@ -5332,10 +5325,7 @@ var XPInstallObserver = {
if (!tab)
return;
let enabled = true;
try {
enabled = Services.prefs.getBoolPref("xpinstall.enabled");
} catch (e) {}
let enabled = Services.prefs.getBoolPref("xpinstall.enabled", true);
let buttons, message, callback;
if (!enabled) {

View File

@ -108,10 +108,7 @@ var gSyncCallbacks = {};
*/
function syncTimerCallback(timer) {
for (let datasetId in gSyncCallbacks) {
let lastSyncTime = 0;
try {
lastSyncTime = Services.prefs.getIntPref(getLastSyncPrefName(datasetId));
} catch(e) { }
let lastSyncTime = Services.prefs.getIntPref(getLastSyncPrefName(datasetId), 0);
let now = getNowInSeconds();
let { interval: interval, callback: callback } = gSyncCallbacks[datasetId];

View File

@ -78,24 +78,14 @@ function InitializeCacheDevices(memDevice, diskDevice) {
this.start = function() {
prefService.setBoolPref("browser.cache.memory.enable", memDevice);
if (memDevice) {
try {
cap = prefService.getIntPref("browser.cache.memory.capacity");
}
catch(ex) {
cap = 0;
}
cap = prefService.getIntPref("browser.cache.memory.capacity", 0);
if (cap == 0) {
prefService.setIntPref("browser.cache.memory.capacity", 1024);
}
}
prefService.setBoolPref("browser.cache.disk.enable", diskDevice);
if (diskDevice) {
try {
cap = prefService.getIntPref("browser.cache.disk.capacity");
}
catch(ex) {
cap = 0;
}
cap = prefService.getIntPref("browser.cache.disk.capacity", 0);
if (cap == 0) {
prefService.setIntPref("browser.cache.disk.capacity", 1024);
}

View File

@ -121,12 +121,7 @@ const testcases = [
function run_test() {
var pbi = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var oldProfile = pbi.getCharPref("network.IDN.restriction_profile", "moderate");
var oldWhiteListCom;
try {
oldWhitelistCom = pbi.getBoolPref("network.IDN.whitelist.com");
} catch(e) {
oldWhitelistCom = false;
}
var oldWhitelistCom = pbi.getBoolPref("network.IDN.whitelist.com", false);
var idnService = Cc["@mozilla.org/network/idn-service;1"].getService(Ci.nsIIDNService);
pbi.setCharPref("network.IDN.restriction_profile", "moderate");

View File

@ -295,12 +295,7 @@ const profiles = ["ASCII", "high", "moderate"];
function run_test() {
var pbi = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
var oldProfile = pbi.getCharPref("network.IDN.restriction_profile", "moderate");
var oldWhiteListCom;
try {
oldWhitelistCom = pbi.getBoolPref("network.IDN.whitelist.com");
} catch(e) {
oldWhitelistCom = false;
}
var oldWhitelistCom = pbi.getBoolPref("network.IDN.whitelist.com", false);
var idnService = Cc["@mozilla.org/network/idn-service;1"].getService(Ci.nsIIDNService);
for (var i = 0; i < profiles.length; ++i) {

View File

@ -149,10 +149,7 @@ TokenServerClientServerError.prototype._toStringFields = function() {
*/
this.TokenServerClient = function TokenServerClient() {
this._log = Log.repository.getLogger("Common.TokenServerClient");
let level = "Debug";
try {
level = Services.prefs.getCharPref(PREF_LOG_LEVEL);
} catch (ex) {}
let level = Services.prefs.getCharPref(PREF_LOG_LEVEL, "Debug");
this._log.level = Log.Level[level];
}
TokenServerClient.prototype = {

View File

@ -51,11 +51,7 @@ WeaveCrypto.prototype = {
this.prefBranch = Services.prefs.getBranch("services.sync.log.");
this.prefBranch.addObserver("cryptoDebug", this.observer, false);
this.observer._self = this;
try {
this.debug = this.prefBranch.getBoolPref("cryptoDebug");
} catch (x) {
this.debug = false;
}
this.debug = this.prefBranch.getBoolPref("cryptoDebug", false);
XPCOMUtils.defineLazyGetter(this, "encoder", () => new TextEncoder(UTF_LABEL));
XPCOMUtils.defineLazyGetter(this, "decoder", () => new TextDecoder(UTF_LABEL, { fatal: true }));
},

View File

@ -1010,12 +1010,7 @@ FxAccountsInternal.prototype = {
// The purpose of this pref is to expedite any auth errors as the result of a
// expired or revoked FxA session token, e.g., from resetting or changing the FxA
// password.
let ignoreCachedAuthCredentials = false;
try {
ignoreCachedAuthCredentials = Services.prefs.getBoolPref("services.sync.debug.ignoreCachedAuthCredentials");
} catch (e) {
// Pref doesn't exist
}
let ignoreCachedAuthCredentials = Services.prefs.getBoolPref("services.sync.debug.ignoreCachedAuthCredentials", false);
let mustBeValidUntil = this.now() + ASSERTION_USE_PERIOD;
let accountData = yield currentState.getUserAccountData(["cert", "keyPair", "sessionToken"]);
@ -1250,12 +1245,7 @@ FxAccountsInternal.prototype = {
},
requiresHttps() {
let allowHttp = false;
try {
allowHttp = Services.prefs.getBoolPref("identity.fxaccounts.allowHttp");
} catch (e) {
// Pref doesn't exist
}
let allowHttp = Services.prefs.getBoolPref("identity.fxaccounts.allowHttp", false);
return allowHttp !== true;
},

View File

@ -72,12 +72,7 @@ this.FxAccountsConfig = {
whitelistValue = whitelistValue.slice(autoconfigURL.length + 1);
// Check and see if the value will be the default, and just clear the pref if it would
// to avoid it showing up as changed in about:config.
let defaultWhitelist;
try {
defaultWhitelist = Services.prefs.getDefaultBranch("webchannel.allowObject.").getCharPref("urlWhitelist");
} catch (e) {
// No default value ...
}
let defaultWhitelist = Services.prefs.getDefaultBranch("webchannel.allowObject.").getCharPref("urlWhitelist", "");
if (defaultWhitelist === whitelistValue) {
Services.prefs.clearUserPref("webchannel.allowObject.urlWhitelist");
@ -88,10 +83,7 @@ this.FxAccountsConfig = {
},
getAutoConfigURL() {
let pref;
try {
pref = Services.prefs.getCharPref("identity.fxaccounts.autoconfig.uri");
} catch (e) { /* no pref */ }
let pref = Services.prefs.getCharPref("identity.fxaccounts.autoconfig.uri", "");
if (!pref) {
// no pref / empty pref means we don't bother here.
return "";

View File

@ -117,12 +117,7 @@ this.Status = {
resetSync: function resetSync() {
// Logger setup.
let logPref = PREFS_BRANCH + "log.logger.status";
let logLevel = "Trace";
try {
logLevel = Services.prefs.getCharPref(logPref);
} catch (ex) {
// Use default.
}
let logLevel = Services.prefs.getCharPref(logPref, "Trace");
this._log.level = Log.Level[logLevel];
this._log.info("Resetting Status.");

View File

@ -360,12 +360,7 @@ this.AsyncShutdown = {
* Access function getPhase. For testing purposes only.
*/
get _getPhase() {
let accepted = false;
try {
accepted = Services.prefs.getBoolPref("toolkit.asyncshutdown.testing");
} catch (ex) {
// Ignore errors
}
let accepted = Services.prefs.getBoolPref("toolkit.asyncshutdown.testing", false);
if (accepted) {
return getPhase;
}
@ -464,12 +459,7 @@ function getPhase(topic) {
* notification. For testing purposes only.
*/
get _trigger() {
let accepted = false;
try {
accepted = Services.prefs.getBoolPref("toolkit.asyncshutdown.testing");
} catch (ex) {
// Ignore errors
}
let accepted = Services.prefs.getBoolPref("toolkit.asyncshutdown.testing", false);
if (accepted) {
return () => spinner.observe();
}

View File

@ -447,12 +447,7 @@ this.ExtensionData = class {
// Errors are handled by the type checks above.
}
let containersEnabled = true;
try {
containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
} catch (e) {
// If we fail here, we are in some xpcshell test.
}
let containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled", true);
let permissions = this.manifest.permissions || [];

View File

@ -413,11 +413,7 @@ this.DownloadIntegration = {
#ifdef MOZ_WIDGET_GONK
directoryPath = this._getDefaultDownloadDirectory();
#else
let prefValue = 1;
try {
prefValue = Services.prefs.getIntPref("browser.download.folderList");
} catch(e) {}
let prefValue = Services.prefs.getIntPref("browser.download.folderList", 1);
switch(prefValue) {
case 0: // Desktop

View File

@ -2280,12 +2280,7 @@ add_task(function* test_toSerializable_startTime() {
*/
add_task(function* test_platform_integration() {
let downloadFiles = [];
let oldDeviceStorageEnabled = false;
try {
oldDeviceStorageEnabled = Services.prefs.getBoolPref("device.storage.enabled");
} catch (e) {
// This happens if the pref doesn't exist.
}
let oldDeviceStorageEnabled = Services.prefs.getBoolPref("device.storage.enabled", false);
let downloadWatcherNotified = false;
let observer = {
observe(subject, topic, data) {

View File

@ -101,10 +101,7 @@ nsDefaultCLH.prototype = {
try {
var chromeURI = prefs.getCharPref("toolkit.defaultChromeURI");
var flags = "chrome,dialog=no,all";
try {
flags = prefs.getCharPref("toolkit.defaultChromeFeatures");
} catch (e) { }
var flags = prefs.getCharPref("toolkit.defaultChromeFeatures", "chrome,dialog=no,all");
var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(nsIWindowWatcher);

View File

@ -477,14 +477,8 @@ const PREF_OSFILE_LOG_REDIRECT = "toolkit.osfile.log.redirect";
* An optional value that the DEBUG flag was set to previously.
*/
function readDebugPref(prefName, oldPref = false) {
let pref = oldPref;
try {
pref = Services.prefs.getBoolPref(prefName);
} catch (x) {
// In case of an error when reading a pref keep it as is.
}
// If neither pref nor oldPref were set, default it to false.
return pref;
return Services.prefs.getBoolPref(prefName, oldPref);
};
/**
@ -558,12 +552,8 @@ Services.prefs.addObserver(PREF_OSFILE_TEST_SHUTDOWN_OBSERVER,
function prefObserver() {
// The temporary phase topic used to trigger the unclosed
// phase warning.
let TOPIC = null;
try {
TOPIC = Services.prefs.getCharPref(
PREF_OSFILE_TEST_SHUTDOWN_OBSERVER);
} catch (x) {
}
let TOPIC = Services.prefs.getCharPref(PREF_OSFILE_TEST_SHUTDOWN_OBSERVER,
"");
if (TOPIC) {
// Generate a phase, add a blocker.
// Note that this can work only if AsyncShutdown itself has been

View File

@ -95,11 +95,7 @@ function observe(subject, topic, data) {
case "nsPref:changed":
if (data == PREF_SHOW_REMOTE_ICONS) {
try {
showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS);
} catch (_) {
showRemoteIcons = true; // no such pref - default is to show the icons.
}
showRemoteIcons = Services.prefs.getBoolPref(PREF_SHOW_REMOTE_ICONS, true);
}
break;

View File

@ -63,14 +63,7 @@ function initDialog() {
// ---------------------------------------------------
function isListOfPrinterFeaturesAvailable() {
var has_printerfeatures = false;
try {
has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures");
} catch (ex) {
}
return has_printerfeatures;
return gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures", false);
}
// ---------------------------------------------------
@ -456,4 +449,3 @@ function onCancel() {
return true;
}

View File

@ -75,15 +75,7 @@ function stripTrailingWhitespace(element) {
// ---------------------------------------------------
function getPrinterDescription(printerName) {
var s = "";
try {
/* This may not work with non-ASCII test (see bug 235763 comment #16) */
s = gPrefs.getCharPref("print.printer_" + printerName + ".printer_description")
} catch (e) {
}
return s;
return gPrefs.getCharPref("print.printer_" + printerName + ".printer_description", "");
}
// ---------------------------------------------------

View File

@ -32,14 +32,7 @@ function checkDouble(element, maxVal) {
// ---------------------------------------------------
function isListOfPrinterFeaturesAvailable() {
var has_printerfeatures = false;
try {
has_printerfeatures = gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures");
} catch (ex) {
}
return has_printerfeatures;
return gPrefs.getBoolPref("print.tmp.printerfeatures." + gPrintSettings.printerName + ".has_special_printerfeatures", false);
}
// ---------------------------------------------------

View File

@ -392,12 +392,7 @@ function isPartnerBuild() {
// Method to determine if we should be using geo-specific defaults
function geoSpecificDefaultsEnabled() {
let geoSpecificDefaults = false;
try {
geoSpecificDefaults = Services.prefs.getBoolPref("browser.search.geoSpecificDefaults");
} catch (e) {}
return geoSpecificDefaults;
return Services.prefs.getBoolPref("browser.search.geoSpecificDefaults", false);
}
// Some notes on countryCode and region prefs:
@ -502,10 +497,7 @@ function isUSTimezone() {
// If it fails we don't touch that pref so isUS() does its normal thing.
var ensureKnownCountryCode = Task.async(function* (ss) {
// If we have a country-code already stored in our prefs we trust it.
let countryCode;
try {
countryCode = Services.prefs.getCharPref("browser.search.countryCode");
} catch (e) {}
let countryCode = Services.prefs.getCharPref("browser.search.countryCode", "");
if (!countryCode) {
// We don't have it cached, so fetch it. fetchCountryCode() will call
@ -728,10 +720,7 @@ var fetchRegionDefault = (ss) => new Promise(resolve => {
// Append the optional cohort value.
const cohortPref = "browser.search.cohort";
let cohort;
try {
cohort = Services.prefs.getCharPref(cohortPref);
} catch (e) {}
let cohort = Services.prefs.getCharPref(cohortPref, "");
if (cohort)
endpoint += "/" + cohort;

View File

@ -36,11 +36,7 @@ this.UITelemetry = {
Services.obs.addObserver(this, "profile-before-change", false);
// Pick up the current value.
try {
this._enabled = Services.prefs.getBoolPref(PREF_ENABLED);
} catch (e) {
this._enabled = false;
}
this._enabled = Services.prefs.getBoolPref(PREF_ENABLED, false);
return this._enabled;
},

View File

@ -19,13 +19,7 @@
if (this.getAttribute("autoscroll") == "false")
return false;
var enabled = true;
try {
enabled = this.mPrefs.getBoolPref("general.autoScroll");
} catch (ex) {
}
return enabled;
return this.mPrefs.getBoolPref("general.autoScroll", true);
]]>
</getter>
</property>
@ -1526,18 +1520,8 @@
return;
// Toggle browse with caret mode
var browseWithCaretOn = false;
var warn = true;
try {
warn = this.mPrefs.getBoolPref(kPrefWarnOnEnable);
} catch (ex) {
}
try {
browseWithCaretOn = this.mPrefs.getBoolPref(kPrefCaretBrowsingOn);
} catch (ex) {
}
var browseWithCaretOn = this.mPrefs.getBoolPref(kPrefCaretBrowsingOn, false);
var warn = this.mPrefs.getBoolPref(kPrefWarnOnEnable, true);
if (warn && !browseWithCaretOn) {
var checkValue = {value:false};
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]

View File

@ -89,12 +89,8 @@
<property name="scrollIncrement" readonly="true">
<getter><![CDATA[
if (this._scrollIncrement === null) {
try {
this._scrollIncrement = this._prefBranch
.getIntPref("toolkit.scrollbox.scrollIncrement");
} catch (ex) {
this._scrollIncrement = 20;
}
this._scrollIncrement = this._prefBranch
.getIntPref("toolkit.scrollbox.scrollIncrement", 20);
}
return this._scrollIncrement;
]]></getter>
@ -107,12 +103,8 @@
if (this.hasAttribute("smoothscroll")) {
this._smoothScroll = (this.getAttribute("smoothscroll") == "true");
} else {
try {
this._smoothScroll = this._prefBranch
.getBoolPref("toolkit.scrollbox.smoothScroll");
} catch (ex) {
this._smoothScroll = true;
}
this._smoothScroll = this._prefBranch
.getBoolPref("toolkit.scrollbox.smoothScroll", true);
}
}
return this._smoothScroll;

View File

@ -149,13 +149,7 @@ this.GMPPrefs = {
get(aKey, aDefaultValue, aPlugin) {
if (aKey === this.KEY_APP_DISTRIBUTION ||
aKey === this.KEY_APP_DISTRIBUTION_VERSION) {
let prefValue = "default";
try {
prefValue = Services.prefs.getDefaultBranch(null).getCharPref(aKey);
} catch (e) {
// use default when pref not found
}
return prefValue;
return Services.prefs.getDefaultBranch(null).getCharPref(aKey, "default");
}
return Preferences.get(this.getPrefKey(aKey, aPlugin), aDefaultValue);
},

View File

@ -118,18 +118,14 @@ LinksStorage.prototype = {
get _storedVersion() {
if (this.__storedVersion === undefined) {
try {
this.__storedVersion =
Services.prefs.getIntPref("browser.newtabpage.storageVersion");
} catch (ex) {
// The storage version is unknown, so either:
// - it's a new profile
// - it's a profile where versioning information got lost
// In this case we still run through all of the valid migrations,
// starting from 1, as if it was a downgrade. As previously stated the
// migrations should already support running on an updated store.
this.__storedVersion = 1;
}
// When the pref is not set, the storage version is unknown, so either:
// - it's a new profile
// - it's a profile where versioning information got lost
// In this case we still run through all of the valid migrations,
// starting from 1, as if it was a downgrade. As previously stated the
// migrations should already support running on an updated store.
this.__storedVersion =
Services.prefs.getIntPref("browser.newtabpage.storageVersion", 1);
}
return this.__storedVersion;
},

View File

@ -16,10 +16,7 @@ function importPrefBranch(aPrefBranch, aPermission, aAction) {
let list = Services.prefs.getChildList(aPrefBranch, {});
for (let pref of list) {
let origins = "";
try {
origins = Services.prefs.getCharPref(pref);
} catch (e) {}
let origins = Services.prefs.getCharPref(pref, "");
if (!origins)
continue;

View File

@ -111,15 +111,7 @@ this.UpdateUtils = {
/* Get the distribution pref values, from defaults only */
function getDistributionPrefValue(aPrefName) {
var prefValue = "default";
try {
prefValue = Services.prefs.getDefaultBranch(null).getCharPref(aPrefName);
} catch (e) {
// use default when pref not found
}
return prefValue;
return Services.prefs.getDefaultBranch(null).getCharPref(aPrefName, "default");
}
/**

View File

@ -186,10 +186,7 @@ var SimpleServiceDiscovery = {
},
_searchFixedDevices: function _searchFixedDevices() {
let fixedDevices = null;
try {
fixedDevices = Services.prefs.getCharPref("browser.casting.fixedDevices");
} catch (e) {}
let fixedDevices = Services.prefs.getCharPref("browser.casting.fixedDevices", "");
if (!fixedDevices) {
return;

View File

@ -253,10 +253,7 @@ nsUnknownContentTypeDialog.prototype = {
if (!aForcePrompt) {
// Check to see if the user wishes to auto save to the default download
// folder without prompting. Note that preference might not be set.
let autodownload = false;
try {
autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR);
} catch (e) { }
let autodownload = prefs.getBoolPref(PREF_BD_USEDOWNLOADDIR, false);
if (autodownload) {
// Retrieve the user's default download directory

View File

@ -168,11 +168,7 @@ var PrefObserver = {
Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this);
Services.obs.removeObserver(this, "xpcom-shutdown");
} else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) {
let debugLogEnabled = false;
try {
debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED);
} catch (e) {
}
let debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false);
if (debugLogEnabled) {
parentLogger.level = Log.Level.Debug;
} else {
@ -821,10 +817,7 @@ var AddonManagerInternal = {
Extension.browserUpdated = appChanged;
let oldPlatformVersion = null;
try {
oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION);
} catch (e) { }
let oldPlatformVersion = Services.prefs.getCharPref(PREF_EM_LAST_PLATFORM_VERSION, "");
if (appChanged !== false) {
logger.debug("Application has been upgraded");
@ -882,10 +875,7 @@ var AddonManagerInternal = {
} catch (e) {}
Services.prefs.addObserver(PREF_MIN_WEBEXT_PLATFORM_VERSION, this, false);
let defaultProvidersEnabled = true;
try {
defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED);
} catch (e) {}
let defaultProvidersEnabled = Services.prefs.getBoolPref(PREF_DEFAULT_PROVIDERS_ENABLED, true);
AddonManagerPrivate.recordSimpleMeasure("default_providers", defaultProvidersEnabled);
// Ensure all default providers have had a chance to register themselves
@ -1226,11 +1216,7 @@ var AddonManagerInternal = {
switch (aData) {
case PREF_EM_CHECK_COMPATIBILITY: {
let oldValue = gCheckCompatibility;
try {
gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY);
} catch (e) {
gCheckCompatibility = true;
}
gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY, true);
this.callManagerListeners("onCompatibilityModeChanged");
@ -1241,11 +1227,7 @@ var AddonManagerInternal = {
}
case PREF_EM_STRICT_COMPATIBILITY: {
let oldValue = gStrictCompatibility;
try {
gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
} catch (e) {
gStrictCompatibility = true;
}
gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY, true);
this.callManagerListeners("onCompatibilityModeChanged");
@ -1256,11 +1238,7 @@ var AddonManagerInternal = {
}
case PREF_EM_CHECK_UPDATE_SECURITY: {
let oldValue = gCheckUpdateSecurity;
try {
gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY);
} catch (e) {
gCheckUpdateSecurity = true;
}
gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, true);
this.callManagerListeners("onCheckUpdateSecurityChanged");
@ -1270,31 +1248,19 @@ var AddonManagerInternal = {
break;
}
case PREF_EM_UPDATE_ENABLED: {
try {
gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED);
} catch (e) {
gUpdateEnabled = true;
}
gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED, true);
this.callManagerListeners("onUpdateModeChanged");
break;
}
case PREF_EM_AUTOUPDATE_DEFAULT: {
try {
gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT);
} catch (e) {
gAutoUpdateDefault = true;
}
gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT, true);
this.callManagerListeners("onUpdateModeChanged");
break;
}
case PREF_EM_HOTFIX_ID: {
try {
gHotfixID = Services.prefs.getCharPref(PREF_EM_HOTFIX_ID);
} catch (e) {
gHotfixID = null;
}
gHotfixID = Services.prefs.getCharPref(PREF_EM_HOTFIX_ID, "");
break;
}
case PREF_MIN_WEBEXT_PLATFORM_VERSION: {
@ -1474,10 +1440,7 @@ var AddonManagerInternal = {
}
if (checkHotfix) {
var hotfixVersion = "";
try {
hotfixVersion = Services.prefs.getCharPref(PREF_EM_HOTFIX_LASTVERSION);
} catch (e) { }
var hotfixVersion = Services.prefs.getCharPref(PREF_EM_HOTFIX_LASTVERSION, "");
let url = null;
if (Services.prefs.getPrefType(PREF_EM_HOTFIX_URL) == Ci.nsIPrefBranch.PREF_STRING)

View File

@ -63,11 +63,7 @@ var PrefObserver = {
Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this);
Services.obs.removeObserver(this, "xpcom-shutdown");
} else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) {
let debugLogEnabled = false;
try {
debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED);
} catch (e) {
}
let debugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false);
if (debugLogEnabled) {
parentLogger.level = Log.Level.Debug;
} else {

View File

@ -54,11 +54,7 @@ XPCOMUtils.defineLazyGetter(this, "_prefs", () => {
Object.defineProperty(this, "_maxUsedThemes", {
get() {
delete this._maxUsedThemes;
try {
this._maxUsedThemes = _prefs.getIntPref("maxUsedThemes");
} catch (e) {
this._maxUsedThemes = DEFAULT_MAX_USED_THEMES_COUNT;
}
this._maxUsedThemes = _prefs.getIntPref("maxUsedThemes", DEFAULT_MAX_USED_THEMES_COUNT);
return this._maxUsedThemes;
},
@ -79,10 +75,7 @@ var _themeIDBeingDisabled = null;
// was combined with isThemeSelected to determine which theme was selected)
// to the new one (where a selectedThemeID determines which theme is selected).
(function() {
let wasThemeSelected = false;
try {
wasThemeSelected = _prefs.getBoolPref("isThemeSelected");
} catch (e) { }
let wasThemeSelected = _prefs.getBoolPref("isThemeSelected", false);
if (wasThemeSelected) {
_prefs.clearUserPref("isThemeSelected");
@ -119,10 +112,7 @@ this.LightweightThemeManager = {
},
get currentTheme() {
let selectedThemeID = null;
try {
selectedThemeID = _prefs.getCharPref("selectedThemeID");
} catch (e) {}
let selectedThemeID = _prefs.getCharPref("selectedThemeID", "");
let data = null;
if (selectedThemeID) {

View File

@ -1977,12 +1977,7 @@ var gCategories = {
var startHidden = false;
if (aType.flags & AddonManager.TYPE_UI_HIDE_EMPTY) {
var prefName = PREF_UI_TYPE_HIDDEN.replace("%TYPE%", aType.id);
try {
startHidden = Services.prefs.getBoolPref(prefName);
} catch (e) {
// Default to hidden
startHidden = true;
}
startHidden = Services.prefs.getBoolPref(prefName, true);
gPendingInitializations++;
getAddonsAndInstalls(aType.id, (aAddonsList, aInstallsList) => {
@ -2563,10 +2558,7 @@ var gSearchView = {
finishSearch();
});
var maxRemoteResults = 0;
try {
maxRemoteResults = Services.prefs.getIntPref(PREF_MAXRESULTS);
} catch (e) {}
var maxRemoteResults = Services.prefs.getIntPref(PREF_MAXRESULTS, 0);
if (maxRemoteResults <= 0) {
finishSearch(0);

View File

@ -653,10 +653,7 @@
delete this.mControl.mAddon;
this.mControl.mInstall = this.mInstall;
this.mControl.setAttribute("status", "installing");
let prompt = false;
try {
prompt = Services.prefs.getBoolPref("extensions.webextPermissionPrompts");
} catch (err) {}
let prompt = Services.prefs.getBoolPref("extensions.webextPermissionPrompts", false);
if (prompt) {
this.mInstall.promptHandler = info => new Promise((resolve, reject) => {
let subject = {

View File

@ -176,11 +176,7 @@ var PrefObserver = {
Services.prefs.removeObserver(PREF_LOGGING_ENABLED, this);
Services.obs.removeObserver(this, "xpcom-shutdown");
} else if (aTopic == NS_PREFBRANCH_PREFCHANGE_TOPIC_ID) {
try {
gDebugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED);
} catch (e) {
gDebugLogEnabled = false;
}
gDebugLogEnabled = Services.prefs.getBoolPref(PREF_LOGGING_ENABLED, false);
}
}
};

View File

@ -525,10 +525,7 @@ this.AddonRepository = {
metadataAge() {
let now = Math.round(Date.now() / 1000);
let lastUpdate = 0;
try {
lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE);
} catch (e) {}
let lastUpdate = Services.prefs.getIntPref(PREF_METADATA_LASTUPDATE, 0);
// Handle clock jumps
if (now < lastUpdate) {
@ -538,10 +535,7 @@ this.AddonRepository = {
},
isMetadataStale() {
let threshold = DEFAULT_METADATA_UPDATETHRESHOLD_SEC;
try {
threshold = Services.prefs.getIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC);
} catch (e) {}
let threshold = Services.prefs.getIntPref(PREF_METADATA_UPDATETHRESHOLD_SEC, DEFAULT_METADATA_UPDATETHRESHOLD_SEC);
return (this.metadataAge() > threshold);
},
@ -1589,10 +1583,7 @@ var AddonDatabase = {
// Create a blank addons.json file
this._saveDBToDisk();
let dbSchema = 0;
try {
dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA);
} catch (e) {}
let dbSchema = Services.prefs.getIntPref(PREF_GETADDONS_DB_SCHEMA, 0);
if (dbSchema < DB_MIN_JSON_SCHEMA) {
let results = yield new Promise((resolve, reject) => {

View File

@ -564,11 +564,7 @@ function UpdateParser(aId, aUpdateKey, aUrl, aObserver) {
this.observer = aObserver;
this.url = aUrl;
let requireBuiltIn = true;
try {
requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS);
} catch (e) {
}
let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true);
logger.debug("Requesting " + aUrl);
try {
@ -605,11 +601,7 @@ UpdateParser.prototype = {
this.request = null;
this._doneAt = new Error("place holder");
let requireBuiltIn = true;
try {
requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS);
} catch (e) {
}
let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true);
try {
CertUtils.checkCert(request.channel, !requireBuiltIn);

View File

@ -1429,10 +1429,7 @@ this.XPIDatabase = {
// when a lightweight theme is applied for example)
text += "\r\n[ThemeDirs]\r\n";
let dssEnabled = false;
try {
dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED);
} catch (e) {}
let dssEnabled = Services.prefs.getBoolPref(PREF_EM_DSS_ENABLED, false);
let themes = [];
if (dssEnabled) {

View File

@ -262,10 +262,7 @@ function get_expected_results(aSortBy, aLocalExpected) {
*/
function check_results(aQuery, aSortBy, aReverseOrder, aShowLocal) {
var xpinstall_enabled = true;
try {
xpinstall_enabled = Services.prefs.getBoolPref(PREF_XPI_ENABLED);
} catch (e) {}
var xpinstall_enabled = Services.prefs.getBoolPref(PREF_XPI_ENABLED, true);
// When XPI Instalation is disabled, those buttons are hidden and unused
if (xpinstall_enabled) {

View File

@ -48,10 +48,7 @@ const PREF_STRICT_COMPAT = "extensions.strictCompatibility";
var PREF_CHECK_COMPATIBILITY;
(function() {
var channel = "default";
try {
channel = Services.prefs.getCharPref("app.update.channel");
} catch (e) { }
var channel = Services.prefs.getCharPref("app.update.channel", "default");
if (channel != "aurora" &&
channel != "beta" &&
channel != "release" &&

View File

@ -335,10 +335,7 @@ this.BootstrapMonitor = {
AddonTestUtils.on("addon-manager-shutdown", () => BootstrapMonitor.shutdownCheck());
function isNightlyChannel() {
var channel = "default";
try {
channel = Services.prefs.getCharPref("app.update.channel");
} catch (e) { }
var channel = Services.prefs.getCharPref("app.update.channel", "default");
return channel != "aurora" && channel != "beta" && channel != "release" && channel != "esr";
}

View File

@ -3208,14 +3208,10 @@ Checker.prototype = {
getUpdateURL: function UC_getUpdateURL(force) {
this._forced = force;
let url;
try {
url = Services.prefs.getDefaultBranch(null).
getCharPref(PREF_APP_UPDATE_URL);
} catch (e) {
}
let url = Services.prefs.getDefaultBranch(null).
getCharPref(PREF_APP_UPDATE_URL, "");
if (!url || url == "") {
if (!url) {
LOG("Checker:getUpdateURL - update URL not defined");
return null;
}

View File

@ -352,17 +352,11 @@ HandlerService.prototype = {
var prefSvc = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefService);
var prefBranch = prefSvc.getBranch("network.protocol-handler.");
try {
alwaysAsk = prefBranch.getBoolPref("warn-external." + type);
} catch (e) {
// will throw if pref didn't exist.
try {
alwaysAsk = prefBranch.getBoolPref("warn-external-default");
} catch (e) {
// Nothing to tell us what to do, so be paranoid and prompt.
alwaysAsk = true;
}
}
// If neither of the prefs exists, be paranoid and prompt.
alwaysAsk =
prefBranch.getBoolPref("warn-external." + type,
prefBranch.getBoolPref("warn-external-default",
true));
}
aHandlerInfo.alwaysAskBeforeHandling = alwaysAsk;