Skip to content

Commit

Permalink
fix(_create_torbrowser_driver): set "intl.accept_langauges" via set_t…
Browse files Browse the repository at this point in the history
  • Loading branch information
cfm committed Jan 16, 2025
1 parent f0b1394 commit 420d5ee
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions securedrop/tests/functional/web_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.remote.remote_connection import LOGGER
from tbselenium.tbdriver import TorBrowserDriver
from tbselenium.utils import set_tbb_pref

_LOGFILE_PATH = abspath(join(dirname(realpath(__file__)), "../log/driver.log"))
_FIREFOX_PATH = "/usr/bin/firefox/firefox"
Expand Down Expand Up @@ -54,8 +55,6 @@ def _create_torbrowser_driver(
"network.proxy.no_proxies_on": "127.0.0.1",
"browser.privatebrowsing.autostart": False,
}
if accept_languages is not None:
pref_dict["intl.accept_languages"] = accept_languages

Path(_TBB_PATH).mkdir(parents=True, exist_ok=True)
torbrowser_driver = None
Expand All @@ -67,6 +66,12 @@ def _create_torbrowser_driver(
pref_dict=pref_dict,
tbb_logfile_path=_LOGFILE_PATH,
)
if accept_languages is not None:
# privacy.spoof_english per
# <https://github.com/arkenfox/user.js/issues/1827#issuecomment-2075819482>.
set_tbb_pref(driver, "privacy.spoof_english", 1)
set_tbb_pref(torbrowser_driver, "intl.accept_languages", accept_languages)

logging.info("Created Tor Browser web driver")
torbrowser_driver.set_window_position(0, 0)
torbrowser_driver.set_window_size(*_BROWSER_SIZE)
Expand Down

0 comments on commit 420d5ee

Please sign in to comment.