Bug 1557790 - fix initialization of blocklist clients, r=aswan

In order for the remote settings blocklist to sync, we need to ensure that
the corresponding remote settings clients are created (see also
https://bugzilla.mozilla.org/show_bug.cgi?id=1557790#c2 ). This is
necessary because the blocklist clients are not in the `main` bucket.

This would otherwise happen as soon as any consumer asked the blocklist
for any block data, but that's not going to happen unless the list of
add-ons or plugins changes. Even if there are no changes to the local
lists of installed things, we do need blocklist updates because
otherwise already-installed items would never get blocked even if/when
they are added to the blocklist.

The client initialization should have no other side effects (in terms of
performance/cost) beyond ensuring they get included in things we ask for
when the update-timer fires.

Differential Revision: https://phabricator.services.mozilla.com/D34550

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-06-11 18:39:45 +00:00
Родитель 69303ee81f
Коммит 01a67ca408
5 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -272,7 +272,7 @@ let JSONBlocklistWrapper = {
item.last_modified = Date.now();
}
}
await blocklistObj._ensureInitialized();
await blocklistObj.ensureInitialized();
let collection = await blocklistObj._client.openCollection();
await collection.clear();
await collection.loadDump(newData);

Просмотреть файл

@ -512,7 +512,7 @@ this.PluginBlocklistRS = {
},
async _ensureEntries() {
await this._ensureInitialized();
await this.ensureInitialized();
if (!this._entries && gBlocklistEnabled) {
await this._updateEntries();
@ -564,7 +564,7 @@ this.PluginBlocklistRS = {
return entry;
},
async _ensureInitialized() {
async ensureInitialized() {
if (!gBlocklistEnabled || this._initialized) {
return;
}
@ -587,7 +587,7 @@ this.PluginBlocklistRS = {
async _onUpdate() {
let oldEntries = this._entries || [];
await this._ensureInitialized();
await this.ensureInitialized();
await this._updateEntries();
const pluginHost = Cc["@mozilla.org/plugin/host;1"].
getService(Ci.nsIPluginHost);
@ -883,7 +883,7 @@ this.PluginBlocklistRS = {
*/
this.ExtensionBlocklistRS = {
async _ensureEntries() {
await this._ensureInitialized();
await this.ensureInitialized();
if (!this._entries && gBlocklistEnabled) {
await this._updateEntries();
}
@ -940,7 +940,7 @@ this.ExtensionBlocklistRS = {
return entry;
},
async _ensureInitialized() {
async ensureInitialized() {
if (!gBlocklistEnabled || this._initialized) {
return;
}
@ -963,7 +963,7 @@ this.ExtensionBlocklistRS = {
async _onUpdate() {
let oldEntries = this._entries || [];
await this._ensureInitialized();
await this.ensureInitialized();
await this._updateEntries();
const types = ["extension", "theme", "locale", "dictionary", "service"];
@ -2531,6 +2531,8 @@ let BlocklistRS = {
loadBlocklistAsync() {
// Need to ensure we notify gfx of new stuff.
GfxBlocklistRS.checkForEntries();
ExtensionBlocklistRS.ensureInitialized();
PluginBlocklistRS.ensureInitialized();
// Also ensure that if we start the other service after this, we
// initialize it straight away.
gLoadingWasTriggered = true;

Просмотреть файл

@ -770,7 +770,7 @@ var AddonTestUtils = {
item.last_modified = Date.now();
}
}
await blocklistObj._ensureInitialized();
await blocklistObj.ensureInitialized();
let collection = await blocklistObj._client.openCollection();
await collection.clear();
await collection.loadDump(newData);

Просмотреть файл

@ -21,8 +21,8 @@ function run_test() {
AddonTestUtils.createAppInfo("XPCShell", "xpcshell@tests.mozilla.org", "1", "");
// This will initialize the remote settings clients for blocklists.
BlocklistGlobal.ExtensionBlocklistRS._ensureInitialized();
BlocklistGlobal.PluginBlocklistRS._ensureInitialized();
BlocklistGlobal.ExtensionBlocklistRS.ensureInitialized();
BlocklistGlobal.PluginBlocklistRS.ensureInitialized();
BlocklistGlobal.GfxBlocklistRS._ensureInitialized();
gBlocklistClients = [

Просмотреть файл

@ -25,7 +25,7 @@ function run_test() {
AddonTestUtils.createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "58", "");
// This will initialize the remote settings clients for blocklists,
// with their specific options etc.
BlocklistGlobal.PluginBlocklistRS._ensureInitialized();
BlocklistGlobal.PluginBlocklistRS.ensureInitialized();
// Obtain one of the instantiated client for our tests.
client = RemoteSettings("plugins", { bucketName: "blocklists" });