diff --git a/toolkit/components/url-classifier/SafeBrowsing.jsm b/toolkit/components/url-classifier/SafeBrowsing.jsm index 32cab18c187f..9a23c4e865a1 100644 --- a/toolkit/components/url-classifier/SafeBrowsing.jsm +++ b/toolkit/components/url-classifier/SafeBrowsing.jsm @@ -130,6 +130,17 @@ this.SafeBrowsing = { } }, + unregisterTables(obsoleteLists) { + let listManager = Cc["@mozilla.org/url-classifier/listmanager;1"]. + getService(Ci.nsIUrlListManager); + + for (let i = 0; i < obsoleteLists.length; ++i) { + for (let j = 0; j < obsoleteLists[i].length; ++j) { + listManager.unregisterTable(obsoleteLists[i][j]); + } + } + }, + initialized: false, phishingEnabled: false, @@ -225,6 +236,21 @@ this.SafeBrowsing = { flashExceptTable, flashSubDocTable, flashSubDocExceptTable; + let obsoleteLists; + // Make a copy of the original lists before we re-read the prefs. + if (this.initialized) { + obsoleteLists = [this.phishingLists, + this.malwareLists, + this.downloadBlockLists, + this.downloadAllowLists, + this.passwordAllowLists, + this.trackingProtectionLists, + this.trackingProtectionWhitelists, + this.blockedLists, + this.flashLists, + this.flashInfobarLists]; + } + [this.phishingLists, this.malwareLists, this.downloadBlockLists, @@ -247,8 +273,29 @@ this.SafeBrowsing = { flashSubDocTable, flashSubDocExceptTable) + if (obsoleteLists) { + let newLists = [this.phishingLists, + this.malwareLists, + this.downloadBlockLists, + this.downloadAllowLists, + this.passwordAllowLists, + this.trackingProtectionLists, + this.trackingProtectionWhitelists, + this.blockedLists, + this.flashLists, + this.flashInfobarLists]; + + for (let i = 0; i < obsoleteLists.length; ++i) { + obsoleteLists[i] = obsoleteLists[i] + .filter(list => newLists[i].indexOf(list) == -1); + } + } + this.updateProviderURLs(); this.registerTables(); + if (obsoleteLists) { + this.unregisterTables(obsoleteLists); + } // XXX The listManager backend gets confused if this is called before the // lists are registered. So only call it here when a pref changes, and not diff --git a/toolkit/components/url-classifier/nsIUrlListManager.idl b/toolkit/components/url-classifier/nsIUrlListManager.idl index 18bed4e02e0b..73c8d59d1918 100644 --- a/toolkit/components/url-classifier/nsIUrlListManager.idl +++ b/toolkit/components/url-classifier/nsIUrlListManager.idl @@ -39,6 +39,11 @@ interface nsIUrlListManager : nsISupports in ACString updateUrl, in ACString gethashUrl); + /** + * Unregister table from the list + */ + void unregisterTable(in ACString tableName); + /** * Turn on update checking for a table. I.e., during the next server * check, download updates for this table. diff --git a/toolkit/components/url-classifier/nsUrlClassifierListManager.js b/toolkit/components/url-classifier/nsUrlClassifierListManager.js index 5f0a1432650b..5f10933163b6 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierListManager.js +++ b/toolkit/components/url-classifier/nsUrlClassifierListManager.js @@ -108,6 +108,24 @@ PROT_ListManager.prototype.registerTable = function(tableName, return true; } +/** + * Unregister a table table from list + */ +PROT_ListManager.prototype.unregisterTable = function(tableName) { + log("unregistering " + tableName); + var table = this.tablesData[tableName]; + if (table) { + if (!this.updatesNeeded_(table.updateUrl) && + this.updateCheckers_[table.updateUrl]) { + this.updateCheckers_[table.updateUrl].cancel(); + this.updateCheckers_[table.updateUrl] = null; + } + delete this.needsUpdate_[table.updateUrl][tableName]; + } + delete this.tablesData[tableName]; + +} + /** * Delete all of our data tables which seem to leak otherwise. * Remove observers diff --git a/toolkit/components/url-classifier/tests/mochitest/chrome.ini b/toolkit/components/url-classifier/tests/mochitest/chrome.ini index bb8f2f3637a9..accf609d6723 100644 --- a/toolkit/components/url-classifier/tests/mochitest/chrome.ini +++ b/toolkit/components/url-classifier/tests/mochitest/chrome.ini @@ -27,6 +27,7 @@ tags = trackingprotection [test_safebrowsing_bug1272239.html] [test_donottrack.html] [test_classifier_changetablepref.html] +[test_classifier_changetablepref_bug1395411.html] [test_reporturl.html] [test_trackingprotection_bug1312515.html] [test_advisory_link.html] diff --git a/toolkit/components/url-classifier/tests/mochitest/test_classifier_changetablepref_bug1395411.html b/toolkit/components/url-classifier/tests/mochitest/test_classifier_changetablepref_bug1395411.html new file mode 100644 index 000000000000..dbf1a3bb0d78 --- /dev/null +++ b/toolkit/components/url-classifier/tests/mochitest/test_classifier_changetablepref_bug1395411.html @@ -0,0 +1,74 @@ + + + +
++ + ++ + + +