Skip to content

Commit b663be7

Browse files
committed
fix(apple): reject screen masks for provider runner captures
1 parent c956372 commit b663be7

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎packages/platform-apple/src/core/__tests__/screenshot.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import { runCmd } from '@agent-device/host-kit/command';
6464
import { withDiagnosticsScope } from '@agent-device/host-kit/diagnostics';
6565
import { retryWithPolicy } from '@agent-device/host-kit/retry';
6666
import { AppError } from '@agent-device/kernel/errors';
67+
import { resolveAppleToolProvider, withAppleToolProvider } from '../tool-provider.ts';
6768

6869
import { IOS_TEST_SIMULATOR, MACOS_TEST_DEVICE } from './apple-core-stub-helpers.ts';
6970

@@ -887,3 +888,22 @@ test.each([MACOS_TEST_DEVICE, { ...IOS_TEST_SIMULATOR, kind: 'device' as const }
887888
assert.equal(mockRunAppleRunnerCommand.mock.calls.length, 0);
888889
},
889890
);
891+
892+
test('screenshotIos rejects a screen mask before a provider-owned runner capture', async () => {
893+
mockRunCmd.mockRejectedValue(new Error('unexpected native capture'));
894+
mockRunAppleRunnerCommand.mockRejectedValue(new Error('unexpected runner capture'));
895+
await withAppleToolProvider(
896+
{ ...resolveAppleToolProvider(), simulatorScreenshotBackend: 'runner' },
897+
async () => {
898+
await assert.rejects(
899+
screenshotIos(IOS_TEST_SIMULATOR, '/tmp/masked.png', { env: {}, screenMask: 'black' }),
900+
{
901+
code: 'UNSUPPORTED_OPERATION',
902+
details: { reason: 'screenshot-screen-mask-unsupported' },
903+
},
904+
);
905+
},
906+
);
907+
assert.equal(mockRunCmd.mock.calls.length, 0);
908+
assert.equal(mockRunAppleRunnerCommand.mock.calls.length, 0);
909+
});

‎packages/platform-apple/src/screenshot-support.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { isHandheldAppleSimulator, type DeviceInfo } from '@agent-device/kernel/device';
2+
import { resolveAppleToolProvider } from './core/tool-provider.ts';
23
import type {
34
ScreenshotCaptureCapabilities,
45
ScreenshotOptions,
@@ -9,6 +10,9 @@ export function appleScreenshotCaptureCapabilities(
910
options: Pick<ScreenshotOptions, 'captureBackend'>,
1011
): ScreenshotCaptureCapabilities {
1112
return {
12-
screenMask: isHandheldAppleSimulator(device) && options.captureBackend !== 'runner',
13+
screenMask:
14+
isHandheldAppleSimulator(device) &&
15+
options.captureBackend !== 'runner' &&
16+
resolveAppleToolProvider().simulatorScreenshotBackend !== 'runner',
1317
};
1418
}

0 commit comments

Comments
 (0)