@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,103 @@
|
|
|
1
|
+
import type { EmptyResult } from "../bidi.js";
|
|
2
|
+
import type { ProxyConfiguration, UserPromptHandler } from "./session.js";
|
|
3
|
+
|
|
4
|
+
/** Represents a collection of zero or more top-level traversables within a remote end.
|
|
5
|
+
* Each user context has an associated storage partition,
|
|
6
|
+
* so that remote end data is not shared between different user contexts. */
|
|
7
|
+
export type UserContext = string;
|
|
8
|
+
|
|
9
|
+
/** Commands available in the WebDriver BiDi browser module. */
|
|
10
|
+
export interface BrowserCommands {
|
|
11
|
+
/** Closes the browser and terminates the session. */
|
|
12
|
+
"browser.close": {
|
|
13
|
+
params: Record<string, never>;
|
|
14
|
+
result: CloseResult;
|
|
15
|
+
};
|
|
16
|
+
/** Creates an isolated user context (own cookies, storage and cache). */
|
|
17
|
+
"browser.createUserContext": {
|
|
18
|
+
params: {
|
|
19
|
+
acceptInsecureCerts?: boolean | undefined;
|
|
20
|
+
proxy?: ProxyConfiguration | undefined;
|
|
21
|
+
unhandledPromptBehavior?: UserPromptHandler | undefined;
|
|
22
|
+
};
|
|
23
|
+
result: CreateUserContextResult;
|
|
24
|
+
};
|
|
25
|
+
/** Removes a user context and closes its browsing contexts. */
|
|
26
|
+
"browser.removeUserContext": {
|
|
27
|
+
params: { userContext: UserContext };
|
|
28
|
+
result: RemoveUserContextResult;
|
|
29
|
+
};
|
|
30
|
+
/** Lists all user contexts, including the default one. */
|
|
31
|
+
"browser.getUserContexts": {
|
|
32
|
+
params: Record<string, never>;
|
|
33
|
+
result: GetUserContextsResult;
|
|
34
|
+
};
|
|
35
|
+
/** Sets where downloads go, or denies them. `null` restores the browser default. */
|
|
36
|
+
"browser.setDownloadBehavior": {
|
|
37
|
+
params: {
|
|
38
|
+
downloadBehavior: DownloadBehavior | null;
|
|
39
|
+
userContexts?: UserContext[] | undefined;
|
|
40
|
+
};
|
|
41
|
+
result: SetDownloadBehaviorResult;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** How downloads are handled. */
|
|
46
|
+
export type DownloadBehavior =
|
|
47
|
+
| { type: "allowed"; destinationFolder: string }
|
|
48
|
+
| { type: "denied" };
|
|
49
|
+
|
|
50
|
+
/** Union of all possible result types returned by browser module commands. */
|
|
51
|
+
export type BrowserResult =
|
|
52
|
+
| CloseResult
|
|
53
|
+
| CreateUserContextResult
|
|
54
|
+
| GetClientWindowsResult
|
|
55
|
+
| GetUserContextsResult
|
|
56
|
+
| RemoveUserContextResult
|
|
57
|
+
| SetClientWindowStateResult
|
|
58
|
+
| SetDownloadBehaviorResult;
|
|
59
|
+
|
|
60
|
+
/** Result of `browser.close`. */
|
|
61
|
+
export type CloseResult = EmptyResult;
|
|
62
|
+
|
|
63
|
+
/** Result of `browser.createUserContext`, containing the newly created user context info. */
|
|
64
|
+
export type CreateUserContextResult = UserContextInfo;
|
|
65
|
+
|
|
66
|
+
/** Metadata about a user context. */
|
|
67
|
+
export interface UserContextInfo {
|
|
68
|
+
userContext: UserContext;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Unique identifier for a browser window. */
|
|
72
|
+
export type ClientWindow = string;
|
|
73
|
+
|
|
74
|
+
/** State and dimensions of a browser client window. */
|
|
75
|
+
export interface ClientWindowInfo {
|
|
76
|
+
/** Whether this window is currently the active (focused) window. */
|
|
77
|
+
active: boolean;
|
|
78
|
+
clientWindow: ClientWindow;
|
|
79
|
+
height: number;
|
|
80
|
+
state: "fullscreen" | "maximized" | "minimized" | "normal";
|
|
81
|
+
width: number;
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Result of `browser.getClientWindows`. */
|
|
87
|
+
export interface GetClientWindowsResult {
|
|
88
|
+
clientWindow: ClientWindowInfo[];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Result of `browser.getUserContexts`. */
|
|
92
|
+
export interface GetUserContextsResult {
|
|
93
|
+
userContexts: UserContextInfo[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Result of `browser.removeUserContext`. */
|
|
97
|
+
export type RemoveUserContextResult = EmptyResult;
|
|
98
|
+
|
|
99
|
+
/** Result of `browser.setClientWindowState`, reflecting the updated window state. */
|
|
100
|
+
export type SetClientWindowStateResult = ClientWindowInfo;
|
|
101
|
+
|
|
102
|
+
/** Result of `browser.setDownloadBehavior`. */
|
|
103
|
+
export type SetDownloadBehaviorResult = EmptyResult;
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import type { EmptyResult } from "../bidi.js";
|
|
2
|
+
import type { ClientWindow, UserContext } from "./browser.js";
|
|
3
|
+
import type { NodeRemoteValue } from "./script.js";
|
|
4
|
+
import type { UserPromptHandlerType } from "./session.js";
|
|
5
|
+
|
|
6
|
+
/** Commands available in the WebDriver BiDi browsingContext module. */
|
|
7
|
+
export interface BrowsingContextModule {
|
|
8
|
+
/** Returns the browsing context tree, optionally limited to a subtree and/or depth. */
|
|
9
|
+
"browsingContext.getTree": {
|
|
10
|
+
params: { maxDepth?: number; root?: BrowsingContext };
|
|
11
|
+
result: { contexts: InfoList };
|
|
12
|
+
};
|
|
13
|
+
/** Creates a new top-level browsing context (tab or window). */
|
|
14
|
+
"browsingContext.create": {
|
|
15
|
+
params: {
|
|
16
|
+
type: "window" | "tab";
|
|
17
|
+
background?: boolean | undefined;
|
|
18
|
+
userContext?: UserContext | undefined;
|
|
19
|
+
};
|
|
20
|
+
result: {
|
|
21
|
+
context: BrowsingContext;
|
|
22
|
+
userContext: UserContext;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** Navigates the given browsing context to a URL, optionally waiting for a readiness state. */
|
|
26
|
+
"browsingContext.navigate": {
|
|
27
|
+
params: {
|
|
28
|
+
context: BrowsingContext;
|
|
29
|
+
url: string;
|
|
30
|
+
wait?: ReadinessState | undefined;
|
|
31
|
+
};
|
|
32
|
+
result: { navigation: BrowsingContext; url: string };
|
|
33
|
+
};
|
|
34
|
+
/** Captures a screenshot of the given browsing context, with optional clip and format. */
|
|
35
|
+
"browsingContext.captureScreenshot": {
|
|
36
|
+
params: {
|
|
37
|
+
context: BrowsingContext;
|
|
38
|
+
origin?: "viewport" | "document" | undefined;
|
|
39
|
+
format?: ImageFormat | undefined;
|
|
40
|
+
clip?: ClipRectangle | undefined;
|
|
41
|
+
};
|
|
42
|
+
/** `data` is the image, Base64-encoded */
|
|
43
|
+
result: { data: string };
|
|
44
|
+
};
|
|
45
|
+
/** Finds nodes with a CSS, XPath, text or accessibility locator. */
|
|
46
|
+
"browsingContext.locateNodes": {
|
|
47
|
+
params: {
|
|
48
|
+
context: BrowsingContext;
|
|
49
|
+
locator: NodeLocator;
|
|
50
|
+
maxNodeCount?: number | undefined;
|
|
51
|
+
serializationOptions?: SerializationOptions | undefined;
|
|
52
|
+
startNodes?: SharedReference[] | undefined;
|
|
53
|
+
};
|
|
54
|
+
result: { nodes: NodeRemoteValue[] };
|
|
55
|
+
};
|
|
56
|
+
/** Accepts or dismisses the open user prompt. */
|
|
57
|
+
"browsingContext.handleUserPrompt": {
|
|
58
|
+
params: { context: BrowsingContext; accept?: boolean | undefined; userText?: string | undefined };
|
|
59
|
+
result: {};
|
|
60
|
+
};
|
|
61
|
+
/** Sets or resets (null) the viewport size and device pixel ratio. */
|
|
62
|
+
"browsingContext.setViewport": {
|
|
63
|
+
params: {
|
|
64
|
+
context?: BrowsingContext | undefined;
|
|
65
|
+
viewport?: { width: number; height: number } | null | undefined;
|
|
66
|
+
devicePixelRatio?: number | null | undefined;
|
|
67
|
+
userContexts?: UserContext[] | undefined;
|
|
68
|
+
};
|
|
69
|
+
result: {};
|
|
70
|
+
};
|
|
71
|
+
/** Reloads the document. */
|
|
72
|
+
"browsingContext.reload": {
|
|
73
|
+
params: {
|
|
74
|
+
context: BrowsingContext;
|
|
75
|
+
ignoreCache?: boolean | undefined;
|
|
76
|
+
wait?: ReadinessState | undefined;
|
|
77
|
+
};
|
|
78
|
+
result: { navigation: Navigation | null; url: string };
|
|
79
|
+
};
|
|
80
|
+
/** Moves through the session history by `delta` entries. */
|
|
81
|
+
"browsingContext.traverseHistory": {
|
|
82
|
+
params: { context: BrowsingContext; delta: number };
|
|
83
|
+
result: {};
|
|
84
|
+
};
|
|
85
|
+
/** Closes a top-level browsing context. */
|
|
86
|
+
"browsingContext.close": {
|
|
87
|
+
params: { context: BrowsingContext; promptUnload?: boolean | undefined };
|
|
88
|
+
result: {};
|
|
89
|
+
};
|
|
90
|
+
/** Renders the document as a PDF; `data` is Base64. */
|
|
91
|
+
"browsingContext.print": {
|
|
92
|
+
params: {
|
|
93
|
+
context: BrowsingContext;
|
|
94
|
+
background?: boolean | undefined;
|
|
95
|
+
margin?: { top?: number; bottom?: number; left?: number; right?: number } | undefined;
|
|
96
|
+
orientation?: "portrait" | "landscape" | undefined;
|
|
97
|
+
page?: { width?: number; height?: number } | undefined;
|
|
98
|
+
pageRanges?: (number | string)[] | undefined;
|
|
99
|
+
scale?: number | undefined;
|
|
100
|
+
shrinkToFit?: boolean | undefined;
|
|
101
|
+
};
|
|
102
|
+
result: { data: string };
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Locators understood by `browsingContext.locateNodes`. */
|
|
107
|
+
export type NodeLocator =
|
|
108
|
+
| { type: "css"; value: string }
|
|
109
|
+
| { type: "xpath"; value: string }
|
|
110
|
+
| {
|
|
111
|
+
type: "innerText";
|
|
112
|
+
value: string;
|
|
113
|
+
ignoreCase?: boolean;
|
|
114
|
+
matchType?: "full" | "partial";
|
|
115
|
+
maxDepth?: number;
|
|
116
|
+
}
|
|
117
|
+
| { type: "accessibility"; value: { name?: string; role?: string } }
|
|
118
|
+
| { type: "context"; value: { context: BrowsingContext } };
|
|
119
|
+
|
|
120
|
+
/** A navigable presents a Document to the user via its active session history entry. */
|
|
121
|
+
export type BrowsingContext = string;
|
|
122
|
+
/** Represents the stage of document loading at which a navigation command will return. */
|
|
123
|
+
export type ReadinessState = "none" | "interactive" | "complete";
|
|
124
|
+
/** Represents a reference to a DOM Node that is usable in any realm (including Sandbox Realms). */
|
|
125
|
+
export type SharedId = string;
|
|
126
|
+
/** Represents a handle to an object owned by the ECMAScript runtime. The handle is only valid in a specific Realm. */
|
|
127
|
+
export type Handle = string;
|
|
128
|
+
export type ImageFormat = {
|
|
129
|
+
/** A MIME type: "image/png" or "image/jpeg". Anything else is silently treated as PNG */
|
|
130
|
+
type: string;
|
|
131
|
+
/** 0 to 1, for "image/jpeg" */
|
|
132
|
+
quality?: number | undefined;
|
|
133
|
+
};
|
|
134
|
+
export type ElementRectangle = {
|
|
135
|
+
x: number;
|
|
136
|
+
y: number;
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
top: number;
|
|
140
|
+
right: number;
|
|
141
|
+
bottom: number;
|
|
142
|
+
left: number;
|
|
143
|
+
};
|
|
144
|
+
export type ClipRectangle = BoxClipRectangle | ElementClipRectangle;
|
|
145
|
+
export type ElementClipRectangle = {
|
|
146
|
+
type: "element";
|
|
147
|
+
element: SharedReference;
|
|
148
|
+
};
|
|
149
|
+
export type BoxClipRectangle = {
|
|
150
|
+
type: "box";
|
|
151
|
+
x: number;
|
|
152
|
+
y: number;
|
|
153
|
+
width: number;
|
|
154
|
+
height: number;
|
|
155
|
+
};
|
|
156
|
+
/** Represents a reference to a node */
|
|
157
|
+
export type SharedReference = {
|
|
158
|
+
sharedId: string;
|
|
159
|
+
handle?: undefined | Handle;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export type InfoList = Info[];
|
|
163
|
+
|
|
164
|
+
/** Represents the properties of a navigable. */
|
|
165
|
+
export type Info = {
|
|
166
|
+
/** null when the tree was not requested this deep */
|
|
167
|
+
children: InfoList | null;
|
|
168
|
+
clientWindow: ClientWindow;
|
|
169
|
+
context: BrowsingContext;
|
|
170
|
+
originalOpener: BrowsingContext | null;
|
|
171
|
+
url: string;
|
|
172
|
+
userContext: UserContext;
|
|
173
|
+
/** Absent or null for top-level contexts */
|
|
174
|
+
parent?: BrowsingContext | null;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** Unique identifier for a navigation within a browsing context. */
|
|
178
|
+
export type Navigation = string;
|
|
179
|
+
|
|
180
|
+
/** Common parameters included in all navigation-related events. */
|
|
181
|
+
export interface BaseNavigationInfo {
|
|
182
|
+
context: BrowsingContext;
|
|
183
|
+
navigation: Navigation;
|
|
184
|
+
timestamp: number;
|
|
185
|
+
url: string;
|
|
186
|
+
userContext: UserContext;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Parameters for navigation events that carry no additional data beyond the base. */
|
|
190
|
+
export type NavigationInfo = BaseNavigationInfo;
|
|
191
|
+
|
|
192
|
+
/** Emitted when a new browsing context is created. */
|
|
193
|
+
export interface ContextCreated {
|
|
194
|
+
method: "browsingContext.contextCreated";
|
|
195
|
+
params: Info;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Emitted when a browsing context is destroyed. */
|
|
199
|
+
export interface ContextDestroyed {
|
|
200
|
+
method: "browsingContext.contextDestroyed";
|
|
201
|
+
params: Info;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Emitted when the DOMContentLoaded event fires in the browsing context. */
|
|
205
|
+
export interface DomContentLoaded {
|
|
206
|
+
method: "browsingContext.domContentLoaded";
|
|
207
|
+
params: NavigationInfo;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** Parameters for a download that was canceled. */
|
|
211
|
+
export interface DownloadCanceledParams extends BaseNavigationInfo {
|
|
212
|
+
status: "canceled";
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Parameters for a download that completed successfully. */
|
|
216
|
+
export interface DownloadCompleteParams extends BaseNavigationInfo {
|
|
217
|
+
status: "complete";
|
|
218
|
+
filepath: string;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/** Parameters for the `browsingContext.downloadEnd` event — either canceled or complete. */
|
|
222
|
+
export type DownloadEndParams = DownloadCanceledParams | DownloadCompleteParams;
|
|
223
|
+
|
|
224
|
+
/** Emitted when a download finishes (either completed or canceled). */
|
|
225
|
+
export interface DownloadEnd {
|
|
226
|
+
method: "browsingContext.downloadEnd";
|
|
227
|
+
params: DownloadEndParams;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Parameters for the `browsingContext.downloadWillBegin` event. */
|
|
231
|
+
export interface DownloadWillBeginParams extends BaseNavigationInfo {
|
|
232
|
+
suggestedFilename: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Emitted just before a download begins. */
|
|
236
|
+
export interface DownloadWillBegin {
|
|
237
|
+
method: "browsingContext.downloadWillBegin";
|
|
238
|
+
params: DownloadWillBeginParams;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** Emitted when a same-document navigation via a fragment identifier completes. */
|
|
242
|
+
export interface FragmentNavigated {
|
|
243
|
+
method: "browsingContext.fragmentNavigated";
|
|
244
|
+
params: NavigationInfo;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** Parameters for the `browsingContext.historyUpdated` event. */
|
|
248
|
+
export interface HistoryUpdatedParameters {
|
|
249
|
+
context: BrowsingContext;
|
|
250
|
+
timestamp: number;
|
|
251
|
+
url: string;
|
|
252
|
+
userContext?: UserContext;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Emitted when the URL changes due to `history.pushState` or `history.replaceState`. */
|
|
256
|
+
export interface HistoryUpdated {
|
|
257
|
+
method: "browsingContext.historyUpdated";
|
|
258
|
+
params: HistoryUpdatedParameters;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Emitted when the `load` event fires in the browsing context. */
|
|
262
|
+
export interface Load {
|
|
263
|
+
method: "browsingContext.load";
|
|
264
|
+
params: NavigationInfo;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** Emitted when a navigation is aborted before completion. */
|
|
268
|
+
export interface NavigationAborted {
|
|
269
|
+
method: "browsingContext.navigationAborted";
|
|
270
|
+
params: NavigationInfo;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** Emitted when a navigation is committed (the response has been received and the new document begins loading). */
|
|
274
|
+
export interface NavigationCommitted {
|
|
275
|
+
method: "browsingContext.navigationCommitted";
|
|
276
|
+
params: NavigationInfo;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Emitted when a navigation fails due to a network or other error. */
|
|
280
|
+
export interface NavigationFailed {
|
|
281
|
+
method: "browsingContext.navigationFailed";
|
|
282
|
+
params: NavigationInfo;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Emitted when a navigation begins. */
|
|
286
|
+
export interface NavigationStarted {
|
|
287
|
+
method: "browsingContext.navigationStarted";
|
|
288
|
+
params: NavigationInfo;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** The type of user prompt (dialog) that was opened. */
|
|
292
|
+
export type UserPromptType = "alert" | "beforeunload" | "confirm" | "prompt";
|
|
293
|
+
|
|
294
|
+
/** Parameters for the `browsingContext.userPromptClosed` event. */
|
|
295
|
+
export interface UserPromptClosedParameters {
|
|
296
|
+
context: BrowsingContext;
|
|
297
|
+
/** Whether the user accepted (e.g. clicked OK) or dismissed the prompt. */
|
|
298
|
+
accepted: boolean;
|
|
299
|
+
type: UserPromptType;
|
|
300
|
+
userContext?: UserContext;
|
|
301
|
+
/** Text entered by the user in a `prompt` dialog, if any. */
|
|
302
|
+
userText?: string;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Emitted when a user prompt (dialog) is closed. */
|
|
306
|
+
export interface UserPromptClosed {
|
|
307
|
+
method: "browsingContext.userPromptClosed";
|
|
308
|
+
params: UserPromptClosedParameters;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** Emitted when a user prompt (dialog) is opened. */
|
|
312
|
+
export interface UserPromptOpened {
|
|
313
|
+
method: "browsingContext.userPromptOpened";
|
|
314
|
+
params: UserPromptOpenedParameters;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** Parameters for the `browsingContext.userPromptOpened` event. */
|
|
318
|
+
export interface UserPromptOpenedParameters {
|
|
319
|
+
context: BrowsingContext;
|
|
320
|
+
/** The handler that will be used to automatically respond to this prompt, per session configuration. */
|
|
321
|
+
handler: UserPromptHandlerType;
|
|
322
|
+
message: string;
|
|
323
|
+
type: UserPromptType;
|
|
324
|
+
userContext?: UserContext;
|
|
325
|
+
defaultValue?: string;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Events emitted by the browsingContext module, keyed by method name. */
|
|
329
|
+
export interface BrowsingContextEvents {
|
|
330
|
+
"browsingContext.contextCreated": { params: Info };
|
|
331
|
+
"browsingContext.contextDestroyed": { params: Info };
|
|
332
|
+
"browsingContext.domContentLoaded": { params: NavigationInfo };
|
|
333
|
+
"browsingContext.downloadEnd": { params: DownloadEndParams };
|
|
334
|
+
"browsingContext.downloadWillBegin": { params: DownloadWillBeginParams };
|
|
335
|
+
"browsingContext.fragmentNavigated": { params: NavigationInfo };
|
|
336
|
+
"browsingContext.historyUpdated": { params: HistoryUpdatedParameters };
|
|
337
|
+
"browsingContext.load": { params: NavigationInfo };
|
|
338
|
+
"browsingContext.navigationAborted": { params: NavigationInfo };
|
|
339
|
+
"browsingContext.navigationCommitted": { params: NavigationInfo };
|
|
340
|
+
"browsingContext.navigationFailed": { params: NavigationInfo };
|
|
341
|
+
"browsingContext.navigationStarted": { params: NavigationInfo };
|
|
342
|
+
"browsingContext.userPromptClosed": { params: UserPromptClosedParameters };
|
|
343
|
+
"browsingContext.userPromptOpened": { params: UserPromptOpenedParameters };
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Union of all events emitted by the browsingContext module. */
|
|
347
|
+
export type BrowsingContextEvent =
|
|
348
|
+
| ContextCreated
|
|
349
|
+
| ContextDestroyed
|
|
350
|
+
| DomContentLoaded
|
|
351
|
+
| DownloadEnd
|
|
352
|
+
| DownloadWillBegin
|
|
353
|
+
| FragmentNavigated
|
|
354
|
+
| HistoryUpdated
|
|
355
|
+
| Load
|
|
356
|
+
| NavigationAborted
|
|
357
|
+
| NavigationCommitted
|
|
358
|
+
| NavigationFailed
|
|
359
|
+
| NavigationStarted
|
|
360
|
+
| UserPromptClosed
|
|
361
|
+
| UserPromptOpened;
|
|
362
|
+
|
|
363
|
+
/** Union of all possible result types returned by browsingContext module commands. */
|
|
364
|
+
export type BrowsingContextResult =
|
|
365
|
+
| ActivateResult
|
|
366
|
+
| CaptureScreenshotResult
|
|
367
|
+
| CloseResult
|
|
368
|
+
| CreateResult
|
|
369
|
+
| GetTreeResult
|
|
370
|
+
| HandleUserPromptResult
|
|
371
|
+
| LocateNodesResult
|
|
372
|
+
| NavigateResult
|
|
373
|
+
| PrintResult
|
|
374
|
+
| ReloadResult
|
|
375
|
+
| SetBypassCSPResult
|
|
376
|
+
| SetViewportResult
|
|
377
|
+
| TraverseHistoryResult;
|
|
378
|
+
|
|
379
|
+
/** Result of `browsingContext.activate`. */
|
|
380
|
+
export type ActivateResult = EmptyResult;
|
|
381
|
+
|
|
382
|
+
/** Result of `browsingContext.captureScreenshot`, containing base64-encoded image data. */
|
|
383
|
+
export interface CaptureScreenshotResult {
|
|
384
|
+
data: string;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Result of `browsingContext.close`. */
|
|
388
|
+
export type CloseResult = EmptyResult;
|
|
389
|
+
|
|
390
|
+
/** Result of `browsingContext.create`. */
|
|
391
|
+
export interface CreateResult {
|
|
392
|
+
context: BrowsingContext;
|
|
393
|
+
userContext?: UserContext;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** Result of `browsingContext.getTree`. */
|
|
397
|
+
export interface GetTreeResult {
|
|
398
|
+
contexts: InfoList;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** Result of `browsingContext.handleUserPrompt`. */
|
|
402
|
+
export type HandleUserPromptResult = EmptyResult;
|
|
403
|
+
|
|
404
|
+
/** Result of `browsingContext.locateNodes`. */
|
|
405
|
+
export interface LocateNodesResult {
|
|
406
|
+
nodes: NodeRemoteValue[];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Result of `browsingContext.navigate` and `browsingContext.reload`. */
|
|
410
|
+
export interface NavigateResult {
|
|
411
|
+
navigation: Navigation;
|
|
412
|
+
url: string;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/** Result of `browsingContext.print`, containing base64-encoded PDF data. */
|
|
416
|
+
export interface PrintResult {
|
|
417
|
+
data: string;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** Result of `browsingContext.reload`. */
|
|
421
|
+
export type ReloadResult = NavigateResult;
|
|
422
|
+
|
|
423
|
+
/** Result of `browsingContext.setBypassCSP`. */
|
|
424
|
+
export type SetBypassCSPResult = EmptyResult;
|
|
425
|
+
|
|
426
|
+
/** Result of `browsingContext.setViewport`. */
|
|
427
|
+
export type SetViewportResult = EmptyResult;
|
|
428
|
+
|
|
429
|
+
/** Result of `browsingContext.traverseHistory`. */
|
|
430
|
+
export type TraverseHistoryResult = EmptyResult;
|