|
1 | 1 | """agentenv's chromium app: Chrome for Testing at the build Playwright 1.64.1 pins, for amd64 and arm64 (Google ships |
2 | | -no Linux arm64 Chrome), a website browser whose flags, policies and settings agentenv's base class gives it. Its data is |
| 2 | +no Linux arm64 Chrome), a website browser whose flags, policies and settings agentenv's base class gives it, with the |
| 3 | +flags and policies of its own that stop the requests this build makes of its own. Its data is |
3 | 4 | its profile, which the image has none of, so every deploy and every reset starts with a clean one.""" |
4 | 5 | import subprocess |
5 | 6 | from pathlib import Path |
|
25 | 26 | PROFILE = ".config/chromium" |
26 | 27 | #: The shared memory, in MiB, Chrome's renderers get in /dev/shm, so a heavy page doesn't fill Docker's 64 MiB. |
27 | 28 | SHM_MB = 1024 |
| 29 | +# What stops the requests this build makes of its own, found against VERSION behind a browser alone's proxy: check them |
| 30 | +# again when VERSION moves. One is left, a Google account check at launch, which none of them stops. |
| 31 | +#: Flags: Safe Browsing's list updates, among its other background services; and the component updater's checks, at |
| 32 | +#: launch and a minute later, pointed at a file it can't fetch, since ComponentUpdatesEnabled leaves the components |
| 33 | +#: Chrome deems critical, such as its CRLSets, checking in. |
| 34 | +QUIET_FLAGS = ["--disable-background-networking", "--component-updater=url-source=file:///dev/null"] |
| 35 | +#: Features off: the AI Mode eligibility check at launch, which no policy stops; and the preconnect to its search engine |
| 36 | +#: at launch, which NetworkPredictionOptions would stop only by turning off the preconnects and prefetches it makes for |
| 37 | +#: pages too. |
| 38 | +DISABLED_FEATURES = ["AimEnabled", "PreconnectToSearch"] |
| 39 | +#: Every language Chromium has a spellcheck dictionary for, from its spellcheck_common.cc: blocklisted, so it fetches |
| 40 | +#: none for the deploy's locale at launch. SpellcheckEnabled false would void the blocklist and still fetch it. |
| 41 | +SPELLCHECK_LANGUAGES = ["af", "bg", "ca", "cs", "cy", "da", "de", "de-DE", "el", "en", "en-AU", "en-CA", "en-GB", |
| 42 | + "en-GB-oxendict", "en-US", "es", "es-419", "es-AR", "es-ES", "es-MX", "es-US", "et", "fa", "fo", |
| 43 | + "fr", "fr-FR", "gl", "he", "hi", "hr", "hu", "hy", "id", "it", "it-IT", "ko", "lt", "lv", "nb", |
| 44 | + "nl", "pl", "pt", "pt-BR", "pt-PT", "ro", "ru", "sh", "sk", "sl", "sq", "sr", "sv", "ta", "tg", |
| 45 | + "tr", "uk", "vi"] |
| 46 | +#: Policies, over agentenv's: the network time query, spellcheck dictionaries, and the autofill server's field |
| 47 | +#: predictions for a page's forms, which agentenv's AutofillSettings leaves on in this build. |
| 48 | +QUIET_POLICIES = {"BrowserNetworkTimeQueriesEnabled": False, "SpellcheckLanguageBlocklist": SPELLCHECK_LANGUAGES, |
| 49 | + "AutofillAddressEnabled": False, "AutofillCreditCardEnabled": False} |
| 50 | +COMMAND = ["chromium/chrome/chrome", "--no-sandbox", f"--class={WINDOW_CLASS}", *QUIET_FLAGS, |
| 51 | + f"--disable-features={','.join(DISABLED_FEATURES)}"] |
28 | 52 |
|
29 | 53 |
|
30 | 54 | @computer_app(supports=[{"os": {"type": "linux", "display": ["x11", "none"]}, "arch": ["amd64", "arm64"]}]) |
31 | 55 | @linux(packages=Packages(apt=PACKAGES), downloads=DOWNLOADS, paths=[PROFILE], shm_mb=SHM_MB, |
32 | | - launch=Launch(at="boot", command=["chromium/chrome/chrome", "--no-sandbox", f"--class={WINDOW_CLASS}"], |
33 | | - window={"class": WINDOW_CLASS}, ready=Ready(window=True))) |
| 56 | + launch=Launch(at="boot", command=COMMAND, window={"class": WINDOW_CLASS}, ready=Ready(window=True))) |
34 | 57 | class Chromium(WebsiteBrowserEnvironment): |
35 | | - """Chrome for Testing without its sandbox, which a container can't give it.""" |
| 58 | + """Chrome for Testing without its sandbox, which a container can't give it, and with none of the requests it makes |
| 59 | + of its own but one: a subclass that declares its own launch keeps ``QUIET_FLAGS`` and ``DISABLED_FEATURES`` in its |
| 60 | + command.""" |
36 | 61 |
|
37 | 62 | version = VERSION |
38 | 63 | #: Where Chrome for Testing reads managed policies; it reads neither Chromium's folder nor Chrome's. |
39 | 64 | policy_dir = Path("/etc/opt/chrome_for_testing/policies/managed") |
| 65 | + policies = QUIET_POLICIES |
40 | 66 | profile = PROFILE |
41 | 67 |
|
42 | 68 | @install_step(scope="system", os="linux") |
|
0 commit comments