Skip to content

Commit fd06b12

Browse files
committed
Bug 1639050 - Enable blocklist v3 on Android nightly r=geckoview-reviewers,robwu,calu
Differential Revision: https://phabricator.services.mozilla.com/D173208 UltraBlame original commit: 92dddcb5cf02b323dab0baeeef3432cb7e642ffc
1 parent b158957 commit fd06b12

File tree

9 files changed

+117
-40
lines changed

9 files changed

+117
-40
lines changed

mobile/android/app/mobile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ pref("xpinstall.whitelist.add", "https://addons.mozilla.org");
155155
pref("extensions.langpacks.signatures.required", true);
156156
pref("xpinstall.signatures.required", true);
157157

158+
#ifndef NIGHTLY_BUILD
159+
160+
pref("extensions.blocklist.useMLBF", false);
161+
#endif
158162

159-
pref("extensions.blocklist.useMLBF", false);
160163

161164

162165

mobile/android/installer/package-manifest.in

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,15 @@
8888
@BINPATH@/application.ini
8989
@BINPATH@/platform.ini
9090
@BINPATH@/defaults/settings/last_modified.json
91-
; TODO bug 1639050: addons-bloomfilters should be used instead of addons.json
91+
#ifdef NIGHTLY_BUILD
92+
; The addons blocklist data is not packaged and will be downloaded after install.
93+
; See https://bugzilla.mozilla.org/show_bug.cgi?id=1639050#c5
94+
; @BINPATH@/defaults/settings/blocklists/addons-bloomfilters.json
95+
; @BINPATH@/defaults/settings/blocklists/addons-bloomfilters/addons-mlbf.bin
96+
; @BINPATH@/defaults/settings/blocklists/addons-bloomfilters/addons-mlbf.bin.meta.json
97+
#else
9298
@BINPATH@/defaults/settings/blocklists/addons.json
99+
#endif
93100
@BINPATH@/defaults/settings/blocklists/gfx.json
94101
@BINPATH@/defaults/settings/main/password-recipes.json
95102
@BINPATH@/defaults/settings/security-state/onecrl.json

services/settings/dumps/blocklists/moz.build

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,19 @@ with Files("**"):
99

1010

