Bug 1636371 - UrlClassifierSkipListService.jsm should call the observer even when RemoteSettings have not been received yet, r=johannh

Differential Revision: https://phabricator.services.mozilla.com/D73925
This commit is contained in:
Andrea Marchesini 2020-05-08 06:16:49 +00:00
Родитель 9f69f88101
Коммит b4b45450ff
2 изменённых файлов: 11 добавлений и 11 удалений

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

@ -28,7 +28,7 @@ class Feature {
}
}
async addObserver(observer) {
async addAndRunObserver(observer) {
this.observers.add(observer);
this.notifyObservers(observer);
}
@ -58,18 +58,15 @@ class Feature {
}
notifyObservers(observer = null) {
// Don't notify until we have the initial data.
if (!this.remoteEntries) {
return;
}
let entries = [];
if (this.prefValue) {
entries = this.prefValue.split(",");
}
for (let entry of this.remoteEntries) {
entries.push(entry);
if (this.remoteEntries) {
for (let entry of this.remoteEntries) {
entries.push(entry);
}
}
let entriesAsString = entries.join(",").toLowerCase();
@ -153,7 +150,7 @@ UrlClassifierSkipListService.prototype = {
featureObj.onRemoteSettingsUpdate(this.entries);
}
}
this.features[feature].addObserver(observer);
this.features[feature].addAndRunObserver(observer);
},
unregisterSkipListObserver(feature, observer) {

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

@ -69,8 +69,10 @@ add_task(async function test_list_changes() {
obs
);
let list = await promise;
Assert.equal(await promise, "", "No items in the list");
// Second event is from the RemoteSettings record.
let list = await waitForEvent(updateEvent, "update");
Assert.equal(list, "example.com", "Has one item in the list");
records.push(
@ -203,9 +205,10 @@ add_task(async function test_list_init_data() {
);
let list = await promise;
Assert.equal(list, "", "Empty list initially");
Assert.equal(
list,
await waitForEvent(updateEvent, "update"),
"tracking.example.com,*.tracking.org",
"Has several items in the list"
);