From 604365dd38555ff89449d9f7901db2a0e6dcdd06 Mon Sep 17 00:00:00 2001 From: "mr. m" Date: Sun, 8 Feb 2026 19:20:36 +0100 Subject: [PATCH] chore: Update external mochitests, b=no-bug, c=tests, scripts, common --- scripts/import_external_tests.py | 30 ++++++++++++++++--- scripts/run_tests.py | 2 +- src/zen/common/styles/zen-theme.css | 2 +- src/zen/tests/mochitests/moz.build | 3 ++ .../browser_content_sandbox_fs_tests.js | 7 ----- ...er_content_sandbox_fs_xdg_xdgConfigHome.js | 7 ----- .../sandbox/browser_xdg_default.toml | 7 ++--- .../sandbox/browser_xdg_mozLegacyHome.toml | 7 +---- .../sandbox/browser_xdg_xdgConfigHome.toml | 6 +--- 9 files changed, 35 insertions(+), 36 deletions(-) diff --git a/scripts/import_external_tests.py b/scripts/import_external_tests.py index 535686c61..d1339a4f4 100644 --- a/scripts/import_external_tests.py +++ b/scripts/import_external_tests.py @@ -18,10 +18,18 @@ FILE_PREFIX = """ # This file is autogenerated by scripts/import_external_tests.py # Do not edit manually. +""" + +BROWSER_MANIFEST_LIST_PREFIX = """ BROWSER_CHROME_MANIFESTS += [ """ +XPCSHELL_MANIFESTS_LIST_PREFIX = """ +XPCSHELL_TESTS_MANIFESTS += [ +""" + FILE_SUFFIX = "]" +VALID_MANIFEST_FILES = ["browser.toml", "xpcshell.toml"] def get_tests_manifest(): @@ -38,12 +46,17 @@ def validate_tests_path(path, files, ignore_list): for ignore in ignore_list: if ignore not in files: die_with_error(f"Ignore file '{ignore}' not found in tests folder '{path}'") - if "browser.toml" not in files or "browser.js" in ignore_list: - die_with_error(f"'browser.toml' not found in tests folder '{path}'") + if not any(manifest_file in files for manifest_file in VALID_MANIFEST_FILES): + die_with_error(f"None of the valid manifest files {VALID_MANIFEST_FILES} found in tests folder '{path}'") def disable_and_replace_manifest(manifest, output_path): - toml_file = os.path.join(output_path, "browser.toml") + toml_file = None + for manifest_file in VALID_MANIFEST_FILES: + candidate = os.path.join(output_path, manifest_file) + if os.path.exists(candidate): + toml_file = candidate + break disabled_tests = manifest.get("disable", []) with open(toml_file, "r") as f: data = f.read() @@ -90,8 +103,17 @@ def write_moz_build_file(manifest): print(f"Writing moz.build file to '{moz_build_path}'") with open(moz_build_path, "w") as f: f.write(FILE_PREFIX) + f.write(BROWSER_MANIFEST_LIST_PREFIX) for test_suite in manifest.keys(): - f.write(f'\t"{test_suite}/browser.toml",\n') + # add for browser.toml first + if not manifest[test_suite].get("xpcshell", False): + f.write(f'\t"{test_suite}/browser.toml",\n') + f.write(FILE_SUFFIX) + f.write(XPCSHELL_MANIFESTS_LIST_PREFIX) + for test_suite in manifest.keys(): + # add for xpcshell.toml + if manifest[test_suite].get("xpcshell", False): + f.write(f'\t"{test_suite}/xpcshell.toml",\n') f.write(FILE_SUFFIX) diff --git a/scripts/run_tests.py b/scripts/run_tests.py index 958b09ce4..743e2f1e2 100644 --- a/scripts/run_tests.py +++ b/scripts/run_tests.py @@ -56,7 +56,7 @@ def main(): os.chdir(engine_dir) def run_mach_with_paths(test_paths): - command = ['./mach', 'mochitest'] + other_args + test_paths + command = ['./mach', 'test'] + other_args + test_paths # Replace the current process with the mach command os.execvp(command[0], command) diff --git a/src/zen/common/styles/zen-theme.css b/src/zen/common/styles/zen-theme.css index 006b40c5e..88d3ff741 100644 --- a/src/zen/common/styles/zen-theme.css +++ b/src/zen/common/styles/zen-theme.css @@ -9,7 +9,7 @@ */ :host(:is(.anonymous-content-host, notification-message)), -:root { +:root:not([windowtype^="Browser:"]) { /* Default values */ --zen-border-radius: 7px; --zen-primary-color: AccentColor; diff --git a/src/zen/tests/mochitests/moz.build b/src/zen/tests/mochitests/moz.build index efc1a106d..2acf5ec61 100644 --- a/src/zen/tests/mochitests/moz.build +++ b/src/zen/tests/mochitests/moz.build @@ -6,9 +6,12 @@ # This file is autogenerated by scripts/import_external_tests.py # Do not edit manually. + BROWSER_CHROME_MANIFESTS += [ "safebrowsing/browser.toml", "sandbox/browser.toml", "shell/browser.toml", "tooltiptext/browser.toml", +] +XPCSHELL_TESTS_MANIFESTS += [ ] \ No newline at end of file diff --git a/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_tests.js b/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_tests.js index 9e2232f40..7a415c2ed 100644 --- a/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_tests.js +++ b/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_tests.js @@ -682,13 +682,6 @@ async function testFileAccessWindowsOnly() { let tests = []; let extDir = GetPerUserExtensionDir(); - // We used to unconditionally create this directory from Firefox, but that - // was dropped in bug 2001887. The value of this directory is questionable; - // the test was added in Firefox 56 (bug 1403744) to cover legacy add-ons, - // but legacy add-on support was discontinued in Firefox 57, and we stopped - // sideloading add-ons from this directory on all builds except ESR in - // Firefox 74 (bug 1602840). - await IOUtils.makeDirectory(extDir.path); tests.push({ desc: "per-user extensions dir", ok: true, diff --git a/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_xdg_xdgConfigHome.js b/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_xdg_xdgConfigHome.js index 678101c5a..992435d7a 100644 --- a/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_xdg_xdgConfigHome.js +++ b/src/zen/tests/mochitests/sandbox/browser_content_sandbox_fs_xdg_xdgConfigHome.js @@ -22,13 +22,6 @@ add_setup(async function setup() { const xdgConfigHome = Services.env.get("XDG_CONFIG_HOME"); Assert.greater(xdgConfigHome.length, 1, "XDG_CONFIG_HOME is defined"); - // Verify the profile directory is inside XDG_CONFIG_HOME - const profileDir = Services.dirsvc.get("ProfD", Ci.nsIFile); - Assert.ok( - profileDir.path.startsWith(xdgConfigHome), - `Profile directory (${profileDir.path}) should be inside XDG_CONFIG_HOME (${xdgConfigHome})` - ); - // If it is there, do actual testing sanityChecks(); }); diff --git a/src/zen/tests/mochitests/sandbox/browser_xdg_default.toml b/src/zen/tests/mochitests/sandbox/browser_xdg_default.toml index ab7d75b8c..e32443de2 100644 --- a/src/zen/tests/mochitests/sandbox/browser_xdg_default.toml +++ b/src/zen/tests/mochitests/sandbox/browser_xdg_default.toml @@ -12,14 +12,11 @@ support-files = [ "browser_content_sandbox_utils.js", "browser_content_sandbox_fs_tests.js", ] -test-directories = [ - "/tmp/.xdg_default_test", - "/tmp/.xdg_default_test/.config/mozilla/firefox/xdg_default_profile", -] +# .config needs to exists for the sandbox to properly add it +test-directories = ["/tmp/.xdg_default_test", "/tmp/.xdg_default_test/.config"] environment = [ "HOME=/tmp/.xdg_default_test", ] -profile-path = "/tmp/.xdg_default_test/.config/mozilla/firefox/xdg_default_profile" ["browser_content_sandbox_fs_xdg_default.js"] run-if = ["os == 'linux'"] diff --git a/src/zen/tests/mochitests/sandbox/browser_xdg_mozLegacyHome.toml b/src/zen/tests/mochitests/sandbox/browser_xdg_mozLegacyHome.toml index 4e30a8e33..242c01464 100644 --- a/src/zen/tests/mochitests/sandbox/browser_xdg_mozLegacyHome.toml +++ b/src/zen/tests/mochitests/sandbox/browser_xdg_mozLegacyHome.toml @@ -12,17 +12,12 @@ support-files = [ "browser_content_sandbox_utils.js", "browser_content_sandbox_fs_tests.js", ] -test-directories = [ - "/tmp/.xdg_mozLegacyHome_test/.config", - "/tmp/.xdg_config_home_test", - "/tmp/.xdg_mozLegacyHome_test/.mozilla/firefox/xdg_mozLegacyHome_profile", -] +test-directories = ["/tmp/.xdg_mozLegacyHome_test/.config", "/tmp/.xdg_config_home_test"] environment = [ "XDG_CONFIG_HOME=/tmp/.xdg_config_home_test", "HOME=/tmp/.xdg_mozLegacyHome_test", "MOZ_LEGACY_HOME=1", ] -profile-path = "/tmp/.xdg_mozLegacyHome_test/.mozilla/firefox/xdg_mozLegacyHome_profile" ["browser_content_sandbox_fs_xdg_mozLegacyHome.js"] run-if = ["os == 'linux'"] diff --git a/src/zen/tests/mochitests/sandbox/browser_xdg_xdgConfigHome.toml b/src/zen/tests/mochitests/sandbox/browser_xdg_xdgConfigHome.toml index b32d0c25d..a6be37835 100644 --- a/src/zen/tests/mochitests/sandbox/browser_xdg_xdgConfigHome.toml +++ b/src/zen/tests/mochitests/sandbox/browser_xdg_xdgConfigHome.toml @@ -11,15 +11,11 @@ support-files = [ "browser_content_sandbox_utils.js", "browser_content_sandbox_fs_tests.js", ] -test-directories = [ - "/tmp/.xdg_config_home_test", - "/tmp/.xdg_config_home_test/mozilla/firefox/xdg_config_home_profile", -] +test-directories = "/tmp/.xdg_config_home_test" environment = [ "XDG_CONFIG_HOME=/tmp/.xdg_config_home_test", "MOZ_LEGACY_HOME=0", ] -profile-path = "/tmp/.xdg_config_home_test/mozilla/firefox/xdg_config_home_profile" ["browser_content_sandbox_fs_xdg_xdgConfigHome.js"] run-if = [