Backed out 5 changesets (bug 1706391) for xpcshell failures at test_gfxBlacklist_Equal_DriverNew.js.

CLOSED TREE

Backed out changeset ccd2f9b9c513 (bug 1706391)
Backed out changeset 4abbf0ced8b8 (bug 1706391)
Backed out changeset 51ed9a912826 (bug 1706391)
Backed out changeset 90724663c6c4 (bug 1706391)
Backed out changeset 6d733a44225a (bug 1706391)
This commit is contained in:
Brindusan Cristian 2021-06-04 22:28:37 +03:00
Родитель 44b5033186
Коммит be4ce39d9a
29 изменённых файлов: 288 добавлений и 252 удалений

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

@ -44,6 +44,10 @@ pref("extensions.getAddons.link.url", "https://addons.mozilla.org/%LOCALE%/firef
pref("extensions.getAddons.langpacks.url", "https://services.addons.mozilla.org/api/v4/addons/language-tools/?app=firefox&type=language&appversion=%VERSION%");
pref("extensions.getAddons.discovery.api_url", "https://services.addons.mozilla.org/api/v4/discovery/?lang=%LOCALE%&edition=%DISTRIBUTION%");
// Use bloomfilters for the addons blocklist, instead of JSON only.
pref("extensions.blocklist.useMLBF", true);
pref("extensions.blocklist.useMLBF.stashes", true);
// The URL for the privacy policy related to recommended extensions.
pref("extensions.recommendations.privacyPolicyUrl", "https://www.mozilla.org/privacy/firefox/?utm_source=firefox-browser&utm_medium=firefox-browser&utm_content=privacy-policy-link#addons");
// The URL for Firefox Color, recommended on the theme page in about:addons.

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

@ -161,9 +161,6 @@ pref("xpinstall.whitelist.add", "https://addons.mozilla.org");
pref("extensions.langpacks.signatures.required", true);
pref("xpinstall.signatures.required", true);
// Use blocklist v2 until blocklist v3 is enabled on Android - bug 1639050
pref("extensions.blocklist.useMLBF", false);
// Disable add-ons that are not installed by the user in all scopes by default (See the SCOPE
// constants in AddonManager.jsm for values to use here, and Bug 1405528 for a rationale).
pref("extensions.autoDisableScopes", 15);

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

@ -2209,6 +2209,8 @@ pref("extensions.abuseReport.amoDetailsURL", "https://services.addons.mozilla.or
// Blocklist preferences
pref("extensions.blocklist.enabled", true);
pref("extensions.blocklist.useMLBF", false);
pref("extensions.blocklist.useMLBF.stashes", false);
// Required blocklist freshness for OneCRL OCSP bypass (default is 30 hours)
// Note that this needs to exceed the interval at which we update OneCRL data,
// configured in services.settings.poll_interval .
@ -2224,7 +2226,9 @@ pref("services.blocklist.bucket", "blocklists");
pref("services.blocklist.addons.collection", "addons");
pref("services.blocklist.addons.checked", 0);
pref("services.blocklist.addons.signer", "remote-settings.content-signature.mozilla.org");
pref("services.blocklist.addons-mlbf.collection", "addons-bloomfilters");
pref("services.blocklist.addons-mlbf.checked", 0);
pref("services.blocklist.addons-mlbf.signer", "remote-settings.content-signature.mozilla.org");
pref("services.blocklist.plugins.collection", "plugins");
pref("services.blocklist.plugins.checked", 0);
pref("services.blocklist.plugins.signer", "remote-settings.content-signature.mozilla.org");

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

@ -243,7 +243,6 @@ class RemoteSettingsClient extends EventEmitter {
constructor(
collectionName,
{
bucketName,
bucketNamePref,
signerName,
filterFunc,
@ -254,7 +253,6 @@ class RemoteSettingsClient extends EventEmitter {
super(["sync"]); // emitted events
this.collectionName = collectionName;
this.bucketName = bucketName;
this.signerName = signerName;
this.filterFunc = filterFunc;
this.localFields = localFields;
@ -266,21 +264,18 @@ class RemoteSettingsClient extends EventEmitter {
// or when pulling data from a dev server.
this.verifySignature = AppConstants.REMOTE_SETTINGS_VERIFY_SIGNATURE;
if (!bucketName) {
// TODO bug 1702759: Remove bucketNamePref.
// The bucket preference value can be changed (eg. `main` to `main-preview`) in order
// to preview the changes to be approved in a real client.
this.bucketNamePref = bucketNamePref;
XPCOMUtils.defineLazyPreferenceGetter(
this,
"bucketName",
this.bucketNamePref,
null,
() => {
this.db.identifier = this.identifier;
}
);
}
// The bucket preference value can be changed (eg. `main` to `main-preview`) in order
// to preview the changes to be approved in a real client.
this.bucketNamePref = bucketNamePref;
XPCOMUtils.defineLazyPreferenceGetter(
this,
"bucketName",
this.bucketNamePref,
null,
() => {
this.db.identifier = this.identifier;
}
);
XPCOMUtils.defineLazyGetter(
this,

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

@ -8,15 +8,12 @@ with Files("**"):
BUG_COMPONENT = ("Toolkit", "Blocklist Implementation")
# The addons blocklist is also in mobile/android/installer/package-manifest.in
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
# Remove this once bug 1639050 is resolved.
FINAL_TARGET_FILES.defaults.settings.blocklists += ["addons.json"]
else:
FINAL_TARGET_FILES.defaults.settings.blocklists += [
"addons-bloomfilters.json",
"gfx.json",
"plugins.json",
]
FINAL_TARGET_FILES.defaults.settings.blocklists += [
"addons-bloomfilters.json",
"addons.json",
"gfx.json",
"plugins.json",
]
FINAL_TARGET_FILES.defaults.settings.blocklists["addons-bloomfilters"] += [
"addons-bloomfilters/addons-mlbf.bin",

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

@ -445,9 +445,9 @@ add_task(async function test_download_cached() {
add_task(clear_state);
add_task(async function test_download_from_dump() {
const client = RemoteSettings("dump-collection", {
bucketName: "dump-bucket",
});
const bucketNamePref = "services.testing.custom-bucket-name-in-this-test";
Services.prefs.setCharPref(bucketNamePref, "dump-bucket");
const client = RemoteSettings("dump-collection", { bucketNamePref });
// Temporarily replace the resource:-URL with another resource:-URL.
const orig_RESOURCE_BASE_URL = Downloader._RESOURCE_BASE_URL;

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

@ -953,20 +953,6 @@ add_task(async function test_bucketname_changes_when_bucket_pref_changes() {
});
add_task(clear_state);
add_task(async function test_bucket_pref_ignored_when_bucketName_set() {
let clientWithBucket = RemoteSettings("coll", { bucketName: "buck" });
equal(clientWithBucket.collectionName, "coll");
equal(clientWithBucket.bucketName, "buck");
Services.prefs.setCharPref(
"services.settings.default_bucket",
"coll-preview"
);
equal(clientWithBucket.bucketName, "buck");
});
add_task(clear_state);
add_task(
async function test_get_loads_default_records_from_a_local_dump_if_preview_collection() {
if (IS_ANDROID) {

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

@ -5928,6 +5928,29 @@ blocklist:
record_in_processes:
- main
mlbf_stashes:
bug_numbers:
- 1633466
- 1649960
- 1689274
description: >
Keep track of whether the bloomfilter-based blocklist engine uses stashes from the
addons-bloomfilters collection, together with an infrequently updated base bloomfilter.
If false, the latest (full) bloom filter is downloaded on every update of the addon blocklist.
This metric is only meaningful if mlbf_enabled is true.
expires: "95"
kind: boolean
release_channel_collection: opt-out
notification_emails:
- addons-dev-internal@mozilla.com
- lgreco@mozilla.com
- awagner@mozilla.com
- rwu@mozilla.com
products:
- 'firefox'
record_in_processes:
- main
mlbf_source:
bug_numbers:
- 1662857
@ -5984,7 +6007,7 @@ blocklist:
- 1689274
description: >
Keep track of the timestamp of the oldest stash of the addons blocklist.
Only meaningful when mlbf_enabled is true.
Only meaningful when mlbf_enabled and mlbf_stashes are true.
The value is a datetime string in UTC format, or "Missing Date" when unavailable.
expires: "95"
kind: string
@ -6006,7 +6029,7 @@ blocklist:
- 1689274
description: >
Keep track of the timestamp of the most recent stash of the addons blocklist.
Only meaningful when mlbf_enabled is true.
Only meaningful when mlbf_enabled and mlbf_stashes are true.
The value is a datetime string in UTC format, or "Missing Date" when unavailable.
expires: "95"
kind: string

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

@ -137,6 +137,7 @@ const PREF_BLOCKLIST_ADDONITEM_URL = "extensions.blocklist.addonItemURL";
const PREF_BLOCKLIST_ENABLED = "extensions.blocklist.enabled";
const PREF_BLOCKLIST_LEVEL = "extensions.blocklist.level";
const PREF_BLOCKLIST_USE_MLBF = "extensions.blocklist.useMLBF";
const PREF_BLOCKLIST_USE_MLBF_STASHES = "extensions.blocklist.useMLBF.stashes";
const PREF_EM_LOGGING_ENABLED = "extensions.logging.enabled";
const DEFAULT_SEVERITY = 3;
const DEFAULT_LEVEL = 2;
@ -153,8 +154,11 @@ const PREF_BLOCKLIST_ADDONS_CHECKED_SECONDS =
"services.blocklist.addons.checked";
const PREF_BLOCKLIST_ADDONS_SIGNER = "services.blocklist.addons.signer";
// Blocklist v3 - MLBF format.
const PREF_BLOCKLIST_ADDONS3_COLLECTION =
"services.blocklist.addons-mlbf.collection";
const PREF_BLOCKLIST_ADDONS3_CHECKED_SECONDS =
"services.blocklist.addons-mlbf.checked";
const PREF_BLOCKLIST_ADDONS3_SIGNER = "services.blocklist.addons-mlbf.signer";
const BlocklistTelemetry = {
init() {
@ -935,6 +939,14 @@ this.ExtensionBlocklistRS = {
* "attachment_type": "bloomfilter-base",
* }
*
* To update the blocklist, a replacement MLBF is published:
*
* {
* "generation_time": 1585692000000,
* "attachment": { ... RemoteSettings attachment ... }
* "attachment_type": "bloomfilter-full",
* }
*
* The collection can also contain stashes:
*
* {
@ -946,6 +958,8 @@ this.ExtensionBlocklistRS = {
*
* Stashes can be used to update the blocklist without forcing the whole MLBF
* to be downloaded again. These stashes are applied on top of the base MLBF.
* The use of stashes is currently optional, and toggled via the
* extensions.blocklist.useMLBF.stashes preference (true = use stashes).
*
* Note: we assign to the global to allow tests to reach the object directly.
*/
@ -1008,7 +1022,6 @@ this.ExtensionBlocklistMLBF = {
this._stashes = null;
return;
}
let records = await this._client.get();
if (isUpdateReplaced()) {
return;
@ -1018,26 +1031,36 @@ this.ExtensionBlocklistMLBF = {
.filter(r => r.attachment)
// Newest attachments first.
.sort((a, b) => b.generation_time - a.generation_time);
const mlbfRecord = mlbfRecords.find(
r => r.attachment_type == "bloomfilter-base"
);
this._stashes = records
.filter(({ stash }) => {
return (
// Exclude non-stashes, e.g. MLBF attachments.
stash &&
// Sanity check for type.
Array.isArray(stash.blocked) &&
Array.isArray(stash.unblocked)
);
})
// Sort by stash time - newest first.
.sort((a, b) => b.stash_time - a.stash_time)
.map(({ stash, stash_time }) => ({
blocked: new Set(stash.blocked),
unblocked: new Set(stash.unblocked),
stash_time,
}));
let mlbfRecord;
if (this.stashesEnabled) {
mlbfRecord = mlbfRecords.find(
r => r.attachment_type == "bloomfilter-base"
);
this._stashes = records
.filter(({ stash }) => {
return (
// Exclude non-stashes, e.g. MLBF attachments.
stash &&
// Sanity check for type.
Array.isArray(stash.blocked) &&
Array.isArray(stash.unblocked)
);
})
// Sort by stash time - newest first.
.sort((a, b) => b.stash_time - a.stash_time)
.map(({ stash, stash_time }) => ({
blocked: new Set(stash.blocked),
unblocked: new Set(stash.unblocked),
stash_time,
}));
} else {
mlbfRecord = mlbfRecords.find(
r =>
r.attachment_type == "bloomfilter-full" ||
r.attachment_type == "bloomfilter-base"
);
this._stashes = null;
}
let mlbf = await this._fetchMLBF(mlbfRecord);
// When a MLBF dump is packaged with the browser, mlbf will always be
@ -1111,12 +1134,21 @@ this.ExtensionBlocklistMLBF = {
return;
}
this._initialized = true;
this._client = RemoteSettings("addons-bloomfilters", {
bucketName: "blocklists",
lastCheckTimePref: PREF_BLOCKLIST_ADDONS3_CHECKED_SECONDS,
});
this._client = RemoteSettings(
Services.prefs.getCharPref(PREF_BLOCKLIST_ADDONS3_COLLECTION),
{
bucketNamePref: PREF_BLOCKLIST_BUCKET,
lastCheckTimePref: PREF_BLOCKLIST_ADDONS3_CHECKED_SECONDS,
signerName: Services.prefs.getCharPref(PREF_BLOCKLIST_ADDONS3_SIGNER),
}
);
this._onUpdate = this._onUpdate.bind(this);
this._client.on("sync", this._onUpdate);
this.stashesEnabled = Services.prefs.getBoolPref(
PREF_BLOCKLIST_USE_MLBF_STASHES,
false
);
Services.telemetry.scalarSet("blocklist.mlbf_stashes", this.stashesEnabled);
},
shutdown() {
@ -1181,18 +1213,13 @@ this.ExtensionBlocklistMLBF = {
},
async getEntry(addon) {
if (!this._stashes) {
if (!this._mlbfData) {
this.ensureInitialized();
await this._updateMLBF(false);
} else if (this._updatePromise) {
// _stashes has been initialized, but the initialization of _mlbfData is
// still pending.
await this._updatePromise;
}
let blockKey = addon.id + ":" + addon.version;
// _stashes will be unset if !gBlocklistEnabled.
if (this._stashes) {
// Stashes are ordered by newest first.
for (let stash of this._stashes) {
@ -1221,7 +1248,7 @@ this.ExtensionBlocklistMLBF = {
// - The RemoteSettings backend is unreachable, and this client was built
// without including a dump of the MLBF.
//
// ... in other words, this is unlikely to happen in practice.
// ... in other words, this shouldn't happen in practice.
return null;
}
let { cascadeFilter, generationTime } = this._mlbfData;
@ -1422,13 +1449,28 @@ let Blocklist = {
case PREF_BLOCKLIST_USE_MLBF:
let oldImpl = this.ExtensionBlocklist;
this._chooseExtensionBlocklistImplementationFromPref();
// The implementation may be unchanged when the pref is ignored.
if (oldImpl != this.ExtensionBlocklist && oldImpl._initialized) {
if (oldImpl._initialized) {
oldImpl.shutdown();
this.ExtensionBlocklist.undoShutdown();
this.ExtensionBlocklist._onUpdate();
} // else neither has been initialized yet. Wait for it to happen.
break;
case PREF_BLOCKLIST_USE_MLBF_STASHES:
ExtensionBlocklistMLBF.stashesEnabled = Services.prefs.getBoolPref(
PREF_BLOCKLIST_USE_MLBF_STASHES,
false
);
if (
ExtensionBlocklistMLBF._initialized &&
!ExtensionBlocklistMLBF._didShutdown
) {
Services.telemetry.scalarSet(
"blocklist.mlbf_stashes",
ExtensionBlocklistMLBF.stashesEnabled
);
ExtensionBlocklistMLBF._onUpdate();
}
break;
}
break;
}
@ -1454,20 +1496,13 @@ let Blocklist = {
BlocklistTelemetry.recordAddonBlockChangeTelemetry(addon, reason);
},
// TODO bug 1649906, bug 1639050: Remove blocklist v2.
// Allow blocklist for Android and unit tests only.
allowDeprecatedBlocklistV2: AppConstants.platform === "android",
_chooseExtensionBlocklistImplementationFromPref() {
if (
this.allowDeprecatedBlocklistV2 &&
!Services.prefs.getBoolPref(PREF_BLOCKLIST_USE_MLBF, false)
) {
this.ExtensionBlocklist = ExtensionBlocklistRS;
Services.telemetry.scalarSet("blocklist.mlbf_enabled", false);
} else {
if (Services.prefs.getBoolPref(PREF_BLOCKLIST_USE_MLBF, false)) {
this.ExtensionBlocklist = ExtensionBlocklistMLBF;
Services.telemetry.scalarSet("blocklist.mlbf_enabled", true);
} else {
this.ExtensionBlocklist = ExtensionBlocklistRS;
Services.telemetry.scalarSet("blocklist.mlbf_enabled", false);
}
},

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

@ -4,8 +4,8 @@
/* eslint no-unused-vars: ["error", {vars: "local", args: "none"}] */
if (!_TEST_NAME.includes("toolkit/mozapps/extensions/test/xpcshell/")) {
Assert.ok(
if (!_TEST_FILE[0].includes("toolkit/mozapps/extensions/test/xpcshell/")) {
ok(
false,
"head_addons.js may not be loaded by tests outside of " +
"the add-on manager component."

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

@ -17,16 +17,6 @@ const MLBF_RECORD = {
generation_time: 1577833200000,
};
function enable_blocklist_v2_instead_of_useMLBF() {
Blocklist.allowDeprecatedBlocklistV2 = true;
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
// Sanity check: blocklist v2 has been enabled.
Assert.ok(
!!Blocklist.ExtensionBlocklist._updateEntries,
"ExtensionBlocklistRS should have been enabled"
);
}
async function load_mlbf_record_as_blob() {
const url = Services.io.newFileURI(
do_get_file("../data/mlbf-blocked1-unblocked2.bin")
@ -49,3 +39,13 @@ function getExtensionBlocklistMLBF() {
);
return ExtensionBlocklistMLBF;
}
async function toggleStashPref(val, callbackAfterPrefChange = () => {}) {
const ExtensionBlocklistMLBF = getExtensionBlocklistMLBF();
Assert.ok(!ExtensionBlocklistMLBF._updatePromise, "no pending update");
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", val);
callbackAfterPrefChange();
// A pref observer should trigger an update.
Assert.ok(ExtensionBlocklistMLBF._updatePromise, "update pending");
await Blocklist.ExtensionBlocklist._updatePromise;
}

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

@ -1,57 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
* https://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// When bug 1639050 is fixed, this whole test can be removed as it is already
// covered by test_blocklist_mlbf_dump.js.
// A known blocked version from bug 1626602.
// Same as in test_blocklist_mlbf_dump.js.
const blockedAddon = {
id: "{6f62927a-e380-401a-8c9e-c485b7d87f0d}",
version: "9.2.0",
signedDate: new Date(1588098908496), // 2020-04-28 (dummy date)
signedState: AddonManager.SIGNEDSTATE_SIGNED,
};
// A known blocked version from bug 1681884, blocklist v3 only but not v2,
// i.e. not listed in services/settings/dumps/blocklists/addons.json.
const blockedAddonV3only = {
id: "{011f65f0-7143-470a-83ca-20ec4297f3f4}",
version: "1.0",
// omiting signedDate/signedState: in blocklist v2 those don't matter.
// In v3 those do matter, so if blocklist v3 were to be enabled, then
// the test would fail.
};
// A known add-on that is not blocked, as of writing. It is likely not going
// to be blocked because it does not have any executable code.
// Same as in test_blocklist_mlbf_dump.js.
const nonBlockedAddon = {
id: "disable-ctrl-q-and-cmd-q@robwu.nl",
version: "1",
signedDate: new Date(1482430349000), // 2016-12-22 (actual signing time).
signedState: AddonManager.SIGNEDSTATE_SIGNED,
};
add_task(async function verify_blocklistv2_dump_first_run() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
Assert.equal(
await Blocklist.getAddonBlocklistState(blockedAddon),
Ci.nsIBlocklistService.STATE_BLOCKED,
"A add-on that is known to be on the v2 blocklist should be blocked"
);
Assert.equal(
await Blocklist.getAddonBlocklistState(blockedAddonV3only),
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
"An add-on that is not part of the v2 blocklist should not be blocked"
);
Assert.equal(
await Blocklist.getAddonBlocklistState(nonBlockedAddon),
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
"A known non-blocked add-on should not be blocked"
);
});

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

@ -4,7 +4,7 @@
"use strict";
// useMLBF=true case is covered by test_blocklist_mlbf.js
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
const BLOCKLIST_DATA = [
{

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

@ -7,7 +7,7 @@
// The same functionality is offered through filter_expression, which is tested
// by services/settings/test/unit/test_remote_settings_jexl_filters.js and
// test_blocklistchange.js.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
var ADDONS = [
{

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

@ -32,15 +32,14 @@ add_task(async function setup() {
BlocklistGlobal.ExtensionBlocklistRS.ensureInitialized();
BlocklistGlobal.GfxBlocklistRS._ensureInitialized();
// ExtensionBlocklistMLBF is covered by test_blocklist_mlbf_dump.js.
gBlocklistClients = [
{
client: BlocklistGlobal.ExtensionBlocklistRS._client,
expectHasDump: IS_ANDROID,
testData: ["i808", "i720", "i539"],
},
{
client: BlocklistGlobal.GfxBlocklistRS._client,
expectHasDump: !IS_ANDROID,
testData: ["g204", "g200", "g36"],
},
];
@ -49,14 +48,20 @@ add_task(async function setup() {
add_task(
async function test_initial_dump_is_loaded_as_synced_when_collection_is_empty() {
for (let { client, expectHasDump } of gBlocklistClients) {
Assert.equal(
for (let { client } of gBlocklistClients) {
if (
IS_ANDROID &&
client.collectionName !=
BlocklistGlobal.ExtensionBlocklistRS._client.collectionName
) {
// On Android we don't ship the dumps of gfx.
continue;
}
Assert.ok(
await RemoteSettingsUtils.hasLocalDump(
client.bucketName,
client.collectionName
),
expectHasDump,
`Expected initial remote settings dump for ${client.collectionName}`
)
);
}
}

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

@ -6,7 +6,7 @@
// and RegExps for each. See bug 897735.
// useMLBF=true only supports blocking by version+ID, not by other fields.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
const BLOCKLIST_DATA = {
extensions: [

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

@ -9,6 +9,7 @@
*/
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", true);
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", true);
const ExtensionBlocklistMLBF = getExtensionBlocklistMLBF();

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

@ -173,13 +173,6 @@ add_task(async function handle_database_corruption() {
);
}
let fetchCount = 0;
const originalFetchMLBF = ExtensionBlocklistMLBF._fetchMLBF;
ExtensionBlocklistMLBF._fetchMLBF = function() {
++fetchCount;
return originalFetchMLBF.apply(this, arguments);
};
// In the fetch_invalid_mlbf_record we checked that a cached / packaged MLBF
// attachment is used as a fallback when the record is invalid. Here we also
// check that there is a fallback when there is no record at all.
@ -187,46 +180,28 @@ add_task(async function handle_database_corruption() {
// Include a dummy record in the list, to prevent RemoteSettings from
// importing a JSON dump with unexpected records.
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [{}] });
Assert.equal(fetchCount, 1, "MLBF read once despite bad record");
// When the collection is empty, the last known MLBF should be used anyway.
await checkBlocklistWorks();
Assert.equal(fetchCount, 1, "MLBF not read again by blocklist query");
// Now we also remove the cached file...
await ExtensionBlocklistMLBF._client.db.saveAttachment(
ExtensionBlocklistMLBF.RS_ATTACHMENT_ID,
null
);
Assert.equal(fetchCount, 1, "MLBF not read again after attachment deletion");
// Deleting the file shouldn't cause issues because the MLBF is loaded once
// and then kept in memory.
await checkBlocklistWorks();
Assert.equal(fetchCount, 1, "MLBF not read again by blocklist query 2");
// Force an update while we don't have any blocklist data nor cache.
await ExtensionBlocklistMLBF._onUpdate();
Assert.equal(fetchCount, 2, "MLBF read again at forced update");
// As a fallback, continue to use the in-memory version of the blocklist.
await checkBlocklistWorks();
Assert.equal(fetchCount, 2, "MLBF not read again by blocklist query 3");
// Memory gone, e.g. after a browser restart.
delete ExtensionBlocklistMLBF._mlbfData;
delete ExtensionBlocklistMLBF._stashes;
Assert.equal(
await Blocklist.getAddonBlocklistState(blockedAddon),
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
"Blocklist can't work if all blocklist data is gone"
);
Assert.equal(fetchCount, 3, "MLBF read again after restart/cleared cache");
Assert.equal(
await Blocklist.getAddonBlocklistState(blockedAddon),
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
"Blocklist can still not work if all blocklist data is gone"
);
// Ideally, the client packages a dump. But if the client did not package the
// dump, then it should not be trying to read the data over and over again.
Assert.equal(fetchCount, 3, "MLBF not read again despite absence of MLBF");
ExtensionBlocklistMLBF._fetchMLBF = originalFetchMLBF;
});

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

@ -4,6 +4,7 @@
"use strict";
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", true);
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", true);
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
@ -189,7 +190,39 @@ add_task(async function stash_time_order() {
await checkBlockState("@b", "2", true);
});
// Attachments with unsupported attachment_type should be ignored.
// Tests that the correct records+attachment are chosen depending on the pref.
add_task(async function mlbf_attachment_type_and_stash_is_correct() {
MLBF_LOAD_ATTEMPTS.length = 0;
const records = [
{ stash_time: 0, stash: { blocked: ["@blocked:1"], unblocked: [] } },
{ attachment_type: "bloomfilter-base", attachment: {}, generation_time: 0 },
{ attachment_type: "bloomfilter-full", attachment: {}, generation_time: 1 },
];
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: records });
// Check that the pref works.
await checkBlockState("@blocked", "1", true);
await toggleStashPref(false);
await checkBlockState("@blocked", "1", false);
await toggleStashPref(true);
await checkBlockState("@blocked", "1", true);
Assert.deepEqual(
MLBF_LOAD_ATTEMPTS.map(r => r?.attachment_type),
[
// Initial load with pref true
"bloomfilter-base",
// Pref off.
"bloomfilter-full",
// Pref on again.
"bloomfilter-base",
],
"Expected attempts to load MLBF as part of update"
);
});
// When stashes are disabled, "bloomfilter-full" may be used (as seen in the
// previous test, mlbf_attachment_type_and_stash_is_correct). With stashes
// enabled, "bloomfilter-full" should be ignored, however.
add_task(async function mlbf_bloomfilter_full_ignored() {
MLBF_LOAD_ATTEMPTS.length = 0;
@ -197,7 +230,7 @@ add_task(async function mlbf_bloomfilter_full_ignored() {
extensionsMLBF: [{ attachment_type: "bloomfilter-full", attachment: {} }],
});
// Only bloomfilter-base records should be used.
// When stashes are enabled, only bloomfilter-base records should be used.
// Since there are no such records, we shouldn't find anything.
Assert.deepEqual(MLBF_LOAD_ATTEMPTS, [null], "no matching MLBFs found");
});

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

@ -4,6 +4,7 @@
"use strict";
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", true);
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", true);
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1");
@ -53,6 +54,7 @@ add_task(async function test_initialization() {
ExtensionBlocklistMLBF.ensureInitialized();
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
// In other parts of this test, this value is not checked any more.
// test_blocklist_telemetry.js already checks lastModified_rs_addons_mlbf.
"blocklist.lastModified_rs_addons_mlbf": undefined,
@ -71,6 +73,7 @@ add_task(async function test_without_mlbf() {
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [{}] });
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
"blocklist.mlbf_source": "unknown",
"blocklist.mlbf_generation_time": "Missing Date",
"blocklist.mlbf_stash_time_oldest": "Missing Date",
@ -91,6 +94,7 @@ add_task(async function test_common_good_case_with_stashes() {
});
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
"blocklist.mlbf_source": "cache_match",
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
"blocklist.mlbf_stash_time_oldest": toUTC(OLDEST_STASH.stash_time),
@ -100,11 +104,48 @@ add_task(async function test_common_good_case_with_stashes() {
// The records and cached attachment carries over to the next tests.
});
add_task(async function test_toggle_stash_pref() {
// The previous test had imported RECORDS_WITH_STASHES_AND_MLBF.
// Verify that toggling the pref causes those stashes to be ignored.
await toggleStashPref(false, () => {
// Telemetry should be updated immediately after setting the pref.
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": false,
});
});
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": false,
"blocklist.mlbf_source": "cache_match",
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
"blocklist.mlbf_stash_time_oldest": "Missing Date",
"blocklist.mlbf_stash_time_newest": "Missing Date",
});
await toggleStashPref(true, () => {
// Telemetry should be updated immediately after setting the pref.
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
});
});
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
"blocklist.mlbf_source": "cache_match",
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
"blocklist.mlbf_stash_time_oldest": toUTC(OLDEST_STASH.stash_time),
"blocklist.mlbf_stash_time_newest": toUTC(NEWEST_STASH.stash_time),
});
});
// Test what happens when there are no stashes in the collection itself.
add_task(async function test_without_stashes() {
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [MLBF_RECORD] });
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
"blocklist.mlbf_source": "cache_match",
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
"blocklist.mlbf_stash_time_oldest": "Missing Date",
@ -118,6 +159,7 @@ add_task(async function test_without_collection_but_cache() {
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [] });
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
"blocklist.mlbf_source": "cache_fallback",
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
"blocklist.mlbf_stash_time_oldest": "Missing Date",
@ -125,8 +167,8 @@ add_task(async function test_without_collection_but_cache() {
});
});
// Test that the mlbf_enabled scalar is updated in response to preference
// changes.
// Test that the mlbf_enabled and mlbf_stashes scalars are updated in response
// to preference changes.
add_task(async function test_toggle_preferences() {
// Disable the blocklist, to prevent the v2 blocklist from initializing.
// We only care about scalar updates in response to preference changes.
@ -134,23 +176,29 @@ add_task(async function test_toggle_preferences() {
// Sanity check: scalars haven't changed.
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
});
// The pref should be ignored by default.
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", false);
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": false,
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
});
// Explicitly enabling blocklist v2 via a test-only API works.
// The test helper expects blocklist v3 to have been enabled by default,
// so restore the pref before calling enable_blocklist_v2_instead_of_useMLBF:
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", true);
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
assertTelemetryScalars({
"blocklist.mlbf_enabled": false,
"blocklist.mlbf_stashes": false,
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
});
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", true);
assertTelemetryScalars({
"blocklist.mlbf_enabled": false,
// The mlbf_stashes scalar is only updated when useMLBF is true.
"blocklist.mlbf_stashes": false,
"blocklist.mlbf_generation_time": toUTC(MLBF_RECORD.generation_time),
});
});

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

@ -4,7 +4,7 @@
*/
// useMLBF=true only supports blocking by version+ID, not by OS/ABI.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
const profileDir = gProfD.clone();
profileDir.append("extensions");

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

@ -7,7 +7,7 @@
// useMLBF=true only supports blocking, not resetting prefs, since extensions
// cannot set arbitrary prefs any more after the removal of legacy addons.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
const BLOCKLIST_DATA = [
{

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

@ -4,7 +4,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// useMLBF=true only supports blocking by version+ID, not by regexp.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
const BLOCKLIST_DATA = [
{

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

@ -5,7 +5,7 @@
// useMLBF=true only supports one type of severity (hard block). The value of
// appDisabled in the extension blocklist is checked in test_blocklist_mlbf.js.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
const URI_EXTENSION_BLOCKLIST_DIALOG =
"chrome://mozapps/content/extensions/blocklist.xhtml";

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

@ -3,6 +3,7 @@
"use strict";
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", true);
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", true);
// Set min version to 42 because the updater defaults to min version 42.
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "42.0", "42.0");

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

@ -31,30 +31,10 @@ Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref("extensions.webextPermissionPrompts", false);
if (AppConstants.platform == "android") {
// test_blocklistchange_v2.js tests blocklist v2, so we should flip the pref
// to enable the v3 blocklist on Android.
Assert.ok(
_TEST_NAME.includes("test_blocklistchange"),
`Expected _TEST_NAME to be test_blocklistchange{,_v2}.js`
);
if (_TEST_NAME.includes("test_blocklistchange.js")) {
Assert.equal(
Services.prefs.getBoolPref("extensions.blocklist.useMLBF"),
false,
"Blocklist v3 disabled by default on Android"
);
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", true);
}
}
// TODO bug 1649906: strip blocklist v2-specific parts of this test.
// All specific logic is already covered by other test files, but the tests
// here trigger the logic via higher-level methods, so it may make sense to
// keep this file even after the removal of blocklist v2.
// TODO bug 1649896: Create new test file for MLBF-specific tests.
const useMLBF = Services.prefs.getBoolPref(
"extensions.blocklist.useMLBF",
true
false
);
var testserver = createHttpServer({ hosts: ["example.com"] });
@ -253,6 +233,7 @@ const BLOCKLIST_DATA = {
// - regexps blocks are converted to hard blocks.
// - Version ranges are expanded to cover all known versions.
if (useMLBF) {
Assert.ok(Services.prefs.getBoolPref("extensions.blocklist.useMLBF.stashes"));
for (let [key, blocks] of Object.entries(BLOCKLIST_DATA)) {
BLOCKLIST_DATA[key] = [];
for (let block of blocks) {

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

@ -5,7 +5,15 @@
// useMLBF=true doesn't support soft blocks, regexps or version ranges.
// Flip the useMLBF preference to make sure that the test_blocklistchange.js
// test works with and without this pref (blocklist v2 and blocklist v3).
enable_blocklist_v2_instead_of_useMLBF();
//
// This is a bit of a hack and to be replaced with a new file in bug 1649906.
Services.prefs.setBoolPref(
"extensions.blocklist.useMLBF",
!Services.prefs.getBoolPref("extensions.blocklist.useMLBF")
);
// The test requires stashes to be enabled.
Services.prefs.setBoolPref("extensions.blocklist.useMLBF.stashes", true);
Services.scriptloader.loadSubScript(
Services.io.newFileURI(do_get_file("test_blocklistchange.js")).spec,

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

@ -3,7 +3,7 @@
*/
// useMLBF=true only supports hard blocks, not soft blocks.
enable_blocklist_v2_instead_of_useMLBF();
Services.prefs.setBoolPref("extensions.blocklist.useMLBF", false);
// Tests that an appDisabled add-on that becomes softBlocked remains disabled
// when becoming appEnabled

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

@ -1,53 +1,53 @@
[DEFAULT]
skip-if = toolkit == 'android'
tags = addons blocklist
head = head.js ../head_addons.js
firefox-appdir = browser
support-files =
../data/**
[test_android_blocklist_dump.js]
run-if = os == "android" # Remove this whole test when bug 1639050 is fixed.
[test_blocklist_addonBlockURL.js]
[test_blocklist_appversion.js]
skip-if = os == "android" && verify # times out
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_blocklist_clients.js]
tags = remote-settings
[test_blocklist_gfx.js]
[test_blocklist_metadata_filters.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_blocklist_mlbf.js]
[test_blocklist_mlbf_dump.js]
skip-if = os == "android" # bug 1639050
[test_blocklist_mlbf_fetch.js]
[test_blocklist_mlbf_stashes.js]
[test_blocklist_mlbf_telemetry.js]
skip-if =
appname == "thunderbird" # Data irrelevant to Thunderbird. Bug 1641400.
os == "android" # can somehow not record telemetry; look into it upon fixing bug 1639050
# Data irrelevant to Thunderbird. Bug 1641400.
skip-if = appname == "thunderbird"
[test_blocklist_mlbf_update.js]
[test_blocklist_osabi.js]
skip-if = os == "android" && verify # times out
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_blocklist_prefs.js]
[test_blocklist_regexp_split.js]
[test_blocklist_severities.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
[test_blocklist_statechange_telemetry.js]
skip-if =
appname == "thunderbird" # Data irrelevant to Thunderbird. Bug 1641400.
os == "android" # can somehow not record telemetry; look into it upon fixing bug 1639050
# Data irrelevant to Thunderbird. Bug 1641400.
skip-if = appname == "thunderbird"
[test_blocklist_targetapp_filter.js]
tags = remote-settings
[test_blocklist_telemetry.js]
tags = remote-settings
skip-if =
appname == "thunderbird" # Data irrelevant to Thunderbird. Bug 1641400.
os == "android" # can somehow not record telemetry; look into it upon fixing bug 1639050
# Data irrelevant to Thunderbird. Bug 1641400.
skip-if = appname == "thunderbird"
[test_blocklistchange.js]
# Times out during parallel runs on desktop
requesttimeoutfactor = 2
skip-if = os == "android" && verify # times out because it takes too much time to run the full test
[test_blocklistchange_v2.js]
# Times out during parallel runs on desktop
requesttimeoutfactor = 2
skip-if = os == "android" && verify # times out in chaos mode on Android because several minutes are spent waiting at https://hg.mozilla.org/mozilla-central/file/3350b680/toolkit/mozapps/extensions/Blocklist.jsm#l698
[test_gfxBlacklist_Device.js]
[test_gfxBlacklist_DriverNew.js]
[test_gfxBlacklist_Equal_DriverNew.js]