Skip to content

Commit aec682a

Browse files
committed
test(ios): pin the PassbookUIService presence probe and record the Apple Pay change
Key the Simulator presence-probe test's pgrep stub on each host's processExecutable instead of answering every pgrep call alike, and add a case where SafariViewService is absent and only a device-scoped PassbookUIService pid is present, asserting the resolved host by registry lookup (kind/bundleId) rather than array index. Without this the positive-presence test always matched SafariViewService by construction and could not tell the two hosts apart. Add the three Unreleased CHANGELOG entries for #2639: bare type/fill now works on the Apple Pay sheet, Simulator captures also probe for a lingering PassbookUIService host, and the iOS system-surface disclosure sentence now names which kind of sheet is on screen. Rewrap the unwrapped comment/doc lines this PR added to the surrounding 100-column style in system-surface-disclosure.ts, ADR 0004, and the test-app README, with no wording changes.
1 parent 58d8b1f commit aec682a

5 files changed

Lines changed: 75 additions & 24 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
## Unreleased
44

5+
- Added (ios): `type` and `fill` work in the Apple Pay sheet on iOS Simulator instead of failing
6+
with `TEXT_INPUT_NOT_FOCUSED`. `com.apple.PassbookUIService` is served in place like the web
7+
sign-in host (#2438).
8+
- Changed (ios): Simulator captures also probe for `com.apple.PassbookUIService`. It can keep
9+
running after the Apple Pay sheet closes, so a later capture in that app can report
10+
`system-surface-host-lingering` while the process stays alive.
11+
- Changed (ios): the in-place system surface disclosure now names the sheet kind. The web sign-in
12+
sentence changed from "A system web sign-in sheet is presented over the app, so this snapshot
13+
shows that sheet (hosted out of the app process)." to "This snapshot shows a system web sign-in
14+
sheet presented over the app (hosted out of the app process), not app content". The payment host
15+
says "the system Apple Pay sheet" instead.
516
- Fixed (android): a chunked `record stop` (recordings over 170 s) no longer warns that screenrecord
617
stopped before record stop at the 180 s limit. Rotation always ends every earlier chunk before
718
stop, so the warning now fires only when the last chunk's recorder had already exited.

‎docs/adr/0004-ios-snapshot-backend-strategy.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,14 @@ teardown) unrepresentable for the delegated-auth flow, because the session never
360360
Captures of a system surface carry a response-level `systemSurface` provenance and the shared
361361
`iosSystemSurfaceDisclosure`, worded per host kind, so the agent is told the controls belong to a
362362
system sheet (web sign-in, Apple Pay) rather than the app. They are also lineaged to the host rather
363-
than the app, so their comparison identity differs from an app capture's by construction: every consumer that asks "are these two captures the
364-
same presentation" refuses a cross-surface pair through ordinary key equality, and no comparison
365-
site carries a surface check of its own. Physical devices always use the runner, so the in-place
366-
serve applies there without a route change; the Simulator route probe is the only
367-
Simulator-specific piece.
368-
369-
The Apple Pay host (`com.apple.PassbookUIService`) joined the registry for text entry as much as
370-
for snapshots. Its billing, shipping, and contact forms hold text fields the session app's tree cannot
363+
than the app, so their comparison identity differs from an app capture's by construction: every
364+
consumer that asks "are these two captures the same presentation" refuses a cross-surface pair
365+
through ordinary key equality, and no comparison site carries a surface check of its own. Physical
366+
devices always use the runner, so the in-place serve applies there without a route change; the
367+
Simulator route probe is the only Simulator-specific piece.
368+
369+
The Apple Pay host (`com.apple.PassbookUIService`) joined the registry for text entry as much as for
370+
snapshots. Its billing, shipping, and contact forms hold text fields the session app's tree cannot
371371
resolve, and a bare `type` addressed to the app process never sees that keyboard. Addressing the
372372
host in place is what lets the runner's first-responder route type into them; no text-entry branch
373373
changed for it.

