mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 1257565 - move addon blocklist tests from services/common to the blocklist dir, r=leplatrem
Differential Revision: https://phabricator.services.mozilla.com/D29835 --HG-- rename : services/common/tests/unit/test_blocklist_clients.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_clients.js rename : services/common/tests/unit/test_blocklist_targetapp_filter.js => toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_targetapp_filter.js extra : moz-landing-system : lando
This commit is contained in:
parent
d773fd23da
commit
509b7f217a
@ -12,10 +12,6 @@ support-files =
|
||||
# Skip signature tests for Thunderbird (Bug 1341983).
|
||||
skip-if = appname == "thunderbird"
|
||||
tags = blocklist
|
||||
[test_blocklist_clients.js]
|
||||
tags = blocklist
|
||||
[test_blocklist_targetapp_filter.js]
|
||||
tags = blocklist
|
||||
[test_blocklist_pinning.js]
|
||||
tags = blocklist
|
||||
|
||||
|
@ -4,3 +4,4 @@
|
||||
let {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Services.prefs.setBoolPref("extensions.blocklist.useXML", false);
|
||||
}
|
||||
|
||||
|
@ -1,18 +1,7 @@
|
||||
const { Constructor: CC } = Components;
|
||||
|
||||
const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
|
||||
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
const { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
const { RemoteSettings } = ChromeUtils.import("resource://services-settings/remote-settings.js");
|
||||
const BlocklistClients = ChromeUtils.import("resource://services-common/blocklist-clients.js", null);
|
||||
|
||||
const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1",
|
||||
"nsIBinaryInputStream", "setInputStream");
|
||||
const BlocklistGlobal = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
|
||||
|
||||
const IS_ANDROID = AppConstants.platform == "android";
|
||||
|
||||
|
||||
let gBlocklistClients;
|
||||
let server;
|
||||
|
||||
@ -29,6 +18,8 @@ async function clear_state() {
|
||||
|
||||
|
||||
function run_test() {
|
||||
AddonTestUtils.createAppInfo("XPCShell", "xpcshell@tests.mozilla.org", "1", "");
|
||||
|
||||
// Set up an HTTP Server
|
||||
server = new HttpServer();
|
||||
server.start(-1);
|
||||
@ -47,14 +38,15 @@ function run_test() {
|
||||
Services.prefs.setBoolPref("security.remote_settings.intermediates.enabled", false);
|
||||
|
||||
// This will initialize the remote settings clients for blocklists.
|
||||
BlocklistClients.initialize();
|
||||
BlocklistGlobal.ExtensionBlocklistRS._ensureInitialized();
|
||||
BlocklistGlobal.PluginBlocklistRS._ensureInitialized();
|
||||
BlocklistGlobal.GfxBlocklistRS._ensureInitialized();
|
||||
|
||||
|
||||
// FIXME: once all the clients are migrated to Blocklist.jsm, we should move
|
||||
// the test there, too. This note is here so I don't forget.
|
||||
gBlocklistClients = [
|
||||
{client: BlocklistClients.AddonBlocklistClient, testData: ["i808", "i720", "i539"]},
|
||||
{client: BlocklistClients.PluginBlocklistClient, testData: ["p1044", "p32", "p28"]},
|
||||
{client: BlocklistClients.GfxBlocklistClient, testData: ["g204", "g200", "g36"]},
|
||||
{client: BlocklistGlobal.ExtensionBlocklistRS._client, testData: ["i808", "i720", "i539"]},
|
||||
{client: BlocklistGlobal.PluginBlocklistRS._client, testData: ["p1044", "p32", "p28"]},
|
||||
{client: BlocklistGlobal.GfxBlocklistRS._client, testData: ["g204", "g200", "g36"]},
|
||||
];
|
||||
|
||||
// Setup server fake responses.
|
||||
@ -92,18 +84,17 @@ function run_test() {
|
||||
server.registerPathHandler(pluginsRecordsPath, handleResponse);
|
||||
|
||||
|
||||
run_next_test();
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
server.stop(() => { });
|
||||
});
|
||||
promiseStartupManager().then(run_next_test);
|
||||
}
|
||||
|
||||
add_task(async function test_initial_dump_is_loaded_as_synced_when_collection_is_empty() {
|
||||
const november2016 = 1480000000000;
|
||||
|
||||
for (let {client} of gBlocklistClients) {
|
||||
if (IS_ANDROID && client.collectionName != BlocklistClients.AddonBlocklistClient.collectionName) {
|
||||
if (IS_ANDROID && client.collectionName != BlocklistGlobal.ExtensionBlocklistRS._client.collectionName) {
|
||||
// On Android we don't ship the dumps of plugins and gfx.
|
||||
continue;
|
||||
}
|
||||
@ -125,7 +116,7 @@ add_task(clear_state);
|
||||
|
||||
add_task(async function test_initial_dump_is_loaded_when_using_get_on_empty_collection() {
|
||||
for (let {client} of gBlocklistClients) {
|
||||
if (IS_ANDROID && client.collectionName != BlocklistClients.AddonBlocklistClient.collectionName) {
|
||||
if (IS_ANDROID && client.collectionName != BlocklistGlobal.ExtensionBlocklistRS._client.collectionName) {
|
||||
// On Android we don't ship the dumps of plugins and gfx.
|
||||
continue;
|
||||
}
|
||||
@ -266,15 +257,17 @@ add_task(async function test_bucketname_changes_when_bucket_pref_changes() {
|
||||
for (const { client } of gBlocklistClients) {
|
||||
equal(client.bucketName, "blocklists");
|
||||
}
|
||||
equal(BlocklistClients.PinningBlocklistClient.bucketName, "pinning");
|
||||
equal(BlocklistGlobal.ExtensionBlocklistRS._client.bucketName, "addons");
|
||||
|
||||
Services.prefs.setCharPref("services.blocklist.bucket", "blocklists-preview");
|
||||
Services.prefs.setCharPref("services.blocklist.pinning.bucket", "pinning-preview");
|
||||
Services.prefs.setCharPref("services.blocklist.addons.bucket", "addons-preview");
|
||||
|
||||
for (const { client } of gBlocklistClients) {
|
||||
equal(client.bucketName, "blocklists-preview", client.identifier);
|
||||
}
|
||||
equal(BlocklistClients.PinningBlocklistClient.bucketName, "pinning-preview");
|
||||
equal(BlocklistGlobal.ExtensionBlocklistRS._client.bucketName, "addons-preview");
|
||||
Services.prefs.clearUserPref("services.blocklist.bucket");
|
||||
Services.prefs.clearUserPref("services.blocklist.addons.bucket");
|
||||
});
|
||||
add_task(clear_state);
|
||||
|
@ -1,4 +1,4 @@
|
||||
const { BlocklistClients } = ChromeUtils.import("resource://services-common/blocklist-clients.js");
|
||||
const BlocklistGlobal = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null);
|
||||
const { RemoteSettings } = ChromeUtils.import("resource://services-settings/remote-settings.js");
|
||||
|
||||
const APP_ID = "xpcshell@tests.mozilla.org";
|
||||
@ -22,9 +22,10 @@ async function createRecords(records) {
|
||||
|
||||
|
||||
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.
|
||||
BlocklistClients.initialize();
|
||||
BlocklistGlobal.PluginBlocklistRS._ensureInitialized();
|
||||
// Obtain one of the instantiated client for our tests.
|
||||
client = RemoteSettings("plugins", { bucketName: "blocklists" });
|
||||
|
||||
@ -35,6 +36,7 @@ add_task(async function test_returns_all_without_target() {
|
||||
await createRecords([{
|
||||
matchName: "Adobe Flex",
|
||||
}, {
|
||||
matchName: "foopydoo",
|
||||
versionRange: [],
|
||||
}, {
|
||||
matchName: "PDF reader",
|
||||
@ -51,6 +53,7 @@ add_task(async function test_returns_all_without_target() {
|
||||
}],
|
||||
matchFilename: "libnpjp2\\.so",
|
||||
}, {
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [],
|
||||
maxVersion: "1",
|
||||
@ -67,12 +70,14 @@ add_task(clear_state);
|
||||
add_task(async function test_returns_without_guid_or_with_matching_guid() {
|
||||
await createRecords([{
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
}],
|
||||
}],
|
||||
}, {
|
||||
willMatch: false,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: "some-guid",
|
||||
@ -80,6 +85,7 @@ add_task(async function test_returns_without_guid_or_with_matching_guid() {
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -87,6 +93,7 @@ add_task(async function test_returns_without_guid_or_with_matching_guid() {
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: TOOLKIT_ID,
|
||||
@ -95,6 +102,7 @@ add_task(async function test_returns_without_guid_or_with_matching_guid() {
|
||||
}]);
|
||||
|
||||
const list = await client.get();
|
||||
info(JSON.stringify(list, null, 2));
|
||||
equal(list.length, 3);
|
||||
ok(list.every(e => e.willMatch));
|
||||
});
|
||||
@ -103,6 +111,7 @@ add_task(clear_state);
|
||||
add_task(async function test_returns_without_app_version_or_with_matching_version() {
|
||||
await createRecords([{
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -110,6 +119,7 @@ add_task(async function test_returns_without_app_version_or_with_matching_versio
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -118,6 +128,7 @@ add_task(async function test_returns_without_app_version_or_with_matching_versio
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -127,6 +138,7 @@ add_task(async function test_returns_without_app_version_or_with_matching_versio
|
||||
}],
|
||||
}, {
|
||||
willMatch: false,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -136,6 +148,7 @@ add_task(async function test_returns_without_app_version_or_with_matching_versio
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: TOOLKIT_ID,
|
||||
@ -144,6 +157,7 @@ add_task(async function test_returns_without_app_version_or_with_matching_versio
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: TOOLKIT_ID,
|
||||
@ -164,6 +178,7 @@ add_task(clear_state);
|
||||
add_task(async function test_multiple_version_and_target_applications() {
|
||||
await createRecords([{
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: "other-guid",
|
||||
@ -177,6 +192,7 @@ add_task(async function test_multiple_version_and_target_applications() {
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: "other-guid",
|
||||
@ -189,6 +205,7 @@ add_task(async function test_multiple_version_and_target_applications() {
|
||||
}],
|
||||
}, {
|
||||
willMatch: false,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -214,6 +231,7 @@ add_task(clear_state);
|
||||
add_task(async function test_complex_version() {
|
||||
await createRecords([{
|
||||
willMatch: false,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -222,6 +240,7 @@ add_task(async function test_complex_version() {
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
||||
@ -230,6 +249,7 @@ add_task(async function test_complex_version() {
|
||||
}],
|
||||
}, {
|
||||
willMatch: true,
|
||||
matchName: "foopydoo",
|
||||
versionRange: [{
|
||||
targetApplication: [{
|
||||
guid: APP_ID,
|
@ -9,6 +9,7 @@ support-files =
|
||||
[test_blocklist_appversion.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_clients.js]
|
||||
[test_blocklist_gfx.js]
|
||||
[test_blocklist_metadata_filters.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
@ -29,6 +30,7 @@ skip-if = os == "android"
|
||||
[test_blocklist_severities.js]
|
||||
# Bug 676992: test consistently hangs on Android
|
||||
skip-if = os == "android"
|
||||
[test_blocklist_targetapp_filter.js]
|
||||
[test_blocklistchange.js]
|
||||
# Times out during parallel runs on desktop
|
||||
requesttimeoutfactor = 2
|
||||
|
Loading…
x
Reference in New Issue
Block a user