Bug 1362466 - Skip default handler injection if pref gecko.handlerService.defaultHandlersVersion not defined. r=paolo
authorJorg K <jorgk@jorgk.com>
Sun, 07 May 2017 10:46:00 -0400
changeset 356992 844ef25e35bb83515dee2fc36f6eb7fde68c1a77
parent 356991 cd18a17db3156e8deb15bf1bfee01d8b5209f71a
child 356993 2999dc55b60bc3ca941611f5b4568574595acc95
push id31778
push usercbook@mozilla.com
push dateMon, 08 May 2017 08:07:41 +0000
treeherdermozilla-central@1fda52a1f3b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1362466
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1362466 - Skip default handler injection if pref gecko.handlerService.defaultHandlersVersion not defined. r=paolo
uriloader/exthandler/nsHandlerService-json.js
--- a/uriloader/exthandler/nsHandlerService-json.js
+++ b/uriloader/exthandler/nsHandlerService-json.js
@@ -117,21 +117,33 @@ HandlerService.prototype = {
   },
 
   /**
    * Injects new default protocol handlers if the version in the preferences is
    * newer than the one in the data store. If we just imported data from the RDF
    * back-end, we only need to update the version in the data store.
    */
   _injectDefaultProtocolHandlersIfNeeded(alreadyInjected) {
+    let prefsDefaultHandlersVersion;
     try {
+      prefsDefaultHandlersVersion = Services.prefs.getComplexValue(
+        "gecko.handlerService.defaultHandlersVersion",
+        Ci.nsIPrefLocalizedString);
+    } catch (ex) {
+      if (ex instanceof Components.Exception &&
+          ex.result == Cr.NS_ERROR_UNEXPECTED) {
+        // This platform does not have any default protocol handlers configured.
+        return;
+      }
+      throw ex;
+    }
+
+    try {
+      prefsDefaultHandlersVersion = Number(prefsDefaultHandlersVersion.data);
       let locale = Services.locale.getAppLocaleAsLangTag();
-      let prefsDefaultHandlersVersion = Number(Services.prefs.getComplexValue(
-        "gecko.handlerService.defaultHandlersVersion",
-        Ci.nsIPrefLocalizedString).data);
 
       let defaultHandlersVersion =
           this._store.data.defaultHandlersVersion[locale] || 0;
       if (defaultHandlersVersion < prefsDefaultHandlersVersion) {
         if (!alreadyInjected) {
           this._injectDefaultProtocolHandlers();
         }
         this._store.data.defaultHandlersVersion[locale] =