browser-debugger-cli 0.8.0 → 0.9.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/README.md +4 -1
- package/dist/cdp/schema.d.ts +4 -1
- package/dist/cdp/schema.js +48 -7
- package/dist/commands/cdp.js +3 -2
- package/dist/commands/cleanup.d.ts +11 -0
- package/dist/commands/cleanup.js +161 -57
- package/dist/commands/console.d.ts +20 -1
- package/dist/commands/console.js +57 -17
- package/dist/commands/details.js +3 -2
- package/dist/commands/dom/DomElementResolver.d.ts +10 -3
- package/dist/commands/dom/DomElementResolver.js +35 -17
- package/dist/commands/dom/a11y.d.ts +10 -0
- package/dist/commands/dom/a11y.js +27 -5
- package/dist/commands/dom/eval.d.ts +3 -1
- package/dist/commands/dom/eval.js +29 -4
- package/dist/commands/dom/form.js +16 -62
- package/dist/commands/dom/formInteraction.js +152 -113
- package/dist/commands/dom/formSummary.d.ts +49 -0
- package/dist/commands/dom/formSummary.js +180 -0
- package/dist/commands/dom/frames.d.ts +2 -1
- package/dist/commands/dom/frames.js +17 -2
- package/dist/commands/dom/get.d.ts +6 -5
- package/dist/commands/dom/get.js +92 -82
- package/dist/commands/dom/helpers/index.d.ts +1 -1
- package/dist/commands/dom/helpers/index.js +1 -1
- package/dist/commands/dom/helpers/query.d.ts +44 -17
- package/dist/commands/dom/helpers/query.js +244 -97
- package/dist/commands/dom/helpers/runElementCommand.d.ts +10 -2
- package/dist/commands/dom/helpers/runElementCommand.js +97 -30
- package/dist/commands/dom/helpers/screenshot.d.ts +4 -1
- package/dist/commands/dom/helpers/screenshot.js +164 -49
- package/dist/commands/dom/index.d.ts +3 -1
- package/dist/commands/dom/index.js +16 -6
- package/dist/commands/dom/layout.d.ts +14 -0
- package/dist/commands/dom/layout.js +54 -0
- package/dist/commands/dom/listeners.d.ts +5 -1
- package/dist/commands/dom/listeners.js +13 -3
- package/dist/commands/dom/query.js +2 -3
- package/dist/commands/dom/screenshot.d.ts +12 -2
- package/dist/commands/dom/screenshot.js +27 -3
- package/dist/commands/dom/semanticUtils.d.ts +6 -13
- package/dist/commands/dom/semanticUtils.js +15 -19
- package/dist/commands/dom/wait.d.ts +13 -0
- package/dist/commands/dom/wait.js +83 -0
- package/dist/commands/helpJson.js +2 -2
- package/dist/commands/network/list.js +4 -11
- package/dist/commands/optionBehaviors.js +112 -21
- package/dist/commands/page.d.ts +2 -1
- package/dist/commands/page.js +41 -5
- package/dist/commands/peek.js +4 -11
- package/dist/commands/sessions.d.ts +8 -0
- package/dist/commands/sessions.js +19 -0
- package/dist/commands/shared/CommandRunner.js +4 -4
- package/dist/commands/shared/dataFetcher.js +2 -2
- package/dist/commands/shared/followMode.d.ts +21 -1
- package/dist/commands/shared/followMode.js +29 -2
- package/dist/commands/shared/handleValidationError.d.ts +2 -2
- package/dist/commands/shared/handleValidationError.js +12 -3
- package/dist/commands/shared/optionTypes.d.ts +40 -5
- package/dist/commands/shared/startHelpers.js +12 -3
- package/dist/commands/shared/validation.d.ts +3 -2
- package/dist/commands/shared/validation.js +4 -3
- package/dist/commands/start.d.ts +63 -0
- package/dist/commands/start.js +115 -15
- package/dist/commands/status.js +29 -7
- package/dist/commands/stop.js +7 -6
- package/dist/commands/tail.js +4 -11
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands.js +2 -0
- package/dist/connection/chromeIdentity.d.ts +65 -0
- package/dist/connection/chromeIdentity.js +143 -0
- package/dist/connection/launcher/profilePreferences.d.ts +47 -0
- package/dist/connection/launcher/profilePreferences.js +151 -0
- package/dist/connection/launcher.d.ts +21 -2
- package/dist/connection/launcher.js +42 -16
- package/dist/connection/portReservation.d.ts +14 -4
- package/dist/connection/portReservation.js +21 -6
- package/dist/connection/startupExit.d.ts +8 -0
- package/dist/connection/startupExit.js +15 -6
- package/dist/constants.d.ts +6 -2
- package/dist/constants.js +9 -2
- package/dist/daemon/SessionController.js +23 -7
- package/dist/daemon/errors.d.ts +1 -1
- package/dist/daemon/errors.js +1 -1
- package/dist/daemon/launcher.d.ts +2 -1
- package/dist/daemon/launcher.js +5 -6
- package/dist/daemon/server/SocketServer.js +1 -2
- package/dist/daemon/session/Session.d.ts +13 -0
- package/dist/daemon/session/Session.js +57 -8
- package/dist/daemon/session/chromeConnection.d.ts +9 -0
- package/dist/daemon/session/chromeConnection.js +45 -8
- package/dist/daemon/session/commandRegistry.js +52 -62
- package/dist/daemon/session/interactions.d.ts +35 -9
- package/dist/daemon/session/interactions.js +36 -9
- package/dist/daemon/session/triggeredRequests.d.ts +67 -0
- package/dist/daemon/session/triggeredRequests.js +157 -0
- package/dist/daemon/session/types.d.ts +5 -1
- package/dist/daemon.js +5393 -1600
- package/dist/errors/messages.d.ts +387 -24
- package/dist/errors/messages.js +761 -67
- package/dist/index.js +3976 -1558
- package/dist/ipc/client.d.ts +12 -1
- package/dist/ipc/client.js +22 -3
- package/dist/ipc/protocol/commands.d.ts +89 -4
- package/dist/ipc/protocol/commands.js +2 -0
- package/dist/ipc/protocol/domTypes.d.ts +258 -7
- package/dist/ipc/session/lifecycle.d.ts +8 -1
- package/dist/ipc/session/queries.d.ts +5 -1
- package/dist/ipc/session/types.d.ts +5 -0
- package/dist/ipc/transport/index.d.ts +2 -1
- package/dist/ipc/transport/index.js +2 -2
- package/dist/runtime/dom/actionEffects.d.ts +106 -0
- package/dist/runtime/dom/actionEffects.js +256 -0
- package/dist/runtime/dom/actionEffectsScripts.d.ts +52 -0
- package/dist/runtime/dom/actionEffectsScripts.js +234 -0
- package/dist/runtime/dom/elementGeometry.d.ts +170 -0
- package/dist/runtime/dom/elementGeometry.js +553 -0
- package/dist/runtime/dom/elementInfo.d.ts +77 -0
- package/dist/runtime/dom/elementInfo.js +191 -0
- package/dist/runtime/dom/evalHelpers.d.ts +51 -6
- package/dist/runtime/dom/evalHelpers.js +136 -26
- package/dist/runtime/dom/eventListeners.d.ts +2 -1
- package/dist/runtime/dom/eventListeners.js +174 -47
- package/dist/runtime/dom/formDiscovery.d.ts +1 -1
- package/dist/runtime/dom/formDiscovery.js +116 -16
- package/dist/runtime/dom/formFillHelpers/fill.d.ts +10 -0
- package/dist/runtime/dom/formFillHelpers/fill.js +125 -10
- package/dist/runtime/dom/formFillHelpers/index.d.ts +2 -2
- package/dist/runtime/dom/formFillHelpers/index.js +2 -2
- package/dist/runtime/dom/formFillHelpers/pressKey.js +14 -3
- package/dist/runtime/dom/formFillHelpers/scroll.d.ts +3 -0
- package/dist/runtime/dom/formFillHelpers/scroll.js +60 -18
- package/dist/runtime/dom/formFillHelpers/shared.d.ts +17 -0
- package/dist/runtime/dom/formFillHelpers/shared.js +25 -1
- package/dist/runtime/dom/formFillHelpers/stability.d.ts +20 -6
- package/dist/runtime/dom/formFillHelpers/stability.js +50 -19
- package/dist/runtime/dom/formSubmitHelpers.d.ts +3 -0
- package/dist/runtime/dom/formSubmitHelpers.js +89 -15
- package/dist/runtime/dom/frameLayout.d.ts +60 -0
- package/dist/runtime/dom/frameLayout.js +140 -0
- package/dist/runtime/dom/frameOrigin.d.ts +50 -0
- package/dist/runtime/dom/frameOrigin.js +62 -0
- package/dist/runtime/dom/frameScopedConnection.d.ts +92 -0
- package/dist/runtime/dom/frameScopedConnection.js +252 -0
- package/dist/runtime/dom/frameSelection.d.ts +1 -1
- package/dist/runtime/dom/frameSelection.js +2 -2
- package/dist/runtime/dom/frames.d.ts +25 -2
- package/dist/runtime/dom/frames.js +202 -63
- package/dist/runtime/dom/layout.d.ts +67 -0
- package/dist/runtime/dom/layout.js +333 -0
- package/dist/runtime/dom/listenerPageScripts.d.ts +66 -0
- package/dist/runtime/dom/listenerPageScripts.js +279 -0
- package/dist/runtime/dom/listenerSummary.d.ts +132 -11
- package/dist/runtime/dom/listenerSummary.js +344 -22
- package/dist/runtime/dom/pageActivity.d.ts +41 -0
- package/dist/runtime/dom/pageActivity.js +123 -0
- package/dist/runtime/dom/reactEventHelpers.d.ts +58 -2
- package/dist/runtime/dom/reactEventHelpers.js +212 -41
- package/dist/runtime/dom/targetNode.d.ts +80 -27
- package/dist/runtime/dom/targetNode.js +249 -33
- package/dist/runtime/dom/wait.d.ts +25 -0
- package/dist/runtime/dom/wait.js +199 -0
- package/dist/runtime/dom/waitCondition.d.ts +71 -0
- package/dist/runtime/dom/waitCondition.js +75 -0
- package/dist/runtime/page/emulation.d.ts +51 -0
- package/dist/runtime/page/emulation.js +80 -0
- package/dist/runtime/page/loadingState.d.ts +36 -0
- package/dist/runtime/page/loadingState.js +86 -0
- package/dist/runtime/page/navigation.d.ts +46 -2
- package/dist/runtime/page/navigation.js +69 -33
- package/dist/session/QueryCacheManager.d.ts +11 -1
- package/dist/session/QueryCacheManager.js +25 -3
- package/dist/session/chromeOwners.d.ts +34 -0
- package/dist/session/chromeOwners.js +51 -0
- package/dist/session/cleanup/staleSession.d.ts +11 -1
- package/dist/session/cleanup/staleSession.js +17 -6
- package/dist/session/cleanup/userCommands.js +2 -4
- package/dist/session/metadata.d.ts +5 -1
- package/dist/session/metadata.js +2 -1
- package/dist/session/paths.d.ts +77 -3
- package/dist/session/paths.js +111 -5
- package/dist/session/port.d.ts +31 -7
- package/dist/session/port.js +50 -43
- package/dist/session/portClaims.d.ts +66 -0
- package/dist/session/portClaims.js +284 -0
- package/dist/session/sessionList.d.ts +58 -0
- package/dist/session/sessionList.js +199 -0
- package/dist/session/sessionName.d.ts +46 -0
- package/dist/session/sessionName.js +97 -0
- package/dist/telemetry/a11y.d.ts +8 -3
- package/dist/telemetry/a11y.js +92 -28
- package/dist/telemetry/requestKinds.d.ts +32 -0
- package/dist/telemetry/requestKinds.js +61 -0
- package/dist/telemetry/requestState.d.ts +31 -0
- package/dist/telemetry/requestState.js +38 -0
- package/dist/types.d.ts +80 -3
- package/dist/ui/formatters/a11y.js +3 -0
- package/dist/ui/formatters/console/chronological.d.ts +8 -0
- package/dist/ui/formatters/console/chronological.js +17 -4
- package/dist/ui/formatters/console/json.js +3 -4
- package/dist/ui/formatters/console/shared.d.ts +12 -0
- package/dist/ui/formatters/console.d.ts +2 -2
- package/dist/ui/formatters/console.js +1 -1
- package/dist/ui/formatters/details.js +2 -1
- package/dist/ui/formatters/dom.d.ts +26 -14
- package/dist/ui/formatters/dom.js +65 -52
- package/dist/ui/formatters/form.js +29 -18
- package/dist/ui/formatters/layout.d.ts +31 -0
- package/dist/ui/formatters/layout.js +53 -0
- package/dist/ui/formatters/listeners.d.ts +3 -2
- package/dist/ui/formatters/listeners.js +73 -9
- package/dist/ui/formatters/networkHeaders.js +13 -0
- package/dist/ui/formatters/preview.js +2 -1
- package/dist/ui/formatters/requestStatus.d.ts +1 -17
- package/dist/ui/formatters/requestStatus.js +2 -30
- package/dist/ui/formatters/sessions.d.ts +12 -0
- package/dist/ui/formatters/sessions.js +40 -0
- package/dist/ui/formatters/status.d.ts +21 -2
- package/dist/ui/formatters/status.js +47 -10
- package/dist/ui/formatters/triggeredRequests.d.ts +36 -0
- package/dist/ui/formatters/triggeredRequests.js +65 -0
- package/dist/ui/formatting.d.ts +10 -0
- package/dist/ui/formatting.js +28 -36
- package/dist/ui/messages/chrome.d.ts +9 -0
- package/dist/ui/messages/chrome.js +17 -5
- package/dist/ui/messages/commands.d.ts +388 -14
- package/dist/ui/messages/commands.js +664 -21
- package/dist/ui/messages/consoleMessages.d.ts +10 -0
- package/dist/ui/messages/consoleMessages.js +17 -0
- package/dist/ui/messages/hints.js +2 -1
- package/dist/ui/messages/preview.js +5 -4
- package/dist/ui/messages/session.d.ts +16 -21
- package/dist/ui/messages/session.js +28 -26
- package/dist/ui/messages/sessionCommand.d.ts +43 -0
- package/dist/ui/messages/sessionCommand.js +52 -0
- package/dist/utils/async.d.ts +8 -0
- package/dist/utils/async.js +19 -0
- package/dist/utils/http.d.ts +22 -1
- package/dist/utils/http.js +28 -9
- package/dist/utils/selectorFilters.d.ts +36 -8
- package/dist/utils/selectorFilters.js +267 -53
- package/dist/utils/shellDetection.d.ts +8 -2
- package/dist/utils/shellDetection.js +120 -33
- package/dist/utils/suggestions.d.ts +26 -0
- package/dist/utils/suggestions.js +73 -0
- package/dist/utils/taskMappings.js +10 -0
- package/dist/utils/url.d.ts +12 -2
- package/dist/utils/url.js +69 -7
- package/package.json +1 -1
- package/dist/ui/formatters/sessionFormatters.d.ts +0 -58
- package/dist/ui/formatters/sessionFormatters.js +0 -121
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { CDPTimeoutError } from '../../connection/errors.js';
|
|
5
5
|
import { trackInFlightRequests } from '../../connection/inFlightRequests.js';
|
|
6
|
-
import { submitTimeoutError } from '../../errors/messages.js';
|
|
6
|
+
import { submitNetworkBusyWarning, submitTimeoutError } from '../../errors/messages.js';
|
|
7
|
+
import { ELEMENT_IDENTITY_JS } from './elementInfo.js';
|
|
7
8
|
import { throwIfInvalidSelector } from './formFillHelpers/shared.js';
|
|
8
9
|
import { FIND_ELEMENTS_JS, selectorArgsJS } from './targetNode.js';
|
|
10
|
+
import { summarizePendingRequests } from '../page/loadingState.js';
|
|
9
11
|
import { EXIT_CODES } from '../../utils/exitCodes.js';
|
|
10
12
|
import { clickElement } from './formFillHelpers/index.js';
|
|
11
13
|
/**
|
|
@@ -61,9 +63,10 @@ const PREPARE_SUBMIT_SCRIPT = `
|
|
|
61
63
|
// Like pressing Enter: the form's default button is the submitter, so its
|
|
62
64
|
// name=value is sent too
|
|
63
65
|
const submitter = submitters.find((f) => !f.matches(':disabled'));
|
|
66
|
+
const element = (${ELEMENT_IDENTITY_JS})(submitter || el);
|
|
64
67
|
if (submitter) el.requestSubmit(submitter);
|
|
65
68
|
else el.requestSubmit();
|
|
66
|
-
return { action: 'submitted', clicked: Boolean(submitter) };
|
|
69
|
+
return { action: 'submitted', clicked: Boolean(submitter), element: element };
|
|
67
70
|
}
|
|
68
71
|
return { action: 'click' };
|
|
69
72
|
})`;
|
|
@@ -84,9 +87,14 @@ const FAILURE_SUGGESTIONS = {
|
|
|
84
87
|
/**
|
|
85
88
|
* Watches navigation and network activity from before a submission is
|
|
86
89
|
* triggered, so fast navigations are not missed.
|
|
90
|
+
*
|
|
91
|
+
* A navigation is a new document committed in the main frame
|
|
92
|
+
* (`Page.frameNavigated`), whatever its URL: a POST that redirects back to
|
|
93
|
+
* the form's own URL (a login error) navigates too.
|
|
87
94
|
*/
|
|
88
95
|
class SubmissionWatcher {
|
|
89
96
|
navigated = false;
|
|
97
|
+
documentRequest;
|
|
90
98
|
onChange = null;
|
|
91
99
|
requests;
|
|
92
100
|
disposers = [];
|
|
@@ -96,27 +104,66 @@ class SubmissionWatcher {
|
|
|
96
104
|
constructor(cdp) {
|
|
97
105
|
this.requests = trackInFlightRequests(cdp, () => this.onChange?.());
|
|
98
106
|
this.disposers.push(this.requests.dispose);
|
|
99
|
-
this.disposers.push(cdp.on('Page.frameNavigated', (params) => {
|
|
100
|
-
if (params.frame.parentId !== undefined)
|
|
107
|
+
this.disposers.push(cdp.on('Page.frameNavigated', (params, sessionId) => {
|
|
108
|
+
if (sessionId !== undefined || params.frame.parentId !== undefined)
|
|
101
109
|
return;
|
|
102
110
|
this.navigated = true;
|
|
103
111
|
this.onChange?.();
|
|
112
|
+
}), cdp.on('Network.requestWillBeSent', (params, sessionId) => {
|
|
113
|
+
if (sessionId !== undefined || params.type !== 'Document')
|
|
114
|
+
return;
|
|
115
|
+
this.documentRequest ??= {
|
|
116
|
+
requestId: params.requestId,
|
|
117
|
+
method: params.request.method,
|
|
118
|
+
url: params.request.url,
|
|
119
|
+
startedAt: Date.now(),
|
|
120
|
+
};
|
|
121
|
+
}), cdp.on('Network.responseReceived', (params) => {
|
|
122
|
+
if (params.requestId !== this.documentRequest?.requestId)
|
|
123
|
+
return;
|
|
124
|
+
this.documentRequest.status = params.response.status;
|
|
125
|
+
this.documentRequest.statusText = params.response.statusText;
|
|
126
|
+
}), cdp.on('Network.loadingFailed', (params) => {
|
|
127
|
+
if (params.requestId !== this.documentRequest?.requestId)
|
|
128
|
+
return;
|
|
129
|
+
this.documentRequest.errorText = params.errorText;
|
|
104
130
|
}));
|
|
105
131
|
}
|
|
106
132
|
/** Whether the main frame navigated since watching began. */
|
|
107
133
|
get navigationOccurred() {
|
|
108
134
|
return this.navigated;
|
|
109
135
|
}
|
|
136
|
+
/** How far the first page request sent since watching began got, if one was sent */
|
|
137
|
+
get firstDocumentRequest() {
|
|
138
|
+
const request = this.documentRequest;
|
|
139
|
+
if (!request)
|
|
140
|
+
return undefined;
|
|
141
|
+
const answered = request.status !== undefined || request.errorText !== undefined;
|
|
142
|
+
return {
|
|
143
|
+
method: request.method,
|
|
144
|
+
url: request.url,
|
|
145
|
+
...(!answered && { pendingMs: Date.now() - request.startedAt }),
|
|
146
|
+
...(request.status !== undefined && { status: request.status }),
|
|
147
|
+
...(request.statusText && { statusText: request.statusText }),
|
|
148
|
+
...(request.errorText !== undefined && { errorText: request.errorText }),
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** Requests still in flight */
|
|
152
|
+
get pendingRequests() {
|
|
153
|
+
return this.requests.count;
|
|
154
|
+
}
|
|
110
155
|
/** Requests started since watching began. */
|
|
111
156
|
get networkRequests() {
|
|
112
157
|
return this.requests.started;
|
|
113
158
|
}
|
|
114
159
|
/**
|
|
115
160
|
* Wait until the network is idle for `waitNetwork` ms and, if requested,
|
|
116
|
-
* the main frame navigated.
|
|
161
|
+
* the main frame navigated. When a requested navigation happened but the
|
|
162
|
+
* network was still busy at the timeout (a slow script or tracker on the
|
|
163
|
+
* new page), the wait ends without an error: resolves to `'busy'`.
|
|
117
164
|
*
|
|
118
165
|
* @param options - Wait conditions
|
|
119
|
-
* @returns
|
|
166
|
+
* @returns `'idle'`, or `'busy'` when only the network wait timed out
|
|
120
167
|
* @throws CDPTimeoutError after `timeout` ms
|
|
121
168
|
*/
|
|
122
169
|
wait(options) {
|
|
@@ -131,13 +178,16 @@ class SubmissionWatcher {
|
|
|
131
178
|
};
|
|
132
179
|
const deadline = setTimeout(() => {
|
|
133
180
|
finish();
|
|
134
|
-
|
|
181
|
+
if (waitNavigation && this.navigated)
|
|
182
|
+
resolve('busy');
|
|
183
|
+
else
|
|
184
|
+
reject(new CDPTimeoutError('Wait for completion timed out', new Error(`${timeout}ms`)));
|
|
135
185
|
}, timeout);
|
|
136
186
|
const check = () => {
|
|
137
187
|
const networkIdle = waitNetwork === 0 || this.requests.count === 0;
|
|
138
188
|
if (networkIdle && (!waitNavigation || this.navigated)) {
|
|
139
189
|
finish();
|
|
140
|
-
resolve();
|
|
190
|
+
resolve('idle');
|
|
141
191
|
}
|
|
142
192
|
};
|
|
143
193
|
const schedule = () => {
|
|
@@ -184,14 +234,16 @@ async function triggerSubmit(cdp, selector, index) {
|
|
|
184
234
|
clicked: false,
|
|
185
235
|
exitCode: FAILURE_EXIT_CODES[reason],
|
|
186
236
|
suggestion: FAILURE_SUGGESTIONS[reason],
|
|
237
|
+
...(reason === 'not-submittable' && { unsuitableElement: true }),
|
|
187
238
|
};
|
|
188
239
|
return { failure };
|
|
189
240
|
}
|
|
190
|
-
if (prepared.action === 'submitted')
|
|
191
|
-
return { clicked: prepared.clicked === true };
|
|
241
|
+
if (prepared.action === 'submitted') {
|
|
242
|
+
return { clicked: prepared.clicked === true, element: prepared.element };
|
|
243
|
+
}
|
|
192
244
|
const click = await clickElement(cdp, selector, index !== undefined ? { index } : {});
|
|
193
245
|
if (click.success)
|
|
194
|
-
return { clicked: true };
|
|
246
|
+
return { clicked: true, element: click.element };
|
|
195
247
|
const failure = {
|
|
196
248
|
success: false,
|
|
197
249
|
error: click.error ?? 'Click failed',
|
|
@@ -202,6 +254,21 @@ async function triggerSubmit(cdp, selector, index) {
|
|
|
202
254
|
};
|
|
203
255
|
return { failure };
|
|
204
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* The requests still running in the session, the longest-running first.
|
|
259
|
+
*
|
|
260
|
+
* @param pendingRequests - Source of the session's pending requests
|
|
261
|
+
* @returns The ones to name and the count, none without a source
|
|
262
|
+
*/
|
|
263
|
+
function pendingSummary(pendingRequests) {
|
|
264
|
+
if (!pendingRequests)
|
|
265
|
+
return {};
|
|
266
|
+
const requests = [...pendingRequests()];
|
|
267
|
+
return {
|
|
268
|
+
pending: summarizePendingRequests(requests, Date.now()),
|
|
269
|
+
pendingCount: requests.length,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
205
272
|
/**
|
|
206
273
|
* Submit a form and wait for the result.
|
|
207
274
|
*
|
|
@@ -218,22 +285,29 @@ export async function submitForm(cdp, selector, options = {}) {
|
|
|
218
285
|
const triggered = await triggerSubmit(cdp, selector, index);
|
|
219
286
|
if ('failure' in triggered)
|
|
220
287
|
return triggered.failure;
|
|
221
|
-
|
|
222
|
-
await watcher.wait({ waitNavigation, waitNetwork, timeout })
|
|
223
|
-
|
|
288
|
+
const outcome = waitNetwork > 0 || waitNavigation
|
|
289
|
+
? await watcher.wait({ waitNavigation, waitNetwork, timeout })
|
|
290
|
+
: 'idle';
|
|
224
291
|
return {
|
|
225
292
|
success: true,
|
|
226
293
|
selector,
|
|
294
|
+
...(triggered.element !== undefined && { element: triggered.element }),
|
|
227
295
|
clicked: triggered.clicked,
|
|
228
296
|
networkRequests: watcher.networkRequests,
|
|
229
297
|
navigationOccurred: watcher.navigationOccurred,
|
|
230
298
|
waitTimeMs: Date.now() - startTime,
|
|
299
|
+
...(outcome === 'busy' && {
|
|
300
|
+
warning: submitNetworkBusyWarning(timeout, watcher.pendingRequests),
|
|
301
|
+
}),
|
|
231
302
|
};
|
|
232
303
|
}
|
|
233
304
|
catch (error) {
|
|
234
305
|
if (!(error instanceof CDPTimeoutError))
|
|
235
306
|
throw error;
|
|
236
|
-
const err = submitTimeoutError(timeout, waitNavigation
|
|
307
|
+
const err = submitTimeoutError(timeout, waitNavigation, {
|
|
308
|
+
document: watcher.firstDocumentRequest,
|
|
309
|
+
...pendingSummary(options.pendingRequests),
|
|
310
|
+
});
|
|
237
311
|
return {
|
|
238
312
|
success: false,
|
|
239
313
|
error: err.message,
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout of an element inside a cross-origin iframe that shares the page's
|
|
3
|
+
* process (an a11y query can return those).
|
|
4
|
+
*
|
|
5
|
+
* The element is measured in its own frame, whose scripts cannot see the top
|
|
6
|
+
* page, so its measurements are relative to the frame's viewport. The
|
|
7
|
+
* iframe element holding the frame is measured in its own document, and the
|
|
8
|
+
* element is placed in the top-level viewport through it: mapped by the
|
|
9
|
+
* frame's position and scale, clipped to the frame's viewport and to what clips the
|
|
10
|
+
* iframe, and fixed, scrolled or hidden as the iframe is.
|
|
11
|
+
*/
|
|
12
|
+
import type { CDPConnection } from '../../connection/cdp.js';
|
|
13
|
+
import type { Protocol } from '../../connection/typed-cdp.js';
|
|
14
|
+
import type { LayoutBox } from '../../ipc/protocol/domTypes.js';
|
|
15
|
+
import { type FrameMapping } from './frameScopedConnection.js';
|
|
16
|
+
import type { RawLayout } from './layout.js';
|
|
17
|
+
/**
|
|
18
|
+
* Ids of all frames below a frame tree's root.
|
|
19
|
+
*
|
|
20
|
+
* @param tree - Frame tree
|
|
21
|
+
* @returns Frame ids, depth-first
|
|
22
|
+
*/
|
|
23
|
+
export declare function childFrameIds(tree: Protocol.Page.FrameTree | undefined): string[];
|
|
24
|
+
/**
|
|
25
|
+
* The iframe element whose document holds an element.
|
|
26
|
+
*
|
|
27
|
+
* @param cdp - CDP connection
|
|
28
|
+
* @param objectId - Remote object of the element
|
|
29
|
+
* @returns Backend node id of the iframe element, undefined when not found
|
|
30
|
+
*/
|
|
31
|
+
export declare function findFrameOwner(cdp: CDPConnection, objectId: string): Promise<number | undefined>;
|
|
32
|
+
/**
|
|
33
|
+
* Overlap of boxes.
|
|
34
|
+
*
|
|
35
|
+
* @param boxes - Boxes (null ones are left out)
|
|
36
|
+
* @returns Overlap (zero size when they do not overlap)
|
|
37
|
+
*/
|
|
38
|
+
export declare function intersection(...boxes: Array<LayoutBox | null>): LayoutBox;
|
|
39
|
+
/**
|
|
40
|
+
* Whether a box lies inside another.
|
|
41
|
+
*
|
|
42
|
+
* @param inner - Inner box
|
|
43
|
+
* @param outer - Outer box
|
|
44
|
+
* @returns True when it does
|
|
45
|
+
*/
|
|
46
|
+
export declare function inside(inner: LayoutBox, outer: LayoutBox): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Place an element measured inside a cross-origin frame in the top-level
|
|
49
|
+
* viewport, through the measurements of the frame's iframe element: mapped by
|
|
50
|
+
* the frame's position and scale (border, padding, `transform`, `zoom`),
|
|
51
|
+
* clipped to the frame's viewport and to what clips the iframe.
|
|
52
|
+
*
|
|
53
|
+
* @param raw - The element, measured in its frame
|
|
54
|
+
* @param owner - The iframe element, measured in its document
|
|
55
|
+
* @param mapping - How the frame's viewport maps into the top-level viewport
|
|
56
|
+
* @returns The element's layout in the top-level page (unchanged when the
|
|
57
|
+
* iframe could not be measured)
|
|
58
|
+
*/
|
|
59
|
+
export declare function placeInOwnerFrame(raw: RawLayout, owner: RawLayout, mapping: FrameMapping): RawLayout;
|
|
60
|
+
//# sourceMappingURL=frameLayout.d.ts.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout of an element inside a cross-origin iframe that shares the page's
|
|
3
|
+
* process (an a11y query can return those).
|
|
4
|
+
*
|
|
5
|
+
* The element is measured in its own frame, whose scripts cannot see the top
|
|
6
|
+
* page, so its measurements are relative to the frame's viewport. The
|
|
7
|
+
* iframe element holding the frame is measured in its own document, and the
|
|
8
|
+
* element is placed in the top-level viewport through it: mapped by the
|
|
9
|
+
* frame's position and scale, clipped to the frame's viewport and to what clips the
|
|
10
|
+
* iframe, and fixed, scrolled or hidden as the iframe is.
|
|
11
|
+
*/
|
|
12
|
+
import { mapBox } from './frameScopedConnection.js';
|
|
13
|
+
import { createLogger } from '../../ui/logging/index.js';
|
|
14
|
+
import { getErrorMessage } from '../../utils/errors.js';
|
|
15
|
+
const log = createLogger('dom');
|
|
16
|
+
/**
|
|
17
|
+
* Ids of all frames below a frame tree's root.
|
|
18
|
+
*
|
|
19
|
+
* @param tree - Frame tree
|
|
20
|
+
* @returns Frame ids, depth-first
|
|
21
|
+
*/
|
|
22
|
+
export function childFrameIds(tree) {
|
|
23
|
+
return (tree?.childFrames ?? []).flatMap((child) => [child.frame.id, ...childFrameIds(child)]);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Backend node id of the document holding an element.
|
|
27
|
+
*
|
|
28
|
+
* @param cdp - CDP connection
|
|
29
|
+
* @param objectId - Remote object of the element
|
|
30
|
+
* @returns The document's backend node id, if it could be read
|
|
31
|
+
*/
|
|
32
|
+
async function ownerDocumentId(cdp, objectId) {
|
|
33
|
+
const doc = (await cdp.send('Runtime.callFunctionOn', {
|
|
34
|
+
objectId,
|
|
35
|
+
functionDeclaration: 'function () { return this.ownerDocument; }',
|
|
36
|
+
}));
|
|
37
|
+
if (!doc.result.objectId)
|
|
38
|
+
return undefined;
|
|
39
|
+
const { node } = (await cdp.send('DOM.describeNode', {
|
|
40
|
+
objectId: doc.result.objectId,
|
|
41
|
+
}));
|
|
42
|
+
return node.backendNodeId;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The iframe element whose document holds an element.
|
|
46
|
+
*
|
|
47
|
+
* @param cdp - CDP connection
|
|
48
|
+
* @param objectId - Remote object of the element
|
|
49
|
+
* @returns Backend node id of the iframe element, undefined when not found
|
|
50
|
+
*/
|
|
51
|
+
export async function findFrameOwner(cdp, objectId) {
|
|
52
|
+
try {
|
|
53
|
+
const documentId = await ownerDocumentId(cdp, objectId);
|
|
54
|
+
const { frameTree } = (await cdp.send('Page.getFrameTree'));
|
|
55
|
+
for (const frameId of childFrameIds(frameTree)) {
|
|
56
|
+
const owner = (await cdp.send('DOM.getFrameOwner', {
|
|
57
|
+
frameId,
|
|
58
|
+
}));
|
|
59
|
+
const { node } = (await cdp.send('DOM.describeNode', {
|
|
60
|
+
backendNodeId: owner.backendNodeId,
|
|
61
|
+
}));
|
|
62
|
+
if (node.contentDocument?.backendNodeId === documentId)
|
|
63
|
+
return owner.backendNodeId;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
log.debug(`Frame owner not found: ${getErrorMessage(error)}`);
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Overlap of boxes.
|
|
73
|
+
*
|
|
74
|
+
* @param boxes - Boxes (null ones are left out)
|
|
75
|
+
* @returns Overlap (zero size when they do not overlap)
|
|
76
|
+
*/
|
|
77
|
+
export function intersection(...boxes) {
|
|
78
|
+
const present = boxes.filter((box) => box !== null);
|
|
79
|
+
const left = Math.max(...present.map((box) => box.x));
|
|
80
|
+
const top = Math.max(...present.map((box) => box.y));
|
|
81
|
+
const right = Math.min(...present.map((box) => box.x + box.width));
|
|
82
|
+
const bottom = Math.min(...present.map((box) => box.y + box.height));
|
|
83
|
+
return { x: left, y: top, width: Math.max(0, right - left), height: Math.max(0, bottom - top) };
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether a box lies inside another.
|
|
87
|
+
*
|
|
88
|
+
* @param inner - Inner box
|
|
89
|
+
* @param outer - Outer box
|
|
90
|
+
* @returns True when it does
|
|
91
|
+
*/
|
|
92
|
+
export function inside(inner, outer) {
|
|
93
|
+
return (inner.x >= outer.x &&
|
|
94
|
+
inner.y >= outer.y &&
|
|
95
|
+
inner.x + inner.width <= outer.x + outer.width &&
|
|
96
|
+
inner.y + inner.height <= outer.y + outer.height);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Place an element measured inside a cross-origin frame in the top-level
|
|
100
|
+
* viewport, through the measurements of the frame's iframe element: mapped by
|
|
101
|
+
* the frame's position and scale (border, padding, `transform`, `zoom`),
|
|
102
|
+
* clipped to the frame's viewport and to what clips the iframe.
|
|
103
|
+
*
|
|
104
|
+
* @param raw - The element, measured in its frame
|
|
105
|
+
* @param owner - The iframe element, measured in its document
|
|
106
|
+
* @param mapping - How the frame's viewport maps into the top-level viewport
|
|
107
|
+
* @returns The element's layout in the top-level page (unchanged when the
|
|
108
|
+
* iframe could not be measured)
|
|
109
|
+
*/
|
|
110
|
+
export function placeInOwnerFrame(raw, owner, mapping) {
|
|
111
|
+
const frame = owner.elements[0];
|
|
112
|
+
if (!raw.page || !owner.page || !frame)
|
|
113
|
+
return raw;
|
|
114
|
+
const frameView = mapBox(mapping, { x: 0, y: 0, ...raw.page.viewport });
|
|
115
|
+
const elements = raw.elements.map((element) => {
|
|
116
|
+
const inner = element.geometry;
|
|
117
|
+
const outer = frame.geometry;
|
|
118
|
+
const rect = mapBox(mapping, inner.rect);
|
|
119
|
+
const ownClip = inner.clip ? mapBox(mapping, inner.clip) : null;
|
|
120
|
+
return {
|
|
121
|
+
...element,
|
|
122
|
+
context: [frame.element, element.context].filter(Boolean).join(' > '),
|
|
123
|
+
geometry: {
|
|
124
|
+
...inner,
|
|
125
|
+
rect,
|
|
126
|
+
clip: intersection(ownClip, frameView, outer.clip),
|
|
127
|
+
clipper: inner.clipper ?? (inside(rect, frameView) ? outer.clipper : frame.element),
|
|
128
|
+
hidden: inner.hidden ?? (outer.hidden ? 'inside a hidden iframe' : null),
|
|
129
|
+
invisible: inner.invisible ?? outer.invisible,
|
|
130
|
+
fixed: outer.fixed,
|
|
131
|
+
sticky: outer.sticky ?? false,
|
|
132
|
+
pageScroll: outer.pageScroll,
|
|
133
|
+
scrollLock: outer.scrollLock ?? null,
|
|
134
|
+
offset: mapping.origin,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
return { ...raw, page: owner.page, elements, crossOriginFrame: false };
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=frameLayout.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The origin a frame's scripts really run with, for `bdg dom frames`.
|
|
3
|
+
*
|
|
4
|
+
* Chrome reports `securityOrigin: "://"` for frames without an origin of
|
|
5
|
+
* their own (srcdoc, about:blank, data:) and the URL's origin for sandboxed
|
|
6
|
+
* frames, so neither tells whether the parent can reach the frame's
|
|
7
|
+
* document. The frame's default execution context knows: it reports the
|
|
8
|
+
* inherited origin for srcdoc and about:blank, and `"://"` for opaque ones
|
|
9
|
+
* (data: URLs, sandboxes without `allow-same-origin`). A frame that has no
|
|
10
|
+
* context yet falls back to the rules below; a frame inside an opaque one
|
|
11
|
+
* counts as opaque too (sandbox flags are inherited).
|
|
12
|
+
*/
|
|
13
|
+
/** Origin of documents that share no origin with anything */
|
|
14
|
+
export declare const OPAQUE_ORIGIN = "null";
|
|
15
|
+
/** What is known about a frame's origin */
|
|
16
|
+
export interface FrameOriginFacts {
|
|
17
|
+
/** Frame URL */
|
|
18
|
+
url: string;
|
|
19
|
+
/** `Page.Frame.securityOrigin` */
|
|
20
|
+
securityOrigin: string;
|
|
21
|
+
/** Origin of the frame's default execution context, when it has one */
|
|
22
|
+
contextOrigin?: string | undefined;
|
|
23
|
+
/** Origin of the parent frame (already resolved) */
|
|
24
|
+
parentOrigin?: string | undefined;
|
|
25
|
+
/** `sandbox` attribute of the frame's element, when present */
|
|
26
|
+
sandbox?: string | undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether a `sandbox` attribute makes the frame's origin opaque.
|
|
30
|
+
*
|
|
31
|
+
* @param sandbox - Attribute value (undefined when the attribute is missing)
|
|
32
|
+
* @returns True unless the attribute is missing or allows same-origin
|
|
33
|
+
*/
|
|
34
|
+
export declare function isOpaqueSandbox(sandbox: string | undefined): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* The origin a frame's scripts run with.
|
|
37
|
+
*
|
|
38
|
+
* @param facts - What Chrome reports about the frame
|
|
39
|
+
* @returns e.g. `https://example.com`, or `"null"` for an opaque origin
|
|
40
|
+
*/
|
|
41
|
+
export declare function effectiveFrameOrigin(facts: FrameOriginFacts): string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the top page's scripts cannot reach a frame's document.
|
|
44
|
+
*
|
|
45
|
+
* @param origin - The frame's effective origin
|
|
46
|
+
* @param topOrigin - The page's effective origin
|
|
47
|
+
* @returns True for a different or opaque origin
|
|
48
|
+
*/
|
|
49
|
+
export declare function isCrossOrigin(origin: string, topOrigin: string): boolean;
|
|
50
|
+
//# sourceMappingURL=frameOrigin.d.ts.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The origin a frame's scripts really run with, for `bdg dom frames`.
|
|
3
|
+
*
|
|
4
|
+
* Chrome reports `securityOrigin: "://"` for frames without an origin of
|
|
5
|
+
* their own (srcdoc, about:blank, data:) and the URL's origin for sandboxed
|
|
6
|
+
* frames, so neither tells whether the parent can reach the frame's
|
|
7
|
+
* document. The frame's default execution context knows: it reports the
|
|
8
|
+
* inherited origin for srcdoc and about:blank, and `"://"` for opaque ones
|
|
9
|
+
* (data: URLs, sandboxes without `allow-same-origin`). A frame that has no
|
|
10
|
+
* context yet falls back to the rules below; a frame inside an opaque one
|
|
11
|
+
* counts as opaque too (sandbox flags are inherited).
|
|
12
|
+
*/
|
|
13
|
+
/** Origin of documents that share no origin with anything */
|
|
14
|
+
export const OPAQUE_ORIGIN = 'null';
|
|
15
|
+
/**
|
|
16
|
+
* Whether a reported origin names a real (tuple) origin.
|
|
17
|
+
*
|
|
18
|
+
* @param origin - Origin as Chrome reports it
|
|
19
|
+
* @returns False for `"://"`, `"null"` and empty
|
|
20
|
+
*/
|
|
21
|
+
function isTupleOrigin(origin) {
|
|
22
|
+
return origin !== undefined && origin !== '' && origin !== '://' && origin !== OPAQUE_ORIGIN;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether a `sandbox` attribute makes the frame's origin opaque.
|
|
26
|
+
*
|
|
27
|
+
* @param sandbox - Attribute value (undefined when the attribute is missing)
|
|
28
|
+
* @returns True unless the attribute is missing or allows same-origin
|
|
29
|
+
*/
|
|
30
|
+
export function isOpaqueSandbox(sandbox) {
|
|
31
|
+
if (sandbox === undefined)
|
|
32
|
+
return false;
|
|
33
|
+
return !sandbox.toLowerCase().split(/\s+/).includes('allow-same-origin');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The origin a frame's scripts run with.
|
|
37
|
+
*
|
|
38
|
+
* @param facts - What Chrome reports about the frame
|
|
39
|
+
* @returns e.g. `https://example.com`, or `"null"` for an opaque origin
|
|
40
|
+
*/
|
|
41
|
+
export function effectiveFrameOrigin(facts) {
|
|
42
|
+
if (facts.contextOrigin !== undefined) {
|
|
43
|
+
return isTupleOrigin(facts.contextOrigin) ? facts.contextOrigin : OPAQUE_ORIGIN;
|
|
44
|
+
}
|
|
45
|
+
if (isOpaqueSandbox(facts.sandbox) || facts.parentOrigin === OPAQUE_ORIGIN)
|
|
46
|
+
return OPAQUE_ORIGIN;
|
|
47
|
+
if (isTupleOrigin(facts.securityOrigin))
|
|
48
|
+
return facts.securityOrigin;
|
|
49
|
+
const inherits = facts.url === '' || facts.url.startsWith('about:');
|
|
50
|
+
return inherits && isTupleOrigin(facts.parentOrigin) ? facts.parentOrigin : OPAQUE_ORIGIN;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether the top page's scripts cannot reach a frame's document.
|
|
54
|
+
*
|
|
55
|
+
* @param origin - The frame's effective origin
|
|
56
|
+
* @param topOrigin - The page's effective origin
|
|
57
|
+
* @returns True for a different or opaque origin
|
|
58
|
+
*/
|
|
59
|
+
export function isCrossOrigin(origin, topOrigin) {
|
|
60
|
+
return origin === OPAQUE_ORIGIN || origin !== topOrigin;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=frameOrigin.js.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run the interaction scripts inside the frame of a cached element that the
|
|
3
|
+
* top page cannot reach.
|
|
4
|
+
*
|
|
5
|
+
* An element from `bdg dom a11y query` may be in a cross-origin iframe that
|
|
6
|
+
* shares the page's process (same site, e.g. a consent dialog served from a
|
|
7
|
+
* subdomain). The top page cannot hold it, so its page scripts run in the
|
|
8
|
+
* element's own frame instead: every `Runtime.evaluate` becomes a
|
|
9
|
+
* `Runtime.callFunctionOn` on the element (which runs in the element's
|
|
10
|
+
* context), and mouse events, whose coordinates the scripts measure in the
|
|
11
|
+
* frame's viewport, are mapped into the top-level viewport
|
|
12
|
+
* ({@link FrameMapping}).
|
|
13
|
+
*/
|
|
14
|
+
import type { CDPConnection } from '../../connection/cdp.js';
|
|
15
|
+
import type { LayoutBox, LayoutPoint } from '../../ipc/protocol/domTypes.js';
|
|
16
|
+
/**
|
|
17
|
+
* How a point in a frame's viewport maps into the top-level viewport:
|
|
18
|
+
* `top = origin + frame * scale` per axis (the scale is not 1 when the
|
|
19
|
+
* iframe, or an ancestor of it, is scaled with `transform` or `zoom`).
|
|
20
|
+
*/
|
|
21
|
+
export interface FrameMapping {
|
|
22
|
+
/** Where the frame viewport's (0, 0) lies in the top-level viewport (border and padding included) */
|
|
23
|
+
origin: LayoutPoint;
|
|
24
|
+
scaleX: number;
|
|
25
|
+
scaleY: number;
|
|
26
|
+
}
|
|
27
|
+
/** A box as the frame and as CDP (top-level viewport) see it */
|
|
28
|
+
interface ReferenceBox {
|
|
29
|
+
/** `getBoundingClientRect()` in the frame */
|
|
30
|
+
rect: LayoutBox;
|
|
31
|
+
/** `DOM.getContentQuads` (top-level viewport), each as x1,y1,…,x4,y4 */
|
|
32
|
+
quads: number[][];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `Runtime.callFunctionOn` parameters that evaluate an expression in the
|
|
36
|
+
* context of the element `objectId` refers to.
|
|
37
|
+
*
|
|
38
|
+
* @param params - `Runtime.evaluate` parameters
|
|
39
|
+
* @param objectId - Remote object of the element
|
|
40
|
+
* @returns Parameters for `Runtime.callFunctionOn`
|
|
41
|
+
* @throws Error for a parameter `Runtime.callFunctionOn` has no counterpart for
|
|
42
|
+
* (e.g. `timeout`), so it is not dropped silently
|
|
43
|
+
*/
|
|
44
|
+
export declare function evaluateOnNodeParams(params: Record<string, unknown>, objectId: string): Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* How the frame maps into the top-level viewport, from one box seen both ways.
|
|
47
|
+
*
|
|
48
|
+
* @param box - The reference box in the frame and in the top-level viewport
|
|
49
|
+
* @returns The mapping
|
|
50
|
+
* @throws CommandError (83) when the box has no quads or size, or is rotated or skewed
|
|
51
|
+
*/
|
|
52
|
+
export declare function frameMappingFrom(box: ReferenceBox): FrameMapping;
|
|
53
|
+
/**
|
|
54
|
+
* Map a point of the frame's viewport into the top-level viewport.
|
|
55
|
+
*
|
|
56
|
+
* @param mapping - Frame mapping
|
|
57
|
+
* @param point - Point in the frame's viewport
|
|
58
|
+
* @returns Point in the top-level viewport
|
|
59
|
+
*/
|
|
60
|
+
export declare function mapPoint(mapping: FrameMapping, point: LayoutPoint): LayoutPoint;
|
|
61
|
+
/**
|
|
62
|
+
* Map a box of the frame's viewport into the top-level viewport.
|
|
63
|
+
*
|
|
64
|
+
* @param mapping - Frame mapping
|
|
65
|
+
* @param box - Box in the frame's viewport
|
|
66
|
+
* @returns Box in the top-level viewport
|
|
67
|
+
*/
|
|
68
|
+
export declare function mapBox(mapping: FrameMapping, box: LayoutBox): LayoutBox;
|
|
69
|
+
/**
|
|
70
|
+
* How the element's frame maps into the top-level viewport.
|
|
71
|
+
*
|
|
72
|
+
* @param cdp - CDP connection
|
|
73
|
+
* @param objectId - Remote object of the element
|
|
74
|
+
* @returns The mapping
|
|
75
|
+
* @throws CommandError (83) when the frame cannot be measured or is rotated or skewed
|
|
76
|
+
*/
|
|
77
|
+
export declare function measureFrameMapping(cdp: CDPConnection, objectId: string): Promise<FrameMapping>;
|
|
78
|
+
/**
|
|
79
|
+
* A view of the session's connection whose page scripts run in the frame of
|
|
80
|
+
* one element and whose mouse events land on that frame.
|
|
81
|
+
*
|
|
82
|
+
* The mapping is measured at the first mouse event (after the scripts scrolled
|
|
83
|
+
* the element into view) and kept for the rest of the action; a failed
|
|
84
|
+
* measurement is not kept (the next event measures again) and fails the event.
|
|
85
|
+
*
|
|
86
|
+
* @param cdp - Session connection
|
|
87
|
+
* @param objectId - Remote object of the element
|
|
88
|
+
* @returns Connection to hand to the interaction functions
|
|
89
|
+
*/
|
|
90
|
+
export declare function frameScopedConnection(cdp: CDPConnection, objectId: string): CDPConnection;
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=frameScopedConnection.d.ts.map
|