Repository navigation
fix: desktop loop refuse to type into a real macOS password field (#5) - #72
Open
bluzername wants to merge 1 commit into
Open
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
…levin#5) On real macOS a password field give role AXTextField with subrole AXSecureTextField, so Field.is_text see it as a normal text field and nothing stop typing into it. The browser backend already had this guard, desktop loop did not. This add a subrole to Field, a new is_secure property (true for the macOS subrole and also for the AXSecureTextField role OSWorld's simulation use), and make type_email/type_text refuse when the focused field is secure. macos.py now read AXSubrole so the real adapter fill it in. Tests: two new unit tests for is_secure (macOS subrole shape and OSWorld role shape, plus a negative case) and two for the type_email / type_text refusal, all in tests/test_actions.py. Confirmed RED first (AttributeError / TypeError before the fix), then GREEN. Full suite: 735 passed, 2 skipped, 1 xfailed. ruff check and ruff format both clean.
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.
This fix the second part of #5. The owner comment say it clear:
Field.is_textcheck role only, and a real macOS password field giverole
AXTextFieldwith subroleAXSecureTextField. That subrole wasnever read, so the desktop loop had no code-level guard, only the
browser backend did (the
secretflag inbrowser/perceive.py).What I change:
Field(models.py) get a newsubrolefield (default"", soevery other adapter and caller still work with no change) and a new
is_secureproperty. It is true whensubrole == "AXSecureTextField"(the real macOS shape) or when
role == "AXSecureTextField"directly(how OSWorld's simulated tree already report a password field in
osworld/a11y.py, which is why that path was already safe).macos.py'sfocused_field()now readAXSubrolefrom theaccessibility API and put it on the
Field, same way it alreadyread role/label/placeholder/value.
actions.py's_type_emailand_type_textnow refuse beforetyping when
screen.field.is_secure, same spot as the existing"no text field is focused" refusal.
I did not touch
windows.py: the issue only talk about macOS and Icould not find how UI Automation report a password field's protected
state in this codebase, so I leave that for a separate issue instead
of guessing.
Tests added in
tests/test_actions.py:test_is_secure_catches_a_macos_password_field_by_its_subroletest_is_secure_catches_an_osworld_password_field_by_its_roletest_is_secure_is_false_for_an_ordinary_text_fieldtest_type_email_refuses_a_focused_password_fieldtest_type_text_refuses_a_focused_password_fieldI check RED first: all 5 fail with
AttributeError/TypeErroronthe code before my change (no
subrole, nois_secure). After thefix they pass.
Full suite:
uv run pytest -q-> 735 passed, 2 skipped, 1 xfailed(same skip/xfail as before my change).
uv run ruff check .anduv run ruff format --check .both clean.Fixes #5 (the password-field part; the README part was already
fixed in #9).