@checkly/playwright-core 1.51.17-beta.2 → 1.54.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +65 -123
- package/browsers.json +16 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +47 -50
- package/lib/browserServerImpl.js +89 -69
- package/lib/checkly/escapeRegExp.js +23 -27
- package/lib/checkly/fetch.js +64 -46
- package/lib/checkly/secretsFilter.js +49 -35
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +400 -359
- package/lib/cli/programWithTestStub.js +51 -45
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +151 -242
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -36
- package/lib/client/browser.js +96 -71
- package/lib/client/browserContext.js +314 -345
- package/lib/client/browserType.js +103 -127
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +90 -113
- package/lib/client/clientHelper.js +48 -39
- package/lib/client/clientInstrumentation.js +40 -37
- package/lib/client/clientStackTrace.js +41 -37
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +188 -214
- package/lib/client/consoleMessage.js +31 -28
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +80 -77
- package/lib/client/elementHandle.js +120 -159
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +124 -121
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +166 -190
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +31 -28
- package/lib/client/frame.js +207 -306
- package/lib/client/harRouter.js +42 -52
- package/lib/client/input.js +42 -69
- package/lib/client/jsHandle.js +54 -69
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +29 -29
- package/lib/client/locator.js +145 -237
- package/lib/client/network.js +282 -307
- package/lib/client/page.js +269 -318
- package/lib/client/platform.js +46 -43
- package/lib/client/playwright.js +51 -76
- package/lib/client/selectors.js +45 -63
- package/lib/client/stream.js +29 -25
- package/lib/client/timeoutSettings.js +55 -41
- package/lib/client/tracing.js +49 -96
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +69 -88
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +43 -56
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +27 -23
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +26 -6
- package/lib/generated/consoleApiSource.js +26 -6
- package/lib/generated/injectedScriptSource.js +26 -6
- package/lib/generated/pollingRecorderSource.js +26 -6
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +26 -6
- package/lib/generated/webSocketMockSource.js +333 -5
- package/lib/inProcessFactory.js +51 -53
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +51 -46
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2807 -2739
- package/lib/protocol/validatorPrimitives.js +114 -73
- package/lib/remote/playwrightConnection.js +88 -242
- package/lib/remote/playwrightServer.js +305 -92
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +251 -241
- package/lib/server/android/backendAdb.js +87 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +297 -158
- package/lib/server/bidi/bidiChromium.js +119 -89
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +129 -113
- package/lib/server/bidi/bidiFirefox.js +86 -76
- package/lib/server/bidi/bidiInput.js +106 -117
- package/lib/server/bidi/bidiNetworkManager.js +142 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +260 -260
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
- package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
- package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
- package/lib/server/browser.js +93 -95
- package/lib/server/browserContext.js +419 -429
- package/lib/server/browserType.js +186 -216
- package/lib/server/callLog.js +47 -44
- package/lib/server/chromium/chromium.js +235 -203
- package/lib/server/chromium/chromiumSwitches.js +100 -67
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +310 -292
- package/lib/server/chromium/crConnection.js +95 -121
- package/lib/server/chromium/crCoverage.js +121 -131
- package/lib/server/chromium/crDevTools.js +60 -51
- package/lib/server/chromium/crDragDrop.js +68 -84
- package/lib/server/chromium/crExecutionContext.js +89 -83
- package/lib/server/chromium/crInput.js +118 -113
- package/lib/server/chromium/crNetworkManager.js +274 -375
- package/lib/server/chromium/crPage.js +536 -593
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +84 -73
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +66 -99
- package/lib/server/clock.js +107 -83
- package/lib/server/codegen/csharp.js +192 -162
- package/lib/server/codegen/java.js +156 -129
- package/lib/server/codegen/javascript.js +163 -148
- package/lib/server/codegen/jsonl.js +32 -28
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -126
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +108 -86
- package/lib/server/debugController.js +147 -151
- package/lib/server/debugger.js +86 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +238 -128
- package/lib/server/dialog.js +84 -39
- package/lib/server/dispatchers/androidDispatcher.js +257 -148
- package/lib/server/dispatchers/artifactDispatcher.js +79 -79
- package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
- package/lib/server/dispatchers/browserDispatcher.js +96 -148
- package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
- package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
- package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
- package/lib/server/dispatchers/dialogDispatcher.js +34 -31
- package/lib/server/dispatchers/dispatcher.js +208 -248
- package/lib/server/dispatchers/electronDispatcher.js +66 -70
- package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
- package/lib/server/dispatchers/frameDispatcher.js +211 -272
- package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
- package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
- package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
- package/lib/server/dispatchers/networkDispatchers.js +117 -128
- package/lib/server/dispatchers/pageDispatcher.js +256 -248
- package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
- package/lib/server/dispatchers/streamDispatcher.js +52 -48
- package/lib/server/dispatchers/tracingDispatcher.js +47 -52
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
- package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
- package/lib/server/dom.js +485 -582
- package/lib/server/download.js +47 -37
- package/lib/server/electron/electron.js +216 -243
- package/lib/server/electron/loader.js +9 -37
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +317 -360
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -60
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +268 -305
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +92 -73
- package/lib/server/firefox/ffInput.js +82 -84
- package/lib/server/firefox/ffNetworkManager.js +137 -114
- package/lib/server/firefox/ffPage.js +261 -293
- package/lib/server/firefox/firefox.js +80 -72
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +98 -114
- package/lib/server/frames.js +845 -1055
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +290 -223
- package/lib/server/harBackend.js +80 -80
- package/lib/server/helper.js +55 -59
- package/lib/server/index.js +59 -99
- package/lib/server/input.js +151 -189
- package/lib/server/instrumentation.js +57 -44
- package/lib/server/javascript.js +133 -134
- package/lib/server/launchApp.js +113 -75
- package/lib/server/localUtils.js +150 -142
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +299 -303
- package/lib/server/page.js +513 -544
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +58 -67
- package/lib/server/progress.js +137 -68
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +70 -86
- package/lib/server/recorder/recorderApp.js +341 -176
- package/lib/server/recorder/recorderInTraceViewer.js +65 -94
- package/lib/server/recorder/recorderRunner.js +93 -116
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +104 -47
- package/lib/server/recorder/throttledFile.js +42 -30
- package/lib/server/recorder.js +395 -275
- package/lib/server/registry/browserFetcher.js +106 -101
- package/lib/server/registry/dependencies.js +245 -196
- package/lib/server/registry/index.js +930 -803
- package/lib/server/registry/nativeDeps.js +1073 -464
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +160 -191
- package/lib/server/selectors.js +90 -51
- package/lib/server/socksClientCertificatesInterceptor.js +171 -186
- package/lib/server/socksInterceptor.js +62 -70
- package/lib/server/trace/recorder/snapshotter.js +76 -102
- package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
- package/lib/server/trace/recorder/tracing.js +354 -362
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +160 -147
- package/lib/server/transport.js +119 -134
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +39 -26
- package/lib/server/utils/comparators.js +105 -103
- package/lib/server/utils/crypto.js +157 -112
- package/lib/server/utils/debug.js +36 -32
- package/lib/server/utils/debugLogger.js +77 -48
- package/lib/server/utils/env.js +52 -37
- package/lib/server/utils/eventsHelper.js +29 -28
- package/lib/server/utils/expectUtils.js +31 -26
- package/lib/server/utils/fileUtils.js +123 -136
- package/lib/server/utils/happyEyeballs.js +141 -126
- package/lib/server/utils/hostPlatform.js +84 -120
- package/lib/server/utils/httpServer.js +106 -121
- package/lib/server/utils/image_tools/colorUtils.js +42 -51
- package/lib/server/utils/image_tools/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +38 -30
- package/lib/server/utils/image_tools/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +50 -37
- package/lib/server/utils/network.js +152 -96
- package/lib/server/utils/nodePlatform.js +87 -79
- package/lib/server/utils/pipeTransport.js +44 -42
- package/lib/server/utils/processLauncher.js +111 -121
- package/lib/server/utils/profiler.js +52 -39
- package/lib/server/utils/socksProxy.js +280 -339
- package/lib/server/utils/spawnAsync.js +37 -41
- package/lib/server/utils/task.js +31 -38
- package/lib/server/utils/userAgent.js +73 -66
- package/lib/server/utils/wsServer.js +68 -75
- package/lib/server/utils/zipFile.js +36 -37
- package/lib/server/utils/zones.js +37 -34
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +77 -61
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +193 -184
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +85 -70
- package/lib/server/webkit/wkInput.js +97 -95
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +568 -667
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +79 -79
- package/lib/utils/expectUtils.js +31 -26
- package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
- package/lib/utils/isomorphic/assert.js +28 -22
- package/lib/utils/isomorphic/colors.js +66 -59
- package/lib/utils/isomorphic/cssParser.js +120 -125
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +38 -37
- package/lib/utils/isomorphic/locatorGenerators.js +358 -357
- package/lib/utils/isomorphic/locatorParser.js +96 -105
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +46 -39
- package/lib/utils/isomorphic/mimeType.js +447 -25
- package/lib/utils/isomorphic/multimap.js +34 -27
- package/lib/utils/isomorphic/protocolFormatter.js +68 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/recorderUtils.js +140 -181
- package/lib/utils/isomorphic/rtti.js +35 -33
- package/lib/utils/isomorphic/selectorParser.js +182 -193
- package/lib/utils/isomorphic/semaphore.js +27 -24
- package/lib/utils/isomorphic/stackTrace.js +87 -98
- package/lib/utils/isomorphic/stringUtils.js +98 -112
- package/lib/utils/isomorphic/time.js +46 -22
- package/lib/utils/isomorphic/timeoutRunner.js +53 -53
- package/lib/utils/isomorphic/traceUtils.js +37 -41
- package/lib/utils/isomorphic/types.js +15 -4
- package/lib/utils/isomorphic/urlMatch.js +113 -67
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils.js +101 -443
- package/lib/utilsBundle.js +101 -52
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +1267 -1057
- package/types/types.d.ts +131 -29
- package/lib/common/socksProxy.js +0 -569
- package/lib/common/timeoutSettings.js +0 -73
- package/lib/common/types.js +0 -5
- package/lib/image_tools/colorUtils.js +0 -98
- package/lib/image_tools/compare.js +0 -108
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/image_tools/stats.js +0 -102
- package/lib/protocol/debug.js +0 -27
- package/lib/protocol/transport.js +0 -82
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
- package/lib/server/recorder/contextRecorder.js +0 -290
- package/lib/server/recorder/recorderCollection.js +0 -104
- package/lib/server/recorder/recorderFrontend.js +0 -5
- package/lib/server/storageScript.js +0 -160
- package/lib/server/timeoutSettings.js +0 -74
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -171
- package/lib/utils/crypto.js +0 -174
- package/lib/utils/debug.js +0 -46
- package/lib/utils/debugLogger.js +0 -91
- package/lib/utils/env.js +0 -49
- package/lib/utils/eventsHelper.js +0 -38
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -210
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -133
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/linuxUtils.js +0 -78
- package/lib/utils/manualPromise.js +0 -109
- package/lib/utils/multimap.js +0 -75
- package/lib/utils/network.js +0 -160
- package/lib/utils/processLauncher.js +0 -248
- package/lib/utils/profiler.js +0 -53
- package/lib/utils/rtti.js +0 -44
- package/lib/utils/semaphore.js +0 -51
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -121
- package/lib/utils/task.js +0 -58
- package/lib/utils/time.js +0 -37
- package/lib/utils/timeoutRunner.js +0 -66
- package/lib/utils/traceUtils.js +0 -44
- package/lib/utils/userAgent.js +0 -105
- package/lib/utils/wsServer.js +0 -127
- package/lib/utils/zipFile.js +0 -75
- package/lib/utils/zones.js +0 -62
- package/lib/vite/htmlReport/index.html +0 -69
- package/lib/vite/recorder/assets/codeMirrorModule-B9YMkrwa.js +0 -24
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/recorder/index.html +0 -29
- package/lib/vite/recorder/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/assets/codeMirrorModule-gU1OOCQO.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-B5n_FjMx.js +0 -1
- package/lib/vite/traceViewer/assets/inspectorTab-6Tru8Mn_.js +0 -235
- package/lib/vite/traceViewer/assets/workbench-B_Nj4NA2.js +0 -25
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.CO3FR0CX.css +0 -1
- package/lib/vite/traceViewer/embedded.DpNPH6mk.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.mLhjB5IF.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.CuE3SYGw.js +0 -2
- package/lib/vite/traceViewer/index.html +0 -47
- package/lib/vite/traceViewer/inspectorTab.CXDulcFG.css +0 -1
- package/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/recorder.BD-uZJs7.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/recorder.tn0RQdqM.css +0 -0
- package/lib/vite/traceViewer/snapshot.html +0 -21
- package/lib/vite/traceViewer/sw.bundle.js +0 -3
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.DHrNgddz.js +0 -5
- package/lib/vite/traceViewer/uiMode.html +0 -21
- package/lib/vite/traceViewer/workbench.B9vIAzH9.css +0 -1
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
|
@@ -1,124 +1,137 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var bidiPage_exports = {};
|
|
30
|
+
__export(bidiPage_exports, {
|
|
31
|
+
BidiPage: () => BidiPage,
|
|
32
|
+
kPlaywrightBindingChannel: () => kPlaywrightBindingChannel
|
|
5
33
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
-
/**
|
|
21
|
-
* Copyright (c) Microsoft Corporation.
|
|
22
|
-
*
|
|
23
|
-
* Licensed under the Apache License, Version 2.0 (the 'License');
|
|
24
|
-
* you may not use this file except in compliance with the License.
|
|
25
|
-
* You may obtain a copy of the License at
|
|
26
|
-
*
|
|
27
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
28
|
-
*
|
|
29
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
-
* distributed under the License is distributed on an 'AS IS' BASIS,
|
|
31
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
-
* See the License for the specific language governing permissions and
|
|
33
|
-
* limitations under the License.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
const UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
|
37
|
-
const kPlaywrightBindingChannel = 'playwrightChannel';
|
|
34
|
+
module.exports = __toCommonJS(bidiPage_exports);
|
|
35
|
+
var import_utils = require("../../utils");
|
|
36
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
37
|
+
var dialog = __toESM(require("../dialog"));
|
|
38
|
+
var dom = __toESM(require("../dom"));
|
|
39
|
+
var import_page = require("../page");
|
|
40
|
+
var import_bidiExecutionContext = require("./bidiExecutionContext");
|
|
41
|
+
var import_bidiInput = require("./bidiInput");
|
|
42
|
+
var import_bidiNetworkManager = require("./bidiNetworkManager");
|
|
43
|
+
var import_bidiPdf = require("./bidiPdf");
|
|
44
|
+
var bidi = __toESM(require("./third_party/bidiProtocol"));
|
|
45
|
+
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
46
|
+
const kPlaywrightBindingChannel = "playwrightChannel";
|
|
38
47
|
class BidiPage {
|
|
39
48
|
constructor(browserContext, bidiSession, opener) {
|
|
40
|
-
this.rawMouse = void 0;
|
|
41
|
-
this.rawKeyboard = void 0;
|
|
42
|
-
this.rawTouchscreen = void 0;
|
|
43
|
-
this._page = void 0;
|
|
44
|
-
this._session = void 0;
|
|
45
|
-
this._opener = void 0;
|
|
46
|
-
this._realmToContext = void 0;
|
|
47
49
|
this._sessionListeners = [];
|
|
48
|
-
this.
|
|
49
|
-
this._networkManager = void 0;
|
|
50
|
-
this._pdf = void 0;
|
|
51
|
-
this._initScriptIds = [];
|
|
50
|
+
this._initScriptIds = /* @__PURE__ */ new Map();
|
|
52
51
|
this._session = bidiSession;
|
|
53
52
|
this._opener = opener;
|
|
54
|
-
this.rawKeyboard = new
|
|
55
|
-
this.rawMouse = new
|
|
56
|
-
this.rawTouchscreen = new
|
|
57
|
-
this._realmToContext = new Map();
|
|
58
|
-
this._page = new
|
|
53
|
+
this.rawKeyboard = new import_bidiInput.RawKeyboardImpl(bidiSession);
|
|
54
|
+
this.rawMouse = new import_bidiInput.RawMouseImpl(bidiSession);
|
|
55
|
+
this.rawTouchscreen = new import_bidiInput.RawTouchscreenImpl(bidiSession);
|
|
56
|
+
this._realmToContext = /* @__PURE__ */ new Map();
|
|
57
|
+
this._page = new import_page.Page(this, browserContext);
|
|
59
58
|
this._browserContext = browserContext;
|
|
60
|
-
this._networkManager = new
|
|
61
|
-
this._pdf = new
|
|
62
|
-
this._page.on(
|
|
63
|
-
this._sessionListeners = [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
this._networkManager = new import_bidiNetworkManager.BidiNetworkManager(this._session, this._page, this._onNavigationResponseStarted.bind(this));
|
|
60
|
+
this._pdf = new import_bidiPdf.BidiPDF(this._session);
|
|
61
|
+
this._page.on(import_page.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame, false));
|
|
62
|
+
this._sessionListeners = [
|
|
63
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.realmCreated", this._onRealmCreated.bind(this)),
|
|
64
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.message", this._onScriptMessage.bind(this)),
|
|
65
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.contextDestroyed", this._onBrowsingContextDestroyed.bind(this)),
|
|
66
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationStarted", this._onNavigationStarted.bind(this)),
|
|
67
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationAborted", this._onNavigationAborted.bind(this)),
|
|
68
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationFailed", this._onNavigationFailed.bind(this)),
|
|
69
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.fragmentNavigated", this._onFragmentNavigated.bind(this)),
|
|
70
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.domContentLoaded", this._onDomContentLoaded.bind(this)),
|
|
71
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.load", this._onLoad.bind(this)),
|
|
72
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.userPromptOpened", this._onUserPromptOpened.bind(this)),
|
|
73
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "log.entryAdded", this._onLogEntryAdded.bind(this))
|
|
74
|
+
];
|
|
75
|
+
this._initialize().then(
|
|
76
|
+
() => this._page.reportAsNew(this._opener?._page),
|
|
77
|
+
(error) => this._page.reportAsNew(this._opener?._page, error)
|
|
78
|
+
);
|
|
74
79
|
}
|
|
75
80
|
async _initialize() {
|
|
76
|
-
// Initialize main frame.
|
|
77
81
|
this._onFrameAttached(this._session.sessionId, null);
|
|
78
|
-
await Promise.all([
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
await Promise.all([
|
|
83
|
+
this.updateHttpCredentials(),
|
|
84
|
+
this.updateRequestInterception(),
|
|
85
|
+
// If the page is created by the Playwright client's call, some initialization
|
|
86
|
+
// may be pending. Wait for it to complete before reporting the page as new.
|
|
87
|
+
//
|
|
88
|
+
// TODO: ideally we'd wait only for the commands that created this page, but currently
|
|
89
|
+
// there is no way in Bidi to track which command created this page.
|
|
90
|
+
this._browserContext.waitForBlockingPageCreations()
|
|
91
|
+
]);
|
|
82
92
|
}
|
|
83
93
|
didClose() {
|
|
84
94
|
this._session.dispose();
|
|
85
|
-
|
|
95
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
86
96
|
this._page._didClose();
|
|
87
97
|
}
|
|
88
98
|
_onFrameAttached(frameId, parentFrameId) {
|
|
89
|
-
return this._page.
|
|
99
|
+
return this._page.frameManager.frameAttached(frameId, parentFrameId);
|
|
90
100
|
}
|
|
91
101
|
_removeContextsForFrame(frame, notifyFrame) {
|
|
92
102
|
for (const [contextId, context] of this._realmToContext) {
|
|
93
103
|
if (context.frame === frame) {
|
|
94
104
|
this._realmToContext.delete(contextId);
|
|
95
|
-
if (notifyFrame)
|
|
105
|
+
if (notifyFrame)
|
|
106
|
+
frame._contextDestroyed(context);
|
|
96
107
|
}
|
|
97
108
|
}
|
|
98
109
|
}
|
|
99
110
|
_onRealmCreated(realmInfo) {
|
|
100
|
-
if (this._realmToContext.has(realmInfo.realm))
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
if (this._realmToContext.has(realmInfo.realm))
|
|
112
|
+
return;
|
|
113
|
+
if (realmInfo.type !== "window")
|
|
114
|
+
return;
|
|
115
|
+
const frame = this._page.frameManager.frame(realmInfo.context);
|
|
116
|
+
if (!frame)
|
|
117
|
+
return;
|
|
104
118
|
let worldName;
|
|
105
119
|
if (!realmInfo.sandbox) {
|
|
106
|
-
worldName =
|
|
107
|
-
// Force creating utility world every time the main world is created (e.g. due to navigation).
|
|
120
|
+
worldName = "main";
|
|
108
121
|
this._touchUtilityWorld(realmInfo.context);
|
|
109
122
|
} else if (realmInfo.sandbox === UTILITY_WORLD_NAME) {
|
|
110
|
-
worldName =
|
|
123
|
+
worldName = "utility";
|
|
111
124
|
} else {
|
|
112
125
|
return;
|
|
113
126
|
}
|
|
114
|
-
const delegate = new
|
|
127
|
+
const delegate = new import_bidiExecutionContext.BidiExecutionContext(this._session, realmInfo);
|
|
115
128
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
|
116
129
|
frame._contextCreated(worldName, context);
|
|
117
130
|
this._realmToContext.set(realmInfo.realm, context);
|
|
118
131
|
}
|
|
119
132
|
async _touchUtilityWorld(context) {
|
|
120
|
-
await this._session.sendMayFail(
|
|
121
|
-
expression:
|
|
133
|
+
await this._session.sendMayFail("script.evaluate", {
|
|
134
|
+
expression: "1 + 1",
|
|
122
135
|
target: {
|
|
123
136
|
context,
|
|
124
137
|
sandbox: UTILITY_WORLD_NAME
|
|
@@ -133,104 +146,110 @@ class BidiPage {
|
|
|
133
146
|
}
|
|
134
147
|
_onRealmDestroyed(params) {
|
|
135
148
|
const context = this._realmToContext.get(params.realm);
|
|
136
|
-
if (!context)
|
|
149
|
+
if (!context)
|
|
150
|
+
return false;
|
|
137
151
|
this._realmToContext.delete(params.realm);
|
|
138
152
|
context.frame._contextDestroyed(context);
|
|
139
153
|
return true;
|
|
140
154
|
}
|
|
141
|
-
|
|
142
155
|
// TODO: route the message directly to the browser
|
|
143
156
|
_onBrowsingContextDestroyed(params) {
|
|
144
157
|
this._browserContext._browser._onBrowsingContextDestroyed(params);
|
|
145
158
|
}
|
|
146
159
|
_onNavigationStarted(params) {
|
|
147
160
|
const frameId = params.context;
|
|
148
|
-
this._page.
|
|
161
|
+
this._page.frameManager.frameRequestedNavigation(frameId, params.navigation);
|
|
149
162
|
const url = params.url.toLowerCase();
|
|
150
|
-
if (url.startsWith(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
163
|
+
if (url.startsWith("file:") || url.startsWith("data:") || url === "about:blank") {
|
|
164
|
+
const frame = this._page.frameManager.frame(frameId);
|
|
165
|
+
if (frame)
|
|
166
|
+
this._page.frameManager.frameCommittedNewDocumentNavigation(
|
|
167
|
+
frameId,
|
|
168
|
+
params.url,
|
|
169
|
+
"",
|
|
170
|
+
params.navigation,
|
|
171
|
+
/* initial */
|
|
172
|
+
false
|
|
173
|
+
);
|
|
155
174
|
}
|
|
156
175
|
}
|
|
157
|
-
|
|
158
176
|
// TODO: there is no separate event for committed navigation, so we approximate it with responseStarted.
|
|
159
177
|
_onNavigationResponseStarted(params) {
|
|
160
178
|
const frameId = params.context;
|
|
161
|
-
const frame = this._page.
|
|
162
|
-
(0,
|
|
163
|
-
this._page.
|
|
164
|
-
|
|
165
|
-
|
|
179
|
+
const frame = this._page.frameManager.frame(frameId);
|
|
180
|
+
(0, import_utils.assert)(frame);
|
|
181
|
+
this._page.frameManager.frameCommittedNewDocumentNavigation(
|
|
182
|
+
frameId,
|
|
183
|
+
params.response.url,
|
|
184
|
+
"",
|
|
185
|
+
params.navigation,
|
|
186
|
+
/* initial */
|
|
187
|
+
false
|
|
188
|
+
);
|
|
166
189
|
}
|
|
167
190
|
_onDomContentLoaded(params) {
|
|
168
191
|
const frameId = params.context;
|
|
169
|
-
this._page.
|
|
192
|
+
this._page.frameManager.frameLifecycleEvent(frameId, "domcontentloaded");
|
|
170
193
|
}
|
|
171
194
|
_onLoad(params) {
|
|
172
|
-
this._page.
|
|
195
|
+
this._page.frameManager.frameLifecycleEvent(params.context, "load");
|
|
173
196
|
}
|
|
174
197
|
_onNavigationAborted(params) {
|
|
175
|
-
this._page.
|
|
198
|
+
this._page.frameManager.frameAbortedNavigation(params.context, "Navigation aborted", params.navigation || void 0);
|
|
176
199
|
}
|
|
177
200
|
_onNavigationFailed(params) {
|
|
178
|
-
this._page.
|
|
201
|
+
this._page.frameManager.frameAbortedNavigation(params.context, "Navigation failed", params.navigation || void 0);
|
|
179
202
|
}
|
|
180
203
|
_onFragmentNavigated(params) {
|
|
181
|
-
this._page.
|
|
204
|
+
this._page.frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);
|
|
182
205
|
}
|
|
183
206
|
_onUserPromptOpened(event) {
|
|
184
|
-
this._page.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
207
|
+
this._page.browserContext.dialogManager.dialogDidOpen(new dialog.Dialog(
|
|
208
|
+
this._page,
|
|
209
|
+
event.type,
|
|
210
|
+
event.message,
|
|
211
|
+
async (accept, userText) => {
|
|
212
|
+
await this._session.send("browsingContext.handleUserPrompt", { context: event.context, accept, userText });
|
|
213
|
+
},
|
|
214
|
+
event.defaultValue
|
|
215
|
+
));
|
|
191
216
|
}
|
|
192
217
|
_onLogEntryAdded(params) {
|
|
193
|
-
|
|
194
|
-
|
|
218
|
+
if (params.type !== "console")
|
|
219
|
+
return;
|
|
195
220
|
const entry = params;
|
|
196
221
|
const context = this._realmToContext.get(params.source.realm);
|
|
197
|
-
if (!context)
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
columnNumber: 1
|
|
203
|
-
};
|
|
204
|
-
this._page._addConsoleMessage(entry.method, entry.args.map(arg => (0, _bidiExecutionContext.createHandle)(context, arg)), location, params.text || undefined);
|
|
222
|
+
if (!context)
|
|
223
|
+
return;
|
|
224
|
+
const callFrame = params.stackTrace?.callFrames[0];
|
|
225
|
+
const location = callFrame ?? { url: "", lineNumber: 1, columnNumber: 1 };
|
|
226
|
+
this._page.addConsoleMessage(entry.method, entry.args.map((arg) => (0, import_bidiExecutionContext.createHandle)(context, arg)), location, params.text || void 0);
|
|
205
227
|
}
|
|
206
228
|
async navigateFrame(frame, url, referrer) {
|
|
207
|
-
const {
|
|
208
|
-
navigation
|
|
209
|
-
} = await this._session.send('browsingContext.navigate', {
|
|
229
|
+
const { navigation } = await this._session.send("browsingContext.navigate", {
|
|
210
230
|
context: frame._id,
|
|
211
231
|
url
|
|
212
232
|
});
|
|
213
|
-
return {
|
|
214
|
-
newDocumentId: navigation || undefined
|
|
215
|
-
};
|
|
233
|
+
return { newDocumentId: navigation || void 0 };
|
|
216
234
|
}
|
|
217
|
-
async updateExtraHTTPHeaders() {
|
|
218
|
-
|
|
219
|
-
async
|
|
220
|
-
|
|
235
|
+
async updateExtraHTTPHeaders() {
|
|
236
|
+
}
|
|
237
|
+
async updateEmulateMedia() {
|
|
238
|
+
}
|
|
239
|
+
async updateUserAgent() {
|
|
221
240
|
}
|
|
222
|
-
async updateUserAgent() {}
|
|
223
241
|
async bringToFront() {
|
|
224
|
-
await this._session.send(
|
|
242
|
+
await this._session.send("browsingContext.activate", {
|
|
225
243
|
context: this._session.sessionId
|
|
226
244
|
});
|
|
227
245
|
}
|
|
228
|
-
async
|
|
246
|
+
async updateEmulatedViewportSize() {
|
|
229
247
|
const options = this._browserContext._options;
|
|
230
|
-
const
|
|
231
|
-
if (
|
|
232
|
-
|
|
233
|
-
|
|
248
|
+
const emulatedSize = this._page.emulatedSize();
|
|
249
|
+
if (!emulatedSize)
|
|
250
|
+
return;
|
|
251
|
+
const viewportSize = emulatedSize.viewport;
|
|
252
|
+
await this._session.send("browsingContext.setViewport", {
|
|
234
253
|
context: this._session.sessionId,
|
|
235
254
|
viewport: {
|
|
236
255
|
width: viewportSize.width,
|
|
@@ -242,158 +261,135 @@ class BidiPage {
|
|
|
242
261
|
async updateRequestInterception() {
|
|
243
262
|
await this._networkManager.setRequestInterception(this._page.needsRequestInterception());
|
|
244
263
|
}
|
|
245
|
-
async updateOffline() {
|
|
264
|
+
async updateOffline() {
|
|
265
|
+
}
|
|
246
266
|
async updateHttpCredentials() {
|
|
247
267
|
await this._networkManager.setCredentials(this._browserContext._options.httpCredentials);
|
|
248
268
|
}
|
|
249
|
-
async updateFileChooserInterception() {
|
|
269
|
+
async updateFileChooserInterception() {
|
|
270
|
+
}
|
|
250
271
|
async reload() {
|
|
251
|
-
await this._session.send(
|
|
272
|
+
await this._session.send("browsingContext.reload", {
|
|
252
273
|
context: this._session.sessionId,
|
|
253
274
|
// ignoreCache: true,
|
|
254
275
|
wait: bidi.BrowsingContext.ReadinessState.Interactive
|
|
255
276
|
});
|
|
256
277
|
}
|
|
257
278
|
async goBack() {
|
|
258
|
-
return await this._session.send(
|
|
279
|
+
return await this._session.send("browsingContext.traverseHistory", {
|
|
259
280
|
context: this._session.sessionId,
|
|
260
281
|
delta: -1
|
|
261
282
|
}).then(() => true).catch(() => false);
|
|
262
283
|
}
|
|
263
284
|
async goForward() {
|
|
264
|
-
return await this._session.send(
|
|
285
|
+
return await this._session.send("browsingContext.traverseHistory", {
|
|
265
286
|
context: this._session.sessionId,
|
|
266
|
-
delta:
|
|
287
|
+
delta: 1
|
|
267
288
|
}).then(() => true).catch(() => false);
|
|
268
289
|
}
|
|
269
290
|
async requestGC() {
|
|
270
|
-
throw new Error(
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// TODO: consider calling this only when bindings are added.
|
|
274
|
-
async _installMainBinding() {
|
|
275
|
-
const functionDeclaration = addMainBinding.toString();
|
|
276
|
-
const args = [{
|
|
277
|
-
type: 'channel',
|
|
278
|
-
value: {
|
|
279
|
-
channel: kPlaywrightBindingChannel,
|
|
280
|
-
ownership: bidi.Script.ResultOwnership.Root
|
|
281
|
-
}
|
|
282
|
-
}];
|
|
283
|
-
const promises = [];
|
|
284
|
-
promises.push(this._session.send('script.addPreloadScript', {
|
|
285
|
-
functionDeclaration,
|
|
286
|
-
arguments: args
|
|
287
|
-
}));
|
|
288
|
-
promises.push(this._session.send('script.callFunction', {
|
|
289
|
-
functionDeclaration,
|
|
290
|
-
arguments: args,
|
|
291
|
-
target: toBidiExecutionContext(await this._page.mainFrame()._mainContext())._target,
|
|
292
|
-
awaitPromise: false,
|
|
293
|
-
userActivation: false
|
|
294
|
-
}));
|
|
295
|
-
await Promise.all(promises);
|
|
291
|
+
throw new Error("Method not implemented.");
|
|
296
292
|
}
|
|
297
293
|
async _onScriptMessage(event) {
|
|
298
|
-
if (event.channel !== kPlaywrightBindingChannel)
|
|
294
|
+
if (event.channel !== kPlaywrightBindingChannel)
|
|
295
|
+
return;
|
|
299
296
|
const pageOrError = await this._page.waitForInitializedOrError();
|
|
300
|
-
if (pageOrError instanceof Error)
|
|
297
|
+
if (pageOrError instanceof Error)
|
|
298
|
+
return;
|
|
301
299
|
const context = this._realmToContext.get(event.source.realm);
|
|
302
|
-
if (!context)
|
|
303
|
-
|
|
304
|
-
|
|
300
|
+
if (!context)
|
|
301
|
+
return;
|
|
302
|
+
if (event.data.type !== "string")
|
|
303
|
+
return;
|
|
304
|
+
await this._page.onBindingCalled(event.data.value, context);
|
|
305
305
|
}
|
|
306
306
|
async addInitScript(initScript) {
|
|
307
|
-
const {
|
|
308
|
-
script
|
|
309
|
-
} = await this._session.send('script.addPreloadScript', {
|
|
307
|
+
const { script } = await this._session.send("script.addPreloadScript", {
|
|
310
308
|
// TODO: remove function call from the source.
|
|
311
309
|
functionDeclaration: `() => { return ${initScript.source} }`,
|
|
312
310
|
// TODO: push to iframes?
|
|
313
311
|
contexts: [this._session.sessionId]
|
|
314
312
|
});
|
|
315
|
-
|
|
316
|
-
}
|
|
317
|
-
async
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
313
|
+
this._initScriptIds.set(initScript, script);
|
|
314
|
+
}
|
|
315
|
+
async removeInitScripts(initScripts) {
|
|
316
|
+
const ids = [];
|
|
317
|
+
for (const script of initScripts) {
|
|
318
|
+
const id = this._initScriptIds.get(script);
|
|
319
|
+
if (id)
|
|
320
|
+
ids.push(id);
|
|
321
|
+
this._initScriptIds.delete(script);
|
|
322
|
+
}
|
|
323
|
+
await Promise.all(ids.map((script) => this._session.send("script.removePreloadScript", { script })));
|
|
323
324
|
}
|
|
324
325
|
async closePage(runBeforeUnload) {
|
|
325
|
-
await this._session.send(
|
|
326
|
+
await this._session.send("browsingContext.close", {
|
|
326
327
|
context: this._session.sessionId,
|
|
327
328
|
promptUnload: runBeforeUnload
|
|
328
329
|
});
|
|
329
330
|
}
|
|
330
|
-
async setBackgroundColor(color) {
|
|
331
|
+
async setBackgroundColor(color) {
|
|
332
|
+
}
|
|
331
333
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
332
334
|
const rect = documentRect || viewportRect;
|
|
333
|
-
const {
|
|
334
|
-
data
|
|
335
|
-
} = await this._session.send('browsingContext.captureScreenshot', {
|
|
335
|
+
const { data } = await progress.race(this._session.send("browsingContext.captureScreenshot", {
|
|
336
336
|
context: this._session.sessionId,
|
|
337
337
|
format: {
|
|
338
|
-
type: `image/${format ===
|
|
338
|
+
type: `image/${format === "png" ? "png" : "jpeg"}`,
|
|
339
339
|
quality: quality ? quality / 100 : 0.8
|
|
340
340
|
},
|
|
341
|
-
origin: documentRect ?
|
|
341
|
+
origin: documentRect ? "document" : "viewport",
|
|
342
342
|
clip: {
|
|
343
|
-
type:
|
|
343
|
+
type: "box",
|
|
344
344
|
...rect
|
|
345
345
|
}
|
|
346
|
-
});
|
|
347
|
-
return Buffer.from(data,
|
|
346
|
+
}));
|
|
347
|
+
return Buffer.from(data, "base64");
|
|
348
348
|
}
|
|
349
349
|
async getContentFrame(handle) {
|
|
350
350
|
const executionContext = toBidiExecutionContext(handle._context);
|
|
351
351
|
const frameId = await executionContext.contentFrameIdForFrame(handle);
|
|
352
|
-
if (!frameId)
|
|
353
|
-
|
|
352
|
+
if (!frameId)
|
|
353
|
+
return null;
|
|
354
|
+
return this._page.frameManager.frame(frameId);
|
|
354
355
|
}
|
|
355
356
|
async getOwnerFrame(handle) {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
var _node$ownerDocument;
|
|
359
|
-
const doc = (_node$ownerDocument = node.ownerDocument) !== null && _node$ownerDocument !== void 0 ? _node$ownerDocument : node;
|
|
357
|
+
const windowHandle = await handle.evaluateHandle((node) => {
|
|
358
|
+
const doc = node.ownerDocument ?? node;
|
|
360
359
|
return doc.defaultView;
|
|
361
360
|
});
|
|
362
|
-
if (!windowHandle)
|
|
361
|
+
if (!windowHandle)
|
|
362
|
+
return null;
|
|
363
363
|
const executionContext = toBidiExecutionContext(handle._context);
|
|
364
364
|
return executionContext.frameIdForWindowHandle(windowHandle);
|
|
365
365
|
}
|
|
366
366
|
async getBoundingBox(handle) {
|
|
367
|
-
const box = await handle.evaluate(element => {
|
|
368
|
-
if (!(element instanceof Element))
|
|
367
|
+
const box = await handle.evaluate((element) => {
|
|
368
|
+
if (!(element instanceof Element))
|
|
369
|
+
return null;
|
|
369
370
|
const rect = element.getBoundingClientRect();
|
|
370
|
-
return {
|
|
371
|
-
x: rect.x,
|
|
372
|
-
y: rect.y,
|
|
373
|
-
width: rect.width,
|
|
374
|
-
height: rect.height
|
|
375
|
-
};
|
|
371
|
+
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
|
|
376
372
|
});
|
|
377
|
-
if (!box)
|
|
373
|
+
if (!box)
|
|
374
|
+
return null;
|
|
378
375
|
const position = await this._framePosition(handle._frame);
|
|
379
|
-
if (!position)
|
|
376
|
+
if (!position)
|
|
377
|
+
return null;
|
|
380
378
|
box.x += position.x;
|
|
381
379
|
box.y += position.y;
|
|
382
380
|
return box;
|
|
383
381
|
}
|
|
384
|
-
|
|
385
382
|
// TODO: move to Frame.
|
|
386
383
|
async _framePosition(frame) {
|
|
387
|
-
if (frame === this._page.mainFrame())
|
|
388
|
-
x: 0,
|
|
389
|
-
y: 0
|
|
390
|
-
};
|
|
384
|
+
if (frame === this._page.mainFrame())
|
|
385
|
+
return { x: 0, y: 0 };
|
|
391
386
|
const element = await frame.frameElement();
|
|
392
387
|
const box = await element.boundingBox();
|
|
393
|
-
if (!box)
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
388
|
+
if (!box)
|
|
389
|
+
return null;
|
|
390
|
+
const style = await element.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch((e) => "error:notconnected");
|
|
391
|
+
if (style === "error:notconnected" || style === "transformed")
|
|
392
|
+
return null;
|
|
397
393
|
box.x += style.left;
|
|
398
394
|
box.y += style.top;
|
|
399
395
|
return box;
|
|
@@ -401,44 +397,43 @@ class BidiPage {
|
|
|
401
397
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
402
398
|
return await handle.evaluateInUtility(([injected, node]) => {
|
|
403
399
|
node.scrollIntoView({
|
|
404
|
-
block:
|
|
405
|
-
inline:
|
|
406
|
-
behavior:
|
|
400
|
+
block: "center",
|
|
401
|
+
inline: "center",
|
|
402
|
+
behavior: "instant"
|
|
407
403
|
});
|
|
408
|
-
}, null).then(() =>
|
|
409
|
-
if (e instanceof Error && e.message.includes(
|
|
410
|
-
|
|
404
|
+
}, null).then(() => "done").catch((e) => {
|
|
405
|
+
if (e instanceof Error && e.message.includes("Node is detached from document"))
|
|
406
|
+
return "error:notconnected";
|
|
407
|
+
if (e instanceof Error && e.message.includes("Node does not have a layout object"))
|
|
408
|
+
return "error:notvisible";
|
|
411
409
|
throw e;
|
|
412
410
|
});
|
|
413
411
|
}
|
|
414
|
-
async setScreencastOptions(options) {
|
|
412
|
+
async setScreencastOptions(options) {
|
|
413
|
+
}
|
|
415
414
|
rafCountForStablePosition() {
|
|
416
415
|
return 1;
|
|
417
416
|
}
|
|
418
417
|
async getContentQuads(handle) {
|
|
419
418
|
const quads = await handle.evaluateInUtility(([injected, node]) => {
|
|
420
|
-
if (!node.isConnected)
|
|
419
|
+
if (!node.isConnected)
|
|
420
|
+
return "error:notconnected";
|
|
421
421
|
const rects = node.getClientRects();
|
|
422
|
-
if (!rects)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
y: rect.top
|
|
426
|
-
|
|
427
|
-
x: rect.right,
|
|
428
|
-
y: rect.
|
|
429
|
-
|
|
430
|
-
x: rect.right,
|
|
431
|
-
y: rect.bottom
|
|
432
|
-
}, {
|
|
433
|
-
x: rect.left,
|
|
434
|
-
y: rect.bottom
|
|
435
|
-
}]);
|
|
422
|
+
if (!rects)
|
|
423
|
+
return null;
|
|
424
|
+
return [...rects].map((rect) => [
|
|
425
|
+
{ x: rect.left, y: rect.top },
|
|
426
|
+
{ x: rect.right, y: rect.top },
|
|
427
|
+
{ x: rect.right, y: rect.bottom },
|
|
428
|
+
{ x: rect.left, y: rect.bottom }
|
|
429
|
+
]);
|
|
436
430
|
}, null);
|
|
437
|
-
if (!quads || quads ===
|
|
438
|
-
|
|
431
|
+
if (!quads || quads === "error:notconnected")
|
|
432
|
+
return quads;
|
|
439
433
|
const position = await this._framePosition(handle._frame);
|
|
440
|
-
if (!position)
|
|
441
|
-
|
|
434
|
+
if (!position)
|
|
435
|
+
return null;
|
|
436
|
+
quads.forEach((quad) => quad.forEach((point) => {
|
|
442
437
|
point.x += position.x;
|
|
443
438
|
point.y += position.y;
|
|
444
439
|
}));
|
|
@@ -446,7 +441,7 @@ class BidiPage {
|
|
|
446
441
|
}
|
|
447
442
|
async setInputFilePaths(handle, paths) {
|
|
448
443
|
const fromContext = toBidiExecutionContext(handle._context);
|
|
449
|
-
await this._session.send(
|
|
444
|
+
await this._session.send("input.setFiles", {
|
|
450
445
|
context: this._session.sessionId,
|
|
451
446
|
element: await fromContext.nodeIdForElementHandle(handle),
|
|
452
447
|
files: paths
|
|
@@ -459,24 +454,27 @@ class BidiPage {
|
|
|
459
454
|
return await executionContext.remoteObjectForNodeId(to, nodeId);
|
|
460
455
|
}
|
|
461
456
|
async getAccessibilityTree(needle) {
|
|
462
|
-
throw new Error(
|
|
457
|
+
throw new Error("Method not implemented.");
|
|
458
|
+
}
|
|
459
|
+
async inputActionEpilogue() {
|
|
460
|
+
}
|
|
461
|
+
async resetForReuse(progress) {
|
|
463
462
|
}
|
|
464
|
-
async inputActionEpilogue() {}
|
|
465
|
-
async resetForReuse() {}
|
|
466
463
|
async pdf(options) {
|
|
467
464
|
return this._pdf.generate(options);
|
|
468
465
|
}
|
|
469
466
|
async getFrameElement(frame) {
|
|
470
467
|
const parent = frame.parentFrame();
|
|
471
|
-
if (!parent)
|
|
468
|
+
if (!parent)
|
|
469
|
+
throw new Error("Frame has been detached.");
|
|
472
470
|
const parentContext = await parent._mainContext();
|
|
473
471
|
const list = await parentContext.evaluateHandle(() => {
|
|
474
|
-
return [...document.querySelectorAll(
|
|
472
|
+
return [...document.querySelectorAll("iframe,frame")];
|
|
475
473
|
});
|
|
476
|
-
const length = await list.evaluate(
|
|
474
|
+
const length = await list.evaluate((list2) => list2.length);
|
|
477
475
|
let foundElement = null;
|
|
478
476
|
for (let i = 0; i < length; i++) {
|
|
479
|
-
const element = await list.evaluateHandle((
|
|
477
|
+
const element = await list.evaluateHandle((list2, i2) => list2[i2], i);
|
|
480
478
|
const candidate = await element.contentFrame();
|
|
481
479
|
if (frame === candidate) {
|
|
482
480
|
foundElement = element;
|
|
@@ -486,17 +484,19 @@ class BidiPage {
|
|
|
486
484
|
}
|
|
487
485
|
}
|
|
488
486
|
list.dispose();
|
|
489
|
-
if (!foundElement)
|
|
487
|
+
if (!foundElement)
|
|
488
|
+
throw new Error("Frame has been detached.");
|
|
490
489
|
return foundElement;
|
|
491
490
|
}
|
|
492
491
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
493
492
|
return true;
|
|
494
493
|
}
|
|
495
494
|
}
|
|
496
|
-
exports.BidiPage = BidiPage;
|
|
497
|
-
function addMainBinding(callback) {
|
|
498
|
-
globalThis['__playwright__binding__'] = callback;
|
|
499
|
-
}
|
|
500
495
|
function toBidiExecutionContext(executionContext) {
|
|
501
496
|
return executionContext.delegate;
|
|
502
|
-
}
|
|
497
|
+
}
|
|
498
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
499
|
+
0 && (module.exports = {
|
|
500
|
+
BidiPage,
|
|
501
|
+
kPlaywrightBindingChannel
|
|
502
|
+
});
|