1111
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "android":
12-
13-
FINAL_TARGET_FILES.defaults.settings.blocklists += ["addons.json", "gfx.json"]
12+
if CONFIG["NIGHTLY_BUILD"]:
13+
FINAL_TARGET_FILES.defaults.settings.blocklists += [
14+
"addons-bloomfilters.json",
15+
"gfx.json",
16+
]
17+
else:
18+
FINAL_TARGET_FILES.defaults.settings.blocklists += ["addons.json", "gfx.json"]
1419
else:
1520
FINAL_TARGET_FILES.defaults.settings.blocklists += [
1621
"addons-bloomfilters.json",
1722
"gfx.json",
1823
"plugins.json",
1924
]
20-
2125
FINAL_TARGET_FILES.defaults.settings.blocklists["addons-bloomfilters"] += [
2226
"addons-bloomfilters/addons-mlbf.bin",
2327
"addons-bloomfilters/addons-mlbf.bin.meta.json",

toolkit/mozapps/extensions/Blocklist.jsm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,10 +1428,9 @@ let Blocklist = {
14281428
recordAddonBlockChangeTelemetry(addon, reason) {
14291429
BlocklistTelemetry.recordAddonBlockChangeTelemetry(addon, reason);
14301430
},
1431-
1432-
14331431

1434-
allowDeprecatedBlocklistV2: AppConstants.platform === "android",
1432+
allowDeprecatedBlocklistV2:
1433+
AppConstants.platform === "android" && !AppConstants.NIGHTLY_BUILD,
14351434

14361435
_chooseExtensionBlocklistImplementationFromPref() {
14371436
if (

toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/head.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ function getExtensionBlocklistMLBF() {
4646
const {
4747
BlocklistPrivate: { ExtensionBlocklistMLBF },
4848
} = ChromeUtils.import("resource://gre/modules/Blocklist.jsm");
49-
Assert.ok(
50-
Services.prefs.getBoolPref("extensions.blocklist.useMLBF", false),
51-
"blocklist.useMLBF should be true"
52-
);
49+
if (Blocklist.allowDeprecatedBlocklistV2) {
50+
Assert.ok(
51+
Services.prefs.getBoolPref("extensions.blocklist.useMLBF", false),
52+
"blocklist.useMLBF should be true"
53+
);
54+
}
5355
return ExtensionBlocklistMLBF;
5456
}

toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_android_blocklist_dump.js

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,29 @@
55

66

77

8+
const IS_USING_BLOCKLIST_V3 = AppConstants.NIGHTLY_BUILD;
9+
const ExtensionBlocklistMLBF = getExtensionBlocklistMLBF();
10+
11+
let MLBF_LOAD_ATTEMPTS;
12+
let MLBF_LOAD_RESULTS;
13+
let originalFetchMLBF;
14+
15+
add_task(async function setup() {
16+
MLBF_LOAD_RESULTS = [];
17+
MLBF_LOAD_ATTEMPTS = [];
18+
19+
20+
originalFetchMLBF = ExtensionBlocklistMLBF._fetchMLBF;
21+
ExtensionBlocklistMLBF._fetchMLBF = async function(record) {
22+
MLBF_LOAD_ATTEMPTS.push(record);
23+
let promise = originalFetchMLBF.apply(this, arguments);
24+
MLBF_LOAD_RESULTS.push(promise);
25+
return promise;
26+
};
27+
});
28+
29+
30+
831

932

1033

@@ -35,23 +58,59 @@ const nonBlockedAddon = {
3558
signedState: AddonManager.SIGNEDSTATE_SIGNED,
3659
};
3760

38-
add_task(async function verify_blocklistv2_dump_first_run() {
39-
createAppInfo("[email protected]", "XPCShell", "1", "1");
40-
41-
Assert.equal(
42-
await Blocklist.getAddonBlocklistState(blockedAddon),
43-
Ci.nsIBlocklistService.STATE_BLOCKED,
44-
"A add-on that is known to be on the v2 blocklist should be blocked"
45-
);
46-
Assert.equal(
47-
await Blocklist.getAddonBlocklistState(blockedAddonV3only),
48-
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
49-
"An add-on that is not part of the v2 blocklist should not be blocked"
50-
);
51-
52-
Assert.equal(
53-
await Blocklist.getAddonBlocklistState(nonBlockedAddon),
54-
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
55-
"A known non-blocked add-on should not be blocked"
56-
);
57-
});
61+
add_task(
62+
{ skip_if: () => IS_USING_BLOCKLIST_V3 },
63+
async function verify_blocklistv2_dump_first_run() {
64+
createAppInfo("[email protected]", "XPCShell", "1", "1");
65+
66+
Assert.equal(
67+
await Blocklist.getAddonBlocklistState(blockedAddon),
68+
Ci.nsIBlocklistService.STATE_BLOCKED,
69+
"A add-on that is known to be on the v2 blocklist should be blocked"
70+
);
71+
Assert.equal(
72+
await Blocklist.getAddonBlocklistState(blockedAddonV3only),
73+
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
74+
"An add-on that is not part of the v2 blocklist should not be blocked"
75+
);
76+
77+
Assert.equal(
78+
await Blocklist.getAddonBlocklistState(nonBlockedAddon),
79+
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
80+
"A known non-blocked add-on should not be blocked"
81+
);
82+
}
83+
);
84+
85+
add_task(
86+
{ skip_if: () => !IS_USING_BLOCKLIST_V3 },
87+
async function verify_a_known_blocked_add_on_is_not_detected_as_blocked_at_first_run() {
88+
89+
Assert.equal(
90+
await Blocklist.getAddonBlocklistState(blockedAddon),
91+
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
92+
"A known blocked add-on should not be blocked at first"
93+
);
94+
95+
await Assert.rejects(
96+
MLBF_LOAD_RESULTS[0],
97+
/DownloadError: Could not download addons-mlbf.bin/,
98+
"Should not find any packaged attachment"
99+
);
100+
101+
MLBF_LOAD_ATTEMPTS.length = 0;
102+
MLBF_LOAD_RESULTS.length = 0;
103+
104+
Assert.equal(
105+
await Blocklist.getAddonBlocklistState(blockedAddon),
106+
Ci.nsIBlocklistService.STATE_NOT_BLOCKED,
107+
"Blocklist is still not populated"
108+
);
109+
Assert.deepEqual(
110+
MLBF_LOAD_ATTEMPTS,
111+
[],
112+
"MLBF is not fetched again after the first lookup"
113+
);
114+
ExtensionBlocklistMLBF._fetchMLBF = originalFetchMLBF;
115+
}
116+
);

toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklist_clients.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const { RemoteSettings } = ChromeUtils.importESModule(
88
"resource://services-settings/remote-settings.sys.mjs"
99
);
1010

11-
const IS_ANDROID = AppConstants.platform == "android";
12-
11+
const IS_ANDROID_WITH_BLOCKLIST_V2 =
12+
AppConstants.platform == "android" && !AppConstants.NIGHTLY_BUILD;
1313
let gBlocklistClients;
1414

1515
async function clear_state() {
@@ -40,7 +40,7 @@ add_task(async function setup() {
4040
gBlocklistClients = [
4141
{
4242
client: BlocklistPrivate.ExtensionBlocklistRS._client,
43-
expectHasDump: IS_ANDROID,
43+
expectHasDump: IS_ANDROID_WITH_BLOCKLIST_V2,
4444
},
4545
{
4646
client: BlocklistPrivate.GfxBlocklistRS._client,

toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/test_blocklistchange.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ const URI_EXTENSION_BLOCKLIST_DIALOG =
2929

3030
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
3131

32-
if (AppConstants.platform == "android") {
32+
const IS_ANDROID_WITH_BLOCKLIST_V2 =
33+
AppConstants.platform == "android" && !AppConstants.NIGHTLY_BUILD;
34+
35+
36+
if (IS_ANDROID_WITH_BLOCKLIST_V2) {
3337

3438

3539
Assert.ok(

toolkit/mozapps/extensions/test/xpcshell/rs-blocklist/xpcshell.ini

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ support-files =
77
../../xpinstall/webmidi_permission.xpi
88

99
[test_android_blocklist_dump.js]
10-
run-if = os == "android" # Remove this whole test when bug 1639050 is fixed.
10+
run-if = os == "android"
1111
[test_blocklist_addonBlockURL.js]
1212
[test_blocklist_appversion.js]
1313
skip-if = os == "android" && verify # times out
@@ -17,13 +17,12 @@ tags = remote-settings
1717
[test_blocklist_metadata_filters.js]
1818
[test_blocklist_mlbf.js]
1919
[test_blocklist_mlbf_dump.js]
20-
skip-if = os == "android" # bug 1639050
21-
[test_blocklist_mlbf_fetch.js]
20+
skip-if = os == "android" # blocklist v3 is not bundled with Android builds, see test_android_blocklist_dump.js instead.[test_blocklist_mlbf_fetch.js][test_blocklist_mlbf_fetch.js]
2221
[test_blocklist_mlbf_stashes.js]
2322
[test_blocklist_mlbf_telemetry.js]
2423
skip-if =
2524
appname == "thunderbird" # Data irrelevant to Thunderbird. Bug 1641400.
26-
os == "android" # can somehow not record telemetry; look into it upon fixing bug 1639050
25+
os == "android" # can somehow not record telemetry; Bug 1820155.
2726
[test_blocklist_mlbf_update.js]
2827
[test_blocklist_osabi.js]
2928
skip-if = os == "android" && verify # times out

0 commit comments

Comments
 (0)