зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
9f69f88101
Коммит
b4b45450ff
|
@ -28,7 +28,7 @@ class Feature {
|
|||
}
|
||||
}
|
||||
|
||||
async addObserver(observer) {
|
||||
async addAndRunObserver(observer) {
|
||||
this.observers.add(observer);
|
||||
this.notifyObservers(observer);
|
||||
}
|
||||
|
@ -58,19 +58,16 @@ 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(",");
|
||||
}
|
||||
|
||||
if (this.remoteEntries) {
|
||||
for (let entry of this.remoteEntries) {
|
||||
entries.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
let entriesAsString = entries.join(",").toLowerCase();
|
||||
if (observer) {
|
||||
|
@ -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"
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче