Bug 1454563 - actually add real fallback from profile to appdir blocklist if loading the profile one fails, r?kmag
MozReview-Commit-ID: AbRLwACqrzU
--- 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 = [];