Repository navigation
macOS engine: background Safari finds type_text's focused field by WebKit's text marker, never inspecting it (#395) - #417
Merged
Conversation
…bKit's text marker, never inspecting it (refs #395) Background Safari names no focused element, and #354's walk gives up past 200 nodes, so on a real-size page type_text answered noFocusedElement. In Safari only (the bundle identifier of the process read), once the application's AXFocusedUIElement answers none, the read-back now takes WebKit's route before the walk: the primary window's first AXWebArea (the walk's bounds), its AXSelectedTextMarkerRange, that range's start marker straight into AXUIElementForTextMarker on the web area, then at most four AXParent hops to the field. The walk still runs when the route claims nothing. Under ruling 1ea561bc:824: the marker lives only in readbackMarkedElement and is released there; nothing reads its bytes or length, the end marker is never resolved, and no other parameterized attribute is asked. Every element on the way is classified (role and subrole in one batch, #405's valueClassification) before anything else is read of it; a closed one ends the lookup with main's reason (secure, or roleUnreadable) and nothing more read. A field is claimed only when it is the app's, reads AXFocused true and its parents reach that web area. After typing, and at a checkpoint, a field the route found is asked itself (AXFocused true on the same handle): no marker call follows delivered text, and the reads do not depend on a secret. ReadbackAX carries every Accessibility call of the live reads, so the tests run the live composition over a stub Safari whose web area answers a real AXTextMarkerRange with a known offset in its bytes. Sminos-Session: cursor235#b93055dd (cua on macbook)
…range (refs #395) The stub web area now answers its range beside an error too, so the range read's error check is exercised rather than covered by the stub. Sminos-Session: cursor235#b93055dd (cua on macbook)
…xt's field (refs #395) Sminos-Session: cursor235#b93055dd (cua on macbook)
… to find the field (refs #395) agent-cursor.md's typing paragraph loses its sentence on background Safari's large page answering no focused field: the text-marker route now finds that field. The docs oracle and the core-documentation test carry the paragraph byte for byte; PROVENANCE.md and the surface inventory's "Table 3 amendment (2026-11-18, #395, ruling 1ea561bc:824)" record it. Sminos-Session: cursor235#b93055dd (cua on macbook)
…d the marker tests fail rather than crash (refs #395) The mutation check found the failed-children guard of the web area's search survived: its only case had no other web area to find. A web area after the element whose children failed now must not be taken. The closed-field and post-input tests unwrap their log positions with a failure instead of a trap. Sminos-Session: cursor235#b93055dd (cua on macbook)
…rker route (refs #395) The entry records ruling 1ea561bc:824's conditions as built, the probe's facts (runs 44296356927 and 44297805982: a 28-byte marker holding the caret as an LE32 word, a password field's included), the choices the ruling left (the route before the walk, the web area under the walk's bounds, four hops to the field, the field focused and under that web area, the field's own AXFocused after typing, Safari by bundle identifier), what is noted and not measured, and the proof with its mutation check. #354's limit 11 points to it. The log is appended oldest first, as this spec's always has been. Sminos-Session: cursor235#b93055dd (cua on macbook)
… runs only on an absent focus answer (refs #395) The high review's findings, as the design ruled: - The web area is checked to be the app's and classified, open as an AXWebArea, before its marker is read; otherwise no claim, and the walk runs. It is not the field, so a closed classification is no refusal. - Each ancestor the claim's scope climb passes is checked to be the app's before it is compared or climbed. - readbackFocusedField takes the application's AXFocusedUIElement as a ReadbackWalkRead: an absent answer (noValue, attributeUnsupported) goes to the primary window, the marker, then the walk; a failed read (another error, or a reply that is not an element) to the walk alone, as on main (ruling 1ea561bc:824). - The marker tests skip, rather than trap, where HIServices' private constructors or the engine's marker symbols do not resolve; the odd-reply test unwraps the symbols with XCTUnwrap. New tests: the web area another process's, unreadable or classified otherwise (five cases, no marker call); a failed or wrong-typed application focus read (no marker call, the walk confirms a small page; attributeUnsupported takes the route); an ancestor another process's. The lookup-order test now shows the web area's classification before its marker read. Each new guard, removed or weakened (six mutations), fails a test. Sminos-Session: cursor235#b93055dd (cua on macbook)
…ecks and the absent-only route (refs #395) Item 2 (c): the web area is checked to be the app's and classified (AXWebArea, open) before its marker is read; each ancestor of the scope climb is checked to be the app's. Item 2 (e) and item 3: the route runs only on an absent answer (noValue or attributeUnsupported); a failed application focus read goes to the walk alone. Item 5: 14 test functions, the new cases, the skip without the constructors, and the six new mutations caught. Sminos-Session: cursor235#b93055dd (cua on macbook)
…pp's own elements (refs #395) The re-review's findings: - [P2] `readbackWebArea` takes an ownership predicate, and `readbackMarkedField` passes `marker.owned`. An element another process serves, the window included, is skipped: its role is not read, it is never the web area and its children are never followed, so a foreign provider cannot pick the page whose marker is read. The probe's `tree()` visited only owned elements. #354's walk is unchanged. The separate ownership check on the web area after the search is dropped, since the search now checks it. - [P3] The tests that showed the fallback walk ran by its reaching node 1000, which the live walk's wall-clock 40 ms bound could stop on a slow runner, now count the window's AXChildren reads instead. The web area's search and the walk each read them first: two after the route claims nothing, one when a failed focus read skips the route. New cases: in the generic search, a foreign group between the window and a web area (not found, the group unread), a foreign sibling that reads as a web area (skipped, the search goes on) and a foreign window (nothing read); in the stub, a web area under another process's group (no marker call, noFocusedElement). Removing the search's ownership guard fails both. Sminos-Session: cursor235#b93055dd (cua on macbook)
…app's own elements (refs #395) Item 3: the web area is the first AXWebArea among the app's own elements, another process's (the window included) skipped unread, as the probe's `tree()` visited only the app's. Item 5: the web area under another process's group, six cases, and the search's ownership among the mutations caught. Sminos-Session: cursor235#b93055dd (cua on macbook)
…ches (refs #395) Sminos-Session: cursor235#b93055dd (cua on macbook)
…ari's text-marker route (refs #395) Sminos-Session: cursor235#b93055dd (cua on macbook)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
What changes
Today: in background Safari, nothing answers AXFocusedUIElement: not the application, not the window, not the web area. type_text's read-back then falls back to #354's bounded walk, which gives up past 200 nodes. On a real-size page, type_text therefore answers
noFocusedElement, even though the text landed.Now: Safari takes WebKit's text-marker route to the field. The web area's AXSelectedTextMarkerRange gives a start marker; AXUIElementForTextMarker(start) gives an AXStaticText; its AXParent is the field. On a 1,600-node page, the route found the field 180/180, and the walk 0/180.
Privacy (ruling 1ea561bc:824, under 811). The marker carries the caret's character offset in plain bytes. WebKit returns it for password fields too, and there the caret is usually at the end, so the offset is usually the length. Condition by condition:
valueClassificationbefore anything else is read from it..refused(.secure). An unreadable role gives.refused(.roleUnreadable). Nothing more is read in either case.com.apple.Safari(exact bundle id), only when the application's AXFocusedUIElement answers absent, and only when the three symbols resolve. A failed focus read goes straight to the walk, as on main. Every other app is unchanged.Files:
native/engine/Sources/Engine/TypeReadbackMarker.swift(new);TypeReadback.swift, whoseReadbackAXmakes every AX call injectable, soReadbackReads.liveruns whole over a stub Safari;Input.swift, the Safari gate.Docs:
Plugin 0.28.15 (ruling 822).
Evidence
Hosted macOS, Safari 27.2. docs/evidence/2026-11-18-safari-marker-route/README.md has the detail.
probe/395-marker, run 44297805982): 462/462 trials, 0 wrong targets, 0 privacy violations.AXStringForTextMarkerRangeon a password selection returns masks at the exact length, which is why the product never calls it.probe/395-qual, run 44308992433), fix0e9f4affagainst mainf2c30fc5, both unmodified, interleaved, 20 trials per cell:noFocusedElementsecure, largenoFocusedElementsecureon both, no value or range in the replysecure, unconfirmed, as it should.Limits
noFocusedElement, never a wrong success. That is macOS engine: #395's marker route may miss the web area in a Safari window with many tabs (scope search bound) #416, which also carries the stub tests' wall-clock debt.secure. That is macOS engine: type_text into a password field confirms by character-count delta, emitting no count (808's rule) #414.Verification
swift test(native/engine) gives 1,347 tests, 0 failures, 1 skipped (CUA_304_TREES, pre-existing). TypeReadbackMarkerTests (14) are new.Closes #395
Sminos-Session: cursor235#b93055dd (cua on macbook)