‎examples/test-app/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ field itself never appears in the accessibility tree and only the keyboard prove
9696
`automation-flattened-value` mirrors what was typed. `automation-open-apple-pay` (iOS only, native
9797
module `modules/apple-pay-lab`) presents the system Apple Pay sheet requiring a billing address plus
9898
contact email and phone; those forms are hosted out of process in `com.apple.PassbookUIService`, and
99-
`automation-apple-pay-result` reports `authorized` or `dismissed` once the sheet closes. CI repacks JavaScript-only changes into the
100-
cached Release app without starting Metro; native configuration changes intentionally produce one
101-
new fingerprinted build that all simulator consumers share.
99+
`automation-apple-pay-result` reports `authorized` or `dismissed` once the sheet closes. CI repacks
100+
JavaScript-only changes into the cached Release app without starting Metro; native configuration
101+
changes intentionally produce one new fingerprinted build that all simulator consumers share.
102102

103103
### iOS simulator
104104

‎packages/platform-apple/src/system-surface-presence.test.ts‎

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,33 @@ const sim = {
2424

2525
type ProbeReply = { exitCode: number; stdout: string };
2626

27-
/** Routes the two probe commands independently so each failure mode can be exercised alone. */
28-
function stubProbes(replies: { pgrep?: ProbeReply | Error; ps?: ProbeReply | Error }): void {
29-
mockRunCmd.mockImplementation(async (command: string) => {
30-
const reply = command === 'pgrep' ? replies.pgrep : replies.ps;
27+
const SAFARI_HOST = IOS_SYSTEM_SURFACE_HOSTS.find(
28+
(host) => host.bundleId === 'com.apple.SafariViewService',
29+
)!;
30+
const PASSBOOK_HOST = IOS_SYSTEM_SURFACE_HOSTS.find((host) => host.kind === 'payment')!;
31+
32+
/** Literals, not registry reads, so a drifted registry executable fails the per-host cases. */
33+
const SAFARI_EXECUTABLE = 'SafariViewService.app/SafariViewService';
34+
const PASSBOOK_EXECUTABLE = 'PassbookUIService.app/PassbookUIService';
35+
36+
/**
37+
* Routes the two probe commands independently so each failure mode can be exercised alone.
38+
* `pgrepByExecutable` answers per `pgrep -f` target; `pgrep` answers every target alike.
39+
*/
40+
function stubProbes(replies: {
41+
pgrep?: ProbeReply | Error;
42+
pgrepByExecutable?: Readonly<Record<string, ProbeReply | Error>>;
43+
ps?: ProbeReply | Error;
44+
}): void {
45+
mockRunCmd.mockImplementation(async (command: string, args: string[] = []) => {
46+
if (command === 'pgrep') {
47+
const executable = args[1] ?? '';
48+
const reply = replies.pgrepByExecutable?.[executable] ?? replies.pgrep;
49+
if (reply === undefined) throw new Error(`unexpected pgrep target ${executable}`);
50+
if (reply instanceof Error) throw reply;
51+
return { exitCode: reply.exitCode, stdout: reply.stdout, stderr: '' };
52+
}
53+
const reply = replies.ps;
3154
if (reply === undefined) throw new Error(`unexpected probe command ${command}`);
3255
if (reply instanceof Error) throw reply;
3356
return { exitCode: reply.exitCode, stdout: reply.stdout, stderr: '' };
@@ -37,10 +60,13 @@ function stubProbes(replies: { pgrep?: ProbeReply | Error; ps?: ProbeReply | Err
3760
const RUNNING = { exitCode: 0, stdout: '900\n' } as const;
3861
const NOT_RUNNING = { exitCode: 1, stdout: '' } as const;
3962
/** The verdict a matched host produces: the host travels with it, to become the capture's lineage. */
40-
const PRESENT = { kind: 'present', host: IOS_SYSTEM_SURFACE_HOSTS[0]! } as const;
41-
const scopedTo = (udid: string): ProbeReply => ({
63+
const SAFARI_PRESENT = { kind: 'present', host: SAFARI_HOST } as const;
64+
const scopedTo = (
65+
udid: string,
66+
executable: string = SAFARI_HOST.processExecutable,
67+
): ProbeReply => ({
4268
exitCode: 0,
43-
stdout: `/…/SafariViewService.app/SafariViewService SIMULATOR_UDID=${udid}`,
69+
stdout: `/…/${executable} SIMULATOR_UDID=${udid}`,
4470
});
4571

4672
beforeEach(() => {
@@ -49,7 +75,21 @@ beforeEach(() => {
4975

5076
test('a host process scoped to this device is present, and names the host it matched', async () => {
5177
stubProbes({ pgrep: RUNNING, ps: scopedTo('UDID-1') });
52-
await expect(createSystemSurfacePresenceProbe()(sim)).resolves.toEqual(PRESENT);
78+
await expect(createSystemSurfacePresenceProbe()(sim)).resolves.toEqual(SAFARI_PRESENT);
79+
});
80+
81+
test('a device-scoped PassbookUIService pid present while SafariViewService is absent resolves to the payment host', async () => {
82+
stubProbes({
83+
pgrepByExecutable: {
84+
[SAFARI_EXECUTABLE]: NOT_RUNNING,
85+
[PASSBOOK_EXECUTABLE]: RUNNING,
86+
},
87+
ps: scopedTo('UDID-1', PASSBOOK_EXECUTABLE),
88+
});
89+
await expect(createSystemSurfacePresenceProbe()(sim)).resolves.toEqual({
90+
kind: 'present',
91+
host: PASSBOOK_HOST,
92+
});
5393
});
5494

5595
test('the same host running for another device is absent', async () => {
@@ -113,7 +153,7 @@ test('absence is not cached: a sheet opening within the TTL is seen immediately'
113153

114154
stubProbes({ pgrep: RUNNING, ps: scopedTo('UDID-1') });
115155
clock += 10; // far inside the memo TTL
116-
await expect(probe(sim)).resolves.toEqual(PRESENT);
156+
await expect(probe(sim)).resolves.toEqual(SAFARI_PRESENT);
117157
});
118158

119159
test('unknown is not cached either', async () => {
@@ -124,7 +164,7 @@ test('unknown is not cached either', async () => {
124164

125165
stubProbes({ pgrep: RUNNING, ps: scopedTo('UDID-1') });
126166
clock += 10;
127-
await expect(probe(sim)).resolves.toEqual(PRESENT);
167+
await expect(probe(sim)).resolves.toEqual(SAFARI_PRESENT);
128168
});
129169

130170
test('a positive observation is memoized within the TTL and re-probed after it', async () => {
@@ -133,7 +173,7 @@ test('a positive observation is memoized within the TTL and re-probed after it',
133173
stubProbes({ pgrep: RUNNING, ps: scopedTo('UDID-1') });
134174
await probe(sim);
135175
const callsAfterFirst = mockRunCmd.mock.calls.length;
136-
await expect(probe(sim)).resolves.toEqual(PRESENT);
176+
await expect(probe(sim)).resolves.toEqual(SAFARI_PRESENT);
137177
expect(mockRunCmd.mock.calls.length).toBe(callsAfterFirst);
138178

139179
clock += 2_000; // past the TTL

‎src/daemon/system-surface-disclosure.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type { DaemonResponse } from './daemon-request.ts';
77
* Append the occluding-system-surface disclosure to a selector-route response whose consumed
88
* snapshot was a system surface: an Android notification shade / quick settings, or an iOS in-place
99
* system sheet such as web sign-in or Apple Pay (#2438). Both found and not-found outcomes must
10-
* explain that app content is occluded: a match found inside the surface is not app content, and a miss is expected while the
11-
* surface covers the app.
10+
* explain that app content is occluded: a match found inside the surface is not app content, and a
11+
* miss is expected while the surface covers the app.
1212
*/
1313
export function withSystemSurfaceDisclosure(
1414
response: DaemonResponse,

0 commit comments

Comments
 (0)