summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-04-20 11:17:30 +0200
committerGitHub <noreply@github.com>2019-04-20 11:17:30 +0200
commite0116ac2b78eb4e621a4d0769e01f8358a6d661c (patch)
treefe2898874f0be34a8425281ecba2cb8cb59fb210
parent32577bdb3d2471c0e5ce4cfd0501a820157230cb (diff)
parent21b4cb27cabecdb5580c01891801c9259689ec87 (diff)
downloadUXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar.gz
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar.lz
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.tar.xz
UXP-e0116ac2b78eb4e621a4d0769e01f8358a6d661c.zip
Merge pull request #1041 from Ascrod/default-pref
Clean up try/catch blocks for preferences
-rw-r--r--application/basilisk/base/content/browser-syncui.js6
-rw-r--r--application/basilisk/base/content/browser.js10
-rw-r--r--application/basilisk/base/content/tabbrowser.xml12
-rw-r--r--application/basilisk/components/customizableui/CustomizableUI.jsm22
-rw-r--r--application/basilisk/components/customizableui/CustomizableWidgets.jsm5
-rw-r--r--application/basilisk/components/customizableui/CustomizeMode.jsm9
-rw-r--r--application/basilisk/components/distribution.js19
-rw-r--r--application/basilisk/components/feeds/FeedWriter.js7
-rw-r--r--application/basilisk/components/feeds/WebContentConverter.js9
-rw-r--r--application/basilisk/components/nsBrowserContentHandler.js15
-rw-r--r--application/basilisk/components/nsBrowserGlue.js33
-rw-r--r--application/basilisk/components/sync/aboutSyncTabs.js8
-rw-r--r--application/basilisk/modules/DirectoryLinksProvider.jsm6
-rw-r--r--application/palemoon/base/content/browser-syncui.js11
-rw-r--r--application/palemoon/base/content/tabbrowser.xml6
-rw-r--r--application/palemoon/components/distribution.js14
-rw-r--r--application/palemoon/components/feeds/FeedWriter.js19
-rw-r--r--application/palemoon/components/feeds/WebContentConverter.js9
-rw-r--r--application/palemoon/components/nsBrowserContentHandler.js15
-rw-r--r--application/palemoon/components/nsBrowserGlue.js15
-rw-r--r--devtools/client/framework/devtools.js7
-rw-r--r--devtools/client/framework/toolbox-process-window.js17
-rw-r--r--devtools/client/framework/toolbox.js7
-rw-r--r--devtools/client/inspector/markup/markup.js7
-rw-r--r--devtools/shared/touch/simulator-core.js15
-rw-r--r--dom/browser-element/BrowserElementChildPreload.js11
-rw-r--r--dom/indexedDB/test/test_globalObjects_other.xul10
-rw-r--r--dom/presentation/PresentationDataChannelSessionTransport.js8
-rw-r--r--dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html8
-rw-r--r--layout/tools/reftest/reftest.jsm94
-rw-r--r--netwerk/test/unit/test_bug650995.js14
-rw-r--r--netwerk/test/unit/test_idn_blacklist.js7
-rw-r--r--netwerk/test/unit/test_idn_urls.js7
-rw-r--r--services/common/tokenserverclient.js5
-rw-r--r--services/crypto/modules/WeaveCrypto.js6
-rw-r--r--services/sync/modules/status.js7
-rw-r--r--toolkit/components/asyncshutdown/AsyncShutdown.jsm29
-rw-r--r--toolkit/components/blocklist/nsBlocklistService.js11
-rw-r--r--toolkit/components/jsdownloads/src/DownloadIntegration.jsm6
-rw-r--r--toolkit/components/nsDefaultCLH.js8
-rw-r--r--toolkit/components/osfile/modules/osfile_async_front.jsm43
-rw-r--r--toolkit/components/places/PlacesCategoriesStarter.js7
-rw-r--r--toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm6
-rw-r--r--toolkit/components/places/UnifiedComplete.js5
-rw-r--r--toolkit/components/places/nsPlacesExpiration.js14
-rw-r--r--toolkit/components/places/tests/unit/test_000_frecency.js10
-rw-r--r--toolkit/components/printing/content/printPageSetup.js9
-rw-r--r--toolkit/components/printing/content/printdialog.js10
-rw-r--r--toolkit/components/printing/content/printjoboptions.js9
-rw-r--r--toolkit/components/search/current/nsSearchService.js25
-rw-r--r--toolkit/components/search/orginal/nsSearchService.js25
-rw-r--r--toolkit/components/telemetry/UITelemetry.jsm6
-rw-r--r--toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js7
-rw-r--r--toolkit/components/urlformatter/tests/unit/test_urlformatter.js6
-rw-r--r--toolkit/content/widgets/browser.xml23
-rw-r--r--toolkit/content/widgets/preferences.xml8
-rw-r--r--toolkit/content/widgets/scrollbox.xml27
-rw-r--r--toolkit/modules/NewTabUtils.jsm20
-rw-r--r--toolkit/modules/PermissionsUtils.jsm5
-rw-r--r--toolkit/modules/UpdateUtils.jsm18
-rw-r--r--toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm5
-rw-r--r--toolkit/mozapps/downloads/nsHelperAppDlg.js5
-rw-r--r--toolkit/mozapps/extensions/AddonManager.jsm79
-rw-r--r--toolkit/mozapps/extensions/DeferredSave.jsm7
-rw-r--r--toolkit/mozapps/extensions/GMPUtils.jsm8
-rw-r--r--toolkit/mozapps/extensions/LightweightThemeManager.jsm15
-rw-r--r--toolkit/mozapps/extensions/internal/AddonLogging.jsm7
-rw-r--r--toolkit/mozapps/extensions/internal/AddonRepository.jsm32
-rw-r--r--toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm14
-rw-r--r--toolkit/mozapps/extensions/internal/XPIProviderUtils.js5
-rw-r--r--uriloader/exthandler/nsHandlerService.js16
71 files changed, 199 insertions, 811 deletions
diff --git a/application/basilisk/base/content/browser-syncui.js b/application/basilisk/base/content/browser-syncui.js
index 67056e221..d0f46247a 100644
--- a/application/basilisk/base/content/browser-syncui.js
+++ b/application/basilisk/base/content/browser-syncui.js
@@ -83,10 +83,7 @@ var gSyncUI = {
_wasDelayed: false,
_needsSetup: function SUI__needsSetup() {
- let firstSync = "";
- try {
- firstSync = Services.prefs.getCharPref("services.sync.firstSync");
- } catch (e) { }
+ let firstSync = Services.prefs.getCharPref("services.sync.firstSync", "");
return Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
firstSync == "notReady";
},
@@ -275,7 +272,6 @@ var gSyncUI = {
openPreferences("paneSync");
},
-
// Helpers
_updateLastSyncTime: function SUI__updateLastSyncTime() {
if (!gBrowser)
diff --git a/application/basilisk/base/content/browser.js b/application/basilisk/base/content/browser.js
index a752f4cd9..926a369dd 100644
--- a/application/basilisk/base/content/browser.js
+++ b/application/basilisk/base/content/browser.js
@@ -2589,15 +2589,9 @@ var gMenuButtonUpdateBadge = {
cancelObserverRegistered: false,
init: function () {
- try {
- this.enabled = Services.prefs.getBoolPref("app.update.badge");
- } catch (e) {}
+ this.enabled = Services.prefs.getBoolPref("app.update.badge", false);
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);
}
diff --git a/application/basilisk/base/content/tabbrowser.xml b/application/basilisk/base/content/tabbrowser.xml
index c2f02512d..0e819a3ed 100644
--- a/application/basilisk/base/content/tabbrowser.xml
+++ b/application/basilisk/base/content/tabbrowser.xml
@@ -4135,11 +4135,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;
@@ -5208,11 +5204,7 @@
window.addEventListener("resize", this, false);
window.addEventListener("load", this, false);
- 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");
]]>
</constructor>
diff --git a/application/basilisk/components/customizableui/CustomizableUI.jsm b/application/basilisk/components/customizableui/CustomizableUI.jsm
index 31126b37c..d56d63d99 100644
--- a/application/basilisk/components/customizableui/CustomizableUI.jsm
+++ b/application/basilisk/components/customizableui/CustomizableUI.jsm
@@ -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",
@@ -1914,16 +1911,10 @@ var CustomizableUIInternal = {
// state immediately when a browser window opens, which is important for
// other consumers of this API.
loadSavedState: function() {
- let state = null;
- try {
- state = Services.prefs.getCharPref(kPrefCustomizationState);
- } catch (e) {
- log.debug("No saved state found");
- // This will fail if nothing has been customized, so silently fall back to
- // the defaults.
- }
-
+ let state = Services.prefs.getCharPref(kPrefCustomizationState, "");
if (!state) {
+ log.debug("No saved state found");
+ // Nothing has been customized, so silently fall back to the defaults.
return;
}
try {
@@ -2208,10 +2199,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.
diff --git a/application/basilisk/components/customizableui/CustomizableWidgets.jsm b/application/basilisk/components/customizableui/CustomizableWidgets.jsm
index 9e8f0ec78..d4a191a97 100644
--- a/application/basilisk/components/customizableui/CustomizableWidgets.jsm
+++ b/application/basilisk/components/customizableui/CustomizableWidgets.jsm
@@ -40,10 +40,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",
diff --git a/application/basilisk/components/customizableui/CustomizeMode.jsm b/application/basilisk/components/customizableui/CustomizeMode.jsm
index 4365ddfbc..2958655d2 100644
--- a/application/basilisk/components/customizableui/CustomizeMode.jsm
+++ b/application/basilisk/components/customizableui/CustomizeMode.jsm
@@ -40,9 +40,7 @@ let gDebug;
XPCOMUtils.defineLazyGetter(this, "log", () => {
let scope = {};
Cu.import("resource://gre/modules/Console.jsm", scope);
- try {
- gDebug = Services.prefs.getBoolPref(kPrefCustomizationDebug);
- } catch (ex) {}
+ gDebug = Services.prefs.getBoolPref(kPrefCustomizationDebug, false);
let consoleOptions = {
maxLogLevel: gDebug ? "all" : "log",
prefix: "CustomizeMode",
@@ -1503,10 +1501,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) {
diff --git a/application/basilisk/components/distribution.js b/application/basilisk/components/distribution.js
index 589129a5a..c30e4dcfe 100644
--- a/application/basilisk/components/distribution.js
+++ b/application/basilisk/components/distribution.js
@@ -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) {}
+ loadFromProfile = Services.prefs.getBoolPref("distribution.testing.loadFromProfile", false);
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties);
try {
@@ -60,13 +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;
},
@@ -291,11 +282,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"])
diff --git a/application/basilisk/components/feeds/FeedWriter.js b/application/basilisk/components/feeds/FeedWriter.js
index 20f1399b0..ceb2a7e2f 100644
--- a/application/basilisk/components/feeds/FeedWriter.js
+++ b/application/basilisk/components/feeds/FeedWriter.js
@@ -19,12 +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");
diff --git a/application/basilisk/components/feeds/WebContentConverter.js b/application/basilisk/components/feeds/WebContentConverter.js
index 2cb5cd145..159eca7c2 100644
--- a/application/basilisk/components/feeds/WebContentConverter.js
+++ b/application/basilisk/components/feeds/WebContentConverter.js
@@ -187,13 +187,8 @@ const Utils = {
// check if it is in the black list
let pb = Services.prefs;
- let allowed;
- try {
- allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol);
- }
- catch (e) {
- allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default");
- }
+ let allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol,
+ pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default"));
if (!allowed) {
throw this.getSecurityError(
`Not allowed to register a protocol handler for ${aProtocol}`,
diff --git a/application/basilisk/components/nsBrowserContentHandler.js b/application/basilisk/components/nsBrowserContentHandler.js
index 74144fc1b..d65e52594 100644
--- a/application/basilisk/components/nsBrowserContentHandler.js
+++ b/application/basilisk/components/nsBrowserContentHandler.js
@@ -100,20 +100,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;
@@ -489,10 +483,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) {
diff --git a/application/basilisk/components/nsBrowserGlue.js b/application/basilisk/components/nsBrowserGlue.js
index 82de33240..b4256523f 100644
--- a/application/basilisk/components/nsBrowserGlue.js
+++ b/application/basilisk/components/nsBrowserGlue.js
@@ -961,10 +961,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) {
@@ -1505,10 +1502,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.
@@ -1578,10 +1572,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);
@@ -1932,10 +1923,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) {
@@ -1988,12 +1976,8 @@ BrowserGlue.prototype = {
if (currentUIVersion < 30) {
// Convert old devedition theme pref to lightweight theme storage
- let lightweightThemeSelected = false;
- let selectedThemeID = null;
- try {
- lightweightThemeSelected = Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID");
- selectedThemeID = Services.prefs.getCharPref("lightweightThemes.selectedThemeID");
- } catch (e) {}
+ let lightweightThemeSelected = Services.prefs.prefHasUserValue("lightweightThemes.selectedThemeID", false);
+ let selectedThemeID = Services.prefs.getCharPref("lightweightThemes.selectedThemeID", "");
let defaultThemeSelected = false;
try {
@@ -2143,10 +2127,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 ||
diff --git a/application/basilisk/components/sync/aboutSyncTabs.js b/application/basilisk/components/sync/aboutSyncTabs.js
index 410494b5b..4808c052f 100644
--- a/application/basilisk/components/sync/aboutSyncTabs.js
+++ b/application/basilisk/components/sync/aboutSyncTabs.js
@@ -254,13 +254,7 @@ var RemoteTabViewer = {
_refetchTabs: function(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 */
- }
+ lastFetch = Services.prefs.getIntPref("services.sync.lastTabFetch", 0);
let now = Math.floor(Date.now() / 1000);
if (now - lastFetch < 30) {
diff --git a/application/basilisk/modules/DirectoryLinksProvider.jsm b/application/basilisk/modules/DirectoryLinksProvider.jsm
index 117564099..85d8b296b 100644
--- a/application/basilisk/modules/DirectoryLinksProvider.jsm
+++ b/application/basilisk/modules/DirectoryLinksProvider.jsm
@@ -189,11 +189,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 Services.locale.getLocaleComponentForUserAgent();
diff --git a/application/palemoon/base/content/browser-syncui.js b/application/palemoon/base/content/browser-syncui.js
index 67056e221..6fad03cdd 100644
--- a/application/palemoon/base/content/browser-syncui.js
+++ b/application/palemoon/base/content/browser-syncui.js
@@ -83,10 +83,7 @@ var gSyncUI = {
_wasDelayed: false,
_needsSetup: function SUI__needsSetup() {
- let firstSync = "";
- try {
- firstSync = Services.prefs.getCharPref("services.sync.firstSync");
- } catch (e) { }
+ let firstSync = Services.prefs.getCharPref("services.sync.firstSync", "");
return Weave.Status.checkSetup() == Weave.CLIENT_NOT_CONFIGURED ||
firstSync == "notReady";
},
@@ -285,11 +282,7 @@ var gSyncUI = {
if (!syncButton)
return;
- let lastSync;
- try {
- lastSync = Services.prefs.getCharPref("services.sync.lastSync");
- }
- catch (e) { };
+ let lastSync = Services.prefs.getCharPref("services.sync.lastSync");
if (!lastSync || this._needsSetup()) {
syncButton.removeAttribute("tooltiptext");
return;
diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml
index 868179b5d..d9366f488 100644
--- a/application/palemoon/base/content/tabbrowser.xml
+++ b/application/palemoon/base/content/tabbrowser.xml
@@ -3628,11 +3628,7 @@
window.addEventListener("resize", this, false);
window.addEventListener("load", this, false);
- 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");
]]>
</constructor>
diff --git a/application/palemoon/components/distribution.js b/application/palemoon/components/distribution.js
index d3300604e..121e55b1b 100644
--- a/application/palemoon/components/distribution.js
+++ b/application/palemoon/components/distribution.js
@@ -38,13 +38,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", function() locale);
return this._locale;
},
@@ -221,11 +215,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"])
diff --git a/application/palemoon/components/feeds/FeedWriter.js b/application/palemoon/components/feeds/FeedWriter.js
index d704835bb..facde5815 100644
--- a/application/palemoon/components/feeds/FeedWriter.js
+++ b/application/palemoon/components/feeds/FeedWriter.js
@@ -18,12 +18,7 @@ function LOG(str) {
var prefB = Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
- var shouldLog = false;
- try {
- shouldLog = prefB.getBoolPref("feeds.log");
- }
- catch (ex) {
- }
+ var shouldLog = prefB.getBoolPref("feeds.log", false);
if (shouldLog)
dump("*** Feeds: " + str + "\n");
@@ -874,11 +869,7 @@ FeedWriter.prototype = {
Cc["@mozilla.org/preferences-service;1"].
getService(Ci.nsIPrefBranch);
- var handler = "bookmarks";
- try {
- handler = prefs.getCharPref(getPrefReaderForType(feedType));
- }
- catch (ex) { }
+ var handler = prefs.getCharPref(getPrefReaderForType(feedType), "bookmarks");
switch (handler) {
case "web": {
@@ -1076,11 +1067,7 @@ FeedWriter.prototype = {
.addEventListener("command", this, false);
// first-run ui
- var showFirstRunUI = true;
- try {
- showFirstRunUI = prefs.getBoolPref(PREF_SHOW_FIRST_RUN_UI);
- }
- catch (ex) { }
+ var showFirstRunUI = prefs.getBoolPref(PREF_SHOW_FIRST_RUN_UI, true);
if (showFirstRunUI) {
var textfeedinfo1, textfeedinfo2;
switch (feedType) {
diff --git a/application/palemoon/components/feeds/WebContentConverter.js b/application/palemoon/components/feeds/WebContentConverter.js
index 41679b028..42e2edee0 100644
--- a/application/palemoon/components/feeds/WebContentConverter.js
+++ b/application/palemoon/components/feeds/WebContentConverter.js
@@ -436,13 +436,8 @@ WebContentConverterRegistrar.prototype = {
// check if it is in the black list
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
- var allowed;
- try {
- allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol);
- }
- catch (e) {
- allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default");
- }
+ var allowed = pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "." + aProtocol,
+ pb.getBoolPref(PREF_HANDLER_EXTERNAL_PREFIX + "-default"));
if (!allowed) {
// XXX this should be a "security exception" according to spec
throw("Not allowed to register a protocol handler for " + aProtocol);
diff --git a/application/palemoon/components/nsBrowserContentHandler.js b/application/palemoon/components/nsBrowserContentHandler.js
index 6a75b40f2..e7f1414c2 100644
--- a/application/palemoon/components/nsBrowserContentHandler.js
+++ b/application/palemoon/components/nsBrowserContentHandler.js
@@ -100,20 +100,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;
@@ -550,10 +544,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");
let override = needHomepageOverride(prefb);
if (override != OVERRIDE_NONE) {
switch (override) {
diff --git a/application/palemoon/components/nsBrowserGlue.js b/application/palemoon/components/nsBrowserGlue.js
index ad48dab29..01a133833 100644
--- a/application/palemoon/components/nsBrowserGlue.js
+++ b/application/palemoon/components/nsBrowserGlue.js
@@ -990,14 +990,8 @@ 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.
- var autoExportHTML = false;
- try {
- autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML");
- } catch(ex) {}
- var smartBookmarksVersion = 0;
- try {
- smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion");
- } catch(ex) {}
+ var autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML", false);
+ var smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion", 0);
if (!autoExportHTML && smartBookmarksVersion != -1)
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
@@ -1556,10 +1550,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, just bail out.
if (smartBookmarksCurrentVersion == -1 ||
diff --git a/devtools/client/framework/devtools.js b/devtools/client/framework/devtools.js
index 90f88023b..976a4b56d 100644
--- a/devtools/client/framework/devtools.js
+++ b/devtools/client/framework/devtools.js
@@ -195,12 +195,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;
},
diff --git a/devtools/client/framework/toolbox-process-window.js b/devtools/client/framework/toolbox-process-window.js
index 8ead718b3..8f75e3e24 100644
--- a/devtools/client/framework/toolbox-process-window.js
+++ b/devtools/client/framework/toolbox-process-window.js
@@ -100,17 +100,12 @@ 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,
diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js
index 926e30647..cde7de0e4 100644
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -1131,12 +1131,7 @@ Toolbox.prototype = {
setToolboxButtonsVisibility: function () {
this.toolboxButtons.forEach(buttonSpec => {
let { visibilityswitch, button, isTargetSupported } = buttonSpec;
- let on = true;
- try {
- on = Services.prefs.getBoolPref(visibilityswitch);
- } catch (ex) {
- // Do nothing.
- }
+ let on = Services.prefs.getBoolPref(visibilityswitch, true);
on = on && isTargetSupported(this.target);
diff --git a/devtools/client/inspector/markup/markup.js b/devtools/client/inspector/markup/markup.js
index d6e9f8c11..a4b65c899 100644
--- a/devtools/client/inspector/markup/markup.js
+++ b/devtools/client/inspector/markup/markup.js
@@ -73,11 +73,8 @@ function MarkupView(inspector, frame, controllerWindow) {
this._elt = this.doc.querySelector("#root");
this.htmlEditor = new HTMLEditor(this.doc);
- 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);
diff --git a/devtools/shared/touch/simulator-core.js b/devtools/shared/touch/simulator-core.js
index 6933f9207..fff7d2e78 100644
--- a/devtools/shared/touch/simulator-core.js
+++ b/devtools/shared/touch/simulator-core.js
@@ -18,19 +18,8 @@ var systemAppOrigin = (function () {
return systemOrigin;
})();
-var threshold = 25;
-try {
- threshold = Services.prefs.getIntPref("ui.dragThresholdX");
-} catch (e) {
- // Fall back to default value
-}
-
-var delay = 500;
-try {
- delay = Services.prefs.getIntPref("ui.click_hold_context_menus.delay");
-} catch (e) {
- // Fall back to default value
-}
+var threshold = Services.prefs.getIntPref("ui.dragThresholdX", 25);
+var delay = Services.prefs.getIntPref("ui.click_hold_context_menus.delay", 500);
function SimulatorCore(simulatorTarget) {
this.simulatorTarget = simulatorTarget;
diff --git a/dom/browser-element/BrowserElementChildPreload.js b/dom/browser-element/BrowserElementChildPreload.js
index 780dfa80e..5adff2cac 100644
--- a/dom/browser-element/BrowserElementChildPreload.js
+++ b/dom/browser-element/BrowserElementChildPreload.js
@@ -1010,11 +1010,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
@@ -1720,10 +1716,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' });
diff --git a/dom/indexedDB/test/test_globalObjects_other.xul b/dom/indexedDB/test/test_globalObjects_other.xul
index eb180a9b4..b527d66bd 100644
--- a/dom/indexedDB/test/test_globalObjects_other.xul
+++ b/dom/indexedDB/test/test_globalObjects_other.xul
@@ -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 + "'");
}
}
diff --git a/dom/presentation/PresentationDataChannelSessionTransport.js b/dom/presentation/PresentationDataChannelSessionTransport.js
index 461e4f2cb..9af6213cb 100644
--- a/dom/presentation/PresentationDataChannelSessionTransport.js
+++ b/dom/presentation/PresentationDataChannelSessionTransport.js
@@ -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);
diff --git a/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html b/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html
index 24d3e4ba3..4dcc361c1 100644
--- a/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageQuotaPrivateBrowsing_perwindowpb.html
@@ -14,13 +14,7 @@ const Ci = Components.interfaces;
const CONTENT_PAGE = "http://mochi.test:8888/chrome/dom/tests/mochitest/localstorage/page_blank.html";
const slavePath = "/chrome/dom/tests/mochitest/localstorage/";
var currentTest = 1;
-var quota;
-
-try {
- quota = Services.prefs.getIntPref("dom.storage.default_quota");
-} catch (ex) {
- quota = 5 * 1024;
-}
+var quota = Services.prefs.getIntPref("dom.storage.default_quota", 5 * 1024);
Services.prefs.setIntPref("browser.startup.page", 0);
Services.prefs.setIntPref("dom.storage.default_quota", 1);
diff --git a/layout/tools/reftest/reftest.jsm b/layout/tools/reftest/reftest.jsm
index bd9976b0f..c885150a4 100644
--- a/layout/tools/reftest/reftest.jsm
+++ b/layout/tools/reftest/reftest.jsm
@@ -277,29 +277,10 @@ 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;
- }
-
- try {
- gB2GisMulet = prefs.getBoolPref("b2g.is_mulet");
- } catch (e) {
- gB2GisMulet = false;
- }
-
- try {
- gBrowserIsIframe = prefs.getBoolPref("reftest.browser.iframe.enabled");
- } catch (e) {
- gBrowserIsIframe = false;
- }
-
- try {
- gLogLevel = prefs.getCharPref("reftest.logLevel");
- } catch (e) {
- gLogLevel ='info';
- }
+ gBrowserIsRemote = prefs.getBoolPref("browser.tabs.remote.autostart", false);
+ gB2GisMulet = prefs.getBoolPref("b2g.is_mulet", false);
+ gBrowserIsIframe = prefs.getBoolPref("reftest.browser.iframe.enabled", false);
+ gLogLevel = prefs.getCharPref("reftest.logLevel", "info");
if (win === undefined || win == null) {
win = window;
@@ -366,11 +347,7 @@ function InitAndStartRefTests()
} catch (e) {}
/* set the gLoadTimeout */
- try {
- gLoadTimeout = prefs.getIntPref("reftest.timeout");
- } catch(e) {
- gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
- }
+ gLoadTimeout = prefs.getIntPref("reftest.timeout", 5 * 60 * 1000); //5 minutes as per bug 479518
/* Get the logfile for android tests */
try {
@@ -381,27 +358,12 @@ function InitAndStartRefTests()
}
} catch(e) {}
- try {
- gRemote = prefs.getBoolPref("reftest.remote");
- } catch(e) {
- gRemote = false;
- }
-
- try {
- gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize");
- } catch(e) {
- gIgnoreWindowSize = false;
- }
+ gRemote = prefs.getBoolPref("reftest.remote", false);
+ gIgnoreWindowSize = prefs.getBoolPref("reftest.ignoreWindowSize", false);
/* Support for running a chunk (subset) of tests. In separate try as this is optional */
- try {
- gTotalChunks = prefs.getIntPref("reftest.totalChunks");
- gThisChunk = prefs.getIntPref("reftest.thisChunk");
- }
- catch(e) {
- gTotalChunks = 0;
- gThisChunk = 0;
- }
+ gTotalChunks = prefs.getIntPref("reftest.totalChunks", 0);
+ gThisChunk = prefs.getIntPref("reftest.thisChunk", 0);
try {
gFocusFilterMode = prefs.getCharPref("reftest.focusFilterMode");
@@ -468,39 +430,17 @@ function StartTests()
logger.error("EXCEPTION: " + e);
}
- try {
- gNoCanvasCache = prefs.getIntPref("reftest.nocache");
- } catch(e) {
- gNoCanvasCache = false;
- }
-
- try {
- gShuffle = prefs.getBoolPref("reftest.shuffle");
- } catch (e) {
- gShuffle = false;
- }
-
- try {
- gRunUntilFailure = prefs.getBoolPref("reftest.runUntilFailure");
- } catch (e) {
- gRunUntilFailure = false;
- }
+ gNoCanvasCache = prefs.getIntPref("reftest.nocache", false);
+ gShuffle = prefs.getBoolPref("reftest.shuffle", 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;
@@ -737,11 +677,7 @@ function BuildConditionSandbox(aURL) {
var prefs = CC["@mozilla.org/preferences-service;1"].
getService(CI.nsIPrefBranch);
- try {
- sandbox.nativeThemePref = !prefs.getBoolPref("mozilla.widget.disable-native-theme");
- } catch (e) {
- sandbox.nativeThemePref = true;
- }
+ sandbox.nativeThemePref = !prefs.getBoolPref("mozilla.widget.disable-native-theme", false);
sandbox.prefs = CU.cloneInto({
getBoolPref: function(p) { return prefs.getBoolPref(p); },
diff --git a/netwerk/test/unit/test_bug650995.js b/netwerk/test/unit/test_bug650995.js
index 3c1ea8d67..bf2e9fa7d 100644
--- a/netwerk/test/unit/test_bug650995.js
+++ b/netwerk/test/unit/test_bug650995.js
@@ -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);
}
diff --git a/netwerk/test/unit/test_idn_blacklist.js b/netwerk/test/unit/test_idn_blacklist.js
index 5ca0173bb..aea45d706 100644
--- a/netwerk/test/unit/test_idn_blacklist.js
+++ b/netwerk/test/unit/test_idn_blacklist.js
@@ -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");
diff --git a/netwerk/test/unit/test_idn_urls.js b/netwerk/test/unit/test_idn_urls.js
index 06a53032b..358854093 100644
--- a/netwerk/test/unit/test_idn_urls.js
+++ b/netwerk/test/unit/test_idn_urls.js
@@ -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) {
diff --git a/services/common/tokenserverclient.js b/services/common/tokenserverclient.js
index b220ab586..ca40f7d93 100644
--- a/services/common/tokenserverclient.js
+++ b/services/common/tokenserverclient.js
@@ -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 = {
diff --git a/services/crypto/modules/WeaveCrypto.js b/services/crypto/modules/WeaveCrypto.js
index c040c4f6f..d0d5bdb18 100644
--- a/services/crypto/modules/WeaveCrypto.js
+++ b/services/crypto/modules/WeaveCrypto.js
@@ -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 }));
},
diff --git a/services/sync/modules/status.js b/services/sync/modules/status.js
index a5b8305b4..1233cbe14 100644
--- a/services/sync/modules/status.js
+++ b/services/sync/modules/status.js
@@ -125,12 +125,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.");
diff --git a/toolkit/components/asyncshutdown/AsyncShutdown.jsm b/toolkit/components/asyncshutdown/AsyncShutdown.jsm
index 62ac36f42..9cdf9e126 100644
--- a/toolkit/components/asyncshutdown/AsyncShutdown.jsm
+++ b/toolkit/components/asyncshutdown/AsyncShutdown.jsm
@@ -79,12 +79,8 @@ const DELAY_WARNING_MS = 10 * 1000;
// Crash the process if shutdown is really too long
// (allowing for sleep).
const PREF_DELAY_CRASH_MS = "toolkit.asyncshutdown.crash_timeout";
-var DELAY_CRASH_MS = 60 * 1000; // One minute
-try {
- DELAY_CRASH_MS = Services.prefs.getIntPref(PREF_DELAY_CRASH_MS);
-} catch (ex) {
- // Ignore errors
-}
+var DELAY_CRASH_MS = Services.prefs.getIntPref(PREF_DELAY_CRASH_MS,
+ 60 * 1000); // One minute
Services.prefs.addObserver(PREF_DELAY_CRASH_MS, function() {
DELAY_CRASH_MS = Services.prefs.getIntPref(PREF_DELAY_CRASH_MS);
}, false);
@@ -207,12 +203,7 @@ function log(msg, prefix = "", error = null) {
}
}
const PREF_DEBUG_LOG = "toolkit.asyncshutdown.log";
-var DEBUG_LOG = false;
-try {
- DEBUG_LOG = Services.prefs.getBoolPref(PREF_DEBUG_LOG);
-} catch (ex) {
- // Ignore errors
-}
+var DEBUG_LOG = Services.prefs.getBoolPref(PREF_DEBUG_LOG, false);
Services.prefs.addObserver(PREF_DEBUG_LOG, function() {
DEBUG_LOG = Services.prefs.getBoolPref(PREF_DEBUG_LOG);
}, false);
@@ -360,12 +351,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 +450,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();
}
diff --git a/toolkit/components/blocklist/nsBlocklistService.js b/toolkit/components/blocklist/nsBlocklistService.js
index 49033fc8f..b0115e25d 100644
--- a/toolkit/components/blocklist/nsBlocklistService.js
+++ b/toolkit/components/blocklist/nsBlocklistService.js
@@ -238,16 +238,7 @@ function getLocale() {
/* Get the distribution pref values, from defaults only */
function getDistributionPrefValue(aPrefName) {
- var prefValue = "default";
-
- var defaults = gPref.getDefaultBranch(null);
- try {
- prefValue = defaults.getCharPref(aPrefName);
- } catch (e) {
- // use default when pref not found
- }
-
- return prefValue;
+ return gPref.getDefaultBranch(null).getCharPref(aPrefName, "default");
}
/**
diff --git a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
index 305284749..a6875ec48 100644
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -368,11 +368,7 @@ this.DownloadIntegration = {
*/
getPreferredDownloadsDirectory: Task.async(function* () {
let directoryPath = null;
- 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
diff --git a/toolkit/components/nsDefaultCLH.js b/toolkit/components/nsDefaultCLH.js
index a081bae49..affbf75ee 100644
--- a/toolkit/components/nsDefaultCLH.js
+++ b/toolkit/components/nsDefaultCLH.js
@@ -104,13 +104,7 @@ nsDefaultCLH.prototype = {
// if the pref is missing, ignore the exception
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);
wwatch.openWindow(null, chromeURI, "_blank",
diff --git a/toolkit/components/osfile/modules/osfile_async_front.jsm b/toolkit/components/osfile/modules/osfile_async_front.jsm
index 93c7e66d6..9f3b7fb21 100644
--- a/toolkit/components/osfile/modules/osfile_async_front.jsm
+++ b/toolkit/components/osfile/modules/osfile_async_front.jsm
@@ -239,10 +239,9 @@ var Scheduler = this.Scheduler = {
* Prepare to kill the OS.File worker after a few seconds.
*/
restartTimer: function(arg) {
- let delay;
- try {
- delay = Services.prefs.getIntPref("osfile.reset_worker_delay");
- } catch(e) {
+ let delay = Services.prefs.getIntPref("osfile.reset_worker_delay", 0);
+
+ if (!delay) {
// Don't auto-shutdown if we don't have a delay preference set.
return;
}
@@ -469,42 +468,24 @@ const PREF_OSFILE_LOG = "toolkit.osfile.log";
const PREF_OSFILE_LOG_REDIRECT = "toolkit.osfile.log.redirect";
/**
- * Safely read a PREF_OSFILE_LOG preference.
- * Returns a value read or, in case of an error, oldPref or false.
- *
- * @param bool oldPref
- * 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;
-};
-
-/**
* Listen to PREF_OSFILE_LOG changes and update gShouldLog flag
* appropriately.
*/
Services.prefs.addObserver(PREF_OSFILE_LOG,
function prefObserver(aSubject, aTopic, aData) {
- SharedAll.Config.DEBUG = readDebugPref(PREF_OSFILE_LOG, SharedAll.Config.DEBUG);
+ SharedAll.Config.DEBUG = Services.prefs.getBoolPref(PREF_OSFILE_LOG, SharedAll.Config.DEBUG);
if (Scheduler.launched) {
// Don't start the worker just to set this preference.
Scheduler.post("SET_DEBUG", [SharedAll.Config.DEBUG]);
}
}, false);
-SharedAll.Config.DEBUG = readDebugPref(PREF_OSFILE_LOG, false);
+SharedAll.Config.DEBUG = Services.prefs.getBoolPref(PREF_OSFILE_LOG, false);
Services.prefs.addObserver(PREF_OSFILE_LOG_REDIRECT,
function prefObserver(aSubject, aTopic, aData) {
- SharedAll.Config.TEST = readDebugPref(PREF_OSFILE_LOG_REDIRECT, OS.Shared.TEST);
+ SharedAll.Config.TEST = Services.prefs.getBoolPref(PREF_OSFILE_LOG_REDIRECT, OS.Shared.TEST);
}, false);
-SharedAll.Config.TEST = readDebugPref(PREF_OSFILE_LOG_REDIRECT, false);
+SharedAll.Config.TEST = Services.prefs.getBoolPref(PREF_OSFILE_LOG_REDIRECT, false);
/**
@@ -515,7 +496,7 @@ var nativeWheneverAvailable = true;
const PREF_OSFILE_NATIVE = "toolkit.osfile.native";
Services.prefs.addObserver(PREF_OSFILE_NATIVE,
function prefObserver(aSubject, aTopic, aData) {
- nativeWheneverAvailable = readDebugPref(PREF_OSFILE_NATIVE, nativeWheneverAvailable);
+ nativeWheneverAvailable = Services.prefs.getBoolPref(PREF_OSFILE_NATIVE, nativeWheneverAvailable);
}, false);
@@ -557,12 +538,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
diff --git a/toolkit/components/places/PlacesCategoriesStarter.js b/toolkit/components/places/PlacesCategoriesStarter.js
index 560bd486a..bab14db52 100644
--- a/toolkit/components/places/PlacesCategoriesStarter.js
+++ b/toolkit/components/places/PlacesCategoriesStarter.js
@@ -77,11 +77,8 @@ PlacesCategoriesStarter.prototype = {
break;
case "idle-daily":
// Once a week run places.sqlite maintenance tasks.
- let lastMaintenance = 0;
- try {
- lastMaintenance =
- Services.prefs.getIntPref("places.database.lastMaintenance");
- } catch (ex) {}
+ let lastMaintenance =
+ Services.prefs.getIntPref("places.database.lastMaintenance", 0);
let nowSeconds = parseInt(Date.now() / 1000);
if (lastMaintenance < nowSeconds - MAINTENANCE_INTERVAL_SECONDS) {
PlacesDBUtils.maintenanceOnIdle();
diff --git a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
index d23d5bc6e..c3bc501eb 100644
--- a/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
+++ b/toolkit/components/places/PlacesRemoteTabsAutocompleteProvider.jsm
@@ -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;
diff --git a/toolkit/components/places/UnifiedComplete.js b/toolkit/components/places/UnifiedComplete.js
index ec5f91111..7b63e29bb 100644
--- a/toolkit/components/places/UnifiedComplete.js
+++ b/toolkit/components/places/UnifiedComplete.js
@@ -437,10 +437,7 @@ XPCOMUtils.defineLazyGetter(this, "Prefs", () => {
store.suggestTyped = prefs.get(...PREF_SUGGEST_HISTORY_ONLYTYPED);
store.suggestSearches = prefs.get(...PREF_SUGGEST_SEARCHES);
store.maxCharsForSearchSuggestions = prefs.get(...PREF_MAX_CHARS_FOR_SUGGEST);
- store.keywordEnabled = true;
- try {
- store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled");
- } catch (ex) {}
+ store.keywordEnabled = Services.prefs.getBoolPref("keyword.enabled", true);
// If history is not set, onlyTyped value should be ignored.
if (!store.suggestHistory) {
diff --git a/toolkit/components/places/nsPlacesExpiration.js b/toolkit/components/places/nsPlacesExpiration.js
index 499934362..767a4d345 100644
--- a/toolkit/components/places/nsPlacesExpiration.js
+++ b/toolkit/components/places/nsPlacesExpiration.js
@@ -812,11 +812,8 @@ nsPlacesExpiration.prototype = {
_loadPrefs: Task.async(function* () {
// Get the user's limit, if it was set.
- try {
- // We want to silently fail since getIntPref throws if it does not exist,
- // and use a default to fallback to.
- this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS);
- } catch (ex) { /* User limit not set */ }
+ this._urisLimit = this._prefBranch.getIntPref(PREF_MAX_URIS,
+ PREF_MAX_URIS_NOTSET);
if (this._urisLimit < 0) {
// Some testing code expects a pref change to be synchronous, so
@@ -874,11 +871,8 @@ nsPlacesExpiration.prototype = {
this._urisLimit);
// Get the expiration interval value.
- try {
- // We want to silently fail since getIntPref throws if it does not exist,
- // and use a default to fallback to.
- this._interval = this._prefBranch.getIntPref(PREF_INTERVAL_SECONDS);
- } catch (ex) { /* User interval not set */ }
+ this._interval = this._prefBranch.getIntPref(PREF_INTERVAL_SECONDS,
+ PREF_INTERVAL_SECONDS_NOTSET);
if (this._interval <= 0) {
this._interval = PREF_INTERVAL_SECONDS_NOTSET;
}
diff --git a/toolkit/components/places/tests/unit/test_000_frecency.js b/toolkit/components/places/tests/unit/test_000_frecency.js
index 0a7347a02..64ee86b59 100644
--- a/toolkit/components/places/tests/unit/test_000_frecency.js
+++ b/toolkit/components/places/tests/unit/test_000_frecency.js
@@ -56,14 +56,8 @@ var prefPrefix = "places.frecency.";
function* task_initializeBucket(bucket) {
let [cutoffName, weightName] = bucket;
// get pref values
- var weight = 0, cutoff = 0;
- try {
- weight = prefs.getIntPref(prefPrefix + weightName);
- } catch (ex) {}
- try {
- cutoff = prefs.getIntPref(prefPrefix + cutoffName);
- } catch (ex) {}
-
+ var weight = prefs.getIntPref(prefPrefix + weightName, 0);
+ var cutoff = prefs.getIntPref(prefPrefix + cutoffName, 0);
if (cutoff < 1)
return;
diff --git a/toolkit/components/printing/content/printPageSetup.js b/toolkit/components/printing/content/printPageSetup.js
index 31eb1bdd3..6bcd97207 100644
--- a/toolkit/components/printing/content/printPageSetup.js
+++ b/toolkit/components/printing/content/printPageSetup.js
@@ -65,14 +65,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);
}
// ---------------------------------------------------
diff --git a/toolkit/components/printing/content/printdialog.js b/toolkit/components/printing/content/printdialog.js
index e5a38ddce..f9ed94bad 100644
--- a/toolkit/components/printing/content/printdialog.js
+++ b/toolkit/components/printing/content/printdialog.js
@@ -79,15 +79,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", "")
}
// ---------------------------------------------------
diff --git a/toolkit/components/printing/content/printjoboptions.js b/toolkit/components/printing/content/printjoboptions.js
index 26f3ffd85..098358940 100644
--- a/toolkit/components/printing/content/printjoboptions.js
+++ b/toolkit/components/printing/content/printjoboptions.js
@@ -33,14 +33,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);
}
// ---------------------------------------------------
diff --git a/toolkit/components/search/current/nsSearchService.js b/toolkit/components/search/current/nsSearchService.js
index 2a8601078..db90e5150 100644
--- a/toolkit/components/search/current/nsSearchService.js
+++ b/toolkit/components/search/current/nsSearchService.js
@@ -390,12 +390,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:
@@ -500,11 +495,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
// storeCountryCode if it gets a result (even if that happens after the
@@ -726,10 +717,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;
@@ -993,11 +981,8 @@ function QueryParameter(aName, aValue, aPurpose) {
function ParamSubstitution(aParamValue, aSearchTerms, aEngine) {
var value = aParamValue;
- var distributionID = Services.appinfo.distributionID;
- try {
- distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID");
- }
- catch (ex) { }
+ var distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID",
+ Services.appinfo.distributionID || "");
var official = MOZ_OFFICIAL;
try {
if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "official"))
diff --git a/toolkit/components/search/orginal/nsSearchService.js b/toolkit/components/search/orginal/nsSearchService.js
index 5b5ce7a57..1cec5f966 100644
--- a/toolkit/components/search/orginal/nsSearchService.js
+++ b/toolkit/components/search/orginal/nsSearchService.js
@@ -418,12 +418,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:
@@ -528,11 +523,7 @@ function isUSTimezone() {
// If it fails we don't touch that pref so isUS() does its normal thing.
var ensureKnownCountryCode = Task.async(function* () {
// 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
// storeCountryCode if it gets a result (even if that happens after the
@@ -732,10 +723,7 @@ var fetchRegionDefault = () => 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;
@@ -1034,11 +1022,8 @@ function QueryParameter(aName, aValue, aPurpose) {
function ParamSubstitution(aParamValue, aSearchTerms, aEngine) {
var value = aParamValue;
- var distributionID = MOZ_DISTRIBUTION_ID;
- try {
- distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID");
- }
- catch (ex) { }
+ var distributionID = Services.prefs.getCharPref(BROWSER_SEARCH_PREF + "distributionID",
+ MOZ_DISTRIBUTION_ID || "");
var official = MOZ_OFFICIAL;
try {
if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "official"))
diff --git a/toolkit/components/telemetry/UITelemetry.jsm b/toolkit/components/telemetry/UITelemetry.jsm
index bd7a34b72..231b52e23 100644
--- a/toolkit/components/telemetry/UITelemetry.jsm
+++ b/toolkit/components/telemetry/UITelemetry.jsm
@@ -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;
},
diff --git a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
index ba4bf225a..5d462c90d 100644
--- a/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
+++ b/toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js
@@ -20,12 +20,7 @@ Cu.import("resource://gre/modules/NetUtil.jsm");
// Log only if browser.safebrowsing.debug is true
function log(...stuff) {
- let logging = null;
- try {
- logging = Services.prefs.getBoolPref("browser.safebrowsing.debug");
- } catch(e) {
- return;
- }
+ let logging = Services.prefs.getBoolPref("browser.safebrowsing.debug", false);
if (!logging) {
return;
}
diff --git a/toolkit/components/urlformatter/tests/unit/test_urlformatter.js b/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
index 393b0dc33..6f218822a 100644
--- a/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
+++ b/toolkit/components/urlformatter/tests/unit/test_urlformatter.js
@@ -27,11 +27,9 @@ function run_test() {
QueryInterface(Ci.nsIXULRuntime);
var abi = macutils && macutils.isUniversalBinary ? "Universal-gcc3" : appInfo.XPCOMABI;
- let channel = "default";
let defaults = prefs.QueryInterface(Ci.nsIPrefService).getDefaultBranch(null);
- try {
- channel = defaults.getCharPref("app.update.channel");
- } catch (e) {}
+ let channel = defaults.getCharPref("app.update.channel", "default");
+
// Set distribution values.
defaults.setCharPref("distribution.id", "bacon");
defaults.setCharPref("distribution.version", "1.0");
diff --git a/toolkit/content/widgets/browser.xml b/toolkit/content/widgets/browser.xml
index 9c72e86d8..11ed998cc 100644
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -19,14 +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>
@@ -1427,18 +1420,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"]
diff --git a/toolkit/content/widgets/preferences.xml b/toolkit/content/widgets/preferences.xml
index 9fb2ac7ea..11de03246 100644
--- a/toolkit/content/widgets/preferences.xml
+++ b/toolkit/content/widgets/preferences.xml
@@ -893,12 +893,8 @@
<![CDATA[
var psvc = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
- var animate = /Mac/.test(navigator.platform);
- try {
- animate = psvc.getBoolPref("browser.preferences.animateFadeIn");
- }
- catch (e) { }
- return animate;
+ return psvc.getBoolPref("browser.preferences.animateFadeIn",
+ /Mac/.test(navigator.platform));
]]>
</getter>
</property>
diff --git a/toolkit/content/widgets/scrollbox.xml b/toolkit/content/widgets/scrollbox.xml
index ff57a5911..219b7cb5e 100644
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -80,13 +80,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>
@@ -99,13 +94,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;
@@ -737,12 +727,9 @@
</content>
<implementation implements="nsITimerCallback, nsIDOMEventListener">
<constructor><![CDATA[
- try {
- this._scrollDelay = this._prefBranch
- .getIntPref("toolkit.scrollbox.clickToScroll.scrollDelay");
- }
- catch (ex) {
- }
+ this._scrollDelay = this._prefBranch
+ .getIntPref("toolkit.scrollbox.clickToScroll.scrollDelay",
+ this._scrollDelay);
]]></constructor>
<destructor><![CDATA[
diff --git a/toolkit/modules/NewTabUtils.jsm b/toolkit/modules/NewTabUtils.jsm
index 548d87dda..35e38156f 100644
--- a/toolkit/modules/NewTabUtils.jsm
+++ b/toolkit/modules/NewTabUtils.jsm
@@ -119,18 +119,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;
- }
+ // 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;
},
diff --git a/toolkit/modules/PermissionsUtils.jsm b/toolkit/modules/PermissionsUtils.jsm
index dfed76f0c..4bf43a3ec 100644
--- a/toolkit/modules/PermissionsUtils.jsm
+++ b/toolkit/modules/PermissionsUtils.jsm
@@ -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;
diff --git a/toolkit/modules/UpdateUtils.jsm b/toolkit/modules/UpdateUtils.jsm
index e92b1b797..fed7c7637 100644
--- a/toolkit/modules/UpdateUtils.jsm
+++ b/toolkit/modules/UpdateUtils.jsm
@@ -31,13 +31,9 @@ this.UpdateUtils = {
* Whether or not to include the partner bits. Default: true.
*/
getUpdateChannel(aIncludePartners = true) {
- let channel = AppConstants.MOZ_UPDATE_CHANNEL;
+ let channel = defaults.getCharPref("app.update.channel",
+ AppConstants.MOZ_UPDATE_CHANNEL);
let defaults = Services.prefs.getDefaultBranch(null);
- try {
- channel = defaults.getCharPref("app.update.channel");
- } catch (e) {
- // use default value when pref not found
- }
if (aIncludePartners) {
try {
@@ -93,15 +89,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 prefValue = Services.prefs.getDefaultBranch(null).getCharPref(aPrefName, "default");
}
/**
diff --git a/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm b/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
index cf9617ea1..4abc93ad1 100644
--- a/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
+++ b/toolkit/modules/secondscreen/SimpleServiceDiscovery.jsm
@@ -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;
diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js
index 58697cc77..27c0fede0 100644
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -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
diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
index 4cd2c3d0a..a48e0034f 100644
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -135,12 +135,7 @@ var PrefObserver = {
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;
}
@@ -791,11 +786,7 @@ var AddonManagerInternal = {
}
catch (e) { }
- 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");
@@ -808,40 +799,30 @@ var AddonManagerInternal = {
this.validateBlocklist();
}
- try {
- gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY);
- } catch (e) {}
+ gCheckCompatibility = Services.prefs.getBoolPref(PREF_EM_CHECK_COMPATIBILITY,
+ gCheckCompatibility);
Services.prefs.addObserver(PREF_EM_CHECK_COMPATIBILITY, this, false);
- try {
- gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY);
- } catch (e) {}
+ gStrictCompatibility = Services.prefs.getBoolPref(PREF_EM_STRICT_COMPATIBILITY,
+ gStrictCompatibility);
Services.prefs.addObserver(PREF_EM_STRICT_COMPATIBILITY, this, false);
- try {
- let defaultBranch = Services.prefs.getDefaultBranch("");
- gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY);
- } catch(e) {}
+ let defaultBranch = Services.prefs.getDefaultBranch("");
+ gCheckUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY,
+ gCheckUpdateSecurityDefault);
- try {
- gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY);
- } catch (e) {}
+ gCheckUpdateSecurity = Services.prefs.getBoolPref(PREF_EM_CHECK_UPDATE_SECURITY,
+ gCheckUpdateSecurity);
Services.prefs.addObserver(PREF_EM_CHECK_UPDATE_SECURITY, this, false);
- try {
- gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED);
- } catch (e) {}
+ gUpdateEnabled = Services.prefs.getBoolPref(PREF_EM_UPDATE_ENABLED, gUpdateEnabled);
Services.prefs.addObserver(PREF_EM_UPDATE_ENABLED, this, false);
- try {
- gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT);
- } catch (e) {}
+ gAutoUpdateDefault = Services.prefs.getBoolPref(PREF_EM_AUTOUPDATE_DEFAULT,
+ gAutoUpdateDefault);
Services.prefs.addObserver(PREF_EM_AUTOUPDATE_DEFAULT, 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
@@ -1167,11 +1148,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");
@@ -1182,11 +1159,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");
@@ -1197,11 +1170,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");
@@ -1212,22 +1181,14 @@ var AddonManagerInternal = {
}
case PREF_EM_UPDATE_ENABLED: {
let oldValue = gUpdateEnabled;
- 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: {
let oldValue = gAutoUpdateDefault;
- 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;
diff --git a/toolkit/mozapps/extensions/DeferredSave.jsm b/toolkit/mozapps/extensions/DeferredSave.jsm
index 89f82b265..f1537fe4b 100644
--- a/toolkit/mozapps/extensions/DeferredSave.jsm
+++ b/toolkit/mozapps/extensions/DeferredSave.jsm
@@ -64,12 +64,7 @@ var PrefObserver = {
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;
}
diff --git a/toolkit/mozapps/extensions/GMPUtils.jsm b/toolkit/mozapps/extensions/GMPUtils.jsm
index 9e41a7a61..a199b4d86 100644
--- a/toolkit/mozapps/extensions/GMPUtils.jsm
+++ b/toolkit/mozapps/extensions/GMPUtils.jsm
@@ -154,13 +154,7 @@ this.GMPPrefs = {
get: function(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);
},
diff --git a/toolkit/mozapps/extensions/LightweightThemeManager.jsm b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
index 372a9f3b8..a4cbf3833 100644
--- a/toolkit/mozapps/extensions/LightweightThemeManager.jsm
+++ b/toolkit/mozapps/extensions/LightweightThemeManager.jsm
@@ -49,12 +49,7 @@ this.__defineGetter__("_prefs", function prefsGetter() {
this.__defineGetter__("_maxUsedThemes", function maxUsedThemesGetter() {
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;
});
@@ -719,12 +714,8 @@ var _previewTimerCallback = {
function _prefObserver(aSubject, aTopic, aData) {
switch (aData) {
case "maxUsedThemes":
- try {
- _maxUsedThemes = _prefs.getIntPref(aData);
- }
- catch (e) {
- _maxUsedThemes = DEFAULT_MAX_USED_THEMES_COUNT;
- }
+ _maxUsedThemes = _prefs.getIntPref(aData, DEFAULT_MAX_USED_THEMES_COUNT);
+
// Update the theme list to remove any themes over the number we keep
_updateUsedThemes(LightweightThemeManager.usedThemes);
break;
diff --git a/toolkit/mozapps/extensions/internal/AddonLogging.jsm b/toolkit/mozapps/extensions/internal/AddonLogging.jsm
index f05a6fe6c..ffa92c791 100644
--- a/toolkit/mozapps/extensions/internal/AddonLogging.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonLogging.jsm
@@ -179,12 +179,7 @@ var PrefObserver = {
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);
}
}
};
diff --git a/toolkit/mozapps/extensions/internal/AddonRepository.jsm b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
index 76a7528c7..9750e9944 100644
--- a/toolkit/mozapps/extensions/internal/AddonRepository.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonRepository.jsm
@@ -486,14 +486,7 @@ this.AddonRepository = {
}
let preference = PREF_GETADDONS_CACHE_ENABLED;
- let enabled = false;
- try {
- enabled = Services.prefs.getBoolPref(preference);
- } catch(e) {
- logger.warn("cacheEnabled: Couldn't get pref: " + preference);
- }
-
- return enabled;
+ return Services.prefs.getBoolPref(preference, false);
},
// A cache of the add-ons stored in the database
@@ -541,11 +534,7 @@ this.AddonRepository = {
metadataAge: function() {
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) {
@@ -555,10 +544,8 @@ this.AddonRepository = {
},
isMetadataStale: function AddonRepo_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);
},
@@ -1543,10 +1530,8 @@ this.AddonRepository = {
// Create url from preference, returning null if preference does not exist
_formatURLPref: function AddonRepo_formatURLPref(aPreference, aSubstitutions) {
- let url = null;
- try {
- url = Services.prefs.getCharPref(aPreference);
- } catch(e) {
+ let url = Services.prefs.getCharPref(aPreference, "");
+ if (!url) {
logger.warn("_formatURLPref: Couldn't get pref: " + aPreference);
return null;
}
@@ -1639,10 +1624,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) => {
diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
index c06dca1d5..a475f7f1f 100644
--- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
+++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm
@@ -608,12 +608,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 {
@@ -651,12 +646,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);
diff --git a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
index f2420bd1a..69d774e4a 100644
--- a/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
+++ b/toolkit/mozapps/extensions/internal/XPIProviderUtils.js
@@ -1410,10 +1410,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) {
diff --git a/uriloader/exthandler/nsHandlerService.js b/uriloader/exthandler/nsHandlerService.js
index c932f9f5d..5e6356ac2 100644
--- a/uriloader/exthandler/nsHandlerService.js
+++ b/uriloader/exthandler/nsHandlerService.js
@@ -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;