Bug 1718749 - Filter blocked sponsored top sites from RemoteSettings when Contile is enabled r=dao

Differential Revision: https://phabricator.services.mozilla.com/D119019
This commit is contained in:
Nan Jiang 2021-07-05 13:22:33 +00:00
Родитель b3cd1ccf21
Коммит 1afd3a5c8e
2 изменённых файлов: 20 добавлений и 2 удалений

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

@ -363,7 +363,6 @@ this.TopSitesFeed = class TopSitesFeed {
// Also drop those sponsored sites that were blocked by the user before
// with the same hostname.
if (
!contileEnabled &&
siteData.sponsored_position &&
sponsoredBlocklist.includes(hostname)
) {

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

@ -2168,12 +2168,31 @@ describe("Top Sites Feed", () => {
sandbox.restore();
});
it("should filter all blocked sponsored tiles from RemoteSettings", async () => {
it("should filter all blocked sponsored tiles from RemoteSettings when Contile is disabled", async () => {
sandbox.stub(feed, "_getRemoteConfig").resolves([
{ url: "https://foo.com", title: "foo", sponsored_position: 1 },
{ url: "https://bar.com", title: "bar", sponsored_position: 2 },
{ url: "https://test.com", title: "test", sponsored_position: 3 },
]);
global.Services.prefs.getStringPref
.withArgs(CONTILE_ENABLED_PREF)
.returns(false);
await feed._readDefaults();
assert.equal(DEFAULT_TOP_SITES.length, 1);
assert.equal(DEFAULT_TOP_SITES[0].label, "test");
});
it("should also filter all blocked sponsored tiles from RemoteSettings when Contile is enabled", async () => {
sandbox.stub(feed, "_getRemoteConfig").resolves([
{ url: "https://foo.com", title: "foo", sponsored_position: 1 },
{ url: "https://bar.com", title: "bar", sponsored_position: 2 },
{ url: "https://test.com", title: "test", sponsored_position: 3 },
]);
global.Services.prefs.getStringPref
.withArgs(CONTILE_ENABLED_PREF)
.returns(true);
await feed._readDefaults();