Repository navigation
Keep hover and pointer overrides on desktop set_viewport - #665
Conversation
Since rubycdp#618, set_viewport sent Emulation.setTouchEmulationEnabled on every call, so every desktop viewport and every resize sent enabled: false. Chrome answers that by resetting hover and pointer to the detected input devices, even if touch emulation was never on, which undoes --blink-settings overrides. On headless Linux, which has no input devices, (hover: hover) and (pointer: fine) stopped matching after set_viewport or resize. set_viewport now sends enabled: false only when the page goes back to a desktop viewport after set_viewport(mobile: true), and only once. Chromium follows the same rule for its own resets since Chrome 141 (Chromium commit a65c088). Fixes rubycdp#664
…on as is A desktop set_viewport or resize no longer sends setTouchEmulationEnabled, so --blink-settings hover and pointer stay. mobile: true still turns touch on and an explicit mobile: false turns it off. Replaces the per-page touch emulation state, so the unit spec for it is removed. Refs rubycdp#664
|
Thanks for the thorough investigation, the repro and the Chromium pointers made this easy to verify. I pushed two commits on top of your branch: a merge of Instead of tracking
Why: whether to send Your feature specs are kept as they were; the |
|
I'm merging but let me know if I miss anything in my version |
Thanks for getting to this so quickly! I'll have a look over your changes, but that seems sensible on first sight. |
Fixes #664.
Since #618,
Page#set_viewportsendsEmulation.setTouchEmulationEnabledon every call, so a desktop viewport sendsenabled: false, and so doesPage#resize. Chrome handlesenabled: falseby resetting hover and pointer to the input devices it detected, even if touch emulation was never on. That undoes--blink-settingsoverrides such as the hover and pointer flag recommended in rubycdp/cuprite#282: on headless Linux,(hover: hover)and(pointer: fine)stop matching afterset_viewportorresize.set_viewportnow sendsenabled: falseonly when the page goes back to a desktop viewport afterset_viewport(mobile: true), and only once;mobile: truestill turns touch emulation on as before. That's the rule Chromium follows for its own resets since Chrome 141 (a65c088), and Playwright never sendsenabled: falseat all.Not covered: a page switched from
mobile: trueback to desktop still has to getenabled: false, so it still loses--blink-settingshover and pointer. No CDP command sets them directly.Behavior change: touch emulation turned on with a raw
page.commandis no longer turned off by a desktopset_viewport, as in 0.18.0.Specs:
:launchspec starts Chrome withprimaryPointerType=2,availablePointerTypes=2and checks(pointer: coarse)right afterset_viewport. Neither Linux nor macOS reports a coarse pointer by itself, so the reset shows on both.mobile: truestill turns touch emulation off. It passes with and without the fix and guards the branch that still sendsenabled: false.enabled: falseis sent only once after a mobile viewport, not on every later desktop call.Checks, rebased on 082de04:
:launchspec and the unit spec fail on macOS (Chrome 155.0.8059.40) and on Linux (Chrome for Testing 155.0.8059.84 in Docker).bundle exec rakeon macOS: 670 examples, 0 failures, 4 pending.spec/unit/page_spec.rbandspec/page_spec.rbon Linux: 31 examples, 0 failures.