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

overriding intl.accept_languages and intl.locale.requested does not take effect #217

Closed
cfm opened this issue Jan 10, 2025 · 4 comments
Closed

Comments

@cfm
Copy link

cfm commented Jan 10, 2025

In freedomofpress/securedrop#7354, we're trying to test our localization by overriding the Accept-Language header via Firefox's intl.accept_languages. In https://gist.github.com/cfm/8a4dddcee3e993998ec4d68e123da89d I've created a minimal reproduction that shows that neither of the following approaches works in tbselenium:

# Manually setting this value in "about:config" is sufficient in an interactive Firefox session.
options.set_preference("intl.accept_languages", LANG)

# Manually setting this value in "about:config" is sufficient in an interactive Tor Browser session.
options.set_preference("intl.locale.requested", LANG)

Tor Browser tickets like tor-browser#41930 and tor-browser#41339 point to the complexity of these preferences but suggest that they should take overrides as usual, which is why I suspect this is an interaction with tbselenium.

@gunesacar
Copy link
Collaborator

Could you try setting this pref using this utility function?
https://github.com/webfp/tor-browser-selenium/blob/main/tbselenium/utils.py#L96

(see, an example use here)

I've had cases where pref changes were not recognized, and the above method (which uses chrome privileges) was the solution. LMK if that doesn't work and I'll dig deeper.

PS: Sorry for the delay in responding. I was out of office.

@gunesacar
Copy link
Collaborator

Sample code to overwrite the Accept-Language header: https://gist.github.com/gunesacar/6f160016546c97d010544311076f06c7

Prints: Accept-Language=de,en-US;q=0.7,en;q=0.3

Another example, iterating over different locales. It also prints navigator.language(s), which are not overwritten!:
https://gist.github.com/gunesacar/71a3a80c1460e7ae6a1d0d151f3f4264

@cfm
Copy link
Author

cfm commented Jan 16, 2025

Thank you, @gunesacar! I was just looking at this and reached basically the same diff. Thanks for pointing me towards set_tbb_pref().

@cfm cfm closed this as completed Jan 16, 2025
@gunesacar
Copy link
Collaborator

Great! Feel to reach out for similar issues.

cfm added a commit to freedomofpress/securedrop that referenced this issue Jan 16, 2025
cfm added a commit to freedomofpress/securedrop that referenced this issue Jan 16, 2025
cfm added a commit to freedomofpress/securedrop that referenced this issue Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants