patchright-core 1.57.0 → 1.59.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 +2688 -297
- package/browsers.json +23 -22
- package/lib/bootstrap.js +77 -0
- package/lib/cli/browserActions.js +308 -0
- package/lib/cli/driver.js +3 -2
- package/lib/cli/installActions.js +171 -0
- package/lib/cli/program.js +48 -413
- package/lib/client/android.js +4 -4
- package/lib/client/api.js +3 -0
- package/lib/client/browser.js +11 -5
- package/lib/client/browserContext.js +20 -23
- package/lib/client/browserType.js +23 -54
- package/lib/client/cdpSession.js +6 -2
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/clientHelper.js +2 -1
- package/lib/client/clock.js +0 -1
- package/lib/client/{webSocket.js → connect.js} +57 -7
- package/lib/client/connection.js +8 -0
- package/lib/client/consoleMessage.js +3 -0
- package/lib/client/debugger.js +57 -0
- package/lib/client/dialog.js +8 -1
- package/lib/client/disposable.js +76 -0
- package/lib/client/electron.js +1 -0
- package/lib/client/elementHandle.js +1 -1
- package/lib/client/events.js +3 -0
- package/lib/client/fetch.js +2 -4
- package/lib/client/frame.js +9 -13
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +4 -8
- package/lib/client/locator.js +13 -36
- package/lib/client/network.js +14 -11
- package/lib/client/page.js +44 -50
- package/lib/client/screencast.js +88 -0
- package/lib/client/selectors.js +3 -1
- package/lib/client/tracing.js +11 -5
- package/lib/client/video.js +13 -20
- package/lib/client/worker.js +6 -6
- package/lib/generated/bindingsControllerSource.js +1 -1
- 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 +1 -1
- package/lib/generated/utilityScriptSource.js +1 -1
- package/lib/mcpBundle.js +78 -0
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/serializers.js +5 -0
- package/lib/protocol/validator.js +228 -58
- package/lib/protocol/validatorPrimitives.js +1 -1
- package/lib/remote/playwrightConnection.js +10 -8
- package/lib/remote/playwrightPipeServer.js +100 -0
- package/lib/remote/playwrightServer.js +14 -10
- package/lib/remote/playwrightWebSocketServer.js +73 -0
- package/lib/remote/serverTransport.js +96 -0
- package/lib/server/android/android.js +2 -2
- package/lib/server/artifact.js +1 -1
- package/lib/server/bidi/bidiBrowser.js +80 -14
- package/lib/server/bidi/bidiChromium.js +23 -14
- package/lib/server/bidi/bidiConnection.js +1 -0
- package/lib/server/bidi/bidiDeserializer.js +116 -0
- package/lib/server/bidi/bidiExecutionContext.js +75 -29
- package/lib/server/bidi/bidiFirefox.js +6 -8
- package/lib/server/bidi/bidiNetworkManager.js +40 -12
- package/lib/server/bidi/bidiPage.js +67 -40
- package/lib/server/bidi/third_party/bidiProtocolCore.js +1 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +3 -1
- package/lib/server/browser.js +84 -21
- package/lib/server/browserContext.js +137 -77
- package/lib/server/browserType.js +26 -16
- package/lib/server/chromium/chromium.js +28 -31
- package/lib/server/chromium/chromiumSwitches.js +16 -4
- package/lib/server/chromium/crBrowser.js +40 -27
- package/lib/server/chromium/crConnection.js +0 -5
- package/lib/server/chromium/crDevTools.js +1 -2
- package/lib/server/chromium/crNetworkManager.js +54 -229
- package/lib/server/chromium/crPage.js +74 -260
- package/lib/server/chromium/crServiceWorker.js +7 -14
- package/lib/server/clock.js +33 -41
- package/lib/server/codegen/javascript.js +6 -29
- package/lib/server/console.js +5 -1
- package/lib/server/debugController.js +12 -6
- package/lib/server/debugger.js +40 -47
- package/lib/server/deviceDescriptorsSource.json +137 -137
- package/lib/server/dispatchers/browserContextDispatcher.js +30 -30
- package/lib/server/dispatchers/browserDispatcher.js +11 -5
- package/lib/server/dispatchers/browserTypeDispatcher.js +7 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +4 -1
- package/lib/server/dispatchers/debuggerDispatcher.js +84 -0
- package/lib/server/dispatchers/dispatcher.js +7 -14
- package/lib/server/dispatchers/disposableDispatcher.js +39 -0
- package/lib/server/dispatchers/electronDispatcher.js +2 -1
- package/lib/server/dispatchers/frameDispatcher.js +7 -7
- package/lib/server/dispatchers/localUtilsDispatcher.js +37 -1
- package/lib/server/dispatchers/networkDispatchers.js +6 -5
- package/lib/server/dispatchers/pageDispatcher.js +101 -34
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +4 -5
- package/lib/server/disposable.js +41 -0
- package/lib/server/dom.js +56 -29
- package/lib/server/download.js +3 -2
- package/lib/server/electron/electron.js +17 -9
- package/lib/server/firefox/ffBrowser.js +9 -29
- package/lib/server/firefox/ffConnection.js +0 -5
- package/lib/server/firefox/ffInput.js +21 -5
- package/lib/server/firefox/ffNetworkManager.js +4 -4
- package/lib/server/firefox/ffPage.js +27 -33
- package/lib/server/firefox/firefox.js +6 -8
- package/lib/server/frameSelectors.js +14 -169
- package/lib/server/frames.js +263 -551
- package/lib/server/har/harRecorder.js +2 -2
- package/lib/server/har/harTracer.js +5 -4
- package/lib/server/input.js +49 -4
- package/lib/server/instrumentation.js +8 -0
- package/lib/server/javascript.js +6 -22
- package/lib/server/launchApp.js +0 -1
- package/lib/server/localUtils.js +6 -6
- package/lib/server/network.js +59 -20
- package/lib/server/overlay.js +138 -0
- package/lib/server/page.js +179 -157
- package/lib/server/progress.js +32 -6
- package/lib/server/recorder/recorderApp.js +84 -104
- package/lib/server/recorder.js +76 -40
- package/lib/server/registry/browserFetcher.js +6 -4
- package/lib/server/registry/index.js +222 -226
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +3 -0
- package/lib/server/screencast.js +137 -0
- package/lib/server/trace/recorder/snapshotter.js +2 -2
- package/lib/server/trace/recorder/snapshotterInjected.js +21 -1
- package/lib/server/trace/recorder/tracing.js +98 -47
- package/lib/server/trace/viewer/traceViewer.js +24 -21
- package/lib/server/usKeyboardLayout.js +7 -0
- package/lib/server/utils/comparators.js +1 -1
- package/lib/server/utils/disposable.js +32 -0
- package/lib/server/utils/eventsHelper.js +3 -1
- package/lib/server/utils/expectUtils.js +87 -2
- package/lib/server/utils/fileUtils.js +16 -2
- package/lib/server/utils/happyEyeballs.js +15 -12
- package/lib/server/utils/httpServer.js +10 -23
- package/lib/server/utils/network.js +39 -29
- package/lib/server/utils/processLauncher.js +8 -6
- package/lib/server/utils/zipFile.js +2 -2
- package/lib/server/videoRecorder.js +194 -0
- package/lib/server/webkit/webkit.js +4 -6
- package/lib/server/webkit/wkBrowser.js +1 -10
- package/lib/server/webkit/wkConnection.js +1 -6
- package/lib/server/webkit/wkInterceptableRequest.js +29 -1
- package/lib/server/webkit/wkPage.js +88 -57
- package/lib/server/webkit/wkWorkers.js +2 -1
- package/lib/serverRegistry.js +156 -0
- package/lib/tools/backend/browserBackend.js +79 -0
- package/lib/tools/backend/common.js +63 -0
- package/lib/tools/backend/config.js +41 -0
- package/lib/tools/backend/console.js +66 -0
- package/lib/tools/backend/context.js +296 -0
- package/lib/tools/backend/cookies.js +152 -0
- package/lib/tools/backend/devtools.js +69 -0
- package/lib/tools/backend/dialogs.js +59 -0
- package/lib/tools/backend/evaluate.js +64 -0
- package/lib/tools/backend/files.js +60 -0
- package/lib/tools/backend/form.js +64 -0
- package/lib/tools/backend/keyboard.js +155 -0
- package/lib/tools/backend/logFile.js +95 -0
- package/lib/tools/backend/mouse.js +168 -0
- package/lib/tools/backend/navigate.js +106 -0
- package/lib/tools/backend/network.js +135 -0
- package/lib/tools/backend/pdf.js +48 -0
- package/lib/tools/backend/response.js +305 -0
- package/lib/tools/backend/route.js +140 -0
- package/lib/tools/backend/runCode.js +77 -0
- package/lib/tools/backend/screenshot.js +88 -0
- package/lib/tools/backend/sessionLog.js +74 -0
- package/lib/tools/backend/snapshot.js +208 -0
- package/lib/tools/backend/storage.js +68 -0
- package/lib/tools/backend/tab.js +445 -0
- package/lib/tools/backend/tabs.js +67 -0
- package/lib/tools/backend/tool.js +47 -0
- package/lib/tools/backend/tools.js +102 -0
- package/lib/tools/backend/tracing.js +78 -0
- package/lib/tools/backend/utils.js +83 -0
- package/lib/tools/backend/verify.js +151 -0
- package/lib/tools/backend/video.js +98 -0
- package/lib/tools/backend/wait.js +63 -0
- package/lib/tools/backend/webstorage.js +223 -0
- package/lib/tools/cli-client/cli.js +6 -0
- package/lib/tools/cli-client/help.json +399 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/program.js +350 -0
- package/lib/tools/cli-client/registry.js +176 -0
- package/lib/tools/cli-client/session.js +289 -0
- package/lib/tools/cli-client/skill/SKILL.md +328 -0
- package/lib/tools/cli-client/skill/references/element-attributes.md +23 -0
- package/lib/tools/cli-client/skill/references/playwright-tests.md +39 -0
- package/lib/tools/cli-client/skill/references/request-mocking.md +87 -0
- package/lib/tools/cli-client/skill/references/running-code.md +231 -0
- package/lib/tools/cli-client/skill/references/session-management.md +169 -0
- package/lib/tools/cli-client/skill/references/storage-state.md +275 -0
- package/lib/tools/cli-client/skill/references/test-generation.md +88 -0
- package/lib/tools/cli-client/skill/references/tracing.md +139 -0
- package/lib/tools/cli-client/skill/references/video-recording.md +143 -0
- package/lib/tools/cli-daemon/command.js +73 -0
- package/lib/tools/cli-daemon/commands.js +956 -0
- package/lib/tools/cli-daemon/daemon.js +157 -0
- package/lib/tools/cli-daemon/helpGenerator.js +177 -0
- package/lib/tools/cli-daemon/program.js +129 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/dashboard/dashboardApp.js +284 -0
- package/lib/tools/dashboard/dashboardController.js +296 -0
- package/lib/tools/exports.js +60 -0
- package/lib/tools/mcp/browserFactory.js +233 -0
- package/lib/tools/mcp/cdpRelay.js +352 -0
- package/lib/tools/mcp/cli-stub.js +7 -0
- package/lib/tools/mcp/config.d.js +16 -0
- package/lib/tools/mcp/config.js +446 -0
- package/lib/tools/mcp/configIni.js +189 -0
- package/lib/tools/mcp/extensionContextFactory.js +55 -0
- package/lib/tools/mcp/index.js +62 -0
- package/lib/tools/mcp/log.js +35 -0
- package/lib/tools/mcp/program.js +107 -0
- package/lib/tools/mcp/protocol.js +28 -0
- package/lib/tools/mcp/watchdog.js +44 -0
- package/lib/tools/trace/SKILL.md +171 -0
- package/lib/tools/trace/installSkill.js +48 -0
- package/lib/tools/trace/traceActions.js +142 -0
- package/lib/tools/trace/traceAttachments.js +69 -0
- package/lib/tools/trace/traceCli.js +87 -0
- package/lib/tools/trace/traceConsole.js +97 -0
- package/lib/tools/trace/traceErrors.js +55 -0
- package/lib/tools/trace/traceOpen.js +69 -0
- package/lib/tools/trace/traceParser.js +96 -0
- package/lib/tools/trace/traceRequests.js +182 -0
- package/lib/tools/trace/traceScreenshot.js +68 -0
- package/lib/tools/trace/traceSnapshot.js +149 -0
- package/lib/tools/trace/traceUtils.js +153 -0
- package/lib/tools/utils/connect.js +32 -0
- package/lib/tools/utils/mcp/http.js +152 -0
- package/lib/tools/utils/mcp/server.js +230 -0
- package/lib/tools/utils/mcp/tool.js +47 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +60 -2
- package/lib/utils/isomorphic/formatUtils.js +64 -0
- package/lib/utils/isomorphic/jsonSchema.js +89 -0
- package/lib/utils/isomorphic/lruCache.js +51 -0
- package/lib/utils/isomorphic/mimeType.js +7 -2
- package/lib/utils/isomorphic/protocolFormatter.js +2 -2
- package/lib/utils/isomorphic/protocolMetainfo.js +127 -98
- package/lib/utils/isomorphic/stringUtils.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +3 -3
- package/lib/utils/isomorphic/trace/entries.js +16 -0
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +492 -0
- package/lib/utils/isomorphic/trace/snapshotServer.js +120 -0
- package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -0
- package/lib/utils/isomorphic/trace/traceLoader.js +132 -0
- package/lib/utils/isomorphic/trace/traceModel.js +366 -0
- package/lib/utils/isomorphic/trace/traceModernizer.js +401 -0
- package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +54 -1
- package/lib/utils/isomorphic/utilityScriptSerializers.js +11 -0
- package/lib/utils/isomorphic/yaml.js +84 -0
- package/lib/utils.js +8 -2
- package/lib/utilsBundle.js +5 -26
- package/lib/utilsBundleImpl/index.js +172 -173
- package/lib/vite/dashboard/assets/index-BAOybkp8.js +50 -0
- package/lib/vite/dashboard/assets/index-CZAYOG76.css +1 -0
- package/lib/vite/dashboard/index.html +28 -0
- package/lib/vite/htmlReport/index.html +2 -70
- package/lib/vite/htmlReport/report.css +1 -0
- package/lib/vite/htmlReport/report.js +72 -0
- package/lib/vite/recorder/assets/codeMirrorModule-C8KMvO9L.js +32 -0
- package/lib/vite/recorder/assets/{codeMirrorModule-C3UTv-Ge.css → codeMirrorModule-DYBRYzYX.css} +1 -1
- package/lib/vite/recorder/assets/{index-Ri0uHF7I.css → index-BSjZa4pk.css} +1 -1
- package/lib/vite/recorder/assets/index-CqAYX1I3.js +193 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-DS0FLvoc.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-GTWI-W_B.js +262 -0
- package/lib/vite/traceViewer/{codeMirrorModule.C3UTv-Ge.css → codeMirrorModule.DYBRYzYX.css} +1 -1
- package/lib/vite/traceViewer/defaultSettingsView.B4dS75f0.css +1 -0
- package/lib/vite/traceViewer/index.CzXZzn5A.css +1 -0
- package/lib/vite/traceViewer/index.Dtstcb7U.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +5 -3
- package/lib/vite/traceViewer/uiMode.Vipi55dB.js +6 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/lib/zipBundleImpl.js +2 -2
- package/lib/zodBundle.js +39 -0
- package/lib/zodBundleImpl.js +40 -0
- package/package.json +7 -1
- package/types/protocol.d.ts +1696 -221
- package/types/types.d.ts +879 -112
- package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
- package/lib/server/chromium/videoRecorder.js +0 -115
- package/lib/server/pageBinding.js +0 -87
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +0 -248
- package/lib/vite/recorder/assets/codeMirrorModule-CBbSe-ZI.js +0 -25
- package/lib/vite/recorder/assets/index-CpZVd2nA.js +0 -193
- package/lib/vite/traceViewer/assets/codeMirrorModule-DHz0wP2C.js +0 -25
- package/lib/vite/traceViewer/assets/defaultSettingsView-WsZP88O6.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.ConWv5KN.css +0 -1
- package/lib/vite/traceViewer/index.C4Y3Aw8n.css +0 -1
- package/lib/vite/traceViewer/index.C8xAeo93.js +0 -2
- package/lib/vite/traceViewer/uiMode.BltraIJB.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
package/lib/client/harRouter.js
CHANGED
|
@@ -52,9 +52,21 @@ class HarRouter {
|
|
|
52
52
|
if (response.action === "fulfill") {
|
|
53
53
|
if (response.status === -1)
|
|
54
54
|
return;
|
|
55
|
+
const transformedHeaders = response.headers.reduce((headersMap, { name, value }) => {
|
|
56
|
+
if (name.toLowerCase() !== "set-cookie") {
|
|
57
|
+
headersMap[name] = value;
|
|
58
|
+
} else {
|
|
59
|
+
if (!headersMap["set-cookie"])
|
|
60
|
+
headersMap["set-cookie"] = value;
|
|
61
|
+
else
|
|
62
|
+
headersMap["set-cookie"] += `
|
|
63
|
+
${value}`;
|
|
64
|
+
}
|
|
65
|
+
return headersMap;
|
|
66
|
+
}, {});
|
|
55
67
|
await route.fulfill({
|
|
56
68
|
status: response.status,
|
|
57
|
-
headers:
|
|
69
|
+
headers: transformedHeaders,
|
|
58
70
|
body: response.body
|
|
59
71
|
});
|
|
60
72
|
return;
|
package/lib/client/jsHandle.js
CHANGED
|
@@ -36,16 +36,12 @@ class JSHandle extends import_channelOwner.ChannelOwner {
|
|
|
36
36
|
this._preview = this._initializer.preview;
|
|
37
37
|
this._channel.on("previewUpdated", ({ preview }) => this._preview = preview);
|
|
38
38
|
}
|
|
39
|
-
async evaluate(pageFunction, arg
|
|
40
|
-
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg)
|
|
39
|
+
async evaluate(pageFunction, arg) {
|
|
40
|
+
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg) });
|
|
41
41
|
return parseResult(result.value);
|
|
42
42
|
}
|
|
43
|
-
async
|
|
44
|
-
const result = await this._channel.
|
|
45
|
-
return parseResult(result.value);
|
|
46
|
-
}
|
|
47
|
-
async evaluateHandle(pageFunction, arg, isolatedContext = true) {
|
|
48
|
-
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg), isolatedContext });
|
|
43
|
+
async evaluateHandle(pageFunction, arg) {
|
|
44
|
+
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: serializeArgument(arg) });
|
|
49
45
|
return JSHandle.from(result.handle);
|
|
50
46
|
}
|
|
51
47
|
async getProperty(propertyName) {
|
package/lib/client/locator.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(locator_exports, {
|
|
|
24
24
|
testIdAttributeName: () => testIdAttributeName
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(locator_exports);
|
|
27
|
-
var import_jsHandle = require("./jsHandle");
|
|
28
27
|
var import_elementHandle = require("./elementHandle");
|
|
29
28
|
var import_locatorGenerators = require("../utils/isomorphic/locatorGenerators");
|
|
30
29
|
var import_locatorUtils = require("../utils/isomorphic/locatorUtils");
|
|
@@ -98,37 +97,14 @@ class Locator {
|
|
|
98
97
|
...options
|
|
99
98
|
});
|
|
100
99
|
}
|
|
101
|
-
async evaluate(pageFunction, arg, options
|
|
102
|
-
return await this._withElement(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
})).value
|
|
110
|
-
),
|
|
111
|
-
{ title: "Evaluate", timeout: options?.timeout }
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
async _evaluateFunction(functionDeclaration, options) {
|
|
115
|
-
return await this._withElement((h) => h._evaluateFunction(functionDeclaration), { title: "Evaluate", timeout: options?.timeout });
|
|
116
|
-
}
|
|
117
|
-
async evaluateAll(pageFunction, arg, isolatedContext = true) {
|
|
118
|
-
return await this._frame.$$eval(this._selector, pageFunction, arg, isolatedContext);
|
|
119
|
-
}
|
|
120
|
-
async evaluateHandle(pageFunction, arg, options, isolatedContext = true) {
|
|
121
|
-
return await this._withElement(
|
|
122
|
-
async (h) => import_jsHandle.JSHandle.from(
|
|
123
|
-
(await h._channel.evaluateExpressionHandle({
|
|
124
|
-
expression: String(pageFunction),
|
|
125
|
-
isFunction: typeof pageFunction === "function",
|
|
126
|
-
arg: (0, import_jsHandle.serializeArgument)(arg),
|
|
127
|
-
isolatedContext
|
|
128
|
-
})).handle
|
|
129
|
-
),
|
|
130
|
-
{ title: "Evaluate", timeout: options?.timeout }
|
|
131
|
-
);
|
|
100
|
+
async evaluate(pageFunction, arg, options) {
|
|
101
|
+
return await this._withElement((h) => h.evaluate(pageFunction, arg), { title: "Evaluate", timeout: options?.timeout });
|
|
102
|
+
}
|
|
103
|
+
async evaluateAll(pageFunction, arg) {
|
|
104
|
+
return await this._frame.$$eval(this._selector, pageFunction, arg);
|
|
105
|
+
}
|
|
106
|
+
async evaluateHandle(pageFunction, arg, options) {
|
|
107
|
+
return await this._withElement((h) => h.evaluateHandle(pageFunction, arg), { title: "Evaluate", timeout: options?.timeout });
|
|
132
108
|
}
|
|
133
109
|
async fill(value, options = {}) {
|
|
134
110
|
return await this._frame.fill(this._selector, value, { strict: true, ...options });
|
|
@@ -220,8 +196,9 @@ class Locator {
|
|
|
220
196
|
async count(_options) {
|
|
221
197
|
return await this._frame._queryCount(this._selector, _options);
|
|
222
198
|
}
|
|
223
|
-
async
|
|
224
|
-
|
|
199
|
+
async normalize() {
|
|
200
|
+
const { resolvedSelector } = await this._frame._channel.resolveSelector({ selector: this._selector });
|
|
201
|
+
return new Locator(this._frame, resolvedSelector);
|
|
225
202
|
}
|
|
226
203
|
async getAttribute(name, options) {
|
|
227
204
|
return await this._frame.getAttribute(this._selector, name, { strict: true, ...options });
|
|
@@ -263,8 +240,8 @@ class Locator {
|
|
|
263
240
|
const mask = options.mask;
|
|
264
241
|
return await this._withElement((h, timeout) => h.screenshot({ ...options, mask, timeout }), { title: "Screenshot", timeout: options.timeout });
|
|
265
242
|
}
|
|
266
|
-
async ariaSnapshot(options) {
|
|
267
|
-
const result = await this._frame._channel.ariaSnapshot({
|
|
243
|
+
async ariaSnapshot(options = {}) {
|
|
244
|
+
const result = await this._frame._channel.ariaSnapshot({ timeout: this._frame._timeout(options), mode: options.mode, selector: this._selector, depth: options.depth });
|
|
268
245
|
return result.snapshot;
|
|
269
246
|
}
|
|
270
247
|
async scrollIntoViewIfNeeded(options = {}) {
|
package/lib/client/network.js
CHANGED
|
@@ -50,8 +50,8 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
50
50
|
this._redirectedFrom = null;
|
|
51
51
|
this._redirectedTo = null;
|
|
52
52
|
this._failureText = null;
|
|
53
|
+
this._response = null;
|
|
53
54
|
this._fallbackOverrides = {};
|
|
54
|
-
this._hasResponse = false;
|
|
55
55
|
this._redirectedFrom = Request.fromNullable(initializer.redirectedFrom);
|
|
56
56
|
if (this._redirectedFrom)
|
|
57
57
|
this._redirectedFrom._redirectedTo = this;
|
|
@@ -67,8 +67,6 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
67
67
|
responseStart: -1,
|
|
68
68
|
responseEnd: -1
|
|
69
69
|
};
|
|
70
|
-
this._hasResponse = this._initializer.hasResponse;
|
|
71
|
-
this._channel.on("response", () => this._hasResponse = true);
|
|
72
70
|
}
|
|
73
71
|
static from(request) {
|
|
74
72
|
return request._object;
|
|
@@ -142,6 +140,9 @@ class Request extends import_channelOwner.ChannelOwner {
|
|
|
142
140
|
async _internalResponse() {
|
|
143
141
|
return Response.fromNullable((await this._channel.response()).response);
|
|
144
142
|
}
|
|
143
|
+
existingResponse() {
|
|
144
|
+
return this._response;
|
|
145
|
+
}
|
|
145
146
|
frame() {
|
|
146
147
|
if (!this._initializer.frame) {
|
|
147
148
|
(0, import_assert.assert)(this.serviceWorker());
|
|
@@ -465,10 +466,9 @@ class WebSocketRouteHandler {
|
|
|
465
466
|
const patterns = [];
|
|
466
467
|
let all = false;
|
|
467
468
|
for (const handler of handlers) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
patterns.push({ regexSource: handler.url.source, regexFlags: handler.url.flags });
|
|
469
|
+
const serialized = (0, import_urlMatch.serializeURLMatch)(handler.url);
|
|
470
|
+
if (serialized)
|
|
471
|
+
patterns.push(serialized);
|
|
472
472
|
else
|
|
473
473
|
all = true;
|
|
474
474
|
}
|
|
@@ -491,6 +491,7 @@ class Response extends import_channelOwner.ChannelOwner {
|
|
|
491
491
|
this._finishedPromise = new import_manualPromise.ManualPromise();
|
|
492
492
|
this._provisionalHeaders = new RawHeaders(initializer.headers);
|
|
493
493
|
this._request = Request.from(this._initializer.request);
|
|
494
|
+
this._request._response = this;
|
|
494
495
|
Object.assign(this._request._timing, this._initializer.timing);
|
|
495
496
|
}
|
|
496
497
|
static from(response) {
|
|
@@ -566,6 +567,9 @@ class Response extends import_channelOwner.ChannelOwner {
|
|
|
566
567
|
async securityDetails() {
|
|
567
568
|
return (await this._channel.securityDetails()).value || null;
|
|
568
569
|
}
|
|
570
|
+
async httpVersion() {
|
|
571
|
+
return (await this._channel.httpVersion()).value;
|
|
572
|
+
}
|
|
569
573
|
}
|
|
570
574
|
class WebSocket extends import_channelOwner.ChannelOwner {
|
|
571
575
|
static from(webSocket) {
|
|
@@ -638,10 +642,9 @@ class RouteHandler {
|
|
|
638
642
|
const patterns = [];
|
|
639
643
|
let all = false;
|
|
640
644
|
for (const handler of handlers) {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
patterns.push({ regexSource: handler.url.source, regexFlags: handler.url.flags });
|
|
645
|
+
const serialized = (0, import_urlMatch.serializeURLMatch)(handler.url);
|
|
646
|
+
if (serialized)
|
|
647
|
+
patterns.push(serialized);
|
|
645
648
|
else
|
|
646
649
|
all = true;
|
|
647
650
|
}
|
package/lib/client/page.js
CHANGED
|
@@ -26,6 +26,7 @@ var import_artifact = require("./artifact");
|
|
|
26
26
|
var import_channelOwner = require("./channelOwner");
|
|
27
27
|
var import_clientHelper = require("./clientHelper");
|
|
28
28
|
var import_coverage = require("./coverage");
|
|
29
|
+
var import_disposable = require("./disposable");
|
|
29
30
|
var import_download = require("./download");
|
|
30
31
|
var import_elementHandle = require("./elementHandle");
|
|
31
32
|
var import_errors = require("./errors");
|
|
@@ -37,6 +38,7 @@ var import_input = require("./input");
|
|
|
37
38
|
var import_jsHandle = require("./jsHandle");
|
|
38
39
|
var import_network = require("./network");
|
|
39
40
|
var import_video = require("./video");
|
|
41
|
+
var import_screencast = require("./screencast");
|
|
40
42
|
var import_waiter = require("./waiter");
|
|
41
43
|
var import_worker = require("./worker");
|
|
42
44
|
var import_timeoutSettings = require("./timeoutSettings");
|
|
@@ -58,11 +60,10 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
58
60
|
this._routes = [];
|
|
59
61
|
this._webSocketRoutes = [];
|
|
60
62
|
this._bindings = /* @__PURE__ */ new Map();
|
|
61
|
-
this._video = null;
|
|
62
63
|
this._closeWasCalled = false;
|
|
63
64
|
this._harRouters = [];
|
|
64
65
|
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
65
|
-
this.
|
|
66
|
+
this._instrumentation.onPage(this);
|
|
66
67
|
this._browserContext = parent;
|
|
67
68
|
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform, this._browserContext._timeoutSettings);
|
|
68
69
|
this.keyboard = new import_input.Keyboard(this);
|
|
@@ -76,6 +77,8 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
76
77
|
this._viewportSize = initializer.viewportSize;
|
|
77
78
|
this._closed = initializer.isClosed;
|
|
78
79
|
this._opener = Page.fromNullable(initializer.opener);
|
|
80
|
+
this._video = new import_video.Video(this, this._connection, initializer.video ? import_artifact.Artifact.from(initializer.video) : void 0);
|
|
81
|
+
this.screencast = new import_screencast.Screencast(this);
|
|
79
82
|
this._channel.on("bindingCall", ({ binding }) => this._onBinding(BindingCall.from(binding)));
|
|
80
83
|
this._channel.on("close", () => this._onClose());
|
|
81
84
|
this._channel.on("crash", () => this._onCrash());
|
|
@@ -89,10 +92,6 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
89
92
|
this._channel.on("locatorHandlerTriggered", ({ uid }) => this._onLocatorHandlerTriggered(uid));
|
|
90
93
|
this._channel.on("route", ({ route }) => this._onRoute(import_network.Route.from(route)));
|
|
91
94
|
this._channel.on("webSocketRoute", ({ webSocketRoute }) => this._onWebSocketRoute(import_network.WebSocketRoute.from(webSocketRoute)));
|
|
92
|
-
this._channel.on("video", ({ artifact }) => {
|
|
93
|
-
const artifactObject = import_artifact.Artifact.from(artifact);
|
|
94
|
-
this._forceVideo()._artifactReady(artifactObject);
|
|
95
|
-
});
|
|
96
95
|
this._channel.on("viewportSizeChanged", ({ viewportSize }) => this._viewportSize = viewportSize);
|
|
97
96
|
this._channel.on("webSocket", ({ webSocket }) => this.emit(import_events.Events.Page.WebSocket, import_network.WebSocket.from(webSocket)));
|
|
98
97
|
this._channel.on("worker", ({ worker }) => this._onWorker(import_worker.Worker.from(worker)));
|
|
@@ -133,7 +132,7 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
133
132
|
route._context = this.context();
|
|
134
133
|
const routeHandlers = this._routes.slice();
|
|
135
134
|
for (const routeHandler of routeHandlers) {
|
|
136
|
-
if (this._closeWasCalled || this._browserContext.
|
|
135
|
+
if (this._closeWasCalled || this._browserContext.isClosed())
|
|
137
136
|
return;
|
|
138
137
|
if (!routeHandler.matches(route.request().url()))
|
|
139
138
|
continue;
|
|
@@ -210,15 +209,17 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
210
209
|
setDefaultTimeout(timeout) {
|
|
211
210
|
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
212
211
|
}
|
|
213
|
-
_forceVideo() {
|
|
214
|
-
if (!this._video)
|
|
215
|
-
this._video = new import_video.Video(this, this._connection);
|
|
216
|
-
return this._video;
|
|
217
|
-
}
|
|
218
212
|
video() {
|
|
219
213
|
if (!this._browserContext._options.recordVideo)
|
|
220
214
|
return null;
|
|
221
|
-
return this.
|
|
215
|
+
return this._video;
|
|
216
|
+
}
|
|
217
|
+
async pickLocator() {
|
|
218
|
+
const { selector } = await this._channel.pickLocator({});
|
|
219
|
+
return this.locator(selector);
|
|
220
|
+
}
|
|
221
|
+
async cancelPickLocator() {
|
|
222
|
+
await this._channel.cancelPickLocator({});
|
|
222
223
|
}
|
|
223
224
|
async $(selector, options) {
|
|
224
225
|
return await this._mainFrame.$(selector, options);
|
|
@@ -229,9 +230,9 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
229
230
|
async dispatchEvent(selector, type, eventInit, options) {
|
|
230
231
|
return await this._mainFrame.dispatchEvent(selector, type, eventInit, options);
|
|
231
232
|
}
|
|
232
|
-
async evaluateHandle(pageFunction, arg
|
|
233
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
234
|
-
return await this._mainFrame.evaluateHandle(pageFunction, arg
|
|
233
|
+
async evaluateHandle(pageFunction, arg) {
|
|
234
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
235
|
+
return await this._mainFrame.evaluateHandle(pageFunction, arg);
|
|
235
236
|
}
|
|
236
237
|
async $eval(selector, pageFunction, arg) {
|
|
237
238
|
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
@@ -251,15 +252,15 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
251
252
|
return await this._mainFrame.addStyleTag(options);
|
|
252
253
|
}
|
|
253
254
|
async exposeFunction(name, callback) {
|
|
254
|
-
await this.
|
|
255
|
-
await this._channel.exposeBinding({ name });
|
|
255
|
+
const result = await this._channel.exposeBinding({ name });
|
|
256
256
|
const binding = (source, ...args) => callback(...args);
|
|
257
257
|
this._bindings.set(name, binding);
|
|
258
|
+
return import_disposable.DisposableObject.from(result.disposable);
|
|
258
259
|
}
|
|
259
260
|
async exposeBinding(name, callback, options = {}) {
|
|
260
|
-
await this.
|
|
261
|
-
await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
261
|
+
const result = await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
262
262
|
this._bindings.set(name, callback);
|
|
263
|
+
return import_disposable.DisposableObject.from(result.disposable);
|
|
263
264
|
}
|
|
264
265
|
async setExtraHTTPHeaders(headers) {
|
|
265
266
|
(0, import_network.validateHeaders)(headers);
|
|
@@ -394,21 +395,18 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
394
395
|
viewportSize() {
|
|
395
396
|
return this._viewportSize || null;
|
|
396
397
|
}
|
|
397
|
-
async evaluate(pageFunction, arg
|
|
398
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
399
|
-
return await this._mainFrame.evaluate(pageFunction, arg
|
|
400
|
-
}
|
|
401
|
-
async _evaluateFunction(functionDeclaration) {
|
|
402
|
-
return this._mainFrame._evaluateFunction(functionDeclaration);
|
|
398
|
+
async evaluate(pageFunction, arg) {
|
|
399
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
400
|
+
return await this._mainFrame.evaluate(pageFunction, arg);
|
|
403
401
|
}
|
|
404
402
|
async addInitScript(script, arg) {
|
|
405
|
-
await this.installInjectRoute();
|
|
406
403
|
const source = await (0, import_clientHelper.evaluationScript)(this._platform, script, arg);
|
|
407
|
-
await this._channel.addInitScript({ source });
|
|
404
|
+
return import_disposable.DisposableObject.from((await this._channel.addInitScript({ source })).disposable);
|
|
408
405
|
}
|
|
409
406
|
async route(url, handler, options = {}) {
|
|
410
407
|
this._routes.unshift(new import_network.RouteHandler(this._platform, this._browserContext._options.baseURL, url, handler, options.times));
|
|
411
408
|
await this._updateInterceptionPatterns({ title: "Route requests" });
|
|
409
|
+
return new import_disposable.DisposableStub(() => this.unroute(url, handler));
|
|
412
410
|
}
|
|
413
411
|
async routeFromHAR(har, options = {}) {
|
|
414
412
|
const localUtils = this._connection.localUtils();
|
|
@@ -506,7 +504,8 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
506
504
|
}
|
|
507
505
|
async close(options = {}) {
|
|
508
506
|
this._closeReason = options.reason;
|
|
509
|
-
|
|
507
|
+
if (!options.runBeforeUnload)
|
|
508
|
+
this._closeWasCalled = true;
|
|
510
509
|
try {
|
|
511
510
|
if (this._ownedContext)
|
|
512
511
|
await this._ownedContext.close();
|
|
@@ -536,12 +535,18 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
536
535
|
async fill(selector, value, options) {
|
|
537
536
|
return await this._mainFrame.fill(selector, value, options);
|
|
538
537
|
}
|
|
539
|
-
async
|
|
540
|
-
|
|
538
|
+
async clearConsoleMessages() {
|
|
539
|
+
await this._channel.clearConsoleMessages();
|
|
540
|
+
}
|
|
541
|
+
async consoleMessages(options) {
|
|
542
|
+
const { messages } = await this._channel.consoleMessages({ filter: options?.filter });
|
|
541
543
|
return messages.map((message) => new import_consoleMessage.ConsoleMessage(this._platform, message, this, null));
|
|
542
544
|
}
|
|
543
|
-
async
|
|
544
|
-
|
|
545
|
+
async clearPageErrors() {
|
|
546
|
+
await this._channel.clearPageErrors();
|
|
547
|
+
}
|
|
548
|
+
async pageErrors(options) {
|
|
549
|
+
const { errors } = await this._channel.pageErrors({ filter: options?.filter });
|
|
545
550
|
return errors.map((error) => (0, import_errors.parseError)(error));
|
|
546
551
|
}
|
|
547
552
|
locator(selector, options) {
|
|
@@ -677,23 +682,12 @@ class Page extends import_channelOwner.ChannelOwner {
|
|
|
677
682
|
}
|
|
678
683
|
return result.pdf;
|
|
679
684
|
}
|
|
680
|
-
async
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
await this.
|
|
686
|
-
try {
|
|
687
|
-
if (route.request().resourceType() === "document" && route.request().url().startsWith("http")) {
|
|
688
|
-
const protocol = route.request().url().split(":")[0];
|
|
689
|
-
await route.fallback({ url: protocol + "://patchright-init-script-inject.internal/" });
|
|
690
|
-
} else {
|
|
691
|
-
await route.fallback();
|
|
692
|
-
}
|
|
693
|
-
} catch (error) {
|
|
694
|
-
await route.fallback();
|
|
695
|
-
}
|
|
696
|
-
});
|
|
685
|
+
async ariaSnapshot(options = {}) {
|
|
686
|
+
const result = await this.mainFrame()._channel.ariaSnapshot({ timeout: this._timeoutSettings.timeout(options), track: options._track, mode: options.mode, depth: options.depth });
|
|
687
|
+
return result.snapshot;
|
|
688
|
+
}
|
|
689
|
+
async _setDockTile(image) {
|
|
690
|
+
await this._channel.setDockTile({ image });
|
|
697
691
|
}
|
|
698
692
|
}
|
|
699
693
|
class BindingCall extends import_channelOwner.ChannelOwner {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var screencast_exports = {};
|
|
20
|
+
__export(screencast_exports, {
|
|
21
|
+
Screencast: () => Screencast
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(screencast_exports);
|
|
24
|
+
var import_artifact = require("./artifact");
|
|
25
|
+
var import_disposable = require("./disposable");
|
|
26
|
+
class Screencast {
|
|
27
|
+
constructor(page) {
|
|
28
|
+
this._started = false;
|
|
29
|
+
this._onFrame = null;
|
|
30
|
+
this._page = page;
|
|
31
|
+
this._page._channel.on("screencastFrame", ({ data }) => {
|
|
32
|
+
void this._onFrame?.({ data });
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async start(options = {}) {
|
|
36
|
+
if (this._started)
|
|
37
|
+
throw new Error("Screencast is already started");
|
|
38
|
+
this._started = true;
|
|
39
|
+
if (options.onFrame)
|
|
40
|
+
this._onFrame = options.onFrame;
|
|
41
|
+
const result = await this._page._channel.screencastStart({
|
|
42
|
+
size: options.size,
|
|
43
|
+
quality: options.quality,
|
|
44
|
+
sendFrames: !!options.onFrame,
|
|
45
|
+
record: !!options.path
|
|
46
|
+
});
|
|
47
|
+
if (result.artifact) {
|
|
48
|
+
this._artifact = import_artifact.Artifact.from(result.artifact);
|
|
49
|
+
this._savePath = options.path;
|
|
50
|
+
}
|
|
51
|
+
return new import_disposable.DisposableStub(() => this.stop());
|
|
52
|
+
}
|
|
53
|
+
async stop() {
|
|
54
|
+
await this._page._wrapApiCall(async () => {
|
|
55
|
+
this._started = false;
|
|
56
|
+
this._onFrame = null;
|
|
57
|
+
await this._page._channel.screencastStop();
|
|
58
|
+
if (this._savePath)
|
|
59
|
+
await this._artifact?.saveAs(this._savePath);
|
|
60
|
+
this._artifact = void 0;
|
|
61
|
+
this._savePath = void 0;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
async showActions(options) {
|
|
65
|
+
await this._page._channel.screencastShowActions({ duration: options?.duration, position: options?.position, fontSize: options?.fontSize });
|
|
66
|
+
return new import_disposable.DisposableStub(() => this._page._channel.screencastHideActions());
|
|
67
|
+
}
|
|
68
|
+
async hideActions() {
|
|
69
|
+
await this._page._channel.screencastHideActions();
|
|
70
|
+
}
|
|
71
|
+
async showOverlay(html, options) {
|
|
72
|
+
const { id } = await this._page._channel.screencastShowOverlay({ html, duration: options?.duration });
|
|
73
|
+
return new import_disposable.DisposableStub(() => this._page._channel.screencastRemoveOverlay({ id }));
|
|
74
|
+
}
|
|
75
|
+
async showChapter(title, options) {
|
|
76
|
+
await this._page._channel.screencastChapter({ title, ...options });
|
|
77
|
+
}
|
|
78
|
+
async showOverlays() {
|
|
79
|
+
await this._page._channel.screencastSetOverlayVisible({ visible: true });
|
|
80
|
+
}
|
|
81
|
+
async hideOverlays() {
|
|
82
|
+
await this._page._channel.screencastSetOverlayVisible({ visible: false });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
Screencast
|
|
88
|
+
});
|
package/lib/client/selectors.js
CHANGED
|
@@ -41,9 +41,11 @@ class Selectors {
|
|
|
41
41
|
setTestIdAttribute(attributeName) {
|
|
42
42
|
this._testIdAttributeName = attributeName;
|
|
43
43
|
(0, import_locator.setTestIdAttribute)(attributeName);
|
|
44
|
-
for (const context of this._contextsForSelectors)
|
|
44
|
+
for (const context of this._contextsForSelectors) {
|
|
45
|
+
context._options.testIdAttributeName = attributeName;
|
|
45
46
|
context._channel.setTestIdAttributeName({ testIdAttributeName: attributeName }).catch(() => {
|
|
46
47
|
});
|
|
48
|
+
}
|
|
47
49
|
}
|
|
48
50
|
_withSelectorOptions(options) {
|
|
49
51
|
return { ...options, selectorEngines: this._selectorEngines, testIdAttributeName: this._testIdAttributeName };
|
package/lib/client/tracing.js
CHANGED
|
@@ -23,10 +23,12 @@ __export(tracing_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(tracing_exports);
|
|
24
24
|
var import_artifact = require("./artifact");
|
|
25
25
|
var import_channelOwner = require("./channelOwner");
|
|
26
|
+
var import_disposable = require("./disposable");
|
|
26
27
|
class Tracing extends import_channelOwner.ChannelOwner {
|
|
27
28
|
constructor(parent, type, guid, initializer) {
|
|
28
29
|
super(parent, type, guid, initializer);
|
|
29
30
|
this._includeSources = false;
|
|
31
|
+
this._additionalSources = /* @__PURE__ */ new Set();
|
|
30
32
|
this._isLive = false;
|
|
31
33
|
this._isTracing = false;
|
|
32
34
|
}
|
|
@@ -34,15 +36,14 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
34
36
|
return channel._object;
|
|
35
37
|
}
|
|
36
38
|
async start(options = {}) {
|
|
37
|
-
await this._parent.installInjectRoute();
|
|
38
39
|
await this._wrapApiCall(async () => {
|
|
39
40
|
this._includeSources = !!options.sources;
|
|
40
|
-
this._isLive = !!options.
|
|
41
|
+
this._isLive = !!options.live;
|
|
41
42
|
await this._channel.tracingStart({
|
|
42
43
|
name: options.name,
|
|
43
44
|
snapshots: options.snapshots,
|
|
44
45
|
screenshots: options.screenshots,
|
|
45
|
-
live: options.
|
|
46
|
+
live: options.live
|
|
46
47
|
});
|
|
47
48
|
const { traceName } = await this._channel.tracingStartChunk({ name: options.name, title: options.title });
|
|
48
49
|
await this._startCollectingStacks(traceName, this._isLive);
|
|
@@ -55,7 +56,10 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
async group(name, options = {}) {
|
|
59
|
+
if (options.location)
|
|
60
|
+
this._additionalSources.add(options.location.file);
|
|
58
61
|
await this._channel.tracingGroup({ name, location: options.location });
|
|
62
|
+
return new import_disposable.DisposableStub(() => this.groupEnd());
|
|
59
63
|
}
|
|
60
64
|
async groupEnd() {
|
|
61
65
|
await this._channel.tracingGroupEnd();
|
|
@@ -81,6 +85,8 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
81
85
|
}
|
|
82
86
|
async _doStopChunk(filePath) {
|
|
83
87
|
this._resetStackCounter();
|
|
88
|
+
const additionalSources = [...this._additionalSources];
|
|
89
|
+
this._additionalSources.clear();
|
|
84
90
|
if (!filePath) {
|
|
85
91
|
await this._channel.tracingStopChunk({ mode: "discard" });
|
|
86
92
|
if (this._stacksId)
|
|
@@ -93,7 +99,7 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
93
99
|
const isLocal = !this._connection.isRemote();
|
|
94
100
|
if (isLocal) {
|
|
95
101
|
const result2 = await this._channel.tracingStopChunk({ mode: "entries" });
|
|
96
|
-
await localUtils.zip({ zipFile: filePath, entries: result2.entries, mode: "write", stacksId: this._stacksId, includeSources: this._includeSources });
|
|
102
|
+
await localUtils.zip({ zipFile: filePath, entries: result2.entries, mode: "write", stacksId: this._stacksId, includeSources: this._includeSources, additionalSources });
|
|
97
103
|
return;
|
|
98
104
|
}
|
|
99
105
|
const result = await this._channel.tracingStopChunk({ mode: "archive" });
|
|
@@ -105,7 +111,7 @@ class Tracing extends import_channelOwner.ChannelOwner {
|
|
|
105
111
|
const artifact = import_artifact.Artifact.from(result.artifact);
|
|
106
112
|
await artifact.saveAs(filePath);
|
|
107
113
|
await artifact.delete();
|
|
108
|
-
await localUtils.zip({ zipFile: filePath, entries: [], mode: "append", stacksId: this._stacksId, includeSources: this._includeSources });
|
|
114
|
+
await localUtils.zip({ zipFile: filePath, entries: [], mode: "append", stacksId: this._stacksId, includeSources: this._includeSources, additionalSources });
|
|
109
115
|
}
|
|
110
116
|
_resetStackCounter() {
|
|
111
117
|
if (this._isTracing) {
|
package/lib/client/video.js
CHANGED
|
@@ -21,36 +21,29 @@ __export(video_exports, {
|
|
|
21
21
|
Video: () => Video
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(video_exports);
|
|
24
|
-
var
|
|
25
|
-
class Video {
|
|
26
|
-
constructor(page, connection) {
|
|
27
|
-
|
|
28
|
-
this._artifactReadyPromise = new import_manualPromise.ManualPromise();
|
|
24
|
+
var import_eventEmitter = require("./eventEmitter");
|
|
25
|
+
class Video extends import_eventEmitter.EventEmitter {
|
|
26
|
+
constructor(page, connection, artifact) {
|
|
27
|
+
super(page._platform);
|
|
29
28
|
this._isRemote = false;
|
|
30
29
|
this._isRemote = connection.isRemote();
|
|
31
|
-
this._artifact =
|
|
32
|
-
}
|
|
33
|
-
_artifactReady(artifact) {
|
|
34
|
-
this._artifactReadyPromise.resolve(artifact);
|
|
30
|
+
this._artifact = artifact;
|
|
35
31
|
}
|
|
36
32
|
async path() {
|
|
37
33
|
if (this._isRemote)
|
|
38
34
|
throw new Error(`Path is not available when connecting remotely. Use saveAs() to save a local copy.`);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return artifact._initializer.absolutePath;
|
|
35
|
+
if (!this._artifact)
|
|
36
|
+
throw new Error("Video recording has not been started.");
|
|
37
|
+
return this._artifact._initializer.absolutePath;
|
|
43
38
|
}
|
|
44
39
|
async saveAs(path) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return await artifact.saveAs(path);
|
|
40
|
+
if (!this._artifact)
|
|
41
|
+
throw new Error("Video recording has not been started.");
|
|
42
|
+
return await this._artifact.saveAs(path);
|
|
49
43
|
}
|
|
50
44
|
async delete() {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
await artifact.delete();
|
|
45
|
+
if (this._artifact)
|
|
46
|
+
await this._artifact.delete();
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
49
|
// Annotate the CommonJS export names for ESM import in node:
|
package/lib/client/worker.js
CHANGED
|
@@ -54,14 +54,14 @@ class Worker extends import_channelOwner.ChannelOwner {
|
|
|
54
54
|
url() {
|
|
55
55
|
return this._initializer.url;
|
|
56
56
|
}
|
|
57
|
-
async evaluate(pageFunction, arg
|
|
58
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
59
|
-
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg)
|
|
57
|
+
async evaluate(pageFunction, arg) {
|
|
58
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
59
|
+
const result = await this._channel.evaluateExpression({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
60
60
|
return (0, import_jsHandle.parseResult)(result.value);
|
|
61
61
|
}
|
|
62
|
-
async evaluateHandle(pageFunction, arg
|
|
63
|
-
(0, import_jsHandle.assertMaxArguments)(arguments.length,
|
|
64
|
-
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg)
|
|
62
|
+
async evaluateHandle(pageFunction, arg) {
|
|
63
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
64
|
+
const result = await this._channel.evaluateExpressionHandle({ expression: String(pageFunction), isFunction: typeof pageFunction === "function", arg: (0, import_jsHandle.serializeArgument)(arg) });
|
|
65
65
|
return import_jsHandle.JSHandle.from(result.handle);
|
|
66
66
|
}
|
|
67
67
|
async waitForEvent(event, optionsOrPredicate = {}) {
|