mirror of
https://github.com/daijro/camoufox.git
synced 2026-10-04 00:00:26 +00:00
Pace humanized moves on their own schedule, and write toggle prefs on every launch (#808)
* fix(juggler): pace a humanized move on its own schedule sendTrajectoryAcked waited each point's full pause after the previous point's ack, so every ack's round trip was added to the move: it took its plan plus one round trip per point. On a page whose main thread is busy 19ms in every 20, moves capped at 0.5s took 0.54-0.71s. Each point is now due at its planned offset from the start of the move, so a late ack delays only its own point and the move ends on its planned time. tests/patches/humanize-pacing.py times eleven capped moves on such a page and checks their median against the cap. It failed 3/3 before (medians 587-607ms) and passes after (484-487ms). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(launch): write toggle prefs on every launch, on or off block_webrtc, block_images and disable_coop wrote their pref only when switched on. A persistent profile keeps a user.js pref in prefs.js, so removing the flag later left the setting in force. A real profile launched once with block_webrtc still had media.peerconnection.enabled false long after, and BrowserScan reported WebRTC disabled. Each pref is now written every launch, with the stock value when its flag is off. A caller's own firefox_user_prefs entry still wins. The same change is made in the TypeScript launcher, with its tests. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ec37d722b7
commit
0cb8c60bb9
@@ -1429,15 +1429,16 @@ def launch_options(
|
||||
if allow_addon_new_tab:
|
||||
set_into(config, 'allowAddonNewtab', True)
|
||||
|
||||
# Set Firefox user preferences
|
||||
# Set Firefox user preferences. Each toggle writes its pref on or off: a
|
||||
# persistent profile keeps a user.js pref in prefs.js after the launch that
|
||||
# set it, so a flag that only wrote when on stayed on for good.
|
||||
if block_images:
|
||||
LeakWarning.warn('block_images', i_know_what_im_doing)
|
||||
firefox_user_prefs['permissions.default.image'] = 2
|
||||
if block_webrtc:
|
||||
firefox_user_prefs['media.peerconnection.enabled'] = False
|
||||
if disable_coop:
|
||||
LeakWarning.warn('disable_coop', i_know_what_im_doing)
|
||||
firefox_user_prefs['browser.tabs.remote.useCrossOriginOpenerPolicy'] = False
|
||||
firefox_user_prefs.setdefault('permissions.default.image', 2 if block_images else 1)
|
||||
firefox_user_prefs.setdefault('media.peerconnection.enabled', not block_webrtc)
|
||||
firefox_user_prefs.setdefault('browser.tabs.remote.useCrossOriginOpenerPolicy', not disable_coop)
|
||||
# A persistent context takes its context options here.
|
||||
if launch_options.get('is_mobile'):
|
||||
LeakWarning.warn('is_mobile', i_know_what_im_doing)
|
||||
|
||||
@@ -171,6 +171,41 @@ class TestUiLocaleFollowsIntlLocale:
|
||||
assert prefs[self.PREF] == "de"
|
||||
|
||||
|
||||
class TestToggleSettingsAreWrittenBothWays:
|
||||
"""A persistent profile keeps every pref it was ever launched with.
|
||||
|
||||
Firefox saves a user.js pref into prefs.js, and a later launch that simply
|
||||
omits it does not clear it. A profile once launched with block_webrtc kept
|
||||
WebRTC off after the flag was removed (a real profile's prefs.js still held
|
||||
media.peerconnection.enabled=false), so each toggle writes its pref on every
|
||||
launch, on or off.
|
||||
"""
|
||||
|
||||
UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:152.0) Gecko/20100101 Firefox/152.0"
|
||||
TOGGLES = [
|
||||
("block_webrtc", "media.peerconnection.enabled", True, False),
|
||||
("block_images", "permissions.default.image", 1, 2),
|
||||
("disable_coop", "browser.tabs.remote.useCrossOriginOpenerPolicy", True, False),
|
||||
]
|
||||
|
||||
def _prefs(self, **kwargs):
|
||||
return utils.launch_options(
|
||||
config={"navigator.userAgent": self.UA}, i_know_what_im_doing=True, **kwargs
|
||||
)["firefox_user_prefs"]
|
||||
|
||||
@pytest.mark.parametrize("flag, pref, stock, toggled", TOGGLES)
|
||||
def test_off_writes_the_stock_value(self, isolated_launch_dependencies, flag, pref, stock, toggled):
|
||||
assert self._prefs()[pref] == stock
|
||||
|
||||
@pytest.mark.parametrize("flag, pref, stock, toggled", TOGGLES)
|
||||
def test_on_writes_the_toggled_value(self, isolated_launch_dependencies, flag, pref, stock, toggled):
|
||||
assert self._prefs(**{flag: True})[pref] == toggled
|
||||
|
||||
@pytest.mark.parametrize("flag, pref, stock, toggled", TOGGLES)
|
||||
def test_caller_pref_wins(self, isolated_launch_dependencies, flag, pref, stock, toggled):
|
||||
assert self._prefs(firefox_user_prefs={pref: toggled})[pref] == toggled
|
||||
|
||||
|
||||
class TestPrefsReachStartup:
|
||||
"""Launcher prefs must be readable by camoufox.cfg at startup.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user