Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tor Browser overrides the Accept-Languages header in the page-layout tests #7354

Open
cfm opened this issue Nov 25, 2024 · 3 comments
Open
Assignees
Labels
blocked on upstream bug i18n Anything related to translation or internationalization of SecureDrop tests

Comments

@cfm
Copy link
Member

cfm commented Nov 25, 2024

Description

Tor Browser's anti-fingerprinting protections prevent both profile-based and options-based configuration from overriding the Accept-Language header used to test localization in the Source Interface's page-layout tests.

Steps to Reproduce

  1. Run LOCALES="de_DE" make translation-test.
  2. Examine the contents of securedrop/tests/functional/pageslayout/screenshots.

Expected Behavior

All screenshots are in German.

Actual Behavior

Journalist Interface screenshots are in German. Source Interface screenshots are in English.

Comments

I tried using Selenium Wire to override the Accept-Language header on the wire, but it conflicts with tbselenium.12

tor-browser-accept-languages.txt

Footnotes

  1. https://gist.github.com/woswos/38b921f0b82de009c12c6494db3f50c5?permalink_comment_id=4455252#gistcomment-4455252

  2. https://github.com/webfp/tor-browser-selenium/discussions/175

@cfm cfm added tests i18n Anything related to translation or internationalization of SecureDrop bug labels Nov 25, 2024
@legoktm
Copy link
Member

legoktm commented Dec 20, 2024

Is this something we should file upstream with https://github.com/webfp/tor-browser-selenium ?

@cfm
Copy link
Member Author

cfm commented Dec 20, 2024

Good idea, but I should come up with a minimal reproduction based on:

--- a/securedrop/tests/functional/web_drivers.py
+++ b/securedrop/tests/functional/web_drivers.py
@@ -50,12 +50,13 @@ def _create_torbrowser_driver(
     # we use session cookies in SD anyway (in private browsing mode all
     # cookies are set as session cookies), this should not affect session
     # lifetime.
-    pref_dict = {
-        "network.proxy.no_proxies_on": "127.0.0.1",
-        "browser.privatebrowsing.autostart": False,
-    }
+    torbrowser_options = webdriver.FirefoxOptions()
+    torbrowser_options.set_preference("network.proxy.no_proxies_on", "127.0.0.1")
+    torbrowser_options.set_preference("browser.privatebrowsing.autostart", False)
+    torbrowser_options.set_preference("privacy.resistFingerprinting", False)
     if accept_languages is not None:
-        pref_dict["intl.accept_languages"] = accept_languages
+        torbrowser_options.set_preference("privacy.spoof_english", False)
+        torbrowser_options.set_preference("intl.accept_languages", accept_languages)
 
     Path(_TBB_PATH).mkdir(parents=True, exist_ok=True)
     torbrowser_driver = None
@@ -63,8 +64,8 @@ def _create_torbrowser_driver(
         try:
             torbrowser_driver = TorBrowserDriver(
                 _TBB_PATH,
+                options=torbrowser_options,
                 tor_cfg=cm.USE_RUNNING_TOR,
-                pref_dict=pref_dict,
                 tbb_logfile_path=_LOGFILE_PATH,
             )
             logging.info("Created Tor Browser web driver")

@cfm
Copy link
Member Author

cfm commented Jan 10, 2025

I've filed this upstream in webfp/tor-browser-selenium#217. At this point, given the complexity of Tor Browser's handling of these preferences, the next step would to have translation tests use Firefox across the board and use Tor Browser only for true functional testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked on upstream bug i18n Anything related to translation or internationalization of SecureDrop tests
Projects
Status: Blocked
Development

No branches or pull requests

2 participants