patchright-core 1.58.2 → 1.59.1
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 +22 -61
- package/lib/client/browserType.js +19 -51
- 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 -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 +10 -23
- package/lib/client/harRouter.js +13 -1
- package/lib/client/jsHandle.js +4 -8
- package/lib/client/locator.js +13 -44
- package/lib/client/network.js +15 -16
- package/lib/client/page.js +41 -75
- 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 -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 +0 -6
- package/lib/mcpBundleImpl.js +91 -0
- package/lib/protocol/validator.js +224 -138
- 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 +110 -58
- package/lib/server/browserType.js +14 -12
- package/lib/server/chromium/chromium.js +15 -12
- package/lib/server/chromium/chromiumSwitches.js +14 -2
- package/lib/server/chromium/crBrowser.js +20 -17
- package/lib/server/chromium/crCoverage.js +1 -13
- package/lib/server/chromium/crDevTools.js +1 -0
- package/lib/server/chromium/crNetworkManager.js +12 -267
- package/lib/server/chromium/crPage.js +67 -199
- package/lib/server/chromium/crServiceWorker.js +7 -14
- package/lib/server/clock.js +33 -41
- 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 +29 -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 +6 -6
- package/lib/server/dispatchers/jsHandleDispatcher.js +2 -2
- 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/frameSelectors.js +5 -172
- package/lib/server/frames.js +234 -687
- 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/javascript.js +6 -26
- package/lib/server/launchApp.js +1 -3
- 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 +157 -105
- 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 +55 -82
- package/lib/server/registry/nativeDeps.js +1 -0
- package/lib/server/screencast.js +90 -143
- package/lib/server/screenshotter.js +0 -6
- package/lib/server/trace/recorder/snapshotter.js +8 -17
- package/lib/server/trace/recorder/snapshotterInjected.js +82 -20
- package/lib/server/trace/recorder/tracing.js +87 -44
- 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 +6 -5
- 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-CFUTFUO7.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-BVA4h_ZY.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.BtyWtaE-.js → index.C5466mMT.js} +1 -1
- package/lib/vite/traceViewer/{index.BVu7tZDe.css → index.CzXZzn5A.css} +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/server/pageBinding.js +0 -87
- package/lib/utils/isomorphic/oldUtilityScriptSerializers.js +0 -248
- package/lib/vite/recorder/assets/index-CVkBxsGf.js +0 -193
- package/lib/vite/traceViewer/assets/defaultSettingsView-CjfmcdOz.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +0 -1
- package/lib/vite/traceViewer/uiMode.fyrXARf2.js +0 -5
- /package/lib/{server/utils → utils/isomorphic}/imageUtils.js +0 -0
- /package/lib/utils/isomorphic/{traceUtils.js → trace/traceUtils.js} +0 -0
|
@@ -34,9 +34,12 @@ var import_networkDispatchers = require("./networkDispatchers");
|
|
|
34
34
|
var import_networkDispatchers2 = require("./networkDispatchers");
|
|
35
35
|
var import_networkDispatchers3 = require("./networkDispatchers");
|
|
36
36
|
var import_webSocketRouteDispatcher = require("./webSocketRouteDispatcher");
|
|
37
|
+
var import_disposableDispatcher = require("./disposableDispatcher");
|
|
37
38
|
var import_instrumentation = require("../instrumentation");
|
|
38
39
|
var import_urlMatch = require("../../utils/isomorphic/urlMatch");
|
|
39
|
-
var
|
|
40
|
+
var import_recorder = require("../recorder");
|
|
41
|
+
var import_disposable = require("../disposable");
|
|
42
|
+
var import_videoRecorder = require("../videoRecorder");
|
|
40
43
|
class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
41
44
|
constructor(parentScope, page) {
|
|
42
45
|
const mainFrame = import_frameDispatcher.FrameDispatcher.from(parentScope, page.mainFrame());
|
|
@@ -44,14 +47,14 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
44
47
|
mainFrame,
|
|
45
48
|
viewportSize: page.emulatedSize()?.viewport,
|
|
46
49
|
isClosed: page.isClosed(),
|
|
47
|
-
opener: PageDispatcher.fromNullable(parentScope, page.opener())
|
|
50
|
+
opener: PageDispatcher.fromNullable(parentScope, page.opener()),
|
|
51
|
+
video: page.video ? createVideoDispatcher(parentScope, page.video) : void 0
|
|
48
52
|
});
|
|
49
53
|
this._type_EventTarget = true;
|
|
50
54
|
this._type_Page = true;
|
|
51
55
|
this._subscriptions = /* @__PURE__ */ new Set();
|
|
52
56
|
this._webSocketInterceptionPatterns = [];
|
|
53
|
-
this.
|
|
54
|
-
this._initScripts = [];
|
|
57
|
+
this._disposables = [];
|
|
55
58
|
this._interceptionUrlMatchers = [];
|
|
56
59
|
this._locatorHandlers = /* @__PURE__ */ new Set();
|
|
57
60
|
this._jsCoverageActive = false;
|
|
@@ -85,9 +88,6 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
85
88
|
this.addObjectListener(import_page.Page.Events.LocatorHandlerTriggered, (uid) => this._dispatchEvent("locatorHandlerTriggered", { uid }));
|
|
86
89
|
this.addObjectListener(import_page.Page.Events.WebSocket, (webSocket) => this._dispatchEvent("webSocket", { webSocket: new import_networkDispatchers3.WebSocketDispatcher(this, webSocket) }));
|
|
87
90
|
this.addObjectListener(import_page.Page.Events.Worker, (worker) => this._dispatchEvent("worker", { worker: new WorkerDispatcher(this, worker) }));
|
|
88
|
-
this.addObjectListener(import_page.Page.Events.Video, (artifact) => this._dispatchEvent("video", { artifact: import_artifactDispatcher.ArtifactDispatcher.from(parentScope, artifact) }));
|
|
89
|
-
if (page.video)
|
|
90
|
-
this._dispatchEvent("video", { artifact: import_artifactDispatcher.ArtifactDispatcher.from(this.parentScope(), page.video) });
|
|
91
91
|
const frames = page.frameManager.frames();
|
|
92
92
|
for (let i = 1; i < frames.length; i++)
|
|
93
93
|
this._onFrameAttached(frames[i]);
|
|
@@ -112,7 +112,8 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
112
112
|
this._dispatchEvent("bindingCall", { binding: binding2 });
|
|
113
113
|
return binding2.promise();
|
|
114
114
|
});
|
|
115
|
-
this.
|
|
115
|
+
this._disposables.push(binding);
|
|
116
|
+
return { disposable: new import_disposableDispatcher.DisposableDispatcher(this, binding) };
|
|
116
117
|
}
|
|
117
118
|
async setExtraHTTPHeaders(params, progress) {
|
|
118
119
|
await this._page.setExtraHTTPHeaders(progress, params.headers);
|
|
@@ -154,7 +155,9 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
154
155
|
await this._page.setViewportSize(progress, params.viewportSize);
|
|
155
156
|
}
|
|
156
157
|
async addInitScript(params, progress) {
|
|
157
|
-
|
|
158
|
+
const initScript = await this._page.addInitScript(params.source);
|
|
159
|
+
this._disposables.push(initScript);
|
|
160
|
+
return { disposable: new import_disposableDispatcher.DisposableDispatcher(this, initScript) };
|
|
158
161
|
}
|
|
159
162
|
async setNetworkInterceptionPatterns(params, progress) {
|
|
160
163
|
const hadMatchers = this._interceptionUrlMatchers.length > 0;
|
|
@@ -163,7 +166,7 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
163
166
|
await this._page.removeRequestInterceptor(this._requestInterceptor);
|
|
164
167
|
this._interceptionUrlMatchers = [];
|
|
165
168
|
} else {
|
|
166
|
-
this._interceptionUrlMatchers = params.patterns.map(
|
|
169
|
+
this._interceptionUrlMatchers = params.patterns.map(import_urlMatch.deserializeURLMatch);
|
|
167
170
|
if (!hadMatchers)
|
|
168
171
|
await this._page.addRequestInterceptor(progress, this._requestInterceptor);
|
|
169
172
|
}
|
|
@@ -209,49 +212,51 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
209
212
|
this._subscriptions.delete(params.event);
|
|
210
213
|
}
|
|
211
214
|
async keyboardDown(params, progress) {
|
|
212
|
-
await this._page.keyboard.
|
|
215
|
+
await this._page.keyboard.apiDown(progress, params.key);
|
|
213
216
|
}
|
|
214
217
|
async keyboardUp(params, progress) {
|
|
215
|
-
await this._page.keyboard.
|
|
218
|
+
await this._page.keyboard.apiUp(progress, params.key);
|
|
216
219
|
}
|
|
217
220
|
async keyboardInsertText(params, progress) {
|
|
218
|
-
await this._page.keyboard.
|
|
221
|
+
await this._page.keyboard.apiInsertText(progress, params.text);
|
|
219
222
|
}
|
|
220
223
|
async keyboardType(params, progress) {
|
|
221
|
-
await this._page.keyboard.
|
|
224
|
+
await this._page.keyboard.apiType(progress, params.text, params);
|
|
222
225
|
}
|
|
223
226
|
async keyboardPress(params, progress) {
|
|
224
|
-
await this._page.keyboard.
|
|
227
|
+
await this._page.keyboard.apiPress(progress, params.key, params);
|
|
228
|
+
}
|
|
229
|
+
async clearConsoleMessages(params, progress) {
|
|
230
|
+
this._page.clearConsoleMessages();
|
|
225
231
|
}
|
|
226
232
|
async consoleMessages(params, progress) {
|
|
227
233
|
this._subscriptions.add("console");
|
|
228
|
-
return { messages: this._page.consoleMessages().map((message) => this.parentScope().serializeConsoleMessage(message, this)) };
|
|
234
|
+
return { messages: this._page.consoleMessages(params.filter).map((message) => this.parentScope().serializeConsoleMessage(message, this)) };
|
|
235
|
+
}
|
|
236
|
+
async clearPageErrors(params, progress) {
|
|
237
|
+
this._page.clearPageErrors();
|
|
229
238
|
}
|
|
230
239
|
async pageErrors(params, progress) {
|
|
231
|
-
return { errors: this._page.pageErrors().map((error) => (0, import_errors.serializeError)(error)) };
|
|
240
|
+
return { errors: this._page.pageErrors(params.filter).map((error) => (0, import_errors.serializeError)(error)) };
|
|
232
241
|
}
|
|
233
242
|
async mouseMove(params, progress) {
|
|
234
|
-
|
|
235
|
-
await this._page.mouse.move(progress, params.x, params.y, params);
|
|
243
|
+
await this._page.mouse.apiMove(progress, params.x, params.y, params);
|
|
236
244
|
}
|
|
237
245
|
async mouseDown(params, progress) {
|
|
238
|
-
|
|
239
|
-
await this._page.mouse.down(progress, params);
|
|
246
|
+
await this._page.mouse.apiDown(progress, params);
|
|
240
247
|
}
|
|
241
248
|
async mouseUp(params, progress) {
|
|
242
|
-
|
|
243
|
-
await this._page.mouse.up(progress, params);
|
|
249
|
+
await this._page.mouse.apiUp(progress, params);
|
|
244
250
|
}
|
|
245
251
|
async mouseClick(params, progress) {
|
|
246
|
-
|
|
247
|
-
await this._page.mouse.click(progress, params.x, params.y, params);
|
|
252
|
+
await this._page.mouse.apiClick(progress, params.x, params.y, params);
|
|
248
253
|
}
|
|
249
254
|
async mouseWheel(params, progress) {
|
|
250
|
-
await this._page.mouse.
|
|
255
|
+
await this._page.mouse.apiWheel(progress, params.deltaX, params.deltaY);
|
|
251
256
|
}
|
|
252
257
|
async touchscreenTap(params, progress) {
|
|
253
258
|
progress.metadata.point = { x: params.x, y: params.y };
|
|
254
|
-
await this._page.touchscreen.
|
|
259
|
+
await this._page.touchscreen.apiTap(progress, params.x, params.y);
|
|
255
260
|
}
|
|
256
261
|
async pdf(params, progress) {
|
|
257
262
|
if (!this._page.pdf)
|
|
@@ -263,12 +268,69 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
263
268
|
this._subscriptions.add("request");
|
|
264
269
|
return { requests: this._page.networkRequests().map((request) => import_networkDispatchers.RequestDispatcher.from(this.parentScope(), request)) };
|
|
265
270
|
}
|
|
266
|
-
async snapshotForAI(params, progress) {
|
|
267
|
-
return await this._page.snapshotForAI(progress, params);
|
|
268
|
-
}
|
|
269
271
|
async bringToFront(params, progress) {
|
|
270
272
|
await progress.race(this._page.bringToFront());
|
|
271
273
|
}
|
|
274
|
+
async pickLocator(params, progress) {
|
|
275
|
+
const recorder = await import_recorder.Recorder.forContext(this._page.browserContext, { omitCallTracking: true, hideToolbar: true });
|
|
276
|
+
const selector = await recorder.pickLocator(progress, this._page);
|
|
277
|
+
return { selector };
|
|
278
|
+
}
|
|
279
|
+
async cancelPickLocator(params, progress) {
|
|
280
|
+
const recorder = await import_recorder.Recorder.existingForContext(this._page.browserContext);
|
|
281
|
+
await recorder?.setMode("none");
|
|
282
|
+
}
|
|
283
|
+
async screencastShowOverlay(params) {
|
|
284
|
+
const id = await this._page.overlay.show(params.html, params.duration);
|
|
285
|
+
return { id };
|
|
286
|
+
}
|
|
287
|
+
async screencastRemoveOverlay(params) {
|
|
288
|
+
await this._page.overlay.remove(params.id);
|
|
289
|
+
}
|
|
290
|
+
async screencastChapter(params) {
|
|
291
|
+
await this._page.overlay.chapter(params);
|
|
292
|
+
}
|
|
293
|
+
async screencastSetOverlayVisible(params) {
|
|
294
|
+
await this._page.overlay.setVisible(params.visible);
|
|
295
|
+
}
|
|
296
|
+
async screencastShowActions(params) {
|
|
297
|
+
this._page.screencast.showActions({ duration: params.duration, position: params.position, fontSize: params.fontSize });
|
|
298
|
+
}
|
|
299
|
+
async screencastHideActions() {
|
|
300
|
+
this._page.screencast.hideActions();
|
|
301
|
+
}
|
|
302
|
+
async screencastStart(params, progress) {
|
|
303
|
+
if (this._screencastClient || this._videoRecorder)
|
|
304
|
+
throw new Error("Screencast is already running");
|
|
305
|
+
if (params.sendFrames) {
|
|
306
|
+
this._screencastClient = {
|
|
307
|
+
onFrame: (frame) => {
|
|
308
|
+
this._dispatchEvent("screencastFrame", { data: frame.buffer });
|
|
309
|
+
},
|
|
310
|
+
dispose: () => {
|
|
311
|
+
},
|
|
312
|
+
size: params.size,
|
|
313
|
+
quality: params.quality
|
|
314
|
+
};
|
|
315
|
+
this._page.screencast.addClient(this._screencastClient);
|
|
316
|
+
}
|
|
317
|
+
let artifact;
|
|
318
|
+
if (params.record) {
|
|
319
|
+
this._videoRecorder = new import_videoRecorder.VideoRecorder(this._page.screencast);
|
|
320
|
+
artifact = this._videoRecorder.start(params);
|
|
321
|
+
}
|
|
322
|
+
return { artifact: artifact ? createVideoDispatcher(this.parentScope(), artifact) : void 0 };
|
|
323
|
+
}
|
|
324
|
+
async screencastStop(params, progress) {
|
|
325
|
+
if (this._videoRecorder) {
|
|
326
|
+
await this._videoRecorder.stop();
|
|
327
|
+
this._videoRecorder = void 0;
|
|
328
|
+
}
|
|
329
|
+
const client = this._screencastClient;
|
|
330
|
+
this._screencastClient = void 0;
|
|
331
|
+
if (client)
|
|
332
|
+
this._page.screencast.removeClient(client);
|
|
333
|
+
}
|
|
272
334
|
async startJSCoverage(params, progress) {
|
|
273
335
|
const coverage = this._page.coverage;
|
|
274
336
|
await coverage.startJSCoverage(progress, params);
|
|
@@ -289,9 +351,6 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
289
351
|
const coverage = this._page.coverage;
|
|
290
352
|
return await coverage.stopCSSCoverage();
|
|
291
353
|
}
|
|
292
|
-
async agent(params, progress) {
|
|
293
|
-
return { agent: new import_pageAgentDispatcher.PageAgentDispatcher(this, params) };
|
|
294
|
-
}
|
|
295
354
|
_onFrameAttached(frame) {
|
|
296
355
|
this._dispatchEvent("frameAttached", { frame: import_frameDispatcher.FrameDispatcher.from(this.parentScope(), frame) });
|
|
297
356
|
}
|
|
@@ -304,12 +363,8 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
304
363
|
this._interceptionUrlMatchers = [];
|
|
305
364
|
this._page.removeRequestInterceptor(this._requestInterceptor).catch(() => {
|
|
306
365
|
});
|
|
307
|
-
|
|
308
|
-
});
|
|
309
|
-
this._bindings = [];
|
|
310
|
-
this._page.removeInitScripts(this._initScripts).catch(() => {
|
|
366
|
+
(0, import_disposable.disposeAll)(this._disposables).catch(() => {
|
|
311
367
|
});
|
|
312
|
-
this._initScripts = [];
|
|
313
368
|
if (this._routeWebSocketInitScript)
|
|
314
369
|
import_webSocketRouteDispatcher.WebSocketRouteDispatcher.uninstall(this.connection, this._page, this._routeWebSocketInitScript).catch(() => {
|
|
315
370
|
});
|
|
@@ -327,6 +382,11 @@ class PageDispatcher extends import_dispatcher.Dispatcher {
|
|
|
327
382
|
this._page.coverage.stopCSSCoverage().catch(() => {
|
|
328
383
|
});
|
|
329
384
|
this._cssCoverageActive = false;
|
|
385
|
+
this.screencastStop({}, void 0).catch(() => {
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
async setDockTile(params) {
|
|
389
|
+
await this._page.setDockTile(params.image);
|
|
330
390
|
}
|
|
331
391
|
}
|
|
332
392
|
class WorkerDispatcher extends import_dispatcher.Dispatcher {
|
|
@@ -385,6 +445,9 @@ class BindingCallDispatcher extends import_dispatcher.Dispatcher {
|
|
|
385
445
|
this._dispose();
|
|
386
446
|
}
|
|
387
447
|
}
|
|
448
|
+
function createVideoDispatcher(parentScope, video) {
|
|
449
|
+
return import_artifactDispatcher.ArtifactDispatcher.from(parentScope.parentScope(), video);
|
|
450
|
+
}
|
|
388
451
|
// Annotate the CommonJS export names for ESM import in node:
|
|
389
452
|
0 && (module.exports = {
|
|
390
453
|
BindingCallDispatcher,
|
|
@@ -101,7 +101,7 @@ class WebSocketRouteDispatcher extends import_dispatcher.Dispatcher {
|
|
|
101
101
|
}, data);
|
|
102
102
|
}
|
|
103
103
|
++data.counter;
|
|
104
|
-
return await target.addInitScript(
|
|
104
|
+
return await target.addInitScript(`
|
|
105
105
|
(() => {
|
|
106
106
|
const module = {};
|
|
107
107
|
${rawWebSocketMockSource.source}
|
|
@@ -115,8 +115,8 @@ class WebSocketRouteDispatcher extends import_dispatcher.Dispatcher {
|
|
|
115
115
|
if (!data || data.connection !== connection)
|
|
116
116
|
return;
|
|
117
117
|
if (--data.counter <= 0)
|
|
118
|
-
await
|
|
119
|
-
await
|
|
118
|
+
await data.binding.dispose();
|
|
119
|
+
await initScript.dispose();
|
|
120
120
|
}
|
|
121
121
|
async connect(params, progress) {
|
|
122
122
|
await this._evaluateAPIRequest(progress, { id: this._id, type: "connect" });
|
|
@@ -152,8 +152,7 @@ class WebSocketRouteDispatcher extends import_dispatcher.Dispatcher {
|
|
|
152
152
|
}
|
|
153
153
|
function matchesPattern(dispatcher, baseURL, url) {
|
|
154
154
|
for (const pattern of dispatcher._webSocketInterceptionPatterns || []) {
|
|
155
|
-
|
|
156
|
-
if ((0, import_urlMatch.urlMatches)(baseURL, url, urlMatch, true))
|
|
155
|
+
if ((0, import_urlMatch.urlMatches)(baseURL, url, (0, import_urlMatch.deserializeURLMatch)(pattern), true))
|
|
157
156
|
return true;
|
|
158
157
|
}
|
|
159
158
|
return false;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 disposable_exports = {};
|
|
20
|
+
__export(disposable_exports, {
|
|
21
|
+
DisposableObject: () => DisposableObject,
|
|
22
|
+
disposeAll: () => disposeAll
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(disposable_exports);
|
|
25
|
+
var import_instrumentation = require("./instrumentation");
|
|
26
|
+
class DisposableObject extends import_instrumentation.SdkObject {
|
|
27
|
+
constructor(parent) {
|
|
28
|
+
super(parent, "disposable");
|
|
29
|
+
this.parent = parent;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function disposeAll(disposables) {
|
|
33
|
+
const copy = [...disposables];
|
|
34
|
+
disposables.length = 0;
|
|
35
|
+
await Promise.all(copy.map((d) => d.dispose()));
|
|
36
|
+
}
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
DisposableObject,
|
|
40
|
+
disposeAll
|
|
41
|
+
});
|
package/lib/server/dom.js
CHANGED
|
@@ -202,17 +202,17 @@ class ElementHandle extends js.JSHandle {
|
|
|
202
202
|
);
|
|
203
203
|
}
|
|
204
204
|
async _clickablePoint() {
|
|
205
|
-
const intersectQuadWithViewport = (
|
|
206
|
-
return
|
|
205
|
+
const intersectQuadWithViewport = (quad2) => {
|
|
206
|
+
return quad2.map((point) => ({
|
|
207
207
|
x: Math.min(Math.max(point.x, 0), metrics.width),
|
|
208
208
|
y: Math.min(Math.max(point.y, 0), metrics.height)
|
|
209
209
|
}));
|
|
210
210
|
};
|
|
211
|
-
const computeQuadArea = (
|
|
211
|
+
const computeQuadArea = (quad2) => {
|
|
212
212
|
let area = 0;
|
|
213
|
-
for (let i = 0; i <
|
|
214
|
-
const p1 =
|
|
215
|
-
const p2 =
|
|
213
|
+
for (let i = 0; i < quad2.length; ++i) {
|
|
214
|
+
const p1 = quad2[i];
|
|
215
|
+
const p2 = quad2[(i + 1) % quad2.length];
|
|
216
216
|
area += (p1.x * p2.y - p2.x * p1.y) / 2;
|
|
217
217
|
}
|
|
218
218
|
return Math.abs(area);
|
|
@@ -225,17 +225,19 @@ class ElementHandle extends js.JSHandle {
|
|
|
225
225
|
return quads;
|
|
226
226
|
if (!quads || !quads.length)
|
|
227
227
|
return "error:notvisible";
|
|
228
|
-
const filtered = quads.map((
|
|
228
|
+
const filtered = quads.map((quad2) => intersectQuadWithViewport(quad2)).filter((quad2) => computeQuadArea(quad2) > 0.99);
|
|
229
229
|
if (!filtered.length)
|
|
230
230
|
return "error:notinviewport";
|
|
231
|
+
const quad = filtered[0];
|
|
232
|
+
const box = quadToRect(quad);
|
|
231
233
|
if (this._page.browserContext._browser.options.name === "firefox") {
|
|
232
|
-
for (const
|
|
233
|
-
const integerPoint = findIntegerPointInsideQuad(
|
|
234
|
+
for (const q of filtered) {
|
|
235
|
+
const integerPoint = findIntegerPointInsideQuad(q);
|
|
234
236
|
if (integerPoint)
|
|
235
|
-
return integerPoint;
|
|
237
|
+
return { point: integerPoint, box };
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
|
-
return quadMiddlePoint(
|
|
240
|
+
return { point: quadMiddlePoint(quad), box };
|
|
239
241
|
}
|
|
240
242
|
async _offsetPoint(offset) {
|
|
241
243
|
const [box, border] = await Promise.all([
|
|
@@ -248,8 +250,11 @@ class ElementHandle extends js.JSHandle {
|
|
|
248
250
|
if (border === "error:notconnected")
|
|
249
251
|
return border;
|
|
250
252
|
return {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
point: {
|
|
254
|
+
x: box.x + border.left + offset.x,
|
|
255
|
+
y: box.y + border.top + offset.y
|
|
256
|
+
},
|
|
257
|
+
box
|
|
253
258
|
};
|
|
254
259
|
}
|
|
255
260
|
async _retryAction(progress, actionName, action, options) {
|
|
@@ -360,11 +365,12 @@ class ElementHandle extends js.JSHandle {
|
|
|
360
365
|
if (scrolled !== "done")
|
|
361
366
|
return scrolled;
|
|
362
367
|
progress.log(" done scrolling");
|
|
363
|
-
const
|
|
364
|
-
if (typeof
|
|
365
|
-
return
|
|
366
|
-
const point = roundPoint(
|
|
368
|
+
const maybeResult = position ? await progress.race(this._offsetPoint(position)) : await progress.race(this._clickablePoint());
|
|
369
|
+
if (typeof maybeResult === "string")
|
|
370
|
+
return maybeResult;
|
|
371
|
+
const point = roundPoint(maybeResult.point);
|
|
367
372
|
progress.metadata.point = point;
|
|
373
|
+
progress.metadata.box = maybeResult.box;
|
|
368
374
|
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
369
375
|
let hitTargetInterceptionHandle;
|
|
370
376
|
if (force) {
|
|
@@ -470,10 +476,15 @@ class ElementHandle extends js.JSHandle {
|
|
|
470
476
|
const result = await this._selectOption(progress, elements, values, options);
|
|
471
477
|
return throwRetargetableDOMError(result);
|
|
472
478
|
}
|
|
479
|
+
async _beforeNonPointerAction(progress) {
|
|
480
|
+
if (progress.metadata.annotate)
|
|
481
|
+
progress.metadata.box = await this.boundingBox() || void 0;
|
|
482
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
|
483
|
+
}
|
|
473
484
|
async _selectOption(progress, elements, values, options) {
|
|
474
485
|
let resultingOptions = [];
|
|
475
486
|
const result = await this._retryAction(progress, "select option", async () => {
|
|
476
|
-
await
|
|
487
|
+
await this._beforeNonPointerAction(progress);
|
|
477
488
|
if (!options.force)
|
|
478
489
|
progress.log(` waiting for element to be visible and enabled`);
|
|
479
490
|
const optionsToSelect = [...elements, ...values];
|
|
@@ -504,7 +515,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
504
515
|
async _fill(progress, value, options) {
|
|
505
516
|
progress.log(` fill("${value}")`);
|
|
506
517
|
return await this._retryAction(progress, "fill", async () => {
|
|
507
|
-
await
|
|
518
|
+
await this._beforeNonPointerAction(progress);
|
|
508
519
|
if (!options.force)
|
|
509
520
|
progress.log(" waiting for element to be visible, enabled and editable");
|
|
510
521
|
const result = await progress.race(this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
|
|
@@ -517,7 +528,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
517
528
|
}, { value, force: options.force }));
|
|
518
529
|
if (result === "needsinput") {
|
|
519
530
|
if (value)
|
|
520
|
-
await this._page.keyboard.
|
|
531
|
+
await this._page.keyboard._insertText(progress, value);
|
|
521
532
|
else
|
|
522
533
|
await this._page.keyboard.press(progress, "Delete");
|
|
523
534
|
return "done";
|
|
@@ -568,7 +579,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
568
579
|
if (result === "error:notconnected" || !result.asElement())
|
|
569
580
|
return "error:notconnected";
|
|
570
581
|
const retargeted = result.asElement();
|
|
571
|
-
await
|
|
582
|
+
await this._beforeNonPointerAction(progress);
|
|
572
583
|
if (localPaths || localDirectory) {
|
|
573
584
|
const localPathsOrDirectory = localDirectory ? [localDirectory] : localPaths;
|
|
574
585
|
await progress.race(Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK))));
|
|
@@ -601,7 +612,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
601
612
|
}
|
|
602
613
|
async _type(progress, text, options) {
|
|
603
614
|
progress.log(`elementHandle.type("${text}")`);
|
|
604
|
-
await
|
|
615
|
+
await this._beforeNonPointerAction(progress);
|
|
605
616
|
const result = await this._focus(
|
|
606
617
|
progress,
|
|
607
618
|
true
|
|
@@ -619,7 +630,7 @@ class ElementHandle extends js.JSHandle {
|
|
|
619
630
|
}
|
|
620
631
|
async _press(progress, key, options) {
|
|
621
632
|
progress.log(`elementHandle.press("${key}")`);
|
|
622
|
-
await
|
|
633
|
+
await this._beforeNonPointerAction(progress);
|
|
623
634
|
return this._page.frameManager.waitForSignalsCreatedBy(progress, !options.noWaitAfter, async () => {
|
|
624
635
|
const result = await this._focus(
|
|
625
636
|
progress,
|
|
@@ -666,9 +677,6 @@ class ElementHandle extends js.JSHandle {
|
|
|
666
677
|
async boundingBox() {
|
|
667
678
|
return this._page.delegate.getBoundingBox(this);
|
|
668
679
|
}
|
|
669
|
-
async ariaSnapshot() {
|
|
670
|
-
return await this.evaluateInUtility(([injected, element]) => injected.ariaSnapshot(element, { mode: "expect" }), {});
|
|
671
|
-
}
|
|
672
680
|
async screenshot(progress, options) {
|
|
673
681
|
return await this._page.screenshotter.screenshotElement(progress, this, options);
|
|
674
682
|
}
|
|
@@ -767,6 +775,16 @@ function roundPoint(point) {
|
|
|
767
775
|
y: (point.y * 100 | 0) / 100
|
|
768
776
|
};
|
|
769
777
|
}
|
|
778
|
+
function quadToRect(quad) {
|
|
779
|
+
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
780
|
+
for (const point of quad) {
|
|
781
|
+
minX = Math.min(minX, point.x);
|
|
782
|
+
minY = Math.min(minY, point.y);
|
|
783
|
+
maxX = Math.max(maxX, point.x);
|
|
784
|
+
maxY = Math.max(maxY, point.y);
|
|
785
|
+
}
|
|
786
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
787
|
+
}
|
|
770
788
|
function quadMiddlePoint(quad) {
|
|
771
789
|
const result = { x: 0, y: 0 };
|
|
772
790
|
for (const point of quad) {
|
package/lib/server/download.js
CHANGED
|
@@ -36,9 +36,10 @@ var import_page = require("./page");
|
|
|
36
36
|
var import_utils = require("../utils");
|
|
37
37
|
var import_artifact = require("./artifact");
|
|
38
38
|
class Download {
|
|
39
|
-
constructor(page, downloadsPath, uuid, url, suggestedFilename) {
|
|
39
|
+
constructor(page, downloadsPath, uuid, url, suggestedFilename, downloadFilename) {
|
|
40
40
|
const unaccessibleErrorMessage = page.browserContext._options.acceptDownloads === "deny" ? "Pass { acceptDownloads: true } when you are creating your browser context." : void 0;
|
|
41
|
-
|
|
41
|
+
const downloadPath = import_path.default.join(downloadsPath, downloadFilename ?? uuid);
|
|
42
|
+
this.artifact = new import_artifact.Artifact(page, downloadPath, unaccessibleErrorMessage, () => {
|
|
42
43
|
return this._page.browserContext.cancelDownload(uuid);
|
|
43
44
|
});
|
|
44
45
|
this._page = page;
|
|
@@ -76,7 +76,6 @@ class ElectronApplication extends import_instrumentation.SdkObject {
|
|
|
76
76
|
this._nodeSession.on("Runtime.consoleAPICalled", (event) => this._onConsoleAPI(event));
|
|
77
77
|
const appClosePromise = new Promise((f) => this.once(ElectronApplication.Events.Close, f));
|
|
78
78
|
this._browserContext.setCustomCloseHandler(async () => {
|
|
79
|
-
await this._browserContext.stopVideoRecording();
|
|
80
79
|
const electronHandle = await this._nodeElectronHandlePromise;
|
|
81
80
|
await electronHandle.evaluate(({ app }) => app.quit()).catch(() => {
|
|
82
81
|
});
|
|
@@ -97,7 +96,7 @@ class ElectronApplication extends import_instrumentation.SdkObject {
|
|
|
97
96
|
if (!this._nodeExecutionContext)
|
|
98
97
|
return;
|
|
99
98
|
const args = event.args.map((arg) => (0, import_crExecutionContext.createHandle)(this._nodeExecutionContext, arg));
|
|
100
|
-
const message = new import_console.ConsoleMessage(null, null, event.type, void 0, args, (0, import_crProtocolHelper.toConsoleMessageLocation)(event.stackTrace));
|
|
99
|
+
const message = new import_console.ConsoleMessage(null, null, event.type, void 0, args, (0, import_crProtocolHelper.toConsoleMessageLocation)(event.stackTrace), event.timestamp);
|
|
101
100
|
this.emit(ElectronApplication.Events.Console, message);
|
|
102
101
|
}
|
|
103
102
|
async initialize() {
|
|
@@ -131,11 +130,17 @@ class Electron extends import_instrumentation.SdkObject {
|
|
|
131
130
|
let app = void 0;
|
|
132
131
|
let electronArguments = ["--inspect=0", "--remote-debugging-port=0", ...options.args || []];
|
|
133
132
|
if (import_os.default.platform() === "linux") {
|
|
134
|
-
|
|
135
|
-
if (runningAsRoot && electronArguments.indexOf("--no-sandbox") === -1)
|
|
133
|
+
if (!options.chromiumSandbox && electronArguments.indexOf("--no-sandbox") === -1)
|
|
136
134
|
electronArguments.unshift("--no-sandbox");
|
|
137
135
|
}
|
|
138
|
-
|
|
136
|
+
let artifactsDir;
|
|
137
|
+
const tempDirectories = [];
|
|
138
|
+
if (options.artifactsDir) {
|
|
139
|
+
artifactsDir = options.artifactsDir;
|
|
140
|
+
} else {
|
|
141
|
+
artifactsDir = await progress.race(import_fs.default.promises.mkdtemp(ARTIFACTS_FOLDER));
|
|
142
|
+
tempDirectories.push(artifactsDir);
|
|
143
|
+
}
|
|
139
144
|
const browserLogsCollector = new import_debugLogger.RecentLogsCollector();
|
|
140
145
|
const env = options.env ? (0, import_processLauncher.envArrayToObject)(options.env) : process.env;
|
|
141
146
|
let command;
|
|
@@ -173,7 +178,7 @@ class Electron extends import_instrumentation.SdkObject {
|
|
|
173
178
|
shell,
|
|
174
179
|
stdio: "pipe",
|
|
175
180
|
cwd: options.cwd,
|
|
176
|
-
tempDirectories
|
|
181
|
+
tempDirectories,
|
|
177
182
|
attemptToGracefullyClose: () => app.close(),
|
|
178
183
|
handleSIGINT: true,
|
|
179
184
|
handleSIGTERM: true,
|
|
@@ -219,7 +224,7 @@ class Electron extends import_instrumentation.SdkObject {
|
|
|
219
224
|
};
|
|
220
225
|
const browserOptions = {
|
|
221
226
|
name: "electron",
|
|
222
|
-
|
|
227
|
+
browserType: "chromium",
|
|
223
228
|
headful: true,
|
|
224
229
|
persistent: contextOptions,
|
|
225
230
|
browserProcess,
|
|
@@ -35,7 +35,6 @@ module.exports = __toCommonJS(ffBrowser_exports);
|
|
|
35
35
|
var import_utils = require("../../utils");
|
|
36
36
|
var import_browser = require("../browser");
|
|
37
37
|
var import_browserContext = require("../browserContext");
|
|
38
|
-
var import_errors = require("../errors");
|
|
39
38
|
var network = __toESM(require("../network"));
|
|
40
39
|
var import_ffConnection = require("./ffConnection");
|
|
41
40
|
var import_ffPage = require("./ffPage");
|
|
@@ -128,7 +127,7 @@ class FFBrowser extends import_browser.Browser {
|
|
|
128
127
|
ffPage._page.frameManager.frameAbortedNavigation(payload.frameId, "Download is starting");
|
|
129
128
|
let originPage = ffPage._page.initializedOrUndefined();
|
|
130
129
|
if (!originPage) {
|
|
131
|
-
ffPage.
|
|
130
|
+
ffPage._reportAsNew(new Error("Starting new page download"));
|
|
132
131
|
if (ffPage._opener)
|
|
133
132
|
originPage = ffPage._opener._page.initializedOrUndefined();
|
|
134
133
|
}
|
|
@@ -141,9 +140,6 @@ class FFBrowser extends import_browser.Browser {
|
|
|
141
140
|
this._downloadFinished(payload.uuid, error);
|
|
142
141
|
}
|
|
143
142
|
_onDisconnect() {
|
|
144
|
-
for (const video of this._idToVideo.values())
|
|
145
|
-
video.artifact.reportFinished(new import_errors.TargetClosedError(this.closeReason()));
|
|
146
|
-
this._idToVideo.clear();
|
|
147
143
|
for (const ffPage of this._ffPages.values())
|
|
148
144
|
ffPage.didClose();
|
|
149
145
|
this._ffPages.clear();
|
|
@@ -173,8 +169,11 @@ class FFBrowserContext extends import_browserContext.BrowserContext {
|
|
|
173
169
|
promises.push(this.doUpdateDefaultViewport());
|
|
174
170
|
if (this._options.hasTouch)
|
|
175
171
|
promises.push(this._browser.session.send("Browser.setTouchOverride", { browserContextId, hasTouch: true }));
|
|
176
|
-
if (this._options.userAgent)
|
|
172
|
+
if (this._options.userAgent) {
|
|
177
173
|
promises.push(this._browser.session.send("Browser.setUserAgentOverride", { browserContextId, userAgent: this._options.userAgent }));
|
|
174
|
+
const { navigatorPlatform } = (0, import_browserContext.calculateUserAgentEmulation)(this._options);
|
|
175
|
+
promises.push(this._browser.session.send("Browser.setPlatformOverride", { browserContextId, platform: navigatorPlatform || null }));
|
|
176
|
+
}
|
|
178
177
|
if (this._options.bypassCSP)
|
|
179
178
|
promises.push(this._browser.session.send("Browser.setBypassCSP", { browserContextId, bypassCSP: true }));
|
|
180
179
|
if (this._options.ignoreHTTPSErrors || this._options.internalIgnoreHTTPSErrors)
|
|
@@ -194,16 +193,6 @@ class FFBrowserContext extends import_browserContext.BrowserContext {
|
|
|
194
193
|
if (this._options.offline)
|
|
195
194
|
promises.push(this.doUpdateOffline());
|
|
196
195
|
promises.push(this.doUpdateDefaultEmulatedMedia());
|
|
197
|
-
if (this._options.recordVideo) {
|
|
198
|
-
promises.push(this._browser.session.send("Browser.setScreencastOptions", {
|
|
199
|
-
// validateBrowserContextOptions ensures correct video size.
|
|
200
|
-
options: {
|
|
201
|
-
...this._options.recordVideo.size,
|
|
202
|
-
quality: 90
|
|
203
|
-
},
|
|
204
|
-
browserContextId: this._browserContextId
|
|
205
|
-
}));
|
|
206
|
-
}
|
|
207
196
|
const proxy = this._options.proxyOverride || this._options.proxy;
|
|
208
197
|
if (proxy) {
|
|
209
198
|
promises.push(this._browser.session.send("Browser.setContextProxy", {
|
|
@@ -270,7 +259,8 @@ class FFBrowserContext extends import_browserContext.BrowserContext {
|
|
|
270
259
|
["geolocation", "geo"],
|
|
271
260
|
["persistent-storage", "persistent-storage"],
|
|
272
261
|
["push", "push"],
|
|
273
|
-
["notifications", "desktop-notification"]
|
|
262
|
+
["notifications", "desktop-notification"],
|
|
263
|
+
["screen-wake-lock", "screen-wake-lock"]
|
|
274
264
|
]);
|
|
275
265
|
const filtered = permissions.map((permission) => {
|
|
276
266
|
const protocolPermission = webPermissionToProtocol.get(permission);
|
|
@@ -296,6 +286,8 @@ class FFBrowserContext extends import_browserContext.BrowserContext {
|
|
|
296
286
|
}
|
|
297
287
|
async setUserAgent(userAgent) {
|
|
298
288
|
await this._browser.session.send("Browser.setUserAgentOverride", { browserContextId: this._browserContextId, userAgent: userAgent || null });
|
|
289
|
+
const { navigatorPlatform } = (0, import_browserContext.calculateUserAgentEmulation)({ userAgent });
|
|
290
|
+
await this._browser.session.send("Browser.setPlatformOverride", { browserContextId: this._browserContextId, platform: navigatorPlatform || null });
|
|
299
291
|
}
|
|
300
292
|
async doUpdateOffline() {
|
|
301
293
|
await this._browser.session.send("Browser.setOnlineOverride", { browserContextId: this._browserContextId, override: this._options.offline ? "offline" : "online" });
|
|
@@ -373,8 +365,6 @@ class FFBrowserContext extends import_browserContext.BrowserContext {
|
|
|
373
365
|
}
|
|
374
366
|
async doClose(reason) {
|
|
375
367
|
if (!this._browserContextId) {
|
|
376
|
-
if (this._options.recordVideo)
|
|
377
|
-
await Promise.all(this._ffPages().map((ffPage) => ffPage._page.screencast.stopVideoRecording()));
|
|
378
368
|
await this._browser.close({ reason });
|
|
379
369
|
} else {
|
|
380
370
|
await this._browser.session.send("Browser.removeBrowserContext", { browserContextId: this._browserContextId });
|