Bug 1454563 - actually add real fallback from profile to appdir blocklist if loading the profile one fails, r=kmag
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Tue, 17 Apr 2018 23:56:45 +0100
changeset 467780 c513037dd5511c2d34e73aa22d9e70d6c18bd15c
parent 467779 897bbf35e781fc7067b7e358379fad54d5342a4f
child 467781 40b4fba437ca6e5c136c5bafa22e13ae07427c81
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1454563
milestone61.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 1454563 - actually add real fallback from profile to appdir blocklist if loading the profile one fails, r=kmag MozReview-Commit-ID: AbRLwACqrzU
toolkit/mozapps/extensions/nsBlocklistService.js
--- a/toolkit/mozapps/extensions/nsBlocklistService.js
+++ b/toolkit/mozapps/extensions/nsBlocklistService.js
@@ -810,41 +810,41 @@ Blocklist.prototype = {
 
     if (!gBlocklistEnabled) {
       LOG("Blocklist::_preloadBlocklistFile: blocklist is disabled");
       return;
     }
 
     let text = await OS.File.read(path, { encoding: "utf-8" });
 
-    await new Promise(resolve => {
-      Services.tm.idleDispatchToMainThread(() => {
+    await new Promise((resolve, reject) => {
+      ChromeUtils.idleDispatch(() => {
         if (!this.isLoaded) {
           Services.telemetry.getHistogramById("BLOCKLIST_SYNC_FILE_LOAD").add(false);
-          this._loadBlocklistFromString(text);
+          try {
+            this._loadBlocklistFromString(text);
+          } catch (ex) {
+            // Loading the blocklist failed. Ensure the caller knows.
+            reject(ex);
+          }
         }
         resolve();
       });
     });
   },
 
   _loadBlocklistFromString(text) {
-    try {
-      var parser = Cc["@mozilla.org/xmlextras/domparser;1"].
-                   createInstance(Ci.nsIDOMParser);
-      var doc = parser.parseFromString(text, "text/xml");
-      if (doc.documentElement.namespaceURI != XMLURI_BLOCKLIST) {
-        LOG("Blocklist::_loadBlocklistFromString: aborting due to incorrect " +
-            "XML Namespace.\r\nExpected: " + XMLURI_BLOCKLIST + "\r\n" +
-            "Received: " + doc.documentElement.namespaceURI);
-        return;
-      }
-    } catch (e) {
-      LOG("Blocklist::_loadBlocklistFromString: Error constructing blocklist " + e);
-      return;
+    var parser = Cc["@mozilla.org/xmlextras/domparser;1"].
+                 createInstance(Ci.nsIDOMParser);
+    var doc = parser.parseFromString(text, "text/xml");
+    if (doc.documentElement.namespaceURI != XMLURI_BLOCKLIST) {
+      LOG("Blocklist::_loadBlocklistFromString: aborting due to incorrect " +
+          "XML Namespace.\r\nExpected: " + XMLURI_BLOCKLIST + "\r\n" +
+          "Received: " + doc.documentElement.namespaceURI);
+      throw new Error("Couldn't find an XML doc with the right namespace!");
     }
     this._loadBlocklistFromXML(doc);
   },
 
   _loadBlocklistFromXML(doc) {
     this._addonEntries = [];
     this._gfxEntries = [];
     this._pluginEntries = [];