patchright-bun-core 1.58.2 → 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 +126 -650
- package/browsers.json +16 -14
- 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 +47 -411
- package/lib/client/android.js +4 -4
- package/lib/client/api.js +3 -3
- package/lib/client/browser.js +8 -0
- package/lib/client/browserContext.js +18 -37
- package/lib/client/browserType.js +19 -51
- package/lib/client/cdpSession.js +6 -2
- package/lib/client/channelOwner.js +1 -1
- package/lib/client/{webSocket.js → connect.js} +57 -7
- package/lib/client/connection.js +8 -4
- 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 -4
- package/lib/client/events.js +3 -3
- package/lib/client/fetch.js +0 -1
- package/lib/client/frame.js +0 -5
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +0 -4
- package/lib/client/locator.js +5 -7
- package/lib/client/network.js +14 -11
- package/lib/client/page.js +34 -48
- package/lib/client/platform.js +0 -3
- package/lib/client/screencast.js +88 -0
- package/lib/client/selectors.js +3 -1
- package/lib/client/tracing.js +11 -4
- package/lib/client/video.js +13 -20
- 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 +0 -6
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/validator.js +216 -118
- 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 +13 -8
- 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/bidi/bidiBrowser.js +30 -8
- package/lib/server/bidi/bidiChromium.js +18 -5
- package/lib/server/bidi/bidiNetworkManager.js +39 -11
- package/lib/server/bidi/bidiPage.js +31 -15
- package/lib/server/bidi/third_party/firefoxPrefs.js +3 -1
- package/lib/server/browser.js +84 -21
- package/lib/server/browserContext.js +97 -58
- package/lib/server/browserType.js +14 -12
- package/lib/server/chromium/chromium.js +15 -13
- package/lib/server/chromium/crBrowser.js +18 -10
- package/lib/server/chromium/crNetworkManager.js +4 -4
- package/lib/server/chromium/crPage.js +26 -64
- package/lib/server/chromium/crServiceWorker.js +5 -4
- package/lib/server/clock.js +33 -33
- 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 +27 -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 +1 -1
- package/lib/server/dispatchers/disposableDispatcher.js +39 -0
- package/lib/server/dispatchers/electronDispatcher.js +2 -1
- package/lib/server/dispatchers/frameDispatcher.js +3 -3
- package/lib/server/dispatchers/localUtilsDispatcher.js +37 -1
- package/lib/server/dispatchers/networkDispatchers.js +6 -5
- package/lib/server/dispatchers/pageDispatcher.js +101 -38
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +4 -5
- package/lib/server/disposable.js +41 -0
- package/lib/server/dom.js +44 -26
- package/lib/server/download.js +3 -2
- package/lib/server/electron/electron.js +12 -7
- package/lib/server/firefox/ffBrowser.js +9 -19
- package/lib/server/firefox/ffInput.js +21 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +24 -27
- package/lib/server/frames.js +40 -11
- 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 +5 -0
- package/lib/server/launchApp.js +0 -1
- package/lib/server/localUtils.js +6 -6
- package/lib/server/network.js +9 -8
- package/lib/server/overlay.js +138 -0
- package/lib/server/page.js +111 -51
- package/lib/server/progress.js +6 -0
- package/lib/server/recorder/recorderApp.js +9 -8
- package/lib/server/recorder.js +76 -40
- package/lib/server/registry/index.js +54 -81
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/screencast.js +90 -143
- package/lib/server/trace/recorder/snapshotter.js +2 -2
- package/lib/server/trace/recorder/tracing.js +87 -36
- package/lib/server/trace/viewer/traceViewer.js +3 -4
- 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/fileUtils.js +16 -2
- package/lib/server/utils/happyEyeballs.js +15 -12
- package/lib/server/utils/hostPlatform.js +0 -15
- package/lib/server/utils/httpServer.js +5 -3
- package/lib/server/utils/network.js +2 -1
- package/lib/server/utils/nodePlatform.js +0 -6
- package/lib/server/utils/processLauncher.js +8 -6
- package/lib/server/utils/zipFile.js +2 -2
- package/lib/server/videoRecorder.js +82 -12
- package/lib/server/webkit/wkBrowser.js +1 -6
- package/lib/server/webkit/wkPage.js +27 -25
- 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/{server/trace/viewer/traceParser.js → tools/trace/installSkill.js} +15 -39
- 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/formatUtils.js +64 -0
- package/lib/utils/isomorphic/jsonSchema.js +89 -0
- package/lib/utils/isomorphic/mimeType.js +7 -2
- package/lib/utils/isomorphic/protocolFormatter.js +2 -2
- package/lib/utils/isomorphic/protocolMetainfo.js +127 -106
- package/lib/utils/isomorphic/stringUtils.js +3 -3
- package/lib/utils/isomorphic/timeoutRunner.js +3 -3
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +35 -42
- package/lib/utils/isomorphic/trace/traceLoader.js +15 -14
- package/lib/utils/isomorphic/trace/traceModel.js +3 -2
- package/lib/utils/isomorphic/trace/traceModernizer.js +1 -0
- package/lib/utils/isomorphic/urlMatch.js +54 -1
- package/lib/utils/isomorphic/utilityScriptSerializers.js +11 -0
- package/lib/utils.js +6 -2
- package/lib/utilsBundle.js +3 -21
- package/lib/utilsBundleImpl/index.js +132 -133
- 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-DadYNm1I.js → codeMirrorModule-C8KMvO9L.js} +20 -20
- package/lib/vite/recorder/assets/index-CqAYX1I3.js +193 -0
- package/lib/vite/recorder/index.html +1 -1
- package/lib/vite/traceViewer/assets/{codeMirrorModule-a5XoALAZ.js → codeMirrorModule-DS0FLvoc.js} +20 -20
- package/lib/vite/traceViewer/assets/defaultSettingsView-GTWI-W_B.js +262 -0
- package/lib/vite/traceViewer/defaultSettingsView.B4dS75f0.css +1 -0
- package/lib/vite/traceViewer/{index.BVu7tZDe.css → index.CzXZzn5A.css} +1 -1
- package/lib/vite/traceViewer/{index.BDwrLSGN.js → index.Dtstcb7U.js} +1 -1
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +4 -4
- 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 +6 -1
- package/types/protocol.d.ts +947 -51
- package/types/types.d.ts +854 -74
- package/lib/client/pageAgent.js +0 -64
- package/lib/mcpBundleImpl/index.js +0 -147
- package/lib/server/agent/actionRunner.js +0 -335
- package/lib/server/agent/actions.js +0 -128
- package/lib/server/agent/codegen.js +0 -111
- package/lib/server/agent/context.js +0 -150
- package/lib/server/agent/expectTools.js +0 -156
- package/lib/server/agent/pageAgent.js +0 -204
- package/lib/server/agent/performTools.js +0 -262
- package/lib/server/agent/tool.js +0 -109
- package/lib/server/dispatchers/pageAgentDispatcher.js +0 -96
- package/lib/vite/recorder/assets/index-BhTWtUlo.js +0 -193
- package/lib/vite/traceViewer/assets/defaultSettingsView-CJSZINFr.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +0 -1
- package/lib/vite/traceViewer/uiMode.CQJ9SCIQ.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
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 overlay_exports = {};
|
|
20
|
+
__export(overlay_exports, {
|
|
21
|
+
Overlay: () => Overlay
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(overlay_exports);
|
|
24
|
+
var import_utils = require("../utils");
|
|
25
|
+
var import_page = require("./page");
|
|
26
|
+
class Overlay {
|
|
27
|
+
constructor(page) {
|
|
28
|
+
this._overlays = /* @__PURE__ */ new Map();
|
|
29
|
+
this._page = page;
|
|
30
|
+
this._page.on(import_page.Page.Events.InternalFrameNavigatedToNewDocument, (frame) => {
|
|
31
|
+
if (frame.parentFrame())
|
|
32
|
+
return;
|
|
33
|
+
for (const [id, html] of this._overlays)
|
|
34
|
+
this._doAdd(id, html).catch((e) => import_utils.debugLogger.log("error", e));
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
dispose() {
|
|
38
|
+
}
|
|
39
|
+
async show(html, duration) {
|
|
40
|
+
const id = (0, import_utils.createGuid)();
|
|
41
|
+
this._overlays.set(id, html);
|
|
42
|
+
await this._doAdd(id, html).catch((e) => import_utils.debugLogger.log("error", e));
|
|
43
|
+
if (duration) {
|
|
44
|
+
await new Promise((f) => setTimeout(f, duration));
|
|
45
|
+
await this.remove(id);
|
|
46
|
+
}
|
|
47
|
+
return id;
|
|
48
|
+
}
|
|
49
|
+
async _doAdd(id, html) {
|
|
50
|
+
const utility = await this._page.mainFrame()._utilityContext();
|
|
51
|
+
await utility.evaluate(({ injected, html: html2, id: id2 }) => {
|
|
52
|
+
return injected.addUserOverlay(id2, html2);
|
|
53
|
+
}, { injected: await utility.injectedScript(), html, id });
|
|
54
|
+
}
|
|
55
|
+
async remove(id) {
|
|
56
|
+
this._overlays.delete(id);
|
|
57
|
+
const utility = await this._page.mainFrame()._utilityContext();
|
|
58
|
+
await utility.evaluate(({ injected, id: id2 }) => {
|
|
59
|
+
injected.removeUserOverlay(id2);
|
|
60
|
+
}, { injected: await utility.injectedScript(), id }).catch((e) => import_utils.debugLogger.log("error", e));
|
|
61
|
+
}
|
|
62
|
+
async chapter(options) {
|
|
63
|
+
const fadeDuration = 300;
|
|
64
|
+
const descriptionHtml = options.description ? `<div id="description">${(0, import_utils.escapeHTML)(options.description)}</div>` : "";
|
|
65
|
+
const styleSheet = `
|
|
66
|
+
@keyframes pw-chapter-fade-in {
|
|
67
|
+
from { opacity: 0; }
|
|
68
|
+
to { opacity: 1; }
|
|
69
|
+
}
|
|
70
|
+
@keyframes pw-chapter-fade-out {
|
|
71
|
+
from { opacity: 1; }
|
|
72
|
+
to { opacity: 0; }
|
|
73
|
+
}
|
|
74
|
+
#background {
|
|
75
|
+
position: absolute;
|
|
76
|
+
inset: 0;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
backdrop-filter: blur(2px);
|
|
81
|
+
animation: pw-chapter-fade-in ${fadeDuration}ms ease-out forwards;
|
|
82
|
+
}
|
|
83
|
+
#background.fade-out {
|
|
84
|
+
animation: pw-chapter-fade-out ${fadeDuration}ms ease-in forwards;
|
|
85
|
+
}
|
|
86
|
+
#content {
|
|
87
|
+
background: rgba(0, 0, 0, 0.7);
|
|
88
|
+
border: 1px solid rgba(255, 255, 255, 0.15);
|
|
89
|
+
border-radius: 16px;
|
|
90
|
+
padding: 40px 56px;
|
|
91
|
+
max-width: 560px;
|
|
92
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
93
|
+
}
|
|
94
|
+
#title {
|
|
95
|
+
color: white;
|
|
96
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
97
|
+
font-size: 28px;
|
|
98
|
+
font-weight: 600;
|
|
99
|
+
line-height: 1.3;
|
|
100
|
+
text-align: center;
|
|
101
|
+
letter-spacing: -0.01em;
|
|
102
|
+
}
|
|
103
|
+
#description {
|
|
104
|
+
color: rgba(255, 255, 255, 0.7);
|
|
105
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
106
|
+
font-size: 15px;
|
|
107
|
+
line-height: 1.5;
|
|
108
|
+
margin-top: 12px;
|
|
109
|
+
text-align: center;
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
const duration = options.duration ?? 2e3;
|
|
113
|
+
const html = `<style>${styleSheet}</style><div id="background"><div id="content"><div id="title">${(0, import_utils.escapeHTML)(options.title)}</div>${descriptionHtml}</div></div>`;
|
|
114
|
+
const id = await this.show(html);
|
|
115
|
+
await new Promise((f) => setTimeout(f, duration));
|
|
116
|
+
const utility = await this._page.mainFrame()._utilityContext();
|
|
117
|
+
await utility.evaluate(({ injected, id: id2, fadeDuration: fadeDuration2 }) => {
|
|
118
|
+
const overlay = injected.getUserOverlay(id2);
|
|
119
|
+
const bg = overlay?.querySelector("#background");
|
|
120
|
+
if (bg)
|
|
121
|
+
bg.classList.add("fade-out");
|
|
122
|
+
return new Promise((f) => injected.utils.builtins.setTimeout(f, fadeDuration2));
|
|
123
|
+
}, { injected: await utility.injectedScript(), id, fadeDuration }).catch((e) => import_utils.debugLogger.log("error", e));
|
|
124
|
+
await this.remove(id);
|
|
125
|
+
}
|
|
126
|
+
async setVisible(visible) {
|
|
127
|
+
if (!this._overlays.size)
|
|
128
|
+
return;
|
|
129
|
+
const utility = await this._page.mainFrame()._utilityContext();
|
|
130
|
+
await utility.evaluate(({ injected, visible: visible2 }) => {
|
|
131
|
+
injected.setUserOverlaysVisible(visible2);
|
|
132
|
+
}, { injected: await utility.injectedScript(), visible }).catch((e) => import_utils.debugLogger.log("error", e));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
136
|
+
0 && (module.exports = {
|
|
137
|
+
Overlay
|
|
138
|
+
});
|
package/lib/server/page.js
CHANGED
|
@@ -32,10 +32,12 @@ __export(page_exports, {
|
|
|
32
32
|
Page: () => Page,
|
|
33
33
|
PageBinding: () => PageBinding,
|
|
34
34
|
Worker: () => Worker,
|
|
35
|
-
WorkerEvent: () => WorkerEvent
|
|
35
|
+
WorkerEvent: () => WorkerEvent,
|
|
36
|
+
ariaSnapshotForFrame: () => ariaSnapshotForFrame
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(page_exports);
|
|
38
39
|
var import_browserContext = require("./browserContext");
|
|
40
|
+
var import_disposable = require("./disposable");
|
|
39
41
|
var import_console = require("./console");
|
|
40
42
|
var import_errors = require("./errors");
|
|
41
43
|
var import_fileChooser = require("./fileChooser");
|
|
@@ -54,6 +56,8 @@ var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
|
54
56
|
var import_utilityScriptSerializers = require("../utils/isomorphic/utilityScriptSerializers");
|
|
55
57
|
var import_callLog = require("./callLog");
|
|
56
58
|
var rawBindingsControllerSource = __toESM(require("../generated/bindingsControllerSource"));
|
|
59
|
+
var import_overlay = require("./overlay");
|
|
60
|
+
var import_dom = require("./dom");
|
|
57
61
|
var import_screencast = require("./screencast");
|
|
58
62
|
const PageEvent = {
|
|
59
63
|
Close: "close",
|
|
@@ -65,16 +69,15 @@ const PageEvent = {
|
|
|
65
69
|
FrameDetached: "framedetached",
|
|
66
70
|
InternalFrameNavigatedToNewDocument: "internalframenavigatedtonewdocument",
|
|
67
71
|
LocatorHandlerTriggered: "locatorhandlertriggered",
|
|
68
|
-
ScreencastFrame: "screencastframe",
|
|
69
|
-
Video: "video",
|
|
70
72
|
WebSocket: "websocket",
|
|
71
73
|
Worker: "worker"
|
|
72
74
|
};
|
|
75
|
+
const navigationMarkSymbol = Symbol("navigationMark");
|
|
73
76
|
class Page extends import_instrumentation.SdkObject {
|
|
74
77
|
constructor(delegate, browserContext) {
|
|
75
78
|
super(browserContext, "page");
|
|
76
79
|
this._closedState = "open";
|
|
77
|
-
this.
|
|
80
|
+
this.closedPromise = new import_manualPromise.ManualPromise();
|
|
78
81
|
this._initializedPromise = new import_manualPromise.ManualPromise();
|
|
79
82
|
this._consoleMessages = [];
|
|
80
83
|
this._pageErrors = [];
|
|
@@ -86,7 +89,6 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
86
89
|
this.initScripts = [];
|
|
87
90
|
this._workers = /* @__PURE__ */ new Map();
|
|
88
91
|
this.requestInterceptors = [];
|
|
89
|
-
this.video = null;
|
|
90
92
|
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
91
93
|
this._lastLocatorHandlerUid = 0;
|
|
92
94
|
this._locatorHandlerRunningCounter = 0;
|
|
@@ -99,6 +101,7 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
99
101
|
this.touchscreen = new input.Touchscreen(delegate.rawTouchscreen, this);
|
|
100
102
|
this.screenshotter = new import_screenshotter.Screenshotter(this);
|
|
101
103
|
this.frameManager = new frames.FrameManager(this);
|
|
104
|
+
this.overlay = new import_overlay.Overlay(this);
|
|
102
105
|
this.screencast = new import_screencast.Screencast(this);
|
|
103
106
|
if (delegate.pdf)
|
|
104
107
|
this.pdf = delegate.pdf.bind(delegate);
|
|
@@ -159,17 +162,20 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
159
162
|
}
|
|
160
163
|
_didClose() {
|
|
161
164
|
this.frameManager.dispose();
|
|
162
|
-
this.screencast.
|
|
165
|
+
this.screencast.dispose();
|
|
166
|
+
this.overlay.dispose();
|
|
163
167
|
(0, import_utils.assert)(this._closedState !== "closed", "Page closed twice");
|
|
164
168
|
this._closedState = "closed";
|
|
165
169
|
this.emit(Page.Events.Close);
|
|
166
|
-
this.
|
|
170
|
+
this.browserContext.emit(import_browserContext.BrowserContext.Events.PageClosed, this);
|
|
171
|
+
this.closedPromise.resolve();
|
|
167
172
|
this.instrumentation.onPageClose(this);
|
|
168
173
|
this.openScope.close(new import_errors.TargetClosedError(this.closeReason()));
|
|
169
174
|
}
|
|
170
175
|
_didCrash() {
|
|
171
176
|
this.frameManager.dispose();
|
|
172
|
-
this.screencast.
|
|
177
|
+
this.screencast.dispose();
|
|
178
|
+
this.overlay.dispose();
|
|
173
179
|
this.emit(Page.Events.Crash);
|
|
174
180
|
this._crashed = true;
|
|
175
181
|
this.instrumentation.onPageClose(this);
|
|
@@ -204,7 +210,7 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
204
210
|
if (this.browserContext._pageBindings.has(name))
|
|
205
211
|
throw new Error(`Function "${name}" has been already registered in the browser context`);
|
|
206
212
|
await progress.race(this.browserContext.exposePlaywrightBindingIfNeeded());
|
|
207
|
-
const binding = new PageBinding(name, playwrightBinding, needsHandle);
|
|
213
|
+
const binding = new PageBinding(this, name, playwrightBinding, needsHandle);
|
|
208
214
|
this._pageBindings.set(name, binding);
|
|
209
215
|
try {
|
|
210
216
|
await progress.race(this.delegate.addInitScript(binding.initScript));
|
|
@@ -215,13 +221,12 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
215
221
|
throw error;
|
|
216
222
|
}
|
|
217
223
|
}
|
|
218
|
-
async
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
await this.delegate.removeInitScripts(
|
|
223
|
-
const cleanup =
|
|
224
|
-
`).join("");
|
|
224
|
+
async removeExposedBinding(binding) {
|
|
225
|
+
if (this._pageBindings.get(binding.name) !== binding)
|
|
226
|
+
return;
|
|
227
|
+
this._pageBindings.delete(binding.name);
|
|
228
|
+
await this.delegate.removeInitScripts([binding.initScript]);
|
|
229
|
+
const cleanup = `{ ${binding.cleanupScript} };`;
|
|
225
230
|
await this.safeNonStallingEvaluateInAllFrames(cleanup, "main");
|
|
226
231
|
}
|
|
227
232
|
async setExtraHTTPHeaders(progress, headers) {
|
|
@@ -251,8 +256,8 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
251
256
|
return;
|
|
252
257
|
await PageBinding.dispatch(this, payload, context);
|
|
253
258
|
}
|
|
254
|
-
addConsoleMessage(worker, type, args, location, text) {
|
|
255
|
-
const message = new import_console.ConsoleMessage(this, worker, type, text, args, location);
|
|
259
|
+
addConsoleMessage(worker, type, args, location, text, timestamp) {
|
|
260
|
+
const message = new import_console.ConsoleMessage(this, worker, type, text, args, location, timestamp);
|
|
256
261
|
const intercepted = this.frameManager.interceptConsoleMessage(message);
|
|
257
262
|
if (intercepted) {
|
|
258
263
|
args.forEach((arg) => arg.dispose());
|
|
@@ -263,8 +268,14 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
263
268
|
if (this._initialized)
|
|
264
269
|
this.emitOnContext(import_browserContext.BrowserContext.Events.Console, message);
|
|
265
270
|
}
|
|
266
|
-
|
|
267
|
-
|
|
271
|
+
clearConsoleMessages() {
|
|
272
|
+
this._consoleMessages.length = 0;
|
|
273
|
+
}
|
|
274
|
+
consoleMessages(filter) {
|
|
275
|
+
if (filter === "all")
|
|
276
|
+
return this._consoleMessages;
|
|
277
|
+
const marked = this._consoleMessages.findLastIndex((m) => m[navigationMarkSymbol]);
|
|
278
|
+
return marked === -1 ? this._consoleMessages : this._consoleMessages.slice(marked + 1);
|
|
268
279
|
}
|
|
269
280
|
addPageError(pageError) {
|
|
270
281
|
this._pageErrors.push(pageError);
|
|
@@ -272,8 +283,14 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
272
283
|
if (this._initialized)
|
|
273
284
|
this.emitOnContext(import_browserContext.BrowserContext.Events.PageError, pageError, this);
|
|
274
285
|
}
|
|
275
|
-
|
|
276
|
-
|
|
286
|
+
clearPageErrors() {
|
|
287
|
+
this._pageErrors.length = 0;
|
|
288
|
+
}
|
|
289
|
+
pageErrors(filter) {
|
|
290
|
+
if (filter === "all")
|
|
291
|
+
return this._pageErrors;
|
|
292
|
+
const marked = this._pageErrors.findLastIndex((e) => e[navigationMarkSymbol]);
|
|
293
|
+
return marked === -1 ? this._pageErrors : this._pageErrors.slice(marked + 1);
|
|
277
294
|
}
|
|
278
295
|
async reload(progress, options) {
|
|
279
296
|
return this.mainFrame().raceNavigationAction(progress, async () => {
|
|
@@ -450,22 +467,21 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
450
467
|
async bringToFront() {
|
|
451
468
|
await this.delegate.bringToFront();
|
|
452
469
|
}
|
|
453
|
-
async addInitScript(
|
|
454
|
-
const initScript = new InitScript(source);
|
|
470
|
+
async addInitScript(source) {
|
|
471
|
+
const initScript = new InitScript(this, source);
|
|
455
472
|
this.initScripts.push(initScript);
|
|
456
473
|
try {
|
|
457
|
-
await
|
|
474
|
+
await this.delegate.addInitScript(initScript);
|
|
458
475
|
} catch (error) {
|
|
459
|
-
|
|
476
|
+
initScript.dispose().catch(() => {
|
|
460
477
|
});
|
|
461
478
|
throw error;
|
|
462
479
|
}
|
|
463
480
|
return initScript;
|
|
464
481
|
}
|
|
465
|
-
async
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
await this.delegate.removeInitScripts(initScripts);
|
|
482
|
+
async removeInitScript(initScript) {
|
|
483
|
+
this.initScripts = this.initScripts.filter((script) => initScript !== script);
|
|
484
|
+
await this.delegate.removeInitScripts([initScript]);
|
|
469
485
|
}
|
|
470
486
|
needsRequestInterception() {
|
|
471
487
|
return this.requestInterceptors.length > 0 || this.browserContext.requestInterceptors.length > 0;
|
|
@@ -581,13 +597,15 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
581
597
|
if (options.reason)
|
|
582
598
|
this._closeReason = options.reason;
|
|
583
599
|
const runBeforeUnload = !!options.runBeforeUnload;
|
|
600
|
+
if (!runBeforeUnload)
|
|
601
|
+
await this.screencast.handlePageOrContextClose();
|
|
584
602
|
if (this._closedState !== "closing") {
|
|
585
603
|
if (!runBeforeUnload)
|
|
586
604
|
this._closedState = "closing";
|
|
587
605
|
await this.delegate.closePage(runBeforeUnload).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
588
606
|
}
|
|
589
607
|
if (!runBeforeUnload)
|
|
590
|
-
await this.
|
|
608
|
+
await this.closedPromise;
|
|
591
609
|
}
|
|
592
610
|
isClosed() {
|
|
593
611
|
return this._closedState === "closed";
|
|
@@ -629,9 +647,16 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
629
647
|
}
|
|
630
648
|
frameNavigatedToNewDocument(frame) {
|
|
631
649
|
this.emit(Page.Events.InternalFrameNavigatedToNewDocument, frame);
|
|
650
|
+
this.browserContext.emit(import_browserContext.BrowserContext.Events.InternalFrameNavigatedToNewDocument, frame, this);
|
|
632
651
|
const origin = frame.origin();
|
|
633
652
|
if (origin)
|
|
634
653
|
this.browserContext.addVisitedOrigin(origin);
|
|
654
|
+
if (frame === this.mainFrame()) {
|
|
655
|
+
if (this._consoleMessages.length > 0)
|
|
656
|
+
this._consoleMessages[this._consoleMessages.length - 1][navigationMarkSymbol] = true;
|
|
657
|
+
if (this._pageErrors.length > 0)
|
|
658
|
+
this._pageErrors[this._pageErrors.length - 1][navigationMarkSymbol] = true;
|
|
659
|
+
}
|
|
635
660
|
}
|
|
636
661
|
allInitScripts() {
|
|
637
662
|
const bindings = [...this.browserContext._pageBindings.values(), ...this._pageBindings.values()].map((binding) => binding.initScript);
|
|
@@ -656,9 +681,8 @@ class Page extends import_instrumentation.SdkObject {
|
|
|
656
681
|
await Promise.all(this.frames().map((frame) => frame.hideHighlight().catch(() => {
|
|
657
682
|
})));
|
|
658
683
|
}
|
|
659
|
-
async
|
|
660
|
-
|
|
661
|
-
return { full: snapshot.full.join("\n"), incremental: snapshot.incremental?.join("\n") };
|
|
684
|
+
async setDockTile(image) {
|
|
685
|
+
await this.delegate.setDockTile(image);
|
|
662
686
|
}
|
|
663
687
|
}
|
|
664
688
|
const WorkerEvent = {
|
|
@@ -687,6 +711,13 @@ class Worker extends import_instrumentation.SdkObject {
|
|
|
687
711
|
if (this.existingExecutionContext)
|
|
688
712
|
this._executionContextPromise.resolve(this.existingExecutionContext);
|
|
689
713
|
}
|
|
714
|
+
_prepareContextForRestart() {
|
|
715
|
+
if (this.existingExecutionContext)
|
|
716
|
+
this.existingExecutionContext.contextDestroyed("Service worker restarted");
|
|
717
|
+
this.existingExecutionContext = null;
|
|
718
|
+
this._workerScriptLoaded = false;
|
|
719
|
+
this._executionContextPromise = new import_manualPromise.ManualPromise();
|
|
720
|
+
}
|
|
690
721
|
didClose() {
|
|
691
722
|
if (this.existingExecutionContext)
|
|
692
723
|
this.existingExecutionContext.contextDestroyed("Worker was closed");
|
|
@@ -700,15 +731,15 @@ class Worker extends import_instrumentation.SdkObject {
|
|
|
700
731
|
return js.evaluateExpression(await this._executionContextPromise, expression, { returnByValue: false, isFunction }, arg);
|
|
701
732
|
}
|
|
702
733
|
}
|
|
703
|
-
class PageBinding {
|
|
734
|
+
class PageBinding extends import_disposable.DisposableObject {
|
|
704
735
|
static {
|
|
705
736
|
this.kController = "__playwright__binding__controller__";
|
|
706
737
|
}
|
|
707
738
|
static {
|
|
708
739
|
this.kBindingName = "__playwright__binding__";
|
|
709
740
|
}
|
|
710
|
-
static createInitScript() {
|
|
711
|
-
return new InitScript(`
|
|
741
|
+
static createInitScript(browserContext) {
|
|
742
|
+
return new InitScript(browserContext, `
|
|
712
743
|
(() => {
|
|
713
744
|
const module = {};
|
|
714
745
|
${rawBindingsControllerSource.source}
|
|
@@ -718,10 +749,11 @@ class PageBinding {
|
|
|
718
749
|
})();
|
|
719
750
|
`);
|
|
720
751
|
}
|
|
721
|
-
constructor(name, playwrightFunction, needsHandle) {
|
|
752
|
+
constructor(parent, name, playwrightFunction, needsHandle) {
|
|
753
|
+
super(parent);
|
|
722
754
|
this.name = name;
|
|
723
755
|
this.playwrightFunction = playwrightFunction;
|
|
724
|
-
this.initScript = new InitScript(`globalThis['${PageBinding.kController}'].addBinding(${JSON.stringify(name)}, ${needsHandle})`);
|
|
756
|
+
this.initScript = new InitScript(parent, `globalThis['${PageBinding.kController}'].addBinding(${JSON.stringify(name)}, ${needsHandle})`);
|
|
725
757
|
this.needsHandle = needsHandle;
|
|
726
758
|
this.cleanupScript = `globalThis['${PageBinding.kController}'].removeBinding(${JSON.stringify(name)})`;
|
|
727
759
|
}
|
|
@@ -747,27 +779,49 @@ class PageBinding {
|
|
|
747
779
|
context.evaluateExpressionHandle(`arg => globalThis['${PageBinding.kController}'].deliverBindingResult(arg)`, { isFunction: true }, { name, seq, error }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
748
780
|
}
|
|
749
781
|
}
|
|
782
|
+
async dispose() {
|
|
783
|
+
await this.parent.removeExposedBinding(this);
|
|
784
|
+
}
|
|
750
785
|
}
|
|
751
|
-
class InitScript {
|
|
752
|
-
constructor(source) {
|
|
786
|
+
class InitScript extends import_disposable.DisposableObject {
|
|
787
|
+
constructor(owner, source) {
|
|
788
|
+
super(owner);
|
|
753
789
|
this.source = `(() => {
|
|
754
790
|
${source}
|
|
755
791
|
})();`;
|
|
756
792
|
}
|
|
793
|
+
async dispose() {
|
|
794
|
+
await this.parent.removeInitScript(this);
|
|
795
|
+
}
|
|
757
796
|
}
|
|
758
|
-
async function
|
|
797
|
+
async function ariaSnapshotForFrame(progress, frame, options = {}) {
|
|
759
798
|
const snapshot = await frame.retryWithProgressAndTimeouts(progress, [1e3, 2e3, 4e3, 8e3], async (continuePolling) => {
|
|
760
799
|
try {
|
|
761
800
|
const context = await progress.race(frame._utilityContext());
|
|
762
801
|
const injectedScript = await progress.race(context.injectedScript());
|
|
763
802
|
const snapshotOrRetry = await progress.race(injectedScript.evaluate((injected, options2) => {
|
|
803
|
+
if (options2.info) {
|
|
804
|
+
const element = injected.querySelector(options2.info.parsed, injected.document, options2.info.strict);
|
|
805
|
+
if (!element)
|
|
806
|
+
return false;
|
|
807
|
+
return injected.incrementalAriaSnapshot(element, options2);
|
|
808
|
+
}
|
|
764
809
|
const node = injected.document.body;
|
|
765
810
|
if (!node)
|
|
766
811
|
return true;
|
|
767
|
-
return injected.incrementalAriaSnapshot(node,
|
|
768
|
-
}, {
|
|
812
|
+
return injected.incrementalAriaSnapshot(node, options2);
|
|
813
|
+
}, {
|
|
814
|
+
mode: options.mode ?? "default",
|
|
815
|
+
refPrefix: frame.seq ? "f" + frame.seq : "",
|
|
816
|
+
track: options.track,
|
|
817
|
+
doNotRenderActive: options.doNotRenderActive,
|
|
818
|
+
info: options.info,
|
|
819
|
+
depth: options.depth
|
|
820
|
+
}));
|
|
769
821
|
if (snapshotOrRetry === true)
|
|
770
822
|
return continuePolling;
|
|
823
|
+
if (snapshotOrRetry === false)
|
|
824
|
+
throw new import_dom.NonRecoverableDOMError(`Selector "${(0, import_selectorParser.stringifySelector)(options.info.parsed)}" does not match any element`);
|
|
771
825
|
return snapshotOrRetry;
|
|
772
826
|
} catch (e) {
|
|
773
827
|
if (frame.isNonRetriableError(e))
|
|
@@ -775,18 +829,23 @@ async function snapshotFrameForAI(progress, frame, options = {}) {
|
|
|
775
829
|
return continuePolling;
|
|
776
830
|
}
|
|
777
831
|
});
|
|
778
|
-
const
|
|
832
|
+
const renderedIframeRefs = snapshot.iframeRefs.filter((ref) => ref in snapshot.iframeDepths);
|
|
833
|
+
const childSnapshotPromises = renderedIframeRefs.map((ref) => {
|
|
834
|
+
const iframeDepth = snapshot.iframeDepths[ref];
|
|
835
|
+
const childDepth = options.depth ? options.depth - iframeDepth - 1 : void 0;
|
|
836
|
+
return ariaSnapshotFrameRef(progress, frame, ref, { ...options, depth: childDepth });
|
|
837
|
+
});
|
|
779
838
|
const childSnapshots = await Promise.all(childSnapshotPromises);
|
|
780
839
|
const full = [];
|
|
781
840
|
let incremental;
|
|
782
841
|
if (snapshot.incremental !== void 0) {
|
|
783
842
|
incremental = snapshot.incremental.split("\n");
|
|
784
|
-
for (let i = 0; i <
|
|
843
|
+
for (let i = 0; i < renderedIframeRefs.length; i++) {
|
|
785
844
|
const childSnapshot = childSnapshots[i];
|
|
786
845
|
if (childSnapshot.incremental)
|
|
787
846
|
incremental.push(...childSnapshot.incremental);
|
|
788
847
|
else if (childSnapshot.full.length)
|
|
789
|
-
incremental.push("- <changed> iframe [ref=" +
|
|
848
|
+
incremental.push("- <changed> iframe [ref=" + renderedIframeRefs[i] + "]:", ...childSnapshot.full.map((l) => " " + l));
|
|
790
849
|
}
|
|
791
850
|
}
|
|
792
851
|
for (const line of snapshot.full.split("\n")) {
|
|
@@ -797,20 +856,20 @@ async function snapshotFrameForAI(progress, frame, options = {}) {
|
|
|
797
856
|
}
|
|
798
857
|
const leadingSpace = match[1];
|
|
799
858
|
const ref = match[2];
|
|
800
|
-
const childSnapshot = childSnapshots[
|
|
859
|
+
const childSnapshot = childSnapshots[renderedIframeRefs.indexOf(ref)] ?? { full: [] };
|
|
801
860
|
full.push(childSnapshot.full.length ? line + ":" : line);
|
|
802
861
|
full.push(...childSnapshot.full.map((l) => leadingSpace + " " + l));
|
|
803
862
|
}
|
|
804
863
|
return { full, incremental };
|
|
805
864
|
}
|
|
806
|
-
async function
|
|
865
|
+
async function ariaSnapshotFrameRef(progress, parentFrame, frameRef, options) {
|
|
807
866
|
const frameSelector = `aria-ref=${frameRef} >> internal:control=enter-frame`;
|
|
808
867
|
const frameBodySelector = `${frameSelector} >> body`;
|
|
809
868
|
const child = await progress.race(parentFrame.selectors.resolveFrameForSelector(frameBodySelector, { strict: true }));
|
|
810
869
|
if (!child)
|
|
811
870
|
return { full: [] };
|
|
812
871
|
try {
|
|
813
|
-
return await
|
|
872
|
+
return await ariaSnapshotForFrame(progress, child.frame, { ...options, info: void 0 });
|
|
814
873
|
} catch {
|
|
815
874
|
return { full: [] };
|
|
816
875
|
}
|
|
@@ -826,5 +885,6 @@ function ensureArrayLimit(array, limit) {
|
|
|
826
885
|
Page,
|
|
827
886
|
PageBinding,
|
|
828
887
|
Worker,
|
|
829
|
-
WorkerEvent
|
|
888
|
+
WorkerEvent,
|
|
889
|
+
ariaSnapshotForFrame
|
|
830
890
|
});
|
package/lib/server/progress.js
CHANGED
|
@@ -39,10 +39,16 @@ class ProgressController {
|
|
|
39
39
|
static createForSdkObject(sdkObject, callMetadata) {
|
|
40
40
|
const logName = sdkObject.logName || "api";
|
|
41
41
|
return new ProgressController(callMetadata, (message) => {
|
|
42
|
+
if (logName === "api" && sdkObject.attribution.playwright?.options.isInternalPlaywright)
|
|
43
|
+
return;
|
|
42
44
|
import_utils.debugLogger.log(logName, message);
|
|
43
45
|
sdkObject.instrumentation.onCallLog(sdkObject, callMetadata, logName, message);
|
|
44
46
|
});
|
|
45
47
|
}
|
|
48
|
+
static runInternalTask(task, timeout) {
|
|
49
|
+
const progress = new ProgressController();
|
|
50
|
+
return progress.run(task, timeout);
|
|
51
|
+
}
|
|
46
52
|
async abort(error) {
|
|
47
53
|
if (this._state === "running") {
|
|
48
54
|
error[kAbortErrorSymbol] = true;
|
|
@@ -125,7 +125,7 @@ class RecorderApp {
|
|
|
125
125
|
if (source) {
|
|
126
126
|
if (source.isRecorded)
|
|
127
127
|
this._selectedGeneratorId = source.id;
|
|
128
|
-
this._recorder.setLanguage(source.language);
|
|
128
|
+
await this._recorder.setLanguage(source.language);
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
131
|
setAutoExpect: async (params) => {
|
|
@@ -133,7 +133,7 @@ class RecorderApp {
|
|
|
133
133
|
this._updateActions();
|
|
134
134
|
},
|
|
135
135
|
setMode: async (params) => {
|
|
136
|
-
this._recorder.setMode(params.mode);
|
|
136
|
+
await this._recorder.setMode(params.mode);
|
|
137
137
|
},
|
|
138
138
|
resume: async () => {
|
|
139
139
|
this._recorder.resume();
|
|
@@ -146,9 +146,9 @@ class RecorderApp {
|
|
|
146
146
|
},
|
|
147
147
|
highlightRequested: async (params) => {
|
|
148
148
|
if (params.selector)
|
|
149
|
-
this._recorder.setHighlightedSelector(params.selector);
|
|
149
|
+
await this._recorder.setHighlightedSelector(params.selector);
|
|
150
150
|
if (params.ariaTemplate)
|
|
151
|
-
this._recorder.setHighlightedAriaTemplate(params.ariaTemplate);
|
|
151
|
+
await this._recorder.setHighlightedAriaTemplate(params.ariaTemplate);
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
154
|
await this._page.exposeBinding(progress, "sendCommand", false, async (_, data) => {
|
|
@@ -181,6 +181,7 @@ class RecorderApp {
|
|
|
181
181
|
return;
|
|
182
182
|
inspectedContext[recorderAppSymbol] = true;
|
|
183
183
|
const sdkLanguage = inspectedContext._browser.sdkLanguage();
|
|
184
|
+
const isChromium = inspectedContext._browser.options.browserType === "chromium";
|
|
184
185
|
const headed = !!inspectedContext._browser.options.headful;
|
|
185
186
|
const recorderPlaywright = require("../playwright").createPlaywright({ sdkLanguage: "javascript", isInternalPlaywright: true });
|
|
186
187
|
const { context: appContext, page } = await (0, import_launchApp2.launchApp)(recorderPlaywright.chromium, {
|
|
@@ -192,9 +193,9 @@ class RecorderApp {
|
|
|
192
193
|
headless: !!process.env.PWTEST_CLI_HEADLESS || (0, import_debug.isUnderTest)() && !headed,
|
|
193
194
|
cdpPort: (0, import_debug.isUnderTest)() ? 0 : void 0,
|
|
194
195
|
handleSIGINT: params.handleSIGINT,
|
|
195
|
-
executablePath:
|
|
196
|
+
executablePath: isChromium ? inspectedContext._browser.options.customExecutablePath : void 0,
|
|
196
197
|
// Use the same channel as the inspected context to guarantee that the browser is installed.
|
|
197
|
-
channel:
|
|
198
|
+
channel: isChromium ? inspectedContext._browser.options.channel : void 0
|
|
198
199
|
}
|
|
199
200
|
});
|
|
200
201
|
const controller = new import_progress.ProgressController();
|
|
@@ -206,8 +207,8 @@ class RecorderApp {
|
|
|
206
207
|
sdkLanguage: inspectedContext._browser.sdkLanguage(),
|
|
207
208
|
wsEndpointForTest: inspectedContext._browser.options.wsEndpoint,
|
|
208
209
|
headed: !!inspectedContext._browser.options.headful,
|
|
209
|
-
executablePath:
|
|
210
|
-
channel:
|
|
210
|
+
executablePath: isChromium ? inspectedContext._browser.options.customExecutablePath : void 0,
|
|
211
|
+
channel: isChromium ? inspectedContext._browser.options.channel : void 0,
|
|
211
212
|
...params
|
|
212
213
|
};
|
|
213
214
|
const recorderApp = new RecorderApp(recorder, appParams, page, appContext._browser.options.wsEndpoint);
|