patchright-core 1.52.4 → 1.55.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/ThirdPartyNotices.txt +65 -123
- package/bin/reinstall_chrome_beta_mac.sh +1 -1
- package/bin/reinstall_chrome_stable_mac.sh +1 -1
- package/bin/reinstall_msedge_beta_mac.sh +1 -1
- package/bin/reinstall_msedge_dev_mac.sh +1 -1
- package/bin/reinstall_msedge_stable_mac.sh +1 -1
- package/browsers.json +14 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +4 -2
- package/lib/browserServerImpl.js +47 -12
- package/lib/cli/program.js +116 -50
- package/lib/cli/programWithTestStub.js +1 -1
- package/lib/client/android.js +30 -34
- package/lib/client/browser.js +54 -17
- package/lib/client/browserContext.js +67 -71
- package/lib/client/browserType.js +25 -34
- package/lib/client/channelOwner.js +20 -24
- package/lib/client/connection.js +6 -10
- package/lib/client/electron.js +8 -3
- package/lib/client/elementHandle.js +18 -21
- package/lib/client/fetch.js +5 -3
- package/lib/client/frame.js +57 -35
- package/lib/client/input.js +3 -1
- package/lib/client/jsHandle.js +4 -0
- package/lib/client/localUtils.js +0 -1
- package/lib/client/locator.js +32 -28
- package/lib/client/network.js +5 -12
- package/lib/client/page.js +32 -32
- package/lib/client/playwright.js +6 -16
- package/lib/client/selectors.js +18 -38
- package/lib/client/timeoutSettings.js +12 -8
- package/lib/client/tracing.js +24 -20
- package/lib/client/waiter.js +2 -2
- package/lib/client/webSocket.js +4 -22
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/generated/webSocketMockSource.js +12 -50
- package/lib/inProcessFactory.js +9 -6
- package/lib/outofprocess.js +0 -2
- package/lib/protocol/validator.js +423 -346
- package/lib/protocol/validatorPrimitives.js +18 -4
- package/lib/remote/playwrightConnection.js +29 -166
- package/lib/remote/playwrightServer.js +233 -35
- package/lib/server/android/android.js +97 -83
- package/lib/server/android/backendAdb.js +0 -2
- package/lib/server/bidi/bidiBrowser.js +139 -73
- package/lib/server/bidi/bidiChromium.js +23 -22
- package/lib/server/bidi/bidiExecutionContext.js +2 -1
- package/lib/server/bidi/bidiFirefox.js +17 -14
- package/lib/server/bidi/bidiInput.js +22 -22
- package/lib/server/bidi/bidiNetworkManager.js +8 -11
- package/lib/server/bidi/bidiPage.js +42 -86
- package/lib/server/bidi/third_party/bidiProtocol.js +5 -133
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/{dispatchers/selectorsDispatcher.js → bidi/third_party/bidiProtocolPermissions.js} +20 -18
- package/lib/server/browser.js +30 -21
- package/lib/server/browserContext.js +203 -165
- package/lib/server/browserType.js +109 -107
- package/lib/server/chromium/chromium.js +84 -69
- package/lib/server/chromium/chromiumSwitches.js +13 -20
- package/lib/server/chromium/crBrowser.js +74 -40
- package/lib/server/chromium/crConnection.js +8 -9
- package/lib/server/chromium/crCoverage.js +11 -8
- package/lib/server/chromium/crDragDrop.js +25 -20
- package/lib/server/chromium/crExecutionContext.js +2 -1
- package/lib/server/chromium/crInput.js +32 -29
- package/lib/server/chromium/crNetworkManager.js +45 -33
- package/lib/server/chromium/crPage.js +98 -73
- package/lib/server/chromium/crServiceWorker.js +13 -18
- package/lib/server/chromium/videoRecorder.js +10 -18
- package/lib/server/clock.js +51 -39
- package/lib/server/codegen/csharp.js +10 -5
- package/lib/server/codegen/java.js +1 -1
- package/lib/server/codegen/javascript.js +1 -1
- package/lib/server/codegen/jsonl.js +2 -1
- package/lib/server/codegen/language.js +22 -1
- package/lib/server/codegen/languages.js +4 -4
- package/lib/server/codegen/python.js +1 -1
- package/lib/server/cookieStore.js +3 -1
- package/lib/server/debugController.js +105 -71
- package/lib/server/debugger.js +6 -23
- package/lib/server/deviceDescriptorsSource.json +237 -127
- package/lib/server/dialog.js +50 -6
- package/lib/server/dispatchers/androidDispatcher.js +77 -62
- package/lib/server/dispatchers/artifactDispatcher.js +18 -18
- package/lib/server/dispatchers/browserContextDispatcher.js +141 -91
- package/lib/server/dispatchers/browserDispatcher.js +55 -88
- package/lib/server/dispatchers/browserTypeDispatcher.js +18 -9
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -4
- package/lib/server/dispatchers/debugControllerDispatcher.js +12 -21
- package/lib/server/dispatchers/dialogDispatcher.js +4 -4
- package/lib/server/dispatchers/dispatcher.js +78 -53
- package/lib/server/dispatchers/electronDispatcher.js +19 -20
- package/lib/server/dispatchers/elementHandlerDispatcher.js +83 -93
- package/lib/server/dispatchers/frameDispatcher.js +99 -102
- package/lib/server/dispatchers/jsHandleDispatcher.js +21 -16
- package/lib/server/dispatchers/jsonPipeDispatcher.js +4 -4
- package/lib/server/dispatchers/localUtilsDispatcher.js +53 -59
- package/lib/server/dispatchers/networkDispatchers.js +41 -35
- package/lib/server/dispatchers/pageDispatcher.js +156 -107
- package/lib/server/dispatchers/playwrightDispatcher.js +37 -25
- package/lib/server/dispatchers/streamDispatcher.js +15 -8
- package/lib/server/dispatchers/tracingDispatcher.js +22 -13
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +46 -35
- package/lib/server/dispatchers/writableStreamDispatcher.js +16 -10
- package/lib/server/dom.js +198 -266
- package/lib/server/download.js +3 -3
- package/lib/server/electron/electron.js +96 -103
- package/lib/server/electron/loader.js +1 -1
- package/lib/server/fetch.js +22 -41
- package/lib/server/fileUploadUtils.js +1 -1
- package/lib/server/firefox/ffBrowser.js +79 -55
- package/lib/server/firefox/ffExecutionContext.js +2 -1
- package/lib/server/firefox/ffInput.js +23 -23
- package/lib/server/firefox/ffNetworkManager.js +8 -6
- package/lib/server/firefox/ffPage.js +39 -36
- package/lib/server/firefox/firefox.js +9 -10
- package/lib/server/frameSelectors.js +65 -22
- package/lib/server/frames.js +516 -544
- package/lib/server/har/harRecorder.js +1 -1
- package/lib/server/har/harTracer.js +4 -2
- package/lib/server/helper.js +3 -7
- package/lib/server/index.js +0 -3
- package/lib/server/input.js +47 -54
- package/lib/server/instrumentation.js +8 -14
- package/lib/server/javascript.js +9 -17
- package/lib/server/launchApp.js +48 -30
- package/lib/server/localUtils.js +45 -38
- package/lib/server/network.js +44 -10
- package/lib/server/page.js +233 -178
- package/lib/server/pageBinding.js +6 -7
- package/lib/server/playwright.js +4 -14
- package/lib/server/progress.js +57 -49
- package/lib/server/recorder/recorderApp.js +298 -95
- package/lib/server/recorder/recorderRunner.js +23 -24
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +67 -10
- package/lib/server/recorder.js +284 -146
- package/lib/server/registry/index.js +83 -48
- package/lib/server/registry/nativeDeps.js +175 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +1 -1
- package/lib/server/screenshotter.js +84 -83
- package/lib/server/selectors.js +12 -12
- package/lib/server/socksClientCertificatesInterceptor.js +198 -136
- package/lib/server/trace/recorder/snapshotter.js +12 -19
- package/lib/server/trace/recorder/tracing.js +36 -27
- package/lib/server/trace/viewer/traceViewer.js +11 -20
- package/lib/server/transport.js +20 -22
- package/lib/server/utils/comparators.js +2 -2
- package/lib/server/utils/debug.js +3 -8
- package/lib/server/utils/debugLogger.js +8 -0
- package/lib/server/utils/hostPlatform.js +3 -1
- package/lib/server/utils/network.js +35 -25
- package/lib/server/utils/nodePlatform.js +1 -1
- package/lib/server/utils/processLauncher.js +4 -1
- package/lib/server/utils/wsServer.js +11 -17
- package/lib/server/webkit/webkit.js +5 -2
- package/lib/server/webkit/wkBrowser.js +51 -28
- package/lib/server/webkit/wkExecutionContext.js +2 -1
- package/lib/server/webkit/wkInput.js +25 -25
- package/lib/server/webkit/wkInterceptableRequest.js +1 -1
- package/lib/server/webkit/wkPage.js +80 -59
- package/lib/server/webkit/wkProvisionalPage.js +1 -1
- package/lib/server/webkit/wkWorkers.js +7 -7
- package/lib/utils/isomorphic/ariaSnapshot.js +13 -7
- package/lib/utils/isomorphic/cssParser.js +1 -2
- package/lib/utils/isomorphic/locatorGenerators.js +18 -0
- package/lib/utils/isomorphic/manualPromise.js +1 -2
- package/lib/utils/isomorphic/mimeType.js +1 -2
- package/lib/utils/isomorphic/multimap.js +1 -2
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +248 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +318 -0
- package/lib/utils/isomorphic/selectorParser.js +3 -4
- package/lib/utils/isomorphic/stringUtils.js +3 -24
- package/lib/utils/isomorphic/time.js +9 -4
- package/lib/utils/isomorphic/timeoutRunner.js +3 -4
- package/lib/utils/isomorphic/traceUtils.js +2 -3
- package/lib/utils/isomorphic/urlMatch.js +21 -7
- package/lib/utils/isomorphic/utilityScriptSerializers.js +208 -205
- package/lib/utils.js +8 -2
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/vite/htmlReport/index.html +17 -17
- package/lib/vite/recorder/assets/{codeMirrorModule-CXVeovup.js → codeMirrorModule-DzQ0k89p.js} +1 -1
- package/lib/vite/recorder/assets/{index-eHBmevrY.css → index-CI4HQ-Zb.css} +1 -1
- package/lib/vite/recorder/assets/index-D7C7daHH.js +184 -0
- package/lib/vite/recorder/index.html +3 -3
- package/lib/vite/traceViewer/assets/{codeMirrorModule-_GLjJL-7.js → codeMirrorModule-Di48jgWx.js} +1 -1
- package/lib/vite/traceViewer/assets/defaultSettingsView-szBn8781.js +256 -0
- package/lib/vite/traceViewer/defaultSettingsView.DVJHpiGt.css +1 -0
- package/lib/vite/traceViewer/index.BFsek2M6.css +1 -0
- package/lib/vite/traceViewer/index.DQvXoPLL.js +2 -0
- package/lib/vite/traceViewer/index.html +6 -6
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/uiMode.dBV3oN9h.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -4
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +712 -107
- package/types/types.d.ts +148 -37
- package/lib/generated/consoleApiSource.js +0 -28
- package/lib/protocol/debug.js +0 -211
- package/lib/server/recorder/contextRecorder.js +0 -286
- package/lib/server/recorder/recorderCollection.js +0 -116
- package/lib/server/recorder/recorderFrontend.js +0 -16
- package/lib/server/storageScript.js +0 -154
- package/lib/server/timeoutSettings.js +0 -89
- package/lib/utils/isomorphic/builtins.js +0 -86
- package/lib/vite/recorder/assets/index-BsWQsSGl.js +0 -184
- package/lib/vite/traceViewer/assets/defaultSettingsView-DtCQiGHe.js +0 -265
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.cFZzK9RN.js +0 -2
- package/lib/vite/traceViewer/uiMode.XVPIqBeS.js +0 -5
package/lib/server/dom.js
CHANGED
|
@@ -40,11 +40,9 @@ __export(dom_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(dom_exports);
|
|
41
41
|
var import_fs = __toESM(require("fs"));
|
|
42
42
|
var js = __toESM(require("./javascript"));
|
|
43
|
-
var import_progress = require("./progress");
|
|
44
43
|
var import_utils = require("../utils");
|
|
45
44
|
var import_fileUploadUtils = require("./fileUploadUtils");
|
|
46
|
-
var
|
|
47
|
-
var injectedScriptSource = __toESM(require("../generated/injectedScriptSource"));
|
|
45
|
+
var rawInjectedScriptSource = __toESM(require("../generated/injectedScriptSource"));
|
|
48
46
|
class NonRecoverableDOMError extends Error {
|
|
49
47
|
}
|
|
50
48
|
function isNonRecoverableDOMError(error) {
|
|
@@ -58,7 +56,7 @@ class FrameExecutionContext extends js.ExecutionContext {
|
|
|
58
56
|
}
|
|
59
57
|
adoptIfNeeded(handle) {
|
|
60
58
|
if (handle instanceof ElementHandle && handle._context !== this)
|
|
61
|
-
return this.frame._page.
|
|
59
|
+
return this.frame._page.delegate.adoptElementHandle(handle, this);
|
|
62
60
|
return null;
|
|
63
61
|
}
|
|
64
62
|
async evaluate(pageFunction, arg) {
|
|
@@ -75,25 +73,24 @@ class FrameExecutionContext extends js.ExecutionContext {
|
|
|
75
73
|
}
|
|
76
74
|
injectedScript() {
|
|
77
75
|
if (!this._injectedScriptPromise) {
|
|
78
|
-
const
|
|
79
|
-
const selectorsRegistry = this.frame._page.
|
|
76
|
+
const customEngines = [];
|
|
77
|
+
const selectorsRegistry = this.frame._page.browserContext.selectors();
|
|
80
78
|
for (const [name, { source: source2 }] of selectorsRegistry._engines)
|
|
81
|
-
|
|
82
|
-
const sdkLanguage = this.frame.
|
|
79
|
+
customEngines.push({ name, source: `(${source2})` });
|
|
80
|
+
const sdkLanguage = this.frame._page.browserContext._browser.sdkLanguage();
|
|
81
|
+
const options = {
|
|
82
|
+
isUnderTest: (0, import_utils.isUnderTest)(),
|
|
83
|
+
sdkLanguage,
|
|
84
|
+
testIdAttributeName: selectorsRegistry.testIdAttributeName(),
|
|
85
|
+
stableRafCount: this.frame._page.delegate.rafCountForStablePosition(),
|
|
86
|
+
browserName: this.frame._page.browserContext._browser.options.name,
|
|
87
|
+
customEngines
|
|
88
|
+
};
|
|
83
89
|
const source = `
|
|
84
90
|
(() => {
|
|
85
91
|
const module = {};
|
|
86
|
-
${
|
|
87
|
-
return new (module.exports.InjectedScript())(
|
|
88
|
-
globalThis,
|
|
89
|
-
${(0, import_utils.isUnderTest)()},
|
|
90
|
-
"${sdkLanguage}",
|
|
91
|
-
${JSON.stringify(selectorsRegistry.testIdAttributeName())},
|
|
92
|
-
${this.frame._page._delegate.rafCountForStablePosition()},
|
|
93
|
-
"${this.frame._page._browserContext._browser.options.name}",
|
|
94
|
-
${process.env.PLAYWRIGHT_INPUT_FILE_TEXTBOX ? "true" : "false"},
|
|
95
|
-
[${custom.join(",\n")}]
|
|
96
|
-
);
|
|
92
|
+
${rawInjectedScriptSource.source}
|
|
93
|
+
return new (module.exports.InjectedScript())(globalThis, ${JSON.stringify(options)});
|
|
97
94
|
})();
|
|
98
95
|
`;
|
|
99
96
|
this._injectedScriptPromise = this.rawEvaluateHandle(source).then((handle) => {
|
|
@@ -125,7 +122,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
125
122
|
const utility = await this._frame._utilityContext();
|
|
126
123
|
return await utility.evaluate(pageFunction, [await utility.injectedScript(), this, arg]);
|
|
127
124
|
} catch (e) {
|
|
128
|
-
if (
|
|
125
|
+
if (this._frame.isNonRetriableError(e))
|
|
129
126
|
throw e;
|
|
130
127
|
return "error:notconnected";
|
|
131
128
|
}
|
|
@@ -135,20 +132,20 @@ class ElementHandle extends js.JSHandle {
|
|
|
135
132
|
const utility = await this._frame._utilityContext();
|
|
136
133
|
return await utility.evaluateHandle(pageFunction, [await utility.injectedScript(), this, arg]);
|
|
137
134
|
} catch (e) {
|
|
138
|
-
if (
|
|
135
|
+
if (this._frame.isNonRetriableError(e))
|
|
139
136
|
throw e;
|
|
140
137
|
return "error:notconnected";
|
|
141
138
|
}
|
|
142
139
|
}
|
|
143
140
|
async ownerFrame() {
|
|
144
|
-
const frameId = await this._page.
|
|
141
|
+
const frameId = await this._page.delegate.getOwnerFrame(this);
|
|
145
142
|
if (!frameId)
|
|
146
143
|
return null;
|
|
147
|
-
const frame = this._page.
|
|
144
|
+
const frame = this._page.frameManager.frame(frameId);
|
|
148
145
|
if (frame)
|
|
149
146
|
return frame;
|
|
150
|
-
for (const page of this._page.
|
|
151
|
-
const frame2 = page.
|
|
147
|
+
for (const page of this._page.browserContext.pages()) {
|
|
148
|
+
const frame2 = page.frameManager.frame(frameId);
|
|
152
149
|
if (frame2)
|
|
153
150
|
return frame2;
|
|
154
151
|
}
|
|
@@ -161,58 +158,46 @@ class ElementHandle extends js.JSHandle {
|
|
|
161
158
|
const isFrameElement = throwRetargetableDOMError(await this.isIframeElement());
|
|
162
159
|
if (!isFrameElement)
|
|
163
160
|
return null;
|
|
164
|
-
return this._page.
|
|
161
|
+
return this._page.delegate.getContentFrame(this);
|
|
165
162
|
}
|
|
166
|
-
async
|
|
167
|
-
|
|
168
|
-
return injected.generateSelectorSimple(node);
|
|
169
|
-
}, {});
|
|
170
|
-
if (selector === "error:notconnected")
|
|
171
|
-
return;
|
|
172
|
-
return (0, import_utils.asLocator)("javascript", selector);
|
|
163
|
+
async getAttribute(progress, name) {
|
|
164
|
+
return this._frame.getAttribute(progress, ":scope", name, {}, this);
|
|
173
165
|
}
|
|
174
|
-
async
|
|
175
|
-
return this._frame.
|
|
166
|
+
async inputValue(progress) {
|
|
167
|
+
return this._frame.inputValue(progress, ":scope", {}, this);
|
|
176
168
|
}
|
|
177
|
-
async
|
|
178
|
-
return this._frame.
|
|
169
|
+
async textContent(progress) {
|
|
170
|
+
return this._frame.textContent(progress, ":scope", {}, this);
|
|
179
171
|
}
|
|
180
|
-
async
|
|
181
|
-
return this._frame.
|
|
172
|
+
async innerText(progress) {
|
|
173
|
+
return this._frame.innerText(progress, ":scope", {}, this);
|
|
182
174
|
}
|
|
183
|
-
async
|
|
184
|
-
return this._frame.
|
|
175
|
+
async innerHTML(progress) {
|
|
176
|
+
return this._frame.innerHTML(progress, ":scope", {}, this);
|
|
185
177
|
}
|
|
186
|
-
async
|
|
187
|
-
return this._frame.
|
|
178
|
+
async dispatchEvent(progress, type, eventInit = {}) {
|
|
179
|
+
return this._frame.dispatchEvent(progress, ":scope", type, eventInit, {}, this);
|
|
188
180
|
}
|
|
189
|
-
async
|
|
190
|
-
return this.
|
|
191
|
-
}
|
|
192
|
-
async _scrollRectIntoViewIfNeeded(rect) {
|
|
193
|
-
return await this._page._delegate.scrollRectIntoViewIfNeeded(this, rect);
|
|
181
|
+
async _scrollRectIntoViewIfNeeded(progress, rect) {
|
|
182
|
+
return await progress.race(this._page.delegate.scrollRectIntoViewIfNeeded(this, rect));
|
|
194
183
|
}
|
|
195
184
|
async _waitAndScrollIntoViewIfNeeded(progress, waitForVisible) {
|
|
196
185
|
const result = await this._retryAction(progress, "scroll into view", async () => {
|
|
197
186
|
progress.log(` waiting for element to be stable`);
|
|
198
|
-
const waitResult = await this.evaluateInUtility(async ([injected, node, { waitForVisible: waitForVisible2 }]) => {
|
|
187
|
+
const waitResult = await progress.race(this.evaluateInUtility(async ([injected, node, { waitForVisible: waitForVisible2 }]) => {
|
|
199
188
|
return await injected.checkElementStates(node, waitForVisible2 ? ["visible", "stable"] : ["stable"]);
|
|
200
|
-
}, { waitForVisible });
|
|
189
|
+
}, { waitForVisible }));
|
|
201
190
|
if (waitResult)
|
|
202
191
|
return waitResult;
|
|
203
|
-
return await this._scrollRectIntoViewIfNeeded();
|
|
192
|
+
return await this._scrollRectIntoViewIfNeeded(progress);
|
|
204
193
|
}, {});
|
|
205
194
|
assertDone(throwRetargetableDOMError(result));
|
|
206
195
|
}
|
|
207
|
-
async scrollIntoViewIfNeeded(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
false
|
|
213
|
-
/* waitForVisible */
|
|
214
|
-
),
|
|
215
|
-
this._page._timeoutSettings.timeout(options)
|
|
196
|
+
async scrollIntoViewIfNeeded(progress) {
|
|
197
|
+
await this._waitAndScrollIntoViewIfNeeded(
|
|
198
|
+
progress,
|
|
199
|
+
false
|
|
200
|
+
/* waitForVisible */
|
|
216
201
|
);
|
|
217
202
|
}
|
|
218
203
|
async _clickablePoint() {
|
|
@@ -232,7 +217,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
232
217
|
return Math.abs(area);
|
|
233
218
|
};
|
|
234
219
|
const [quads, metrics] = await Promise.all([
|
|
235
|
-
this._page.
|
|
220
|
+
this._page.delegate.getContentQuads(this),
|
|
236
221
|
this._page.mainFrame()._utilityContext().then((utility) => utility.evaluate(() => ({ width: innerWidth, height: innerHeight })))
|
|
237
222
|
]);
|
|
238
223
|
if (quads === "error:notconnected")
|
|
@@ -242,7 +227,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
242
227
|
const filtered = quads.map((quad) => intersectQuadWithViewport(quad)).filter((quad) => computeQuadArea(quad) > 0.99);
|
|
243
228
|
if (!filtered.length)
|
|
244
229
|
return "error:notinviewport";
|
|
245
|
-
if (this._page.
|
|
230
|
+
if (this._page.browserContext._browser.options.name === "firefox") {
|
|
246
231
|
for (const quad of filtered) {
|
|
247
232
|
const integerPoint = findIntegerPointInsideQuad(quad);
|
|
248
233
|
if (integerPoint)
|
|
@@ -269,13 +254,13 @@ class ElementHandle extends js.JSHandle {
|
|
|
269
254
|
async _retryAction(progress, actionName, action, options) {
|
|
270
255
|
let retry = 0;
|
|
271
256
|
const waitTime = [0, 20, 100, 100, 500];
|
|
272
|
-
while (
|
|
257
|
+
while (true) {
|
|
273
258
|
if (retry) {
|
|
274
259
|
progress.log(`retrying ${actionName} action${options.trial ? " (trial run)" : ""}`);
|
|
275
260
|
const timeout = waitTime[Math.min(retry - 1, waitTime.length - 1)];
|
|
276
261
|
if (timeout) {
|
|
277
262
|
progress.log(` waiting ${timeout}ms`);
|
|
278
|
-
const result2 = await this.evaluateInUtility(([injected, node, timeout2]) => new Promise((f) => setTimeout(f, timeout2)), timeout);
|
|
263
|
+
const result2 = await progress.race(this.evaluateInUtility(([injected, node, timeout2]) => new Promise((f) => setTimeout(f, timeout2)), timeout));
|
|
279
264
|
if (result2 === "error:notconnected")
|
|
280
265
|
return result2;
|
|
281
266
|
}
|
|
@@ -302,6 +287,10 @@ class ElementHandle extends js.JSHandle {
|
|
|
302
287
|
progress.log(" did not find some options");
|
|
303
288
|
continue;
|
|
304
289
|
}
|
|
290
|
+
if (result === "error:optionnotenabled") {
|
|
291
|
+
progress.log(" option being selected is not enabled");
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
305
294
|
if (typeof result === "object" && "hitTargetDescription" in result) {
|
|
306
295
|
progress.log(` ${result.hitTargetDescription} intercepts pointer events`);
|
|
307
296
|
continue;
|
|
@@ -312,7 +301,6 @@ class ElementHandle extends js.JSHandle {
|
|
|
312
301
|
}
|
|
313
302
|
return result;
|
|
314
303
|
}
|
|
315
|
-
return "done";
|
|
316
304
|
}
|
|
317
305
|
async _retryPointerAction(progress, actionName, waitForEnabled, action, options) {
|
|
318
306
|
const skipActionPreChecks = actionName === "move and up";
|
|
@@ -337,51 +325,49 @@ class ElementHandle extends js.JSHandle {
|
|
|
337
325
|
return "done";
|
|
338
326
|
}, forceScrollOptions);
|
|
339
327
|
}
|
|
340
|
-
return await this._scrollRectIntoViewIfNeeded(position ? { x: position.x, y: position.y, width: 0, height: 0 } : void 0);
|
|
328
|
+
return await this._scrollRectIntoViewIfNeeded(progress, position ? { x: position.x, y: position.y, width: 0, height: 0 } : void 0);
|
|
341
329
|
};
|
|
342
330
|
if (this._frame.parentFrame()) {
|
|
343
|
-
progress.
|
|
344
|
-
|
|
345
|
-
});
|
|
331
|
+
await progress.race(doScrollIntoView().catch(() => {
|
|
332
|
+
}));
|
|
346
333
|
}
|
|
347
334
|
if (options.__testHookBeforeStable)
|
|
348
|
-
await options.__testHookBeforeStable();
|
|
335
|
+
await progress.race(options.__testHookBeforeStable());
|
|
349
336
|
if (!force) {
|
|
350
337
|
const elementStates = waitForEnabled ? ["visible", "enabled", "stable"] : ["visible", "stable"];
|
|
351
338
|
progress.log(` waiting for element to be ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
|
|
352
|
-
const result = await this.evaluateInUtility(async ([injected, node, { elementStates: elementStates2 }]) => {
|
|
339
|
+
const result = await progress.race(this.evaluateInUtility(async ([injected, node, { elementStates: elementStates2 }]) => {
|
|
353
340
|
return await injected.checkElementStates(node, elementStates2);
|
|
354
|
-
}, { elementStates });
|
|
341
|
+
}, { elementStates }));
|
|
355
342
|
if (result)
|
|
356
343
|
return result;
|
|
357
344
|
progress.log(` element is ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
|
|
358
345
|
}
|
|
359
346
|
if (options.__testHookAfterStable)
|
|
360
|
-
await options.__testHookAfterStable();
|
|
347
|
+
await progress.race(options.__testHookAfterStable());
|
|
361
348
|
progress.log(" scrolling into view if needed");
|
|
362
|
-
progress.
|
|
363
|
-
const scrolled = await doScrollIntoView();
|
|
349
|
+
const scrolled = await progress.race(doScrollIntoView());
|
|
364
350
|
if (scrolled !== "done")
|
|
365
351
|
return scrolled;
|
|
366
352
|
progress.log(" done scrolling");
|
|
367
|
-
const maybePoint = position ? await this._offsetPoint(position) : await this._clickablePoint();
|
|
353
|
+
const maybePoint = position ? await progress.race(this._offsetPoint(position)) : await progress.race(this._clickablePoint());
|
|
368
354
|
if (typeof maybePoint === "string")
|
|
369
355
|
return maybePoint;
|
|
370
356
|
const point = roundPoint(maybePoint);
|
|
371
357
|
progress.metadata.point = point;
|
|
372
|
-
await this.instrumentation.onBeforeInputAction(this, progress.metadata);
|
|
358
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
373
359
|
let hitTargetInterceptionHandle;
|
|
374
360
|
if (force) {
|
|
375
361
|
progress.log(` forcing action`);
|
|
376
362
|
} else {
|
|
377
363
|
if (options.__testHookBeforeHitTarget)
|
|
378
|
-
await options.__testHookBeforeHitTarget();
|
|
379
|
-
const frameCheckResult = await this._checkFrameIsHitTarget(point);
|
|
364
|
+
await progress.race(options.__testHookBeforeHitTarget());
|
|
365
|
+
const frameCheckResult = await progress.race(this._checkFrameIsHitTarget(point));
|
|
380
366
|
if (frameCheckResult === "error:notconnected" || "hitTargetDescription" in frameCheckResult)
|
|
381
367
|
return frameCheckResult;
|
|
382
368
|
const hitPoint = frameCheckResult.framePoint;
|
|
383
369
|
const actionType = actionName === "move and up" ? "drag" : actionName === "hover" || actionName === "tap" ? actionName : "mouse";
|
|
384
|
-
const handle = await this.evaluateHandleInUtility(([injected, node, { actionType: actionType2, hitPoint: hitPoint2, trial }]) => injected.setupHitTargetInterceptor(node, actionType2, hitPoint2, trial), { actionType, hitPoint, trial: !!options.trial });
|
|
370
|
+
const handle = await progress.race(this.evaluateHandleInUtility(([injected, node, { actionType: actionType2, hitPoint: hitPoint2, trial }]) => injected.setupHitTargetInterceptor(node, actionType2, hitPoint2, trial), { actionType, hitPoint, trial: !!options.trial }));
|
|
385
371
|
if (handle === "error:notconnected")
|
|
386
372
|
return handle;
|
|
387
373
|
if (!handle._objectId) {
|
|
@@ -391,23 +377,17 @@ class ElementHandle extends js.JSHandle {
|
|
|
391
377
|
return { hitTargetDescription: error };
|
|
392
378
|
}
|
|
393
379
|
hitTargetInterceptionHandle = handle;
|
|
394
|
-
progress.cleanupWhenAborted(() => {
|
|
395
|
-
hitTargetInterceptionHandle.evaluate((h) => h.stop()).catch((e) => {
|
|
396
|
-
});
|
|
397
|
-
hitTargetInterceptionHandle.dispose();
|
|
398
|
-
});
|
|
399
380
|
}
|
|
400
|
-
const actionResult = await this._page.
|
|
381
|
+
const actionResult = await this._page.frameManager.waitForSignalsCreatedBy(progress, options.waitAfter === true, async () => {
|
|
401
382
|
if (options.__testHookBeforePointerAction)
|
|
402
|
-
await options.__testHookBeforePointerAction();
|
|
403
|
-
progress.throwIfAborted();
|
|
383
|
+
await progress.race(options.__testHookBeforePointerAction());
|
|
404
384
|
let restoreModifiers;
|
|
405
385
|
if (options && options.modifiers)
|
|
406
|
-
restoreModifiers = await this._page.keyboard.ensureModifiers(options.modifiers);
|
|
386
|
+
restoreModifiers = await this._page.keyboard.ensureModifiers(progress, options.modifiers);
|
|
407
387
|
progress.log(` performing ${actionName} action`);
|
|
408
388
|
await action(point);
|
|
409
389
|
if (restoreModifiers)
|
|
410
|
-
await this._page.keyboard.ensureModifiers(restoreModifiers);
|
|
390
|
+
await this._page.keyboard.ensureModifiers(progress, restoreModifiers);
|
|
411
391
|
if (hitTargetInterceptionHandle) {
|
|
412
392
|
const stopHitTargetInterception = this._frame.raceAgainstEvaluationStallingEvents(() => {
|
|
413
393
|
return hitTargetInterceptionHandle.evaluate((h) => h.stop());
|
|
@@ -415,7 +395,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
415
395
|
hitTargetInterceptionHandle?.dispose();
|
|
416
396
|
});
|
|
417
397
|
if (options.waitAfter !== false) {
|
|
418
|
-
const hitTargetResult = await stopHitTargetInterception;
|
|
398
|
+
const hitTargetResult = await progress.race(stopHitTargetInterception);
|
|
419
399
|
if (hitTargetResult !== "done")
|
|
420
400
|
return hitTargetResult;
|
|
421
401
|
}
|
|
@@ -423,89 +403,78 @@ class ElementHandle extends js.JSHandle {
|
|
|
423
403
|
progress.log(` ${options.trial ? "trial " : ""}${actionName} action done`);
|
|
424
404
|
progress.log(" waiting for scheduled navigations to finish");
|
|
425
405
|
if (options.__testHookAfterPointerAction)
|
|
426
|
-
await options.__testHookAfterPointerAction();
|
|
406
|
+
await progress.race(options.__testHookAfterPointerAction());
|
|
427
407
|
return "done";
|
|
408
|
+
}).finally(() => {
|
|
409
|
+
const stopPromise = hitTargetInterceptionHandle?.evaluate((h) => h.stop()).catch(() => {
|
|
410
|
+
});
|
|
411
|
+
stopPromise?.then(() => hitTargetInterceptionHandle?.dispose());
|
|
428
412
|
});
|
|
429
413
|
if (actionResult !== "done")
|
|
430
414
|
return actionResult;
|
|
431
415
|
progress.log(" navigations have finished");
|
|
432
416
|
return "done";
|
|
433
417
|
}
|
|
434
|
-
async _markAsTargetElement(
|
|
435
|
-
if (!metadata.id)
|
|
418
|
+
async _markAsTargetElement(progress) {
|
|
419
|
+
if (!progress.metadata.id)
|
|
436
420
|
return;
|
|
437
|
-
await this.evaluateInUtility(([injected, node, callId]) => {
|
|
421
|
+
await progress.race(this.evaluateInUtility(([injected, node, callId]) => {
|
|
438
422
|
if (node.nodeType === 1)
|
|
439
423
|
injected.markTargetElements(/* @__PURE__ */ new Set([node]), callId);
|
|
440
|
-
}, metadata.id);
|
|
424
|
+
}, progress.metadata.id));
|
|
441
425
|
}
|
|
442
|
-
async hover(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
const result = await this._hover(progress, options);
|
|
447
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
448
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
426
|
+
async hover(progress, options) {
|
|
427
|
+
await this._markAsTargetElement(progress);
|
|
428
|
+
const result = await this._hover(progress, options);
|
|
429
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
449
430
|
}
|
|
450
431
|
_hover(progress, options) {
|
|
451
|
-
return this._retryPointerAction(progress, "hover", false, (point) => this._page.mouse.move(point.x, point.y), { ...options, waitAfter: "disabled" });
|
|
432
|
+
return this._retryPointerAction(progress, "hover", false, (point) => this._page.mouse.move(progress, point.x, point.y), { ...options, waitAfter: "disabled" });
|
|
452
433
|
}
|
|
453
|
-
async click(
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
const result = await this._click(progress, { ...options, waitAfter: !options.noWaitAfter });
|
|
458
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
459
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
434
|
+
async click(progress, options) {
|
|
435
|
+
await this._markAsTargetElement(progress);
|
|
436
|
+
const result = await this._click(progress, { ...options, waitAfter: !options.noWaitAfter });
|
|
437
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
460
438
|
}
|
|
461
439
|
_click(progress, options) {
|
|
462
|
-
return this._retryPointerAction(progress, "click", true, (point) => this._page.mouse.click(point.x, point.y, options), options);
|
|
440
|
+
return this._retryPointerAction(progress, "click", true, (point) => this._page.mouse.click(progress, point.x, point.y, options), options);
|
|
463
441
|
}
|
|
464
|
-
async dblclick(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
const result = await this._dblclick(progress, options);
|
|
469
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
470
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
442
|
+
async dblclick(progress, options) {
|
|
443
|
+
await this._markAsTargetElement(progress);
|
|
444
|
+
const result = await this._dblclick(progress, options);
|
|
445
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
471
446
|
}
|
|
472
447
|
_dblclick(progress, options) {
|
|
473
|
-
return this._retryPointerAction(progress, "dblclick", true, (point) => this._page.mouse.
|
|
448
|
+
return this._retryPointerAction(progress, "dblclick", true, (point) => this._page.mouse.click(progress, point.x, point.y, { ...options, clickCount: 2 }), { ...options, waitAfter: "disabled" });
|
|
474
449
|
}
|
|
475
|
-
async tap(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
const result = await this._tap(progress, options);
|
|
480
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
481
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
450
|
+
async tap(progress, options) {
|
|
451
|
+
await this._markAsTargetElement(progress);
|
|
452
|
+
const result = await this._tap(progress, options);
|
|
453
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
482
454
|
}
|
|
483
455
|
_tap(progress, options) {
|
|
484
|
-
return this._retryPointerAction(progress, "tap", true, (point) => this._page.touchscreen.tap(point.x, point.y), { ...options, waitAfter: "disabled" });
|
|
456
|
+
return this._retryPointerAction(progress, "tap", true, (point) => this._page.touchscreen.tap(progress, point.x, point.y), { ...options, waitAfter: "disabled" });
|
|
485
457
|
}
|
|
486
|
-
async selectOption(
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
const result = await this._selectOption(progress, elements, values, options);
|
|
491
|
-
return throwRetargetableDOMError(result);
|
|
492
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
458
|
+
async selectOption(progress, elements, values, options) {
|
|
459
|
+
await this._markAsTargetElement(progress);
|
|
460
|
+
const result = await this._selectOption(progress, elements, values, options);
|
|
461
|
+
return throwRetargetableDOMError(result);
|
|
493
462
|
}
|
|
494
463
|
async _selectOption(progress, elements, values, options) {
|
|
495
464
|
let resultingOptions = [];
|
|
496
465
|
const result = await this._retryAction(progress, "select option", async () => {
|
|
497
|
-
await this.instrumentation.onBeforeInputAction(this, progress.metadata);
|
|
466
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
498
467
|
if (!options.force)
|
|
499
468
|
progress.log(` waiting for element to be visible and enabled`);
|
|
500
469
|
const optionsToSelect = [...elements, ...values];
|
|
501
|
-
const result2 = await this.evaluateInUtility(async ([injected, node, { optionsToSelect: optionsToSelect2, force }]) => {
|
|
470
|
+
const result2 = await progress.race(this.evaluateInUtility(async ([injected, node, { optionsToSelect: optionsToSelect2, force }]) => {
|
|
502
471
|
if (!force) {
|
|
503
472
|
const checkResult = await injected.checkElementStates(node, ["visible", "enabled"]);
|
|
504
473
|
if (checkResult)
|
|
505
474
|
return checkResult;
|
|
506
475
|
}
|
|
507
476
|
return injected.selectOptions(node, optionsToSelect2);
|
|
508
|
-
}, { optionsToSelect, force: options.force });
|
|
477
|
+
}, { optionsToSelect, force: options.force }));
|
|
509
478
|
if (Array.isArray(result2)) {
|
|
510
479
|
progress.log(" selected specified option(s)");
|
|
511
480
|
resultingOptions = result2;
|
|
@@ -517,71 +486,61 @@ class ElementHandle extends js.JSHandle {
|
|
|
517
486
|
return result;
|
|
518
487
|
return resultingOptions;
|
|
519
488
|
}
|
|
520
|
-
async fill(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
const result = await this._fill(progress, value, options);
|
|
525
|
-
assertDone(throwRetargetableDOMError(result));
|
|
526
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
489
|
+
async fill(progress, value, options) {
|
|
490
|
+
await this._markAsTargetElement(progress);
|
|
491
|
+
const result = await this._fill(progress, value, options);
|
|
492
|
+
assertDone(throwRetargetableDOMError(result));
|
|
527
493
|
}
|
|
528
494
|
async _fill(progress, value, options) {
|
|
529
495
|
progress.log(` fill("${value}")`);
|
|
530
496
|
return await this._retryAction(progress, "fill", async () => {
|
|
531
|
-
await this.instrumentation.onBeforeInputAction(this, progress.metadata);
|
|
497
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
532
498
|
if (!options.force)
|
|
533
499
|
progress.log(" waiting for element to be visible, enabled and editable");
|
|
534
|
-
const result = await this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
|
|
500
|
+
const result = await progress.race(this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
|
|
535
501
|
if (!force) {
|
|
536
502
|
const checkResult = await injected.checkElementStates(node, ["visible", "enabled", "editable"]);
|
|
537
503
|
if (checkResult)
|
|
538
504
|
return checkResult;
|
|
539
505
|
}
|
|
540
506
|
return injected.fill(node, value2);
|
|
541
|
-
}, { value, force: options.force });
|
|
542
|
-
progress.throwIfAborted();
|
|
507
|
+
}, { value, force: options.force }));
|
|
543
508
|
if (result === "needsinput") {
|
|
544
509
|
if (value)
|
|
545
|
-
await this._page.keyboard.insertText(value);
|
|
510
|
+
await this._page.keyboard.insertText(progress, value);
|
|
546
511
|
else
|
|
547
|
-
await this._page.keyboard.press("Delete");
|
|
512
|
+
await this._page.keyboard.press(progress, "Delete");
|
|
548
513
|
return "done";
|
|
549
514
|
} else {
|
|
550
515
|
return result;
|
|
551
516
|
}
|
|
552
517
|
}, options);
|
|
553
518
|
}
|
|
554
|
-
async selectText(
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
const controller = new import_progress.ProgressController(metadata, this);
|
|
575
|
-
return controller.run(async (progress) => {
|
|
576
|
-
await this._markAsTargetElement(metadata);
|
|
577
|
-
const result = await this._setInputFiles(progress, inputFileItems);
|
|
578
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
579
|
-
}, this._page._timeoutSettings.timeout(params));
|
|
519
|
+
async selectText(progress, options) {
|
|
520
|
+
const result = await this._retryAction(progress, "selectText", async () => {
|
|
521
|
+
if (!options.force)
|
|
522
|
+
progress.log(" waiting for element to be visible");
|
|
523
|
+
return await progress.race(this.evaluateInUtility(async ([injected, node, { force }]) => {
|
|
524
|
+
if (!force) {
|
|
525
|
+
const checkResult = await injected.checkElementStates(node, ["visible"]);
|
|
526
|
+
if (checkResult)
|
|
527
|
+
return checkResult;
|
|
528
|
+
}
|
|
529
|
+
return injected.selectText(node);
|
|
530
|
+
}, { force: options.force }));
|
|
531
|
+
}, options);
|
|
532
|
+
assertDone(throwRetargetableDOMError(result));
|
|
533
|
+
}
|
|
534
|
+
async setInputFiles(progress, params) {
|
|
535
|
+
const inputFileItems = await progress.race((0, import_fileUploadUtils.prepareFilesForUpload)(this._frame, params));
|
|
536
|
+
await this._markAsTargetElement(progress);
|
|
537
|
+
const result = await this._setInputFiles(progress, inputFileItems);
|
|
538
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
580
539
|
}
|
|
581
540
|
async _setInputFiles(progress, items) {
|
|
582
541
|
const { filePayloads, localPaths, localDirectory } = items;
|
|
583
542
|
const multiple = filePayloads && filePayloads.length > 1 || localPaths && localPaths.length > 1;
|
|
584
|
-
const result = await this.evaluateHandleInUtility(([injected, node, { multiple: multiple2, directoryUpload }]) => {
|
|
543
|
+
const result = await progress.race(this.evaluateHandleInUtility(([injected, node, { multiple: multiple2, directoryUpload }]) => {
|
|
585
544
|
const element = injected.retarget(node, "follow-label");
|
|
586
545
|
if (!element)
|
|
587
546
|
return;
|
|
@@ -595,53 +554,44 @@ class ElementHandle extends js.JSHandle {
|
|
|
595
554
|
if (!directoryUpload && inputElement.webkitdirectory)
|
|
596
555
|
throw injected.createStacklessError("[webkitdirectory] input requires passing a path to a directory");
|
|
597
556
|
return inputElement;
|
|
598
|
-
}, { multiple, directoryUpload: !!localDirectory });
|
|
557
|
+
}, { multiple, directoryUpload: !!localDirectory }));
|
|
599
558
|
if (result === "error:notconnected" || !result.asElement())
|
|
600
559
|
return "error:notconnected";
|
|
601
560
|
const retargeted = result.asElement();
|
|
602
|
-
await this.instrumentation.onBeforeInputAction(this, progress.metadata);
|
|
603
|
-
progress.throwIfAborted();
|
|
561
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
604
562
|
if (localPaths || localDirectory) {
|
|
605
563
|
const localPathsOrDirectory = localDirectory ? [localDirectory] : localPaths;
|
|
606
|
-
await Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK)));
|
|
564
|
+
await progress.race(Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK))));
|
|
607
565
|
const waitForInputEvent = localDirectory ? this.evaluate((node) => new Promise((fulfill) => {
|
|
608
566
|
node.addEventListener("input", fulfill, { once: true });
|
|
609
567
|
})).catch(() => {
|
|
610
568
|
}) : Promise.resolve();
|
|
611
|
-
await this._page.
|
|
612
|
-
await waitForInputEvent;
|
|
569
|
+
await progress.race(this._page.delegate.setInputFilePaths(retargeted, localPathsOrDirectory));
|
|
570
|
+
await progress.race(waitForInputEvent);
|
|
613
571
|
} else {
|
|
614
|
-
await retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), filePayloads);
|
|
572
|
+
await progress.race(retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), filePayloads));
|
|
615
573
|
}
|
|
616
574
|
return "done";
|
|
617
575
|
}
|
|
618
|
-
async focus(
|
|
619
|
-
|
|
620
|
-
await
|
|
621
|
-
|
|
622
|
-
const result = await this._focus(progress);
|
|
623
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
624
|
-
}, 0);
|
|
576
|
+
async focus(progress) {
|
|
577
|
+
await this._markAsTargetElement(progress);
|
|
578
|
+
const result = await this._focus(progress);
|
|
579
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
625
580
|
}
|
|
626
581
|
async _focus(progress, resetSelectionIfNotFocused) {
|
|
627
|
-
progress.
|
|
628
|
-
return await this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused2]) => injected.focusNode(node, resetSelectionIfNotFocused2), resetSelectionIfNotFocused);
|
|
582
|
+
return await progress.race(this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused2]) => injected.focusNode(node, resetSelectionIfNotFocused2), resetSelectionIfNotFocused));
|
|
629
583
|
}
|
|
630
584
|
async _blur(progress) {
|
|
631
|
-
progress.
|
|
632
|
-
return await this.evaluateInUtility(([injected, node]) => injected.blurNode(node), {});
|
|
585
|
+
return await progress.race(this.evaluateInUtility(([injected, node]) => injected.blurNode(node), {}));
|
|
633
586
|
}
|
|
634
|
-
async type(
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
const result = await this._type(progress, text, options);
|
|
639
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
640
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
587
|
+
async type(progress, text, options) {
|
|
588
|
+
await this._markAsTargetElement(progress);
|
|
589
|
+
const result = await this._type(progress, text, options);
|
|
590
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
641
591
|
}
|
|
642
592
|
async _type(progress, text, options) {
|
|
643
593
|
progress.log(`elementHandle.type("${text}")`);
|
|
644
|
-
await this.instrumentation.onBeforeInputAction(this, progress.metadata);
|
|
594
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
645
595
|
const result = await this._focus(
|
|
646
596
|
progress,
|
|
647
597
|
true
|
|
@@ -649,22 +599,18 @@ class ElementHandle extends js.JSHandle {
|
|
|
649
599
|
);
|
|
650
600
|
if (result !== "done")
|
|
651
601
|
return result;
|
|
652
|
-
|
|
653
|
-
await this._page.keyboard.type(text, options);
|
|
602
|
+
await this._page.keyboard.type(progress, text, options);
|
|
654
603
|
return "done";
|
|
655
604
|
}
|
|
656
|
-
async press(
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
const result = await this._press(progress, key, options);
|
|
661
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
662
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
605
|
+
async press(progress, key, options) {
|
|
606
|
+
await this._markAsTargetElement(progress);
|
|
607
|
+
const result = await this._press(progress, key, options);
|
|
608
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
663
609
|
}
|
|
664
610
|
async _press(progress, key, options) {
|
|
665
611
|
progress.log(`elementHandle.press("${key}")`);
|
|
666
|
-
await this.instrumentation.onBeforeInputAction(this, progress.metadata);
|
|
667
|
-
return this._page.
|
|
612
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
613
|
+
return this._page.frameManager.waitForSignalsCreatedBy(progress, !options.noWaitAfter, async () => {
|
|
668
614
|
const result = await this._focus(
|
|
669
615
|
progress,
|
|
670
616
|
true
|
|
@@ -672,33 +618,26 @@ class ElementHandle extends js.JSHandle {
|
|
|
672
618
|
);
|
|
673
619
|
if (result !== "done")
|
|
674
620
|
return result;
|
|
675
|
-
|
|
676
|
-
await this._page.keyboard.press(key, options);
|
|
621
|
+
await this._page.keyboard.press(progress, key, options);
|
|
677
622
|
return "done";
|
|
678
623
|
});
|
|
679
624
|
}
|
|
680
|
-
async check(
|
|
681
|
-
const
|
|
682
|
-
return
|
|
683
|
-
const result = await this._setChecked(progress, true, options);
|
|
684
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
685
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
625
|
+
async check(progress, options) {
|
|
626
|
+
const result = await this._setChecked(progress, true, options);
|
|
627
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
686
628
|
}
|
|
687
|
-
async uncheck(
|
|
688
|
-
const
|
|
689
|
-
return
|
|
690
|
-
const result = await this._setChecked(progress, false, options);
|
|
691
|
-
return assertDone(throwRetargetableDOMError(result));
|
|
692
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
629
|
+
async uncheck(progress, options) {
|
|
630
|
+
const result = await this._setChecked(progress, false, options);
|
|
631
|
+
return assertDone(throwRetargetableDOMError(result));
|
|
693
632
|
}
|
|
694
633
|
async _setChecked(progress, state, options) {
|
|
695
634
|
const isChecked = async () => {
|
|
696
|
-
const result2 = await this.evaluateInUtility(([injected, node]) => injected.elementState(node, "checked"), {});
|
|
635
|
+
const result2 = await progress.race(this.evaluateInUtility(([injected, node]) => injected.elementState(node, "checked"), {}));
|
|
697
636
|
if (result2 === "error:notconnected" || result2.received === "error:notconnected")
|
|
698
637
|
throwElementIsNotAttached();
|
|
699
638
|
return result2.matches;
|
|
700
639
|
};
|
|
701
|
-
await this._markAsTargetElement(progress
|
|
640
|
+
await this._markAsTargetElement(progress);
|
|
702
641
|
if (await isChecked() === state)
|
|
703
642
|
return "done";
|
|
704
643
|
const result = await this._click(progress, { ...options, waitAfter: "disabled" });
|
|
@@ -711,17 +650,13 @@ class ElementHandle extends js.JSHandle {
|
|
|
711
650
|
return "done";
|
|
712
651
|
}
|
|
713
652
|
async boundingBox() {
|
|
714
|
-
return this._page.
|
|
653
|
+
return this._page.delegate.getBoundingBox(this);
|
|
715
654
|
}
|
|
716
|
-
async ariaSnapshot(
|
|
717
|
-
return await this.evaluateInUtility(([injected, element
|
|
655
|
+
async ariaSnapshot() {
|
|
656
|
+
return await this.evaluateInUtility(([injected, element]) => injected.ariaSnapshot(element, { mode: "expect" }), {});
|
|
718
657
|
}
|
|
719
|
-
async screenshot(
|
|
720
|
-
|
|
721
|
-
return controller.run(
|
|
722
|
-
(progress) => this._page._screenshotter.screenshotElement(progress, this, options),
|
|
723
|
-
this._page._timeoutSettings.timeout(options)
|
|
724
|
-
);
|
|
658
|
+
async screenshot(progress, options) {
|
|
659
|
+
return await this._page.screenshotter.screenshotElement(progress, this, options);
|
|
725
660
|
}
|
|
726
661
|
async querySelector(selector, options) {
|
|
727
662
|
return this._frame.selectors.query(selector, options, this);
|
|
@@ -735,42 +670,39 @@ class ElementHandle extends js.JSHandle {
|
|
|
735
670
|
async evalOnSelectorAll(selector, expression, isFunction, arg) {
|
|
736
671
|
return this._frame.evalOnSelectorAll(selector, expression, isFunction, arg, this);
|
|
737
672
|
}
|
|
738
|
-
async isVisible(
|
|
739
|
-
return this._frame.isVisible(
|
|
673
|
+
async isVisible(progress) {
|
|
674
|
+
return this._frame.isVisible(progress, ":scope", {}, this);
|
|
740
675
|
}
|
|
741
|
-
async isHidden(
|
|
742
|
-
return this._frame.isHidden(
|
|
676
|
+
async isHidden(progress) {
|
|
677
|
+
return this._frame.isHidden(progress, ":scope", {}, this);
|
|
743
678
|
}
|
|
744
|
-
async isEnabled(
|
|
745
|
-
return this._frame.isEnabled(
|
|
679
|
+
async isEnabled(progress) {
|
|
680
|
+
return this._frame.isEnabled(progress, ":scope", {}, this);
|
|
746
681
|
}
|
|
747
|
-
async isDisabled(
|
|
748
|
-
return this._frame.isDisabled(
|
|
682
|
+
async isDisabled(progress) {
|
|
683
|
+
return this._frame.isDisabled(progress, ":scope", {}, this);
|
|
749
684
|
}
|
|
750
|
-
async isEditable(
|
|
751
|
-
return this._frame.isEditable(
|
|
685
|
+
async isEditable(progress) {
|
|
686
|
+
return this._frame.isEditable(progress, ":scope", {}, this);
|
|
752
687
|
}
|
|
753
|
-
async isChecked(
|
|
754
|
-
return this._frame.isChecked(
|
|
688
|
+
async isChecked(progress) {
|
|
689
|
+
return this._frame.isChecked(progress, ":scope", {}, this);
|
|
755
690
|
}
|
|
756
|
-
async waitForElementState(
|
|
757
|
-
const
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
}, {});
|
|
765
|
-
assertDone(throwRetargetableDOMError(result));
|
|
766
|
-
}, this._page._timeoutSettings.timeout(options));
|
|
691
|
+
async waitForElementState(progress, state) {
|
|
692
|
+
const actionName = `wait for ${state}`;
|
|
693
|
+
const result = await this._retryAction(progress, actionName, async () => {
|
|
694
|
+
return await progress.race(this.evaluateInUtility(async ([injected, node, state2]) => {
|
|
695
|
+
return await injected.checkElementStates(node, [state2]) || "done";
|
|
696
|
+
}, state));
|
|
697
|
+
}, {});
|
|
698
|
+
assertDone(throwRetargetableDOMError(result));
|
|
767
699
|
}
|
|
768
|
-
async waitForSelector(
|
|
769
|
-
return this._frame.waitForSelector(
|
|
700
|
+
async waitForSelector(progress, selector, options) {
|
|
701
|
+
return await this._frame.waitForSelector(progress, selector, true, options, this);
|
|
770
702
|
}
|
|
771
703
|
async _adoptTo(context) {
|
|
772
704
|
if (this._context !== context) {
|
|
773
|
-
const adopted = await this._page.
|
|
705
|
+
const adopted = await this._page.delegate.adoptElementHandle(this, context);
|
|
774
706
|
this.dispose();
|
|
775
707
|
return adopted;
|
|
776
708
|
}
|