Bug 1640953 - Prevent RS dumps from being loaded in some blocklist tests r=gijs CLOSED TREE

RemoteSettings helpfully falls back to loading from the JSON dumps when
the list of records is empty. This breaks tests that load an empty
blocklist, because unexpected records may appear.

Fix this by inserting a dummy value in the blocklist. Invalid records
should be ignored anyway, so this is a good way to prevent the dump from
being loaded.

Differential Revision: https://phabricator.services.mozilla.com/D76875
This commit is contained in:
Rob Wu 2020-05-26 17:05:06 +00:00
Родитель a69a178a69
Коммит 5f41144b5c
2 изменённых файлов: 7 добавлений и 2 удалений

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

@ -173,7 +173,9 @@ add_task(async function handle_database_corruption() {
// 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.
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [] });
// Include a dummy record in the list, to prevent RemoteSettings from
// importing a JSON dump with unexpected records.
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [{}] });
// When the collection is empty, the last known MLBF should be used anyway.
await checkBlocklistWorks();

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

@ -66,7 +66,10 @@ add_task(async function test_initialization() {
// Test what happens if there is no blocklist data at all.
add_task(async function test_without_mlbf() {
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [] });
// Add one (invalid) value to the blocklist, to prevent the RemoteSettings
// client from importing the JSON dump (which could potentially cause the
// test to fail due to the unexpected imported records).
await AddonTestUtils.loadBlocklistRawData({ extensionsMLBF: [{}] });
assertTelemetryScalars({
"blocklist.mlbf_enabled": true,
"blocklist.mlbf_stashes": true,