tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

win_unittest.py (19381B)


      1 # This Source Code Form is subject to the terms of the Mozilla Public
      2 # License, v. 2.0. If a copy of the MPL was not distributed with this
      3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
      4 
      5 import os
      6 import platform
      7 import sys
      8 
      9 # OS Specifics
     10 ABS_WORK_DIR = os.path.join(os.getcwd(), "build")
     11 BINARY_PATH = os.path.join(ABS_WORK_DIR, "firefox", "firefox.exe")
     12 INSTALLER_PATH = os.path.join(ABS_WORK_DIR, "installer.zip")
     13 NODEJS_PATH = None
     14 if "MOZ_FETCHES_DIR" in os.environ:
     15    NODEJS_PATH = os.path.join(os.environ["MOZ_FETCHES_DIR"], "node/node.exe")
     16 
     17 REQUIRE_GPU = False
     18 if "REQUIRE_GPU" in os.environ:
     19    REQUIRE_GPU = os.environ["REQUIRE_GPU"] == "1"
     20 
     21 USE_HARDWARE = False
     22 if "USE_HARDWARE" in os.environ:
     23    USE_HARDWARE = os.environ["USE_HARDWARE"] == "1"
     24 
     25 PYWIN32 = "pywin32==306"
     26 
     27 XPCSHELL_NAME = "xpcshell.exe"
     28 EXE_SUFFIX = ".exe"
     29 DISABLE_SCREEN_SAVER = False
     30 ADJUST_MOUSE_AND_SCREEN = True
     31 DESKTOP_VISUALFX_THEME = {
     32    "Let Windows choose": 0,
     33    "Best appearance": 1,
     34    "Best performance": 2,
     35    "Custom": 3,
     36 }.get("Best appearance")
     37 TASKBAR_AUTOHIDE_REG_PATH = {
     38    "Windows 7": r"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects2",
     39    "Windows 10": r"HKCU:SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3",
     40 }.get(f"{platform.system()} {platform.release()}")
     41 #####
     42 config = {
     43    "exes": {
     44        "python": sys.executable,
     45        "hg": os.path.join(os.environ.get("PROGRAMFILES", ""), "Mercurial", "hg"),
     46    },
     47    ###
     48    "installer_path": INSTALLER_PATH,
     49    "binary_path": BINARY_PATH,
     50    "xpcshell_name": XPCSHELL_NAME,
     51    "virtualenv_modules": [PYWIN32, "six==1.16.0", "vcversioner==2.16.0.0"],
     52    "virtualenv_path": "venv",
     53    "exe_suffix": EXE_SUFFIX,
     54    "run_file_names": {
     55        "mochitest": "runtests.py",
     56        "reftest": "runreftest.py",
     57        "xpcshell": "runxpcshelltests.py",
     58        "cppunittest": "runcppunittests.py",
     59        "gtest": "rungtests.py",
     60        "jittest": "jit_test.py",
     61    },
     62    "minimum_tests_zip_dirs": [
     63        "bin/*",
     64        "certs/*",
     65        "config/*",
     66        "mach",
     67        "marionette/*",
     68        "modules/*",
     69        "mozbase/*",
     70        "tools/*",
     71        "mozpack/*",
     72        "mozbuild/*",
     73    ],
     74    "suite_definitions": {
     75        "cppunittest": {
     76            "options": [
     77                "--symbols-path=%(symbols_path)s",
     78                "--utility-path=tests/bin",
     79                "--xre-path=%(abs_app_dir)s",
     80            ],
     81            "run_filename": "runcppunittests.py",
     82            "testsdir": "cppunittest",
     83        },
     84        "jittest": {
     85            "options": [
     86                "tests/bin/js",
     87                "--no-slow",
     88                "--no-progress",
     89                "--format=automation",
     90                "--jitflags=all",
     91                "--timeout=970",  # Keep in sync with run_timeout below.
     92            ],
     93            "run_filename": "jit_test.py",
     94            "testsdir": "jit-test/jit-test",
     95            "run_timeout": 1000,  # Keep in sync with --timeout above.
     96        },
     97        "mochitest": {
     98            "options": [
     99                "--appname=%(binary_path)s",
    100                "--utility-path=tests/bin",
    101                "--extra-profile-file=tests/bin/plugins",
    102                "--symbols-path=%(symbols_path)s",
    103                "--certificate-path=tests/certs",
    104                "--quiet",
    105                "--log-errorsummary=%(error_summary_file)s",
    106                "--screenshot-on-fail",
    107                "--cleanup-crashes",
    108                "--marionette-startup-timeout=180",
    109            ],
    110            "run_filename": "runtests.py",
    111            "testsdir": "mochitest",
    112        },
    113        "reftest": {
    114            "options": [
    115                "--appname=%(binary_path)s",
    116                "--utility-path=tests/bin",
    117                "--extra-profile-file=tests/bin/plugins",
    118                "--symbols-path=%(symbols_path)s",
    119                "--log-errorsummary=%(error_summary_file)s",
    120                "--cleanup-crashes",
    121                "--marionette-startup-timeout=180",
    122                "--sandbox-read-whitelist=%(abs_work_dir)s",
    123            ],
    124            "run_filename": "runreftest.py",
    125            "testsdir": "reftest",
    126        },
    127        "xpcshell": {
    128            "options": [
    129                "--self-test",
    130                "--symbols-path=%(symbols_path)s",
    131                "--log-errorsummary=%(error_summary_file)s",
    132                "--utility-path=tests/bin",
    133                "--manifest=tests/xpcshell/tests/xpcshell.toml",
    134            ],
    135            "run_filename": "runxpcshelltests.py",
    136            "testsdir": "xpcshell",
    137        },
    138        "gtest": {
    139            "options": [
    140                "--xre-path=%(abs_res_dir)s",
    141                "--cwd=%(gtest_dir)s",
    142                "--symbols-path=%(symbols_path)s",
    143                "--utility-path=tests/bin",
    144                "%(binary_path)s",
    145            ],
    146            "run_filename": "rungtests.py",
    147        },
    148    },
    149    # local mochi suites
    150    "all_mochitest_suites": {
    151        "mochitest-plain": ["--chunk-by-dir=4"],
    152        "mochitest-plain-gpu": ["--subsuite=gpu"],
    153        "mochitest-media": ["--subsuite=media"],
    154        "mochitest-chrome": ["--flavor=chrome", "--chunk-by-dir=4", "--disable-e10s"],
    155        "mochitest-chrome-gpu": ["--flavor=chrome", "--subsuite=gpu", "--disable-e10s"],
    156        "mochitest-browser-chrome": ["--flavor=browser", "--chunk-by-runtime"],
    157        "mochitest-browser-screenshots": [
    158            "--flavor=browser",
    159            "--subsuite=screenshots",
    160        ],
    161        "mochitest-webgl1-core": ["--subsuite=webgl1-core"],
    162        "mochitest-webgl1-ext": ["--subsuite=webgl1-ext"],
    163        "mochitest-webgl2-core": ["--subsuite=webgl2-core"],
    164        "mochitest-webgl2-ext": ["--subsuite=webgl2-ext"],
    165        "mochitest-webgl2-deqp": ["--subsuite=webgl2-deqp"],
    166        "mochitest-webgpu": ["--subsuite=webgpu"],
    167        "mochitest-devtools-chrome": [
    168            "--flavor=browser",
    169            "--subsuite=devtools",
    170            "--chunk-by-runtime",
    171        ],
    172        "mochitest-browser-a11y": ["--flavor=browser", "--subsuite=a11y"],
    173        "mochitest-browser-media": ["--flavor=browser", "--subsuite=media-bc"],
    174        "mochitest-browser-translations": [
    175            "--flavor=browser",
    176            "--subsuite=translations",
    177        ],
    178        "mochitest-a11y": ["--flavor=a11y", "--disable-e10s"],
    179        "mochitest-remote": ["--flavor=browser", "--subsuite=remote"],
    180    },
    181    # local reftest suites
    182    "all_reftest_suites": {
    183        "crashtest": {
    184            "options": ["--suite=crashtest", "--topsrcdir=tests/reftest/tests"],
    185            "tests": ["tests/reftest/tests/testing/crashtest/crashtests.list"],
    186        },
    187        "jsreftest": {
    188            "options": [
    189                "--extra-profile-file=tests/jsreftest/tests/js/src/tests/user.js",
    190                "--suite=jstestbrowser",
    191                "--topsrcdir=tests/jsreftest/tests",
    192            ],
    193            "tests": ["tests/jsreftest/tests/js/src/tests/jstests.list"],
    194        },
    195        "reftest": {
    196            "options": ["--suite=reftest", "--topsrcdir=tests/reftest/tests"],
    197            "tests": ["tests/reftest/tests/layout/reftests/reftest.list"],
    198        },
    199    },
    200    "all_xpcshell_suites": {
    201        "xpcshell": {
    202            "options": [
    203                "--xpcshell=%(abs_app_dir)s/" + XPCSHELL_NAME,
    204                "--msix-app-binary=%(binary_path)s",
    205                "--msix-app-path=%(install_dir)s",
    206                "--msix-xre-path=%(install_dir)s",
    207            ],
    208            "tests": [],
    209        },
    210    },
    211    "all_cppunittest_suites": {"cppunittest": ["tests/cppunittest"]},
    212    "all_gtest_suites": {"gtest": []},
    213    "all_jittest_suites": {
    214        "jittest": [],
    215        "jittest-chunked": [],
    216    },
    217    "run_cmd_checks_enabled": True,
    218    "preflight_run_cmd_suites": [
    219        {
    220            "name": "disable_screen_saver",
    221            "cmd": ["xset", "s", "off", "s", "reset"],
    222            "architectures": ["32bit", "64bit"],
    223            "halt_on_failure": False,
    224            "enabled": DISABLE_SCREEN_SAVER,
    225        },
    226        {
    227            "name": "run mouse & screen adjustment script",
    228            "cmd": [
    229                sys.executable,
    230                os.path.join(
    231                    os.getcwd(),
    232                    "mozharness",
    233                    "external_tools",
    234                    "mouse_and_screen_resolution.py",
    235                ),
    236                "--configuration-file",
    237                os.path.join(
    238                    os.getcwd(),
    239                    "mozharness",
    240                    "external_tools",
    241                    "machine-configuration.json",
    242                ),
    243                (
    244                    "--platform=win10-vm"
    245                    if REQUIRE_GPU and (platform.uname().version == "10.0.19045")
    246                    else (
    247                        "--platform=win11-hw"
    248                        if REQUIRE_GPU and (platform.uname().version == "10.0.26100")
    249                        else "--platform=win7"
    250                    )
    251                ),
    252            ],
    253            "architectures": ["32bit", "64bit"],
    254            "halt_on_failure": True,
    255            "enabled": ADJUST_MOUSE_AND_SCREEN,
    256        },
    257        {
    258            "name": "enable microphone access for msix",
    259            "cmd": [
    260                "powershell",
    261                "-command",
    262                r'New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\ -Name "Mozilla.MozillaFirefoxNightly_5x4grbbqzn2q4" -Force',
    263            ],
    264            "architectures": ["32bit", "64bit"],
    265            "halt_on_failure": True,
    266            "enabled": True,
    267        },
    268        {
    269            "name": "enable microphone access for msix, add allow key",
    270            "cmd": [
    271                "powershell",
    272                "-command",
    273                r'New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\Mozilla.MozillaFirefoxNightly_5x4grbbqzn2q4 -Name "Value" -Value "Allow" -Force',
    274            ],
    275            "architectures": ["32bit", "64bit"],
    276            "halt_on_failure": True,
    277            "enabled": True,
    278        },
    279        {
    280            "name": "enable microphone access for msix (central)",
    281            "cmd": [
    282                "powershell",
    283                "-command",
    284                r'New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\ -Name "Mozilla.MozillaFirefoxNightly_jag0gd4e3s9p2" -Force',
    285            ],
    286            "architectures": ["32bit", "64bit"],
    287            "halt_on_failure": True,
    288            "enabled": True,
    289        },
    290        {
    291            "name": "enable microphone access for msix, add allow key (central)",
    292            "cmd": [
    293                "powershell",
    294                "-command",
    295                r'New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\Mozilla.MozillaFirefoxNightly_jag0gd4e3s9p2 -Name "Value" -Value "Allow" -Force',
    296            ],
    297            "architectures": ["32bit", "64bit"],
    298            "halt_on_failure": True,
    299            "enabled": True,
    300        },
    301        {
    302            "name": "enable microphone access for msix (beta)",
    303            "cmd": [
    304                "powershell",
    305                "-command",
    306                r'New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\ -Name "Mozilla.MozillaFirefoxBeta_5x4grbbqzn2q4" -Force',
    307            ],
    308            "architectures": ["32bit", "64bit"],
    309            "halt_on_failure": True,
    310            "enabled": True,
    311        },
    312        {
    313            "name": "enable microphone access for msix, add allow key (beta)",
    314            "cmd": [
    315                "powershell",
    316                "-command",
    317                r'New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\Mozilla.MozillaFirefoxBeta_5x4grbbqzn2q4 -Name "Value" -Value "Allow" -Force',
    318            ],
    319            "architectures": ["32bit", "64bit"],
    320            "halt_on_failure": True,
    321            "enabled": True,
    322        },
    323        {
    324            "name": "enable microphone access for msix (beta)",
    325            "cmd": [
    326                "powershell",
    327                "-command",
    328                r'New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\ -Name "Mozilla.MozillaFirefoxBeta_jag0gd4e3s9p2" -Force',
    329            ],
    330            "architectures": ["32bit", "64bit"],
    331            "halt_on_failure": True,
    332            "enabled": True,
    333        },
    334        {
    335            "name": "enable microphone access for msix, add allow key (beta)",
    336            "cmd": [
    337                "powershell",
    338                "-command",
    339                r'New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\Mozilla.MozillaFirefoxBeta_jag0gd4e3s9p2 -Name "Value" -Value "Allow" -Force',
    340            ],
    341            "architectures": ["32bit", "64bit"],
    342            "halt_on_failure": True,
    343            "enabled": True,
    344        },
    345        {
    346            "name": "enable microphone access for msix (release)",
    347            "cmd": [
    348                "powershell",
    349                "-command",
    350                r'New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\ -Name "Mozilla.MozillaFirefox_jag0gd4e3s9p2" -Force',
    351            ],
    352            "architectures": ["32bit", "64bit"],
    353            "halt_on_failure": True,
    354            "enabled": True,
    355        },
    356        {
    357            "name": "enable microphone access for msix, add allow key (release)",
    358            "cmd": [
    359                "powershell",
    360                "-command",
    361                r'New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\Mozilla.MozillaFirefox_jag0gd4e3s9p2 -Name "Value" -Value "Allow" -Force',
    362            ],
    363            "architectures": ["32bit", "64bit"],
    364            "halt_on_failure": True,
    365            "enabled": True,
    366        },
    367        {
    368            "name": "enable microphone access for msix (esr)",
    369            "cmd": [
    370                "powershell",
    371                "-command",
    372                r'New-Item -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\ -Name "Mozilla.MozillaFirefox_5x4grbbqzn2q4" -Force',
    373            ],
    374            "architectures": ["32bit", "64bit"],
    375            "halt_on_failure": True,
    376            "enabled": True,
    377        },
    378        {
    379            "name": "enable microphone access for msix, add allow key (esr)",
    380            "cmd": [
    381                "powershell",
    382                "-command",
    383                r'New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\microphone\Mozilla.MozillaFirefox_5x4grbbqzn2q4 -Name "Value" -Value "Allow" -Force',
    384            ],
    385            "architectures": ["32bit", "64bit"],
    386            "halt_on_failure": True,
    387            "enabled": True,
    388        },
    389        {
    390            "name": "disable windows security and maintenance notifications",
    391            "cmd": [
    392                "powershell",
    393                "-command",
    394                "\"&{$p='HKCU:SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Notifications\\Settings\\Windows.SystemToast.SecurityAndMaintenance';if(!(Test-Path -Path $p)){&New-Item -Path $p -Force}&Set-ItemProperty -Path $p -Name Enabled -Value 0}\"",  # noqa
    395            ],
    396            "architectures": ["32bit", "64bit"],
    397            "halt_on_failure": True,
    398            "enabled": (platform.release() == "10"),
    399        },
    400        {
    401            "name": "set windows VisualFX",
    402            "cmd": [
    403                "powershell",
    404                "-command",
    405                f"\"&{{&Set-ItemProperty -Path 'HKCU:Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VisualEffects' -Name VisualFXSetting -Value {DESKTOP_VISUALFX_THEME}}}\"",
    406            ],
    407            "architectures": ["32bit", "64bit"],
    408            "halt_on_failure": True,
    409            "enabled": True,
    410        },
    411        {
    412            "name": "create scrollbars always show key",
    413            "cmd": [
    414                "powershell",
    415                "-command",
    416                "New-ItemProperty -Path 'HKCU:\\Control Panel\\Accessibility' -Name 'DynamicScrollbars' -Value 0",
    417            ],
    418            "architectures": ["32bit", "64bit"],
    419            "halt_on_failure": False,
    420            "enabled": True,
    421        },
    422        {
    423            "name": "hide windows taskbar",
    424            "cmd": [
    425                "powershell",
    426                "-command",
    427                f"\"&{{$p='{TASKBAR_AUTOHIDE_REG_PATH}';$v=(Get-ItemProperty -Path $p).Settings;$v[8]=3;&Set-ItemProperty -Path $p -Name Settings -Value $v}}\"",
    428            ],
    429            "architectures": ["32bit", "64bit"],
    430            "halt_on_failure": True,
    431            "enabled": True,
    432        },
    433        {
    434            "name": "restart windows explorer",
    435            "cmd": [
    436                "powershell",
    437                "-command",
    438                '"&{&Stop-Process -ProcessName explorer}"',
    439            ],
    440            "architectures": ["32bit", "64bit"],
    441            "halt_on_failure": True,
    442            "enabled": True,
    443        },
    444        {
    445            "name": "prepare chrome profile",
    446            "cmd": [
    447                "powershell",
    448                "-command",
    449                "if (test-path ${env:ProgramFiles(x86)}\\Google\\Chrome\\Application\\chrome.exe) {start chrome; Start-Sleep -s 30; taskkill /F /IM chrome.exe /T}",
    450            ],
    451            "architectures": ["32bit", "64bit"],
    452            "halt_on_failure": True,
    453            "enabled": False,
    454        },
    455        {
    456            "name": "ensure proper graphics driver",
    457            "cmd": [
    458                "powershell",
    459                "-command",
    460                'if (-Not ((Get-CimInstance win32_VideoController).InstalledDisplayDrivers | Out-String).contains("nvgrid")) { echo "Missing nvgrid driver: " + (Get-CimInstance win32_VideoController).InstalledDisplayDrivers; exit 4; }',
    461            ],
    462            "architectures": ["32bit", "64bit"],
    463            "halt_on_failure": True,
    464            "enabled": True if REQUIRE_GPU and not USE_HARDWARE else False,
    465            "fatal_exit_code": 4,
    466        },
    467        {
    468            "name": "ensure display refresh rate == 60",
    469            "cmd": [
    470                "powershell",
    471                "-command",
    472                'if (-Not ((Get-WmiObject win32_videocontroller).CurrentRefreshRate | Out-String).contains("60")) { echo "Screen refresh rate != 60: " + ((Get-WmiObject win32_videocontroller).CurrentRefreshRate | Out-String); exit 4; }',
    473            ],
    474            "architectures": ["32bit", "64bit"],
    475            "halt_on_failure": True,
    476            "enabled": True if REQUIRE_GPU and USE_HARDWARE else False,
    477            "fatal_exit_code": 4,
    478        },
    479    ],
    480    "vcs_output_timeout": 1000,
    481    "minidump_save_path": "%(abs_work_dir)s/../minidumps",
    482    "unstructured_flavors": {
    483        "gtest": [],
    484        "cppunittest": [],
    485        "jittest": [],
    486    },
    487    "nodejs_path": NODEJS_PATH,
    488 }