Commits:
-
5c0ae36e
by Beatriz Rizental at 2026-05-13T19:50:55+02:00
fixup! BB 43243: Modify mozharness scripts for Base Browser
I was trying to run the mozharness scripts with a nightly build
and I learned that they weren't working due to the nightly not
being a debug app. This addresses that issue and should work
for any version of the app.
Without it the geckoview-config.yaml file isn't read, unless the app
is android:debuggable.
-
9840a7ac
by Beatriz Rizental at 2026-05-13T19:50:55+02:00
fixup! TB 40933: Add tor-launcher functionality
Bug 44212: Implement a mock tor provider, for tests
-
edc7be67
by Beatriz Rizental at 2026-05-13T19:50:55+02:00
fixup! BB 43243: Modify mozharness scripts for Base Browser
Bug 44212: Refactor a bit of the marionette on android mozharness support
-
b35eb6b8
by Beatriz Rizental at 2026-05-13T19:50:55+02:00
TB 43243: Modify mozharness scripts for Tor Browser
Bug 44212: Support the mock Tor provider in mozharness Android tests.
5 changed files:
Changes:
testing/mozharness/configs/android/android_common.py
| ... |
... |
@@ -323,6 +323,19 @@ config = { |
|
323
|
323
|
"%(abs_marionette_manifest_dir)s/unit-tests.toml",
|
|
324
|
324
|
],
|
|
325
|
325
|
},
|
|
|
326
|
+ "marionette-mocktorprovider": {
|
|
|
327
|
+ "run_filename": "runtests.py",
|
|
|
328
|
+ "testsdir": "marionette/harness/marionette_harness",
|
|
|
329
|
+ "install": True,
|
|
|
330
|
+ "options": [
|
|
|
331
|
+ "-vv",
|
|
|
332
|
+ "--address=127.0.0.1:2828",
|
|
|
333
|
+ "--app=fennec",
|
|
|
334
|
+ ],
|
|
|
335
|
+ "tests": [
|
|
|
336
|
+ "%(abs_marionette_manifest_dir)s/unit-tests.toml",
|
|
|
337
|
+ ],
|
|
|
338
|
+ },
|
|
326
|
339
|
}, # end suite_definitions
|
|
327
|
340
|
"unstructured_suites": [
|
|
328
|
341
|
"jittest",
|
testing/mozharness/scripts/android_emulator_unittest.py
| ... |
... |
@@ -13,6 +13,8 @@ import sys |
|
13
|
13
|
import tempfile
|
|
14
|
14
|
import time
|
|
15
|
15
|
|
|
|
16
|
+import yaml
|
|
|
17
|
+
|
|
16
|
18
|
# load modules from parent dir
|
|
17
|
19
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
18
|
20
|
sys.path.insert(1, os.path.dirname(here))
|
| ... |
... |
@@ -30,7 +32,14 @@ from mozharness.mozilla.testing.codecoverage import ( |
|
30
|
32
|
from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
|
|
31
|
33
|
|
|
32
|
34
|
SUITE_DEFAULT_E10S = ["geckoview-junit", "mochitest", "reftest"]
|
|
33
|
|
-SUITE_NO_E10S = ["cppunittest", "gtest", "jittest", "xpcshell", "marionette"]
|
|
|
35
|
+SUITE_NO_E10S = [
|
|
|
36
|
+ "cppunittest",
|
|
|
37
|
+ "gtest",
|
|
|
38
|
+ "jittest",
|
|
|
39
|
+ "xpcshell",
|
|
|
40
|
+ "marionette",
|
|
|
41
|
+ "marionette-mocktorprovider",
|
|
|
42
|
+]
|
|
34
|
43
|
SUITE_REPEATABLE = ["mochitest", "reftest", "xpcshell"]
|
|
35
|
44
|
|
|
36
|
45
|
|
| ... |
... |
@@ -509,23 +518,31 @@ class AndroidEmulatorTest( |
|
509
|
518
|
|
|
510
|
519
|
self.register_virtualenv_module(requirements=[requirements])
|
|
511
|
520
|
|
|
512
|
|
- def _marionette_setup(self):
|
|
|
521
|
+ def _marionette_setup(self, mock_tor_provider=False):
|
|
513
|
522
|
adb = self.query_exe("adb")
|
|
514
|
523
|
|
|
515
|
524
|
self.run_command([adb, "forward", "tcp:2828", "tcp:2828"])
|
|
516
|
525
|
|
|
517
|
526
|
with tempfile.NamedTemporaryFile(suffix=".yaml") as tmp_file:
|
|
518
|
|
- tmp_file.write(
|
|
519
|
|
- b"""args:
|
|
520
|
|
-- --marionette
|
|
521
|
|
-- --remote-allow-system-access
|
|
522
|
|
-"""
|
|
523
|
|
- )
|
|
|
527
|
+ config = {"args": ["--marionette", "--remote-allow-system-access"]}
|
|
|
528
|
+
|
|
|
529
|
+ if mock_tor_provider:
|
|
|
530
|
+ config["env"] = {"TOR_PROVIDER": "mock"}
|
|
|
531
|
+
|
|
|
532
|
+ tmp_file.write(yaml.dump(config, encoding="utf-8"))
|
|
524
|
533
|
tmp_file.flush()
|
|
525
|
534
|
|
|
526
|
535
|
remote_path = f"/data/local/tmp/{self.package_name}-geckoview-config.yaml"
|
|
527
|
536
|
self.run_command([adb, "push", tmp_file.name, remote_path])
|
|
528
|
537
|
|
|
|
538
|
+ self.run_command([
|
|
|
539
|
+ adb,
|
|
|
540
|
+ "shell",
|
|
|
541
|
+ "am",
|
|
|
542
|
+ "set-debug-app",
|
|
|
543
|
+ "--persistent",
|
|
|
544
|
+ self.package_name,
|
|
|
545
|
+ ])
|
|
529
|
546
|
self.run_command([
|
|
530
|
547
|
adb,
|
|
531
|
548
|
"shell",
|
| ... |
... |
@@ -569,7 +586,7 @@ class AndroidEmulatorTest( |
|
569
|
586
|
if requirements:
|
|
570
|
587
|
self.register_virtualenv_module(requirements=[requirements])
|
|
571
|
588
|
|
|
572
|
|
- if ("marionette", "marionette") in suites:
|
|
|
589
|
+ if any("marionette" in suite_name for _, suite_name in self._query_suites()):
|
|
573
|
590
|
self._configure_marionette_virtualenv(action)
|
|
574
|
591
|
|
|
575
|
592
|
def download_and_extract(self):
|
| ... |
... |
@@ -609,8 +626,8 @@ class AndroidEmulatorTest( |
|
609
|
626
|
for per_test_suite, suite in suites:
|
|
610
|
627
|
self.test_suite = suite
|
|
611
|
628
|
|
|
612
|
|
- if self.test_suite == "marionette":
|
|
613
|
|
- self._marionette_setup()
|
|
|
629
|
+ if "marionette" in self.test_suite:
|
|
|
630
|
+ self._marionette_setup(self.test_suite == "marionette-mocktorprovider")
|
|
614
|
631
|
|
|
615
|
632
|
try:
|
|
616
|
633
|
cwd = self._query_tests_dir(self.test_suite)
|
| ... |
... |
@@ -693,9 +710,10 @@ class AndroidEmulatorTest( |
|
693
|
710
|
|
|
694
|
711
|
@PostScriptAction("run-tests")
|
|
695
|
712
|
def marionette_teardown(self, *args, **kwargs):
|
|
696
|
|
- if ("marionette", "marionette") in self._query_suites():
|
|
|
713
|
+ if any("marionette" in suite_name for _, suite_name in self._query_suites()):
|
|
697
|
714
|
adb = self.query_exe("adb")
|
|
698
|
715
|
self.run_command([adb, "shell", "am", "force-stop", self.package_name])
|
|
|
716
|
+ self.run_command([adb, "shell", "am", "clear-debug-app"])
|
|
699
|
717
|
self.run_command([adb, "uninstall", self.package_name])
|
|
700
|
718
|
self.run_command([
|
|
701
|
719
|
adb,
|
toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs
| ... |
... |
@@ -7,6 +7,8 @@ ChromeUtils.defineESModuleGetters(lazy, { |
|
7
|
7
|
TorLauncherUtil:
|
|
8
|
8
|
"moz-src:///toolkit/components/tor-launcher/TorLauncherUtil.sys.mjs",
|
|
9
|
9
|
TorProvider: "moz-src:///toolkit/components/tor-launcher/TorProvider.sys.mjs",
|
|
|
10
|
+ TorProviderMock:
|
|
|
11
|
+ "moz-src:///toolkit/components/tor-launcher/TorProviderMock.sys.mjs",
|
|
10
|
12
|
TorProviderNone:
|
|
11
|
13
|
"moz-src:///toolkit/components/tor-launcher/TorProviderNone.sys.mjs",
|
|
12
|
14
|
});
|
| ... |
... |
@@ -74,6 +76,7 @@ export class TorBootstrapError extends Error { |
|
74
|
76
|
}
|
|
75
|
77
|
|
|
76
|
78
|
export const TorProviders = Object.freeze({
|
|
|
79
|
+ mock: "mock",
|
|
77
|
80
|
none: "none",
|
|
78
|
81
|
tor: "tor",
|
|
79
|
82
|
});
|
| ... |
... |
@@ -218,6 +221,9 @@ export class TorProviderBuilder { |
|
218
|
221
|
|
|
219
|
222
|
let providerClass;
|
|
220
|
223
|
switch (this.providerType) {
|
|
|
224
|
+ case TorProviders.mock:
|
|
|
225
|
+ providerClass = lazy.TorProviderMock;
|
|
|
226
|
+ break;
|
|
221
|
227
|
case TorProviders.tor:
|
|
222
|
228
|
providerClass = lazy.TorProvider;
|
|
223
|
229
|
break;
|
toolkit/components/tor-launcher/TorProviderMock.sys.mjs
|
|
1
|
+import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs";
|
|
|
2
|
+import { TorProviderBase } from "moz-src:///toolkit/components/tor-launcher/TorProviderBase.sys.mjs";
|
|
|
3
|
+import { TorProviderTopics } from "moz-src:///toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs";
|
|
|
4
|
+
|
|
|
5
|
+const kBootstrapSteps = [
|
|
|
6
|
+ { PROGRESS: 5, TAG: "starting", SUMMARY: "Starting" },
|
|
|
7
|
+ { PROGRESS: 14, TAG: "handshake", SUMMARY: "Handshaking with a relay" },
|
|
|
8
|
+ {
|
|
|
9
|
+ PROGRESS: 45,
|
|
|
10
|
+ TAG: "requesting_descriptors",
|
|
|
11
|
+ SUMMARY: "Asking for relay descriptors",
|
|
|
12
|
+ },
|
|
|
13
|
+ {
|
|
|
14
|
+ PROGRESS: 75,
|
|
|
15
|
+ TAG: "loading_descriptors",
|
|
|
16
|
+ SUMMARY: "Loading relay descriptors",
|
|
|
17
|
+ },
|
|
|
18
|
+ { PROGRESS: 100, TAG: "done", SUMMARY: "Done" },
|
|
|
19
|
+];
|
|
|
20
|
+
|
|
|
21
|
+const kBootstrapStepDelayMs = 500;
|
|
|
22
|
+
|
|
|
23
|
+/**
|
|
|
24
|
+ * A mock tor provider for testing purposes. Fakes all provider operations
|
|
|
25
|
+ * without starting a real Tor daemon. This implementation is intentionally
|
|
|
26
|
+ * minimal and will be extended as test requirements become clearer.
|
|
|
27
|
+ */
|
|
|
28
|
+export class TorProviderMock extends TorProviderBase {
|
|
|
29
|
+ #bootstrapTimeoutIds = [];
|
|
|
30
|
+
|
|
|
31
|
+ async _initInternal() {}
|
|
|
32
|
+
|
|
|
33
|
+ async _uninitInternal() {
|
|
|
34
|
+ this.#cancelBootstrap();
|
|
|
35
|
+ }
|
|
|
36
|
+
|
|
|
37
|
+ async writeBridgeSettings(_bridges) {}
|
|
|
38
|
+
|
|
|
39
|
+ async writeProxySettings(_proxy) {}
|
|
|
40
|
+
|
|
|
41
|
+ async writeFirewallSettings(_firewall) {}
|
|
|
42
|
+
|
|
|
43
|
+ async flushSettings() {}
|
|
|
44
|
+
|
|
|
45
|
+ async connect() {
|
|
|
46
|
+ this.#cancelBootstrap();
|
|
|
47
|
+ for (const [i, step] of kBootstrapSteps.entries()) {
|
|
|
48
|
+ const id = setTimeout(
|
|
|
49
|
+ () => {
|
|
|
50
|
+ Services.obs.notifyObservers(
|
|
|
51
|
+ { ...step, TYPE: "NOTICE" },
|
|
|
52
|
+ TorProviderTopics.BootstrapStatus
|
|
|
53
|
+ );
|
|
|
54
|
+ },
|
|
|
55
|
+ (i + 1) * kBootstrapStepDelayMs
|
|
|
56
|
+ );
|
|
|
57
|
+ this.#bootstrapTimeoutIds.push(id);
|
|
|
58
|
+ }
|
|
|
59
|
+ }
|
|
|
60
|
+
|
|
|
61
|
+ async stopBootstrap() {
|
|
|
62
|
+ this.#cancelBootstrap();
|
|
|
63
|
+ }
|
|
|
64
|
+
|
|
|
65
|
+ #cancelBootstrap() {
|
|
|
66
|
+ for (const id of this.#bootstrapTimeoutIds) {
|
|
|
67
|
+ clearTimeout(id);
|
|
|
68
|
+ }
|
|
|
69
|
+ this.#bootstrapTimeoutIds = [];
|
|
|
70
|
+ }
|
|
|
71
|
+
|
|
|
72
|
+ async newnym() {}
|
|
|
73
|
+
|
|
|
74
|
+ async getBridges() {
|
|
|
75
|
+ return [];
|
|
|
76
|
+ }
|
|
|
77
|
+
|
|
|
78
|
+ async getPluggableTransports() {
|
|
|
79
|
+ return [];
|
|
|
80
|
+ }
|
|
|
81
|
+
|
|
|
82
|
+ async onionAuthAdd(_address, _b64PrivateKey, _isPermanent) {}
|
|
|
83
|
+
|
|
|
84
|
+ async onionAuthRemove(_address) {}
|
|
|
85
|
+
|
|
|
86
|
+ async onionAuthViewKeys() {
|
|
|
87
|
+ return [];
|
|
|
88
|
+ }
|
|
|
89
|
+
|
|
|
90
|
+ get currentBridge() {
|
|
|
91
|
+ return null;
|
|
|
92
|
+ }
|
|
|
93
|
+} |
toolkit/components/tor-launcher/moz.build
| ... |
... |
@@ -9,6 +9,7 @@ MOZ_SRC_FILES += [ |
|
9
|
9
|
"TorProvider.sys.mjs",
|
|
10
|
10
|
"TorProviderBase.sys.mjs",
|
|
11
|
11
|
"TorProviderBuilder.sys.mjs",
|
|
|
12
|
+ "TorProviderMock.sys.mjs",
|
|
12
|
13
|
"TorProviderNone.sys.mjs",
|
|
13
|
14
|
"TorStartupService.sys.mjs",
|
|
14
|
15
|
]
|
|