Bug 1463782 - allow toolkit apps in kinto blocklist, r=leplatrem

MozReview-Commit-ID: G1uqNw1Njni

--HG--
extra : rebase_source : 31637d596df1a9e85d0f21cfaced08508139037b
This commit is contained in:
Gijs Kruitbosch 2018-05-23 18:01:36 +01:00
Родитель fb4762b5e6
Коммит 286e8f602d
4 изменённых файлов: 48 добавлений и 10 удалений

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

@ -147,14 +147,17 @@ async function targetAppFilter(entry, environment) {
return entry; return entry;
} }
const { appID, version: appVersion } = environment; const { appID, version: appVersion, toolkitVersion } = environment;
const { versionRange } = entry; const { versionRange } = entry;
// Everywhere in this method, we avoid checking the minVersion, because
// we want to retain items whose minVersion is higher than the current
// app version, so that we have the items around for app updates.
// Gfx blocklist has a specific versionRange object, which is not a list. // Gfx blocklist has a specific versionRange object, which is not a list.
if (!Array.isArray(versionRange)) { if (!Array.isArray(versionRange)) {
const { minVersion = "0", maxVersion = "*" } = versionRange; const { maxVersion = "*" } = versionRange;
const matchesRange = (Services.vc.compare(appVersion, minVersion) >= 0 && const matchesRange = (Services.vc.compare(appVersion, maxVersion) <= 0);
Services.vc.compare(appVersion, maxVersion) <= 0);
return matchesRange ? entry : null; return matchesRange ? entry : null;
} }
@ -173,12 +176,15 @@ async function targetAppFilter(entry, environment) {
if (!guid) { if (!guid) {
return entry; return entry;
} }
const { minVersion = "0", maxVersion = "*" } = ta; const { maxVersion = "*" } = ta;
if (guid == appID && if (guid == appID &&
Services.vc.compare(appVersion, minVersion) >= 0 &&
Services.vc.compare(appVersion, maxVersion) <= 0) { Services.vc.compare(appVersion, maxVersion) <= 0) {
return entry; return entry;
} }
if (guid == "toolkit@mozilla.org" &&
Services.vc.compare(toolkitVersion, maxVersion) <= 0) {
return entry;
}
} }
} }
// Skip this entry. // Skip this entry.

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

@ -64,6 +64,11 @@ class ClientEnvironment extends ClientEnvironmentBase {
Services.appinfo.QueryInterface(Ci.nsIXULAppInfo); Services.appinfo.QueryInterface(Ci.nsIXULAppInfo);
return Services.appinfo.ID; return Services.appinfo.ID;
} }
static get toolkitVersion() {
Services.appinfo.QueryInterface(Ci.nsIPlatformInfo);
return Services.appinfo.platformVersion;
}
} }
/** /**

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

@ -227,7 +227,7 @@ add_task(async function test_sync_event_data_is_filtered_for_target() {
let called = false; let called = false;
client.on("sync", e => called = true); client.on("sync", e => called = true);
await client.maybeSync(timestamp3 + 1, fakeServerTime - 10); await client.maybeSync(timestamp3 + 1, fakeServerTime - 10);
equal(called, false, `no sync event for ${client.collectionName}`); equal(called, false, `shouldn't have sync event for ${client.collectionName}`);
// In ?_since=5000 entries, only one entry matches. // In ?_since=5000 entries, only one entry matches.
let syncEventData; let syncEventData;
@ -546,7 +546,7 @@ function getSampleResponse(req, port) {
"versionRange": [{ "versionRange": [{
"targetApplication": [{ "targetApplication": [{
"guid": "xpcshell@tests.mozilla.org", "guid": "xpcshell@tests.mozilla.org",
"minVersion": "99999" "maxVersion": "20"
}], }],
}], }],
"id": "86771771-e803-4006-95e9-c9275d58b3d1" "id": "86771771-e803-4006-95e9-c9275d58b3d1"

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

@ -2,6 +2,7 @@ const BlocklistClients = ChromeUtils.import("resource://services-common/blocklis
const { RemoteSettings } = ChromeUtils.import("resource://services-common/remote-settings.js", {}); const { RemoteSettings } = ChromeUtils.import("resource://services-common/remote-settings.js", {});
const APP_ID = "xpcshell@tests.mozilla.org"; const APP_ID = "xpcshell@tests.mozilla.org";
const TOOLKIT_ID = "toolkit@mozilla.org";
let client; let client;
@ -84,10 +85,17 @@ add_task(async function test_returns_without_guid_or_with_matching_guid() {
guid: APP_ID, guid: APP_ID,
}] }]
}] }]
}, {
willMatch: true,
versionRange: [{
targetApplication: [{
guid: TOOLKIT_ID,
}]
}]
}]); }]);
const list = await client.get(); const list = await client.get();
equal(list.length, 2); equal(list.length, 3);
ok(list.every(e => e.willMatch)); ok(list.every(e => e.willMatch));
}); });
add_task(clear_state); add_task(clear_state);
@ -126,10 +134,29 @@ add_task(async function test_returns_without_app_version_or_with_matching_versio
maxVersion: "1", maxVersion: "1",
}] }]
}] }]
}, {
willMatch: true,
versionRange: [{
targetApplication: [{
guid: TOOLKIT_ID,
minVersion: "0",
}]
}]
}, {
willMatch: true,
versionRange: [{
targetApplication: [{
guid: TOOLKIT_ID,
minVersion: "0",
maxVersion: "9999",
}]
}]
// We can't test the false case with maxVersion for toolkit, because the toolkit version
// is 0 in xpcshell.
}]); }]);
const list = await client.get(); const list = await client.get();
equal(list.length, 3); equal(list.length, 5);
ok(list.every(e => e.willMatch)); ok(list.every(e => e.willMatch));
}); });
add_task(clear_state); add_task(clear_state);