@itmetsam/samurai-framework 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +7 -0
- package/.env.example +3 -0
- package/.github/actions/setup/action.yml +16 -0
- package/.github/workflows/ci.yml +71 -0
- package/.trunk/configs/.markdownlint.yaml +2 -0
- package/.trunk/configs/.yamllint.yaml +7 -0
- package/.trunk/configs/svgo.config.mjs +14 -0
- package/.trunk/trunk.yaml +34 -0
- package/docs/superpowers/bidi-roadmap.md +60 -0
- package/docs/superpowers/plans/2026-09-29-auto-wait.md +1827 -0
- package/docs/superpowers/plans/2026-09-29-expect.md +1350 -0
- package/docs/superpowers/plans/2026-10-01-ci.md +350 -0
- package/docs/superpowers/plans/2026-10-01-test-api-alignment.md +1821 -0
- package/docs/superpowers/recorder-roadmap.md +52 -0
- package/docs/superpowers/specs/2026-09-29-auto-wait-design.md +185 -0
- package/docs/superpowers/specs/2026-09-29-bidi-foundation-design.md +130 -0
- package/docs/superpowers/specs/2026-09-29-contexts-and-storage-design.md +88 -0
- package/docs/superpowers/specs/2026-09-29-downloads-and-file-dialogs-design.md +94 -0
- package/docs/superpowers/specs/2026-09-29-emulation-design.md +88 -0
- package/docs/superpowers/specs/2026-09-29-expect-design.md +130 -0
- package/docs/superpowers/specs/2026-09-29-locate-nodes-design.md +90 -0
- package/docs/superpowers/specs/2026-09-29-logs-and-errors-design.md +87 -0
- package/docs/superpowers/specs/2026-09-29-navigation-waits-design.md +83 -0
- package/docs/superpowers/specs/2026-09-29-network-data-design.md +78 -0
- package/docs/superpowers/specs/2026-09-29-network-interception-design.md +91 -0
- package/docs/superpowers/specs/2026-09-29-network-tracking-design.md +86 -0
- package/docs/superpowers/specs/2026-09-29-page-api-design.md +90 -0
- package/docs/superpowers/specs/2026-09-29-preload-scripts-design.md +82 -0
- package/docs/superpowers/specs/2026-09-29-script-call-function-design.md +107 -0
- package/docs/superpowers/specs/2026-09-29-set-files-design.md +62 -0
- package/docs/superpowers/specs/2026-09-29-user-prompts-design.md +75 -0
- package/docs/superpowers/specs/2026-10-01-ci-design.md +106 -0
- package/docs/superpowers/specs/2026-10-01-test-api-alignment-design.md +241 -0
- package/package.json +27 -0
- package/public/logo-dark.svg +236 -0
- package/public/logo-light.svg +262 -0
- package/samurai.config.ts +7 -0
- package/src/api.ts +4 -0
- package/src/assert/assertion-error.test.ts +55 -0
- package/src/assert/assertion-error.ts +62 -0
- package/src/assert/expect-locator.test.ts +217 -0
- package/src/assert/expect.test.ts +73 -0
- package/src/assert/expect.ts +299 -0
- package/src/browser/browser-context.browser-test.ts +201 -0
- package/src/browser/browser-context.test.ts +407 -0
- package/src/browser/browser-context.ts +208 -0
- package/src/browser/browser-finder.ts +110 -0
- package/src/browser/browser.test.ts +88 -0
- package/src/browser/browser.ts +515 -0
- package/src/browser/context-tree.test.ts +86 -0
- package/src/browser/context-tree.ts +70 -0
- package/src/browser/dialog.browser-test.ts +144 -0
- package/src/browser/dialog.test.ts +322 -0
- package/src/browser/dialog.ts +83 -0
- package/src/browser/download.test.ts +161 -0
- package/src/browser/download.ts +172 -0
- package/src/browser/downloads-dir.test.ts +75 -0
- package/src/browser/downloads-dir.ts +39 -0
- package/src/browser/emulation.browser-test.ts +186 -0
- package/src/browser/emulation.test.ts +200 -0
- package/src/browser/emulation.ts +204 -0
- package/src/browser/file-chooser.test.ts +142 -0
- package/src/browser/file-chooser.ts +99 -0
- package/src/browser/file-paths.ts +18 -0
- package/src/browser/goto.browser-test.ts +44 -0
- package/src/browser/navigation-error.ts +26 -0
- package/src/browser/navigation.browser-test.ts +172 -0
- package/src/browser/page-api.browser-test.ts +228 -0
- package/src/browser/page-logs.browser-test.ts +119 -0
- package/src/browser/page-logs.test.ts +212 -0
- package/src/browser/page-logs.ts +208 -0
- package/src/browser/page-wait.ts +19 -0
- package/src/browser/page.test.ts +1567 -0
- package/src/browser/page.ts +1176 -0
- package/src/browser/pdf.ts +62 -0
- package/src/browser/screenshot.ts +65 -0
- package/src/browser/transfers.browser-test.ts +180 -0
- package/src/config/config.ts +33 -0
- package/src/config/default.ts +5 -0
- package/src/config/fixtures.test.ts +137 -0
- package/src/config/mask.test.ts +143 -0
- package/src/config/mask.ts +87 -0
- package/src/config/run-settings.test.ts +163 -0
- package/src/config/run-settings.ts +114 -0
- package/src/config/secrets.ts +70 -0
- package/src/config/variables.ts +31 -0
- package/src/index.ts +10 -0
- package/src/locator/action-timeout-error.test.ts +83 -0
- package/src/locator/action-timeout-error.ts +72 -0
- package/src/locator/element-state.test.ts +181 -0
- package/src/locator/element-state.ts +159 -0
- package/src/locator/locate-nodes.browser-test.ts +169 -0
- package/src/locator/locator-actions.test.ts +355 -0
- package/src/locator/locator-chain.test.ts +292 -0
- package/src/locator/locator.browser-test.ts +137 -0
- package/src/locator/locator.test.ts +179 -0
- package/src/locator/locator.ts +656 -0
- package/src/locator/selector-errors.ts +18 -0
- package/src/locator/selector.test.ts +124 -0
- package/src/locator/selector.ts +107 -0
- package/src/locator/set-files.browser-test.ts +141 -0
- package/src/locator/set-files.test.ts +191 -0
- package/src/locator/text-locator.test.ts +118 -0
- package/src/locator/text-locator.ts +38 -0
- package/src/logger/index.test.ts +28 -0
- package/src/logger/index.ts +40 -0
- package/src/network/data-collector.test.ts +111 -0
- package/src/network/data-collector.ts +92 -0
- package/src/network/network-data.browser-test.ts +192 -0
- package/src/network/network-tracker.browser-test.ts +151 -0
- package/src/network/network-tracker.test.ts +307 -0
- package/src/network/network-tracker.ts +286 -0
- package/src/network/network-wait.ts +28 -0
- package/src/network/response.test.ts +93 -0
- package/src/network/response.ts +58 -0
- package/src/network/router.browser-test.ts +260 -0
- package/src/network/router.test.ts +528 -0
- package/src/network/router.ts +420 -0
- package/src/network/url-match.test.ts +69 -0
- package/src/network/url-match.ts +41 -0
- package/src/runner/page-logs-report.test.ts +144 -0
- package/src/runner/page-logs-report.ts +82 -0
- package/src/runner/prepare-run.test.ts +33 -0
- package/src/runner/prepare-run.ts +36 -0
- package/src/runner/registry.test.ts +59 -0
- package/src/runner/registry.ts +46 -0
- package/src/runner/reporter.test.ts +73 -0
- package/src/runner/reporter.ts +109 -0
- package/src/runner/test-error.test.ts +39 -0
- package/src/runner/test-error.ts +20 -0
- package/src/runner/test-runner.ts +184 -0
- package/src/script/call-function.browser-test.ts +112 -0
- package/src/script/call-function.test.ts +174 -0
- package/src/script/call-function.ts +113 -0
- package/src/script/element-handle.ts +11 -0
- package/src/script/helpers.test.ts +116 -0
- package/src/script/helpers.ts +68 -0
- package/src/script/preload.browser-test.ts +144 -0
- package/src/script/preload.test.ts +180 -0
- package/src/script/preload.ts +102 -0
- package/src/script/serialize.test.ts +182 -0
- package/src/script/serialize.ts +203 -0
- package/src/testing/browser-fixture.ts +18 -0
- package/src/testing/fake-websocket.ts +72 -0
- package/src/testing/stub-connector.ts +154 -0
- package/src/tests/index.spec.ts +30 -0
- package/src/transport/bidi-connection.test.ts +155 -0
- package/src/transport/bidi-connection.ts +256 -0
- package/src/transport/bidi-error.ts +23 -0
- package/src/transport/foundation.browser-test.ts +73 -0
- package/src/transport/subscriptions.test.ts +140 -0
- package/src/transport/subscriptions.ts +110 -0
- package/src/types/bidi-commands.test-d.ts +55 -0
- package/src/types/bidi-modules/browser.d.ts +103 -0
- package/src/types/bidi-modules/browsing-context.d.ts +430 -0
- package/src/types/bidi-modules/emulation.d.ts +280 -0
- package/src/types/bidi-modules/input.d.ts +201 -0
- package/src/types/bidi-modules/log.d.ts +49 -0
- package/src/types/bidi-modules/network.d.ts +358 -0
- package/src/types/bidi-modules/permissions.d.ts +19 -0
- package/src/types/bidi-modules/script.d.ts +543 -0
- package/src/types/bidi-modules/session.d.ts +135 -0
- package/src/types/bidi-modules/storage.d.ts +92 -0
- package/src/types/bidi-modules/web-extensions.d.ts +9 -0
- package/src/types/bidi-protocols/command.d.ts +7 -0
- package/src/types/bidi-protocols/error.d.ts +38 -0
- package/src/types/bidi-protocols/event.d.ts +17 -0
- package/src/types/bidi.d.ts +65 -0
- package/src/types/browser.d.ts +1 -0
- package/src/types/config.d.ts +157 -0
- package/src/types/env.d.ts +5 -0
- package/src/types/test.d.ts +95 -0
- package/src/wait/wait-until.test.ts +117 -0
- package/src/wait/wait-until.ts +86 -0
- package/tsconfig.json +44 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import type { EmptyResult } from "../bidi.js";
|
|
2
|
+
import type { UserContext } from "./browser.js";
|
|
3
|
+
import type { BrowsingContext } from "./browsing-context.js";
|
|
4
|
+
|
|
5
|
+
/** Commands available in the emulation module, keyed by method name. */
|
|
6
|
+
export interface EmulationCommands {
|
|
7
|
+
"emulation.setForcedColorsModeThemeOverride": {
|
|
8
|
+
params: SetForcedColorsModeThemeOverrideParameters;
|
|
9
|
+
result: SetForcedColorsModeThemeOverrideResult;
|
|
10
|
+
};
|
|
11
|
+
"emulation.setGeolocationOverride": {
|
|
12
|
+
params: SetGeolocationOverrideParameters;
|
|
13
|
+
result: SetGeolocationOverrideResult;
|
|
14
|
+
};
|
|
15
|
+
"emulation.setLocaleOverride": { params: SetLocaleOverrideParameters; result: SetLocaleOverrideResult };
|
|
16
|
+
"emulation.setNetworkConditions": { params: SetNetworkConditionsParameters; result: EmptyResult };
|
|
17
|
+
"emulation.setScreenOrientationOverride": {
|
|
18
|
+
params: SetScreenOrientationOverrideParameters;
|
|
19
|
+
result: SetScreenOrientationOverrideResult;
|
|
20
|
+
};
|
|
21
|
+
"emulation.setScreenSettingsOverride": { params: SetScreenSettingsOverrideParameters; result: EmptyResult };
|
|
22
|
+
"emulation.setScriptingEnabled": { params: SetScriptingEnabledParameters; result: SetScriptingEnabledResult };
|
|
23
|
+
"emulation.setScrollbarTypeOverride": {
|
|
24
|
+
params: SetScrollbarTypeOverrideParameters;
|
|
25
|
+
result: SetScrollbarTypeOverrideResult;
|
|
26
|
+
};
|
|
27
|
+
"emulation.setTimezoneOverride": { params: SetTimezoneOverrideParameters; result: SetTimezoneOverrideResult };
|
|
28
|
+
"emulation.setTouchOverride": { params: SetTouchOverrideParameters; result: SetTouchOverrideResult };
|
|
29
|
+
"emulation.setUserAgentOverride": { params: SetUserAgentOverrideParameters; result: SetUserAgentOverrideResult };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Union of all possible result types returned by emulation module commands. */
|
|
33
|
+
export type EmulationResult =
|
|
34
|
+
| SetForcedColorsModeThemeOverrideResult
|
|
35
|
+
| SetGeolocationOverrideResult
|
|
36
|
+
| SetLocaleOverrideResult
|
|
37
|
+
| SetScreenOrientationOverrideResult
|
|
38
|
+
| SetScriptingEnabledResult
|
|
39
|
+
| SetScrollbarTypeOverrideResult
|
|
40
|
+
| SetTimezoneOverrideResult
|
|
41
|
+
| SetTouchOverrideResult
|
|
42
|
+
| SetUserAgentOverrideResult;
|
|
43
|
+
|
|
44
|
+
/** Result of `emulation.setForcedColorsModeThemeOverride`. */
|
|
45
|
+
export type SetForcedColorsModeThemeOverrideResult = EmptyResult;
|
|
46
|
+
/** Result of `emulation.setGeolocationOverride`. */
|
|
47
|
+
export type SetGeolocationOverrideResult = EmptyResult;
|
|
48
|
+
/** Result of `emulation.setLocaleOverride`. */
|
|
49
|
+
export type SetLocaleOverrideResult = EmptyResult;
|
|
50
|
+
/** Result of `emulation.setScreenOrientationOverride`. */
|
|
51
|
+
export type SetScreenOrientationOverrideResult = EmptyResult;
|
|
52
|
+
/** Result of `emulation.setScriptingEnabled`. */
|
|
53
|
+
export type SetScriptingEnabledResult = EmptyResult;
|
|
54
|
+
/** Result of `emulation.setScrollbarTypeOverride`. */
|
|
55
|
+
export type SetScrollbarTypeOverrideResult = EmptyResult;
|
|
56
|
+
/** Result of `emulation.setTimezoneOverride`. */
|
|
57
|
+
export type SetTimezoneOverrideResult = EmptyResult;
|
|
58
|
+
/** Result of `emulation.setTouchOverride`. */
|
|
59
|
+
export type SetTouchOverrideResult = EmptyResult;
|
|
60
|
+
/** Result of `emulation.setUserAgentOverride`. */
|
|
61
|
+
export type SetUserAgentOverrideResult = EmptyResult;
|
|
62
|
+
|
|
63
|
+
/** Union of all commands in the emulation module, which overrides device and environment properties. */
|
|
64
|
+
export type EmulationCommand =
|
|
65
|
+
| SetForcedColorsModeThemeOverride
|
|
66
|
+
| SetGeolocationOverride
|
|
67
|
+
| SetLocaleOverride
|
|
68
|
+
| SetNetworkConditions
|
|
69
|
+
| SetScreenOrientationOverride
|
|
70
|
+
| SetScreenSettingsOverride
|
|
71
|
+
| SetScriptingEnabled
|
|
72
|
+
| SetScrollbarTypeOverride
|
|
73
|
+
| SetTimezoneOverride
|
|
74
|
+
| SetTouchOverride
|
|
75
|
+
| SetUserAgentOverride;
|
|
76
|
+
|
|
77
|
+
/** The color scheme theme to emulate for forced-colors media queries. */
|
|
78
|
+
export type ForcedColorsModeTheme = "light" | "dark";
|
|
79
|
+
|
|
80
|
+
/** Parameters for `emulation.setForcedColorsModeThemeOverride`. */
|
|
81
|
+
export interface SetForcedColorsModeThemeOverrideParameters {
|
|
82
|
+
/** The theme to force, or `null` to reset to the real value. */
|
|
83
|
+
theme: ForcedColorsModeTheme | null;
|
|
84
|
+
contexts?: BrowsingContext[];
|
|
85
|
+
userContexts?: UserContext[];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Overrides the forced-colors media feature theme (e.g. to simulate Windows High Contrast). */
|
|
89
|
+
export interface SetForcedColorsModeThemeOverride {
|
|
90
|
+
method: "emulation.setForcedColorsModeThemeOverride";
|
|
91
|
+
params: SetForcedColorsModeThemeOverrideParameters;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Indicates that the geolocation position is unavailable. */
|
|
95
|
+
export interface GeolocationPositionError {
|
|
96
|
+
type: "positionUnavailable";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A geolocation override response that simulates an unavailable position. */
|
|
100
|
+
export interface GeolocationCoordinatesResponseError {
|
|
101
|
+
error: GeolocationPositionError;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A geolocation override response with specific coordinates (or `null` to reset). */
|
|
105
|
+
export interface GeolocationCoordinatesResponse {
|
|
106
|
+
coordinates: GeolocationCoordinates | null;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Either a successful coordinates override or an error response. */
|
|
110
|
+
export type GeolocationOverrideResponse =
|
|
111
|
+
| GeolocationCoordinatesResponse
|
|
112
|
+
| GeolocationCoordinatesResponseError;
|
|
113
|
+
|
|
114
|
+
/** Parameters for `emulation.setGeolocationOverride`. */
|
|
115
|
+
export type SetGeolocationOverrideParameters = GeolocationOverrideResponse & {
|
|
116
|
+
contexts?: BrowsingContext[];
|
|
117
|
+
userContexts?: UserContext[];
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/** Overrides the geolocation position reported to scripts. */
|
|
121
|
+
export interface SetGeolocationOverride {
|
|
122
|
+
method: "emulation.setGeolocationOverride";
|
|
123
|
+
params: SetGeolocationOverrideParameters;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Parameters for `emulation.setLocaleOverride`. */
|
|
127
|
+
export interface SetLocaleOverrideParameters {
|
|
128
|
+
/** BCP 47 locale tag to override with, or `null` to reset. */
|
|
129
|
+
locale: string | null;
|
|
130
|
+
contexts?: BrowsingContext[];
|
|
131
|
+
userContexts?: UserContext[];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Overrides the locale reported to scripts (e.g. `Intl` APIs). */
|
|
135
|
+
export interface SetLocaleOverride {
|
|
136
|
+
method: "emulation.setLocaleOverride";
|
|
137
|
+
params: SetLocaleOverrideParameters;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Network conditions to simulate — currently only `offline` is supported. */
|
|
141
|
+
export type NetworkConditions = NetworkConditionsOffline;
|
|
142
|
+
|
|
143
|
+
/** Simulates a completely offline network connection. */
|
|
144
|
+
export interface NetworkConditionsOffline {
|
|
145
|
+
type: "offline";
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Parameters for `emulation.setNetworkConditions`. */
|
|
149
|
+
export interface SetNetworkConditionsParameters {
|
|
150
|
+
/** The network conditions to simulate, or `null` to reset. */
|
|
151
|
+
networkConditions: NetworkConditions | null;
|
|
152
|
+
contexts?: BrowsingContext[];
|
|
153
|
+
userContexts?: UserContext[];
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Simulates network conditions such as being offline. */
|
|
157
|
+
export interface SetNetworkConditions {
|
|
158
|
+
method: "emulation.setNetworkConditions";
|
|
159
|
+
params: SetNetworkConditionsParameters;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Parameters for `emulation.setScreenOrientationOverride`. */
|
|
163
|
+
export interface SetScreenOrientationOverrideParameters {
|
|
164
|
+
/** The orientation to emulate, or `null` to reset. */
|
|
165
|
+
screenOrientation: ScreenOrientation | null;
|
|
166
|
+
contexts?: BrowsingContext[];
|
|
167
|
+
userContexts?: UserContext[];
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** The natural orientation and current type of the screen. */
|
|
171
|
+
export interface ScreenOrientation {
|
|
172
|
+
natural: ScreenOrientationNatural;
|
|
173
|
+
type: ScreenOrientationType;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The device's natural (hardware) orientation. */
|
|
177
|
+
export type ScreenOrientationNatural = "landscape" | "portrait";
|
|
178
|
+
|
|
179
|
+
/** The logical screen orientation type as defined by the Screen Orientation API. */
|
|
180
|
+
export type ScreenOrientationType =
|
|
181
|
+
| "portrait-primary"
|
|
182
|
+
| "portrait-secondary"
|
|
183
|
+
| "landscape-primary"
|
|
184
|
+
| "landscape-secondary";
|
|
185
|
+
|
|
186
|
+
/** Overrides the screen orientation reported to scripts. */
|
|
187
|
+
export interface SetScreenOrientationOverride {
|
|
188
|
+
method: "emulation.setScreenOrientationOverride";
|
|
189
|
+
params: SetScreenOrientationOverrideParameters;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** Width and height of a screen area in CSS pixels. */
|
|
193
|
+
export interface ScreenArea {
|
|
194
|
+
width: number;
|
|
195
|
+
height: number;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Parameters for `emulation.setScreenSettingsOverride`. */
|
|
199
|
+
export interface SetScreenSettingsOverrideParameters {
|
|
200
|
+
/** The screen area dimensions to emulate, or `null` to reset. */
|
|
201
|
+
screenArea: ScreenArea | null;
|
|
202
|
+
contexts?: BrowsingContext[];
|
|
203
|
+
userContexts?: UserContext[];
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** Overrides screen size settings (e.g. `screen.width` / `screen.height`) reported to scripts. */
|
|
207
|
+
export interface SetScreenSettingsOverride {
|
|
208
|
+
method: "emulation.setScreenSettingsOverride";
|
|
209
|
+
params: SetScreenSettingsOverrideParameters;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Parameters for `emulation.setScriptingEnabled`. */
|
|
213
|
+
export interface SetScriptingEnabledParameters {
|
|
214
|
+
/** `false` to disable JavaScript execution, or `null` to reset to default. */
|
|
215
|
+
enabled: false | null;
|
|
216
|
+
contexts?: BrowsingContext[];
|
|
217
|
+
userContexts?: UserContext[];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/** Disables or re-enables JavaScript execution in the given contexts. */
|
|
221
|
+
export interface SetScriptingEnabled {
|
|
222
|
+
method: "emulation.setScriptingEnabled";
|
|
223
|
+
params: SetScriptingEnabledParameters;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Parameters for `emulation.setScrollbarTypeOverride`. */
|
|
227
|
+
export interface SetScrollbarTypeOverrideParameters {
|
|
228
|
+
/** `"classic"` for always-visible scrollbars, `"overlay"` for overlay scrollbars, or `null` to reset. */
|
|
229
|
+
scrollbarType: "classic" | "overlay" | null;
|
|
230
|
+
contexts?: BrowsingContext[];
|
|
231
|
+
userContexts?: UserContext[];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/** Overrides the scrollbar rendering style in the given contexts. */
|
|
235
|
+
export interface SetScrollbarTypeOverride {
|
|
236
|
+
method: "emulation.setScrollbarTypeOverride";
|
|
237
|
+
params: SetScrollbarTypeOverrideParameters;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** Parameters for `emulation.setTimezoneOverride`. */
|
|
241
|
+
export interface SetTimezoneOverrideParameters {
|
|
242
|
+
/** A valid IANA timezone identifier (e.g. `"America/New_York"`), or `null` to reset. */
|
|
243
|
+
timezone: string | null;
|
|
244
|
+
contexts?: BrowsingContext[];
|
|
245
|
+
userContexts?: UserContext[];
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Overrides the timezone used by scripts (e.g. `Intl.DateTimeFormat`). */
|
|
249
|
+
export interface SetTimezoneOverride {
|
|
250
|
+
method: "emulation.setTimezoneOverride";
|
|
251
|
+
params: SetTimezoneOverrideParameters;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Parameters for `emulation.setTouchOverride`. */
|
|
255
|
+
export interface SetTouchOverrideParameters {
|
|
256
|
+
/** Maximum number of simultaneous touch points to emulate, or `null` to reset. */
|
|
257
|
+
maxTouchPoints: number | null;
|
|
258
|
+
contexts?: BrowsingContext[];
|
|
259
|
+
userContexts?: UserContext[];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/** Overrides touch support, enabling touch events in non-touch environments. */
|
|
263
|
+
export interface SetTouchOverride {
|
|
264
|
+
method: "emulation.setTouchOverride";
|
|
265
|
+
params: SetTouchOverrideParameters;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** Parameters for `emulation.setUserAgentOverride`. */
|
|
269
|
+
export interface SetUserAgentOverrideParameters {
|
|
270
|
+
/** The user-agent string to report, or `null` to reset to the real value. */
|
|
271
|
+
userAgent: string | null;
|
|
272
|
+
contexts?: BrowsingContext[];
|
|
273
|
+
userContexts?: UserContext[];
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** Overrides the User-Agent string reported by the browser. */
|
|
277
|
+
export interface SetUserAgentOverride {
|
|
278
|
+
method: "emulation.setUserAgentOverride";
|
|
279
|
+
params: SetUserAgentOverrideParameters;
|
|
280
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { EmptyResult } from "../bidi.js";
|
|
2
|
+
import type { UserContext } from "./browser.js";
|
|
3
|
+
import type { BrowsingContext, SharedReference } from "./browsing-context.js";
|
|
4
|
+
|
|
5
|
+
/** Commands available in the WebDriver BiDi input module, which simulates user input. */
|
|
6
|
+
export interface InputCommands {
|
|
7
|
+
/** Performs a sequence of input actions (keyboard, mouse, wheel, etc.) in the given browsing context. */
|
|
8
|
+
"input.performActions": {
|
|
9
|
+
params: {
|
|
10
|
+
context: BrowsingContext;
|
|
11
|
+
actions: SourceActions[];
|
|
12
|
+
};
|
|
13
|
+
result: {};
|
|
14
|
+
};
|
|
15
|
+
/** Sets the files of an `<input type=file>` element; `[]` clears them. */
|
|
16
|
+
"input.setFiles": {
|
|
17
|
+
params: {
|
|
18
|
+
context: BrowsingContext;
|
|
19
|
+
element: SharedReference;
|
|
20
|
+
files: string[];
|
|
21
|
+
};
|
|
22
|
+
result: {};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** A set of actions for a single input source — none, key, pointer, or wheel. */
|
|
27
|
+
export type SourceActions =
|
|
28
|
+
| NoneSourceActions
|
|
29
|
+
| KeySourceActions
|
|
30
|
+
| PointerSourceActions
|
|
31
|
+
| WheelSourceActions;
|
|
32
|
+
|
|
33
|
+
/** Actions for a null input source, which only supports pause. */
|
|
34
|
+
export interface NoneSourceActions {
|
|
35
|
+
type: "none";
|
|
36
|
+
id: string;
|
|
37
|
+
actions: NoneSourceAction[];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** A single action for a null input source. */
|
|
41
|
+
export type NoneSourceAction = PauseAction;
|
|
42
|
+
|
|
43
|
+
/** Actions for a keyboard input source. */
|
|
44
|
+
export interface KeySourceActions {
|
|
45
|
+
type: "key";
|
|
46
|
+
id: string;
|
|
47
|
+
actions: KeySourceAction[];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A single action for a keyboard input source. */
|
|
51
|
+
export type KeySourceAction = PauseAction | KeyDownAction | KeyUpAction;
|
|
52
|
+
|
|
53
|
+
/** Actions for a pointer input source (mouse, pen, or touch). */
|
|
54
|
+
export interface PointerSourceActions {
|
|
55
|
+
type: "pointer";
|
|
56
|
+
id: string;
|
|
57
|
+
parameters?: PointerParameters | undefined;
|
|
58
|
+
actions: PointerSourceAction[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** The kind of pointer device being simulated. */
|
|
62
|
+
export type PointerType = "mouse" | "pen" | "touch";
|
|
63
|
+
|
|
64
|
+
/** Optional configuration for a pointer input source. */
|
|
65
|
+
export interface PointerParameters {
|
|
66
|
+
pointerType: PointerType;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A single action for a pointer input source. */
|
|
70
|
+
export type PointerSourceAction =
|
|
71
|
+
| PauseAction
|
|
72
|
+
| PointerDownAction
|
|
73
|
+
| PointerUpAction
|
|
74
|
+
| PointerMoveAction;
|
|
75
|
+
|
|
76
|
+
/** Actions for a wheel input source. */
|
|
77
|
+
export interface WheelSourceActions {
|
|
78
|
+
type: "wheel";
|
|
79
|
+
id: string;
|
|
80
|
+
actions: WheelSourceAction[];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A single action for a wheel input source. */
|
|
84
|
+
export type WheelSourceAction = PauseAction | WheelScrollAction;
|
|
85
|
+
|
|
86
|
+
/** Pauses the input sequence for an optional duration in milliseconds. */
|
|
87
|
+
export interface PauseAction {
|
|
88
|
+
type: "pause";
|
|
89
|
+
duration?: number | undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Simulates pressing a key down. */
|
|
93
|
+
export interface KeyDownAction {
|
|
94
|
+
type: "keyDown";
|
|
95
|
+
value: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Simulates releasing a key. */
|
|
99
|
+
export interface KeyUpAction {
|
|
100
|
+
type: "keyUp";
|
|
101
|
+
value: string;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* 0 — Left button (primary)
|
|
106
|
+
* 1 — Middle button (scroll wheel click)
|
|
107
|
+
* 2 — Right button (context menu)
|
|
108
|
+
* 3 — Back button
|
|
109
|
+
* 4 — Forward button
|
|
110
|
+
*/
|
|
111
|
+
export type PointerButton = 0 | 1 | 2 | 3 | 4;
|
|
112
|
+
|
|
113
|
+
/** Simulates releasing a pointer button. */
|
|
114
|
+
export interface PointerUpAction {
|
|
115
|
+
type: "pointerUp";
|
|
116
|
+
button: PointerButton;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Simulates pressing a pointer button down. */
|
|
120
|
+
export interface PointerDownAction {
|
|
121
|
+
type: "pointerDown";
|
|
122
|
+
button: PointerButton;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Simulates moving a pointer to a new position. */
|
|
126
|
+
export interface PointerMoveAction extends PointerCommonProperties {
|
|
127
|
+
type: "pointerMove";
|
|
128
|
+
x: number;
|
|
129
|
+
y: number;
|
|
130
|
+
duration?: number;
|
|
131
|
+
origin?: Origin;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Physical properties common to all pointer actions (pressure, tilt, etc.). */
|
|
135
|
+
export interface PointerCommonProperties {
|
|
136
|
+
width?: number;
|
|
137
|
+
height?: number;
|
|
138
|
+
/** Normalized pressure of the pointer; 0.0..1.0 */
|
|
139
|
+
pressure?: number;
|
|
140
|
+
/** Tangential (barrel) pressure; -1.0..1.0 */
|
|
141
|
+
tangentialPressure?: number;
|
|
142
|
+
/** Clockwise rotation of the pointer around its major axis; 0..359 */
|
|
143
|
+
twist?: number;
|
|
144
|
+
/** Angle between the pointer and the device surface; 0 .. Math.PI / 2 */
|
|
145
|
+
altitudeAngle?: number;
|
|
146
|
+
/** Clockwise angle of the pointer projection on the XY plane; 0 .. 2 * Math.PI */
|
|
147
|
+
azimuthAngle?: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Simulates a wheel scroll at a given position. */
|
|
151
|
+
export interface WheelScrollAction extends PointerCommonProperties {
|
|
152
|
+
type: "scroll";
|
|
153
|
+
x: number;
|
|
154
|
+
y: number;
|
|
155
|
+
deltaX: number;
|
|
156
|
+
deltaY: number;
|
|
157
|
+
duration?: number | undefined;
|
|
158
|
+
origin: Origin;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** An origin defined by a specific DOM element's position. */
|
|
162
|
+
export interface ElementOrigin {
|
|
163
|
+
type: "element";
|
|
164
|
+
element: SharedReference;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The reference point for pointer/wheel coordinates — viewport, current pointer position, or a specific element. */
|
|
168
|
+
export type Origin = "viewport" | "pointer" | ElementOrigin;
|
|
169
|
+
|
|
170
|
+
/** Events emitted by the input module, keyed by method name. */
|
|
171
|
+
export interface InputEvents {
|
|
172
|
+
"input.fileDialogOpened": { params: FileDialogInfo };
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Union of all events emitted by the input module. */
|
|
176
|
+
export type InputEvent = FileDialogOpened;
|
|
177
|
+
|
|
178
|
+
/** Parameters for the `input.fileDialogOpened` event. */
|
|
179
|
+
export interface FileDialogInfo {
|
|
180
|
+
context: BrowsingContext;
|
|
181
|
+
userContext?: UserContext;
|
|
182
|
+
/** The file input element that triggered the dialog, if any. */
|
|
183
|
+
element?: SharedReference;
|
|
184
|
+
/** Whether the dialog allows selecting multiple files. */
|
|
185
|
+
multiple: boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** Emitted when a file picker dialog is opened. */
|
|
189
|
+
export interface FileDialogOpened {
|
|
190
|
+
method: "input.fileDialogOpened";
|
|
191
|
+
params: FileDialogInfo;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export type InputResult =
|
|
195
|
+
| PerformActionResult
|
|
196
|
+
| ReleaseActionResult
|
|
197
|
+
| SetFilesResult;
|
|
198
|
+
|
|
199
|
+
export type PerformActionResult = EmptyResult;
|
|
200
|
+
export type ReleaseActionResult = EmptyResult;
|
|
201
|
+
export type SetFilesResult = EmptyResult;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { RemoteValue, Source, StackTrace } from "./script.js";
|
|
2
|
+
|
|
3
|
+
/** The severity level of a log entry. */
|
|
4
|
+
export type Level = "debug" | "info" | "warn" | "error";
|
|
5
|
+
|
|
6
|
+
/** A log entry — either a generic, console, or JavaScript error entry. */
|
|
7
|
+
export type Entry = GenericLogEntry | ConsoleLogEntry | JavascriptLogEntry;
|
|
8
|
+
|
|
9
|
+
/** Common fields shared by all log entry types. */
|
|
10
|
+
export interface BaseLogEntry {
|
|
11
|
+
level: Level;
|
|
12
|
+
source: Source;
|
|
13
|
+
/** Human-readable text representation of the log entry. */
|
|
14
|
+
text: string | null;
|
|
15
|
+
timestamp: number;
|
|
16
|
+
stackTrace?: StackTrace;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** A log entry of an unrecognized or custom type. */
|
|
20
|
+
export interface GenericLogEntry extends BaseLogEntry {
|
|
21
|
+
type: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** A log entry produced by a `console.*` method call. */
|
|
25
|
+
export interface ConsoleLogEntry extends BaseLogEntry {
|
|
26
|
+
type: "console";
|
|
27
|
+
/** The console method that produced this entry (e.g. `log`, `warn`, `error`). */
|
|
28
|
+
method: string;
|
|
29
|
+
args: RemoteValue[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A log entry produced by an uncaught JavaScript error. */
|
|
33
|
+
export interface JavascriptLogEntry extends BaseLogEntry {
|
|
34
|
+
type: "javascript";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Events emitted by the log module, keyed by method name. */
|
|
38
|
+
export interface LogEvents {
|
|
39
|
+
"log.entryAdded": { params: Entry };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Union of all events emitted by the log module. */
|
|
43
|
+
export type LogEvent = EntryAdded;
|
|
44
|
+
|
|
45
|
+
/** Emitted when a new log entry is added (e.g. a console message or JS error). */
|
|
46
|
+
export interface EntryAdded {
|
|
47
|
+
method: "log.entryAdded";
|
|
48
|
+
params: Entry;
|
|
49
|
+
}
|