brizental pushed to branch tor-browser-150.0a1-16.0-2 at The Tor Project / Applications / Tor Browser 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: - testing/mozharness/configs/android/android_common.py - testing/mozharness/scripts/android_emulator_unittest.py - toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs - + toolkit/components/tor-launcher/TorProviderMock.sys.mjs - toolkit/components/tor-launcher/moz.build Changes: ===================================== testing/mozharness/configs/android/android_common.py ===================================== @@ -323,6 +323,19 @@ config = { "%(abs_marionette_manifest_dir)s/unit-tests.toml", ], }, + "marionette-mocktorprovider": { + "run_filename": "runtests.py", + "testsdir": "marionette/harness/marionette_harness", + "install": True, + "options": [ + "-vv", + "--address=127.0.0.1:2828", + "--app=fennec", + ], + "tests": [ + "%(abs_marionette_manifest_dir)s/unit-tests.toml", + ], + }, }, # end suite_definitions "unstructured_suites": [ "jittest", ===================================== testing/mozharness/scripts/android_emulator_unittest.py ===================================== @@ -13,6 +13,8 @@ import sys import tempfile import time +import yaml + # load modules from parent dir here = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(1, os.path.dirname(here)) @@ -30,7 +32,14 @@ from mozharness.mozilla.testing.codecoverage import ( from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options SUITE_DEFAULT_E10S = ["geckoview-junit", "mochitest", "reftest"] -SUITE_NO_E10S = ["cppunittest", "gtest", "jittest", "xpcshell", "marionette"] +SUITE_NO_E10S = [ + "cppunittest", + "gtest", + "jittest", + "xpcshell", + "marionette", + "marionette-mocktorprovider", +] SUITE_REPEATABLE = ["mochitest", "reftest", "xpcshell"] @@ -509,23 +518,31 @@ class AndroidEmulatorTest( self.register_virtualenv_module(requirements=[requirements]) - def _marionette_setup(self): + def _marionette_setup(self, mock_tor_provider=False): adb = self.query_exe("adb") self.run_command([adb, "forward", "tcp:2828", "tcp:2828"]) with tempfile.NamedTemporaryFile(suffix=".yaml") as tmp_file: - tmp_file.write( - b"""args: -- --marionette -- --remote-allow-system-access -""" - ) + config = {"args": ["--marionette", "--remote-allow-system-access"]} + + if mock_tor_provider: + config["env"] = {"TOR_PROVIDER": "mock"} + + tmp_file.write(yaml.dump(config, encoding="utf-8")) tmp_file.flush() remote_path = f"/data/local/tmp/{self.package_name}-geckoview-config.yaml" self.run_command([adb, "push", tmp_file.name, remote_path]) + self.run_command([ + adb, + "shell", + "am", + "set-debug-app", + "--persistent", + self.package_name, + ]) self.run_command([ adb, "shell", @@ -569,7 +586,7 @@ class AndroidEmulatorTest( if requirements: self.register_virtualenv_module(requirements=[requirements]) - if ("marionette", "marionette") in suites: + if any("marionette" in suite_name for _, suite_name in self._query_suites()): self._configure_marionette_virtualenv(action) def download_and_extract(self): @@ -609,8 +626,8 @@ class AndroidEmulatorTest( for per_test_suite, suite in suites: self.test_suite = suite - if self.test_suite == "marionette": - self._marionette_setup() + if "marionette" in self.test_suite: + self._marionette_setup(self.test_suite == "marionette-mocktorprovider") try: cwd = self._query_tests_dir(self.test_suite) @@ -693,9 +710,10 @@ class AndroidEmulatorTest( @PostScriptAction("run-tests") def marionette_teardown(self, *args, **kwargs): - if ("marionette", "marionette") in self._query_suites(): + if any("marionette" in suite_name for _, suite_name in self._query_suites()): adb = self.query_exe("adb") self.run_command([adb, "shell", "am", "force-stop", self.package_name]) + self.run_command([adb, "shell", "am", "clear-debug-app"]) self.run_command([adb, "uninstall", self.package_name]) self.run_command([ adb, ===================================== toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs ===================================== @@ -7,6 +7,8 @@ ChromeUtils.defineESModuleGetters(lazy, { TorLauncherUtil: "moz-src:///toolkit/components/tor-launcher/TorLauncherUtil.sys.mjs", TorProvider: "moz-src:///toolkit/components/tor-launcher/TorProvider.sys.mjs", + TorProviderMock: + "moz-src:///toolkit/components/tor-launcher/TorProviderMock.sys.mjs", TorProviderNone: "moz-src:///toolkit/components/tor-launcher/TorProviderNone.sys.mjs", }); @@ -74,6 +76,7 @@ export class TorBootstrapError extends Error { } export const TorProviders = Object.freeze({ + mock: "mock", none: "none", tor: "tor", }); @@ -218,6 +221,9 @@ export class TorProviderBuilder { let providerClass; switch (this.providerType) { + case TorProviders.mock: + providerClass = lazy.TorProviderMock; + break; case TorProviders.tor: providerClass = lazy.TorProvider; break; ===================================== toolkit/components/tor-launcher/TorProviderMock.sys.mjs ===================================== @@ -0,0 +1,93 @@ +import { setTimeout, clearTimeout } from "resource://gre/modules/Timer.sys.mjs"; +import { TorProviderBase } from "moz-src:///toolkit/components/tor-launcher/TorProviderBase.sys.mjs"; +import { TorProviderTopics } from "moz-src:///toolkit/components/tor-launcher/TorProviderBuilder.sys.mjs"; + +const kBootstrapSteps = [ + { PROGRESS: 5, TAG: "starting", SUMMARY: "Starting" }, + { PROGRESS: 14, TAG: "handshake", SUMMARY: "Handshaking with a relay" }, + { + PROGRESS: 45, + TAG: "requesting_descriptors", + SUMMARY: "Asking for relay descriptors", + }, + { + PROGRESS: 75, + TAG: "loading_descriptors", + SUMMARY: "Loading relay descriptors", + }, + { PROGRESS: 100, TAG: "done", SUMMARY: "Done" }, +]; + +const kBootstrapStepDelayMs = 500; + +/** + * A mock tor provider for testing purposes. Fakes all provider operations + * without starting a real Tor daemon. This implementation is intentionally + * minimal and will be extended as test requirements become clearer. + */ +export class TorProviderMock extends TorProviderBase { + #bootstrapTimeoutIds = []; + + async _initInternal() {} + + async _uninitInternal() { + this.#cancelBootstrap(); + } + + async writeBridgeSettings(_bridges) {} + + async writeProxySettings(_proxy) {} + + async writeFirewallSettings(_firewall) {} + + async flushSettings() {} + + async connect() { + this.#cancelBootstrap(); + for (const [i, step] of kBootstrapSteps.entries()) { + const id = setTimeout( + () => { + Services.obs.notifyObservers( + { ...step, TYPE: "NOTICE" }, + TorProviderTopics.BootstrapStatus + ); + }, + (i + 1) * kBootstrapStepDelayMs + ); + this.#bootstrapTimeoutIds.push(id); + } + } + + async stopBootstrap() { + this.#cancelBootstrap(); + } + + #cancelBootstrap() { + for (const id of this.#bootstrapTimeoutIds) { + clearTimeout(id); + } + this.#bootstrapTimeoutIds = []; + } + + async newnym() {} + + async getBridges() { + return []; + } + + async getPluggableTransports() { + return []; + } + + async onionAuthAdd(_address, _b64PrivateKey, _isPermanent) {} + + async onionAuthRemove(_address) {} + + async onionAuthViewKeys() { + return []; + } + + get currentBridge() { + return null; + } +} ===================================== toolkit/components/tor-launcher/moz.build ===================================== @@ -9,6 +9,7 @@ MOZ_SRC_FILES += [ "TorProvider.sys.mjs", "TorProviderBase.sys.mjs", "TorProviderBuilder.sys.mjs", + "TorProviderMock.sys.mjs", "TorProviderNone.sys.mjs", "TorStartupService.sys.mjs", ] View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/636582e... -- View it on GitLab: https://gitlab.torproject.org/tpo/applications/tor-browser/-/compare/636582e... You're receiving this email because of your account on gitlab.torproject.org. Manage all notifications: https://gitlab.torproject.org/-/profile/notifications | Help: https://gitlab.torproject.org/help
participants (1)
-
brizental (@brizental)