Repository navigation
Keep hover and pointer overrides on desktop set_viewport - #665
Open
top-sigrid wants to merge 1 commit into
Open
top-sigrid wants to merge 1 commit into
top-sigrid wants to merge 1 commit into
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.