rebrowser-playwright-core 1.49.0 → 1.52.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 +381 -55
- package/bin/reinstall_msedge_beta_linux.sh +6 -0
- package/bin/reinstall_msedge_dev_linux.sh +6 -0
- package/bin/reinstall_msedge_stable_linux.sh +6 -0
- package/browsers.json +28 -13
- package/index.js +0 -1
- package/lib/androidServerImpl.js +42 -48
- package/lib/browserServerImpl.js +60 -64
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +314 -354
- package/lib/cli/programWithTestStub.js +51 -44
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +146 -254
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -39
- package/lib/client/browser.js +59 -68
- package/lib/client/browserContext.js +302 -322
- package/lib/client/browserType.js +95 -143
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +109 -139
- package/lib/client/clientHelper.js +49 -42
- package/lib/client/clientInstrumentation.js +40 -35
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +203 -218
- package/lib/client/consoleMessage.js +33 -33
- 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 +74 -76
- package/lib/client/elementHandle.js +126 -163
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +127 -127
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +154 -178
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +189 -307
- package/lib/client/harRouter.js +44 -56
- package/lib/client/input.js +40 -69
- package/lib/client/jsHandle.js +55 -71
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +53 -28
- package/lib/client/locator.js +144 -230
- package/lib/client/network.js +285 -301
- package/lib/client/page.js +273 -312
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +62 -57
- package/lib/client/selectors.js +51 -43
- package/lib/client/stream.js +30 -45
- package/lib/client/timeoutSettings.js +75 -0
- package/lib/client/tracing.js +49 -82
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +71 -91
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +111 -0
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +28 -43
- package/lib/generated/clockSource.js +26 -5
- package/lib/generated/consoleApiSource.js +26 -5
- package/lib/generated/injectedScriptSource.js +26 -5
- package/lib/generated/pollingRecorderSource.js +26 -5
- package/lib/generated/utilityScriptSource.js +26 -5
- package/lib/generated/webSocketMockSource.js +375 -4
- package/lib/inProcessFactory.js +53 -48
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +53 -42
- package/lib/protocol/debug.js +209 -25
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2712 -2667
- package/lib/protocol/validatorPrimitives.js +115 -75
- package/lib/remote/playwrightConnection.js +144 -152
- package/lib/remote/playwrightServer.js +106 -77
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +216 -206
- package/lib/server/android/backendAdb.js +89 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +227 -158
- package/lib/server/bidi/bidiChromium.js +106 -78
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +161 -97
- package/lib/server/bidi/bidiFirefox.js +76 -68
- package/lib/server/bidi/bidiInput.js +90 -102
- package/lib/server/bidi/bidiNetworkManager.js +141 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +262 -261
- 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 +241 -223
- package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +149 -111
- package/lib/server/browser.js +76 -84
- package/lib/server/browserContext.js +343 -360
- package/lib/server/browserType.js +169 -181
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/chromium.js +212 -190
- package/lib/server/chromium/chromiumSwitches.js +99 -44
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +262 -280
- package/lib/server/chromium/crConnection.js +121 -178
- package/lib/server/chromium/crCoverage.js +113 -127
- package/lib/server/chromium/crDevTools.js +64 -55
- package/lib/server/chromium/crDragDrop.js +62 -79
- package/lib/server/chromium/crExecutionContext.js +100 -91
- package/lib/server/chromium/crInput.js +101 -88
- package/lib/server/chromium/crNetworkManager.js +269 -370
- package/lib/server/chromium/crPage.js +509 -595
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +85 -69
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +65 -99
- package/lib/server/clock.js +58 -46
- package/lib/server/codegen/csharp.js +191 -156
- package/lib/server/codegen/java.js +163 -125
- package/lib/server/codegen/javascript.js +166 -143
- package/lib/server/codegen/jsonl.js +33 -29
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -125
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +105 -86
- package/lib/server/debugController.js +102 -154
- package/lib/server/debugger.js +82 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +131 -131
- package/lib/server/dialog.js +36 -35
- package/lib/server/dispatchers/androidDispatcher.js +196 -107
- package/lib/server/dispatchers/artifactDispatcher.js +62 -62
- package/lib/server/dispatchers/browserContextDispatcher.js +177 -217
- package/lib/server/dispatchers/browserDispatcher.js +78 -97
- package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
- package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
- package/lib/server/dispatchers/debugControllerDispatcher.js +48 -64
- package/lib/server/dispatchers/dialogDispatcher.js +30 -27
- package/lib/server/dispatchers/dispatcher.js +180 -229
- package/lib/server/dispatchers/electronDispatcher.js +54 -57
- package/lib/server/dispatchers/elementHandlerDispatcher.js +79 -116
- package/lib/server/dispatchers/frameDispatcher.js +93 -162
- package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
- package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
- package/lib/server/dispatchers/localUtilsDispatcher.js +107 -365
- package/lib/server/dispatchers/networkDispatchers.js +92 -109
- package/lib/server/dispatchers/pageDispatcher.js +130 -169
- package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
- package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
- package/lib/server/dispatchers/streamDispatcher.js +42 -44
- package/lib/server/dispatchers/tracingDispatcher.js +36 -41
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +100 -135
- package/lib/server/dispatchers/writableStreamDispatcher.js +54 -39
- package/lib/server/dom.js +424 -443
- package/lib/server/download.js +45 -35
- package/lib/server/electron/electron.js +156 -175
- package/lib/server/electron/loader.js +8 -36
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +302 -331
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -57
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +218 -274
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +103 -77
- package/lib/server/firefox/ffInput.js +72 -63
- package/lib/server/firefox/ffNetworkManager.js +131 -110
- package/lib/server/firefox/ffPage.js +244 -302
- package/lib/server/firefox/firefox.js +76 -69
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +77 -111
- package/lib/server/frames.js +719 -855
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +288 -224
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +56 -59
- package/lib/server/index.js +59 -106
- package/lib/server/input.js +136 -166
- package/lib/server/instrumentation.js +49 -44
- package/lib/server/javascript.js +157 -151
- package/lib/server/launchApp.js +92 -73
- package/lib/server/localUtils.js +211 -0
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +263 -297
- package/lib/server/page.js +353 -432
- package/lib/server/pageBinding.js +88 -0
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +60 -67
- package/lib/server/progress.js +56 -51
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/contextRecorder.js +135 -148
- package/lib/server/recorder/recorderApp.js +129 -132
- package/lib/server/recorder/recorderCollection.js +57 -57
- package/lib/server/recorder/recorderFrontend.js +15 -4
- package/lib/server/recorder/recorderRunner.js +80 -100
- package/lib/server/recorder/recorderUtils.js +59 -72
- package/lib/server/recorder/throttledFile.js +42 -31
- package/lib/server/recorder.js +186 -190
- package/lib/server/registry/browserFetcher.js +107 -100
- package/lib/server/registry/dependencies.js +247 -198
- package/lib/server/registry/index.js +928 -709
- package/lib/server/registry/nativeDeps.js +1073 -461
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +166 -182
- package/lib/server/selectors.js +85 -46
- package/lib/server/socksClientCertificatesInterceptor.js +166 -185
- package/lib/server/socksInterceptor.js +62 -67
- package/lib/server/storageScript.js +154 -0
- package/lib/server/timeoutSettings.js +89 -0
- package/lib/server/trace/recorder/snapshotter.js +70 -88
- package/lib/server/trace/recorder/snapshotterInjected.js +246 -218
- package/lib/server/trace/recorder/tracing.js +324 -327
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +172 -137
- package/lib/server/transport.js +125 -133
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +47 -0
- package/lib/server/utils/debugLogger.js +114 -0
- package/lib/server/utils/env.js +68 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +109 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/{image_tools → server/utils/image_tools}/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/{image_tools → server/utils/image_tools}/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +217 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +238 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +132 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +76 -63
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +163 -180
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +96 -73
- package/lib/server/webkit/wkInput.js +87 -75
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +536 -645
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +77 -77
- package/lib/utils/isomorphic/ariaSnapshot.js +245 -128
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/builtins.js +90 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +123 -127
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +344 -349
- package/lib/utils/isomorphic/locatorParser.js +103 -106
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +115 -0
- package/lib/utils/isomorphic/mimeType.js +453 -22
- package/lib/utils/isomorphic/multimap.js +81 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +183 -193
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +113 -106
- package/lib/utils/isomorphic/time.js +44 -0
- package/lib/utils/isomorphic/timeoutRunner.js +67 -0
- package/lib/utils/isomorphic/traceUtils.js +52 -32
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +114 -71
- package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
- package/lib/utils.js +101 -0
- package/lib/utilsBundle.js +101 -76
- package/lib/utilsBundleImpl/index.js +114 -116
- package/lib/vite/htmlReport/index.html +26 -20
- package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +24 -0
- package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
- package/lib/vite/recorder/assets/{index-iA1aAGZg.css → index-eHBmevrY.css} +1 -1
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +265 -0
- package/lib/vite/traceViewer/assets/{xtermModule-BeNbaIVa.js → xtermModule-BoAIEibi.js} +7 -7
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +1 -0
- package/lib/vite/traceViewer/index.DvtSwn6E.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -7
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/{uiMode.voC1ZiOQ.css → uiMode.BatfzHMG.css} +1 -1
- package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -7
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +7 -7
- package/types/protocol.d.ts +819 -127
- package/types/types.d.ts +196 -75
- package/bin/PrintDeps.exe +0 -0
- package/bin/README.md +0 -2
- 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/imageChannel.js +0 -70
- package/lib/protocol/transport.js +0 -82
- package/lib/server/ariaSnapshot.js +0 -33
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
- package/lib/server/recorder/recorderInTraceViewer.js +0 -144
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -153
- package/lib/utils/crypto.js +0 -171
- 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/expectUtils.js +0 -33
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -194
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -139
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/isomorphic/recorderUtils.js +0 -227
- 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/sequence.js +0 -64
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -134
- 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 -71
- package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +0 -24
- package/lib/vite/recorder/assets/index-_cTWgVuJ.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-KatbITLF.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-DdpLd2bb.js +0 -68
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
- package/lib/vite/traceViewer/assets/workbench-CdYbzWFD.js +0 -9
- package/lib/vite/traceViewer/embedded.6m3UZh7r.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
- package/lib/vite/traceViewer/index.WUV-8boJ.js +0 -2
- package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
- package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- package/lib/vite/traceViewer/recorder.OT2tVHgn.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/uiMode.BZBTyvGn.js +0 -5
- package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
- /package/lib/vite/recorder/assets/{codeMirrorModule-ez37Vkbh.css → codeMirrorModule-C3UTv-Ge.css} +0 -0
- /package/lib/vite/traceViewer/{codeMirrorModule.ez37Vkbh.css → codeMirrorModule.C3UTv-Ge.css} +0 -0
- /package/lib/vite/traceViewer/{index.CrbWWHbf.css → index.CFOW-Ezb.css} +0 -0
- /package/lib/vite/traceViewer/{xtermModule.DSXBckUd.css → xtermModule.Beg8tuEN.css} +0 -0
|
@@ -1,101 +1,101 @@
|
|
|
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
|
+
addMainBinding: () => addMainBinding,
|
|
33
|
+
kPlaywrightBindingChannel: () => kPlaywrightBindingChannel
|
|
5
34
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var dialog =
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
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';
|
|
35
|
+
module.exports = __toCommonJS(bidiPage_exports);
|
|
36
|
+
var import_utils = require("../../utils");
|
|
37
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
38
|
+
var import_browserContext = require("../browserContext");
|
|
39
|
+
var dialog = __toESM(require("../dialog"));
|
|
40
|
+
var dom = __toESM(require("../dom"));
|
|
41
|
+
var import_page = require("../page");
|
|
42
|
+
var import_bidiExecutionContext = require("./bidiExecutionContext");
|
|
43
|
+
var import_bidiInput = require("./bidiInput");
|
|
44
|
+
var import_bidiNetworkManager = require("./bidiNetworkManager");
|
|
45
|
+
var import_bidiPdf = require("./bidiPdf");
|
|
46
|
+
var bidi = __toESM(require("./third_party/bidiProtocol"));
|
|
47
|
+
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
48
|
+
const kPlaywrightBindingChannel = "playwrightChannel";
|
|
38
49
|
class BidiPage {
|
|
39
50
|
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._pagePromise = void 0;
|
|
45
|
-
this._session = void 0;
|
|
46
|
-
this._opener = void 0;
|
|
47
|
-
this._realmToContext = void 0;
|
|
48
51
|
this._sessionListeners = [];
|
|
49
|
-
this._browserContext = void 0;
|
|
50
|
-
this._networkManager = void 0;
|
|
51
|
-
this._pdf = void 0;
|
|
52
|
-
this._initializedPage = null;
|
|
53
52
|
this._initScriptIds = [];
|
|
54
53
|
this._session = bidiSession;
|
|
55
54
|
this._opener = opener;
|
|
56
|
-
this.rawKeyboard = new
|
|
57
|
-
this.rawMouse = new
|
|
58
|
-
this.rawTouchscreen = new
|
|
59
|
-
this._realmToContext = new Map();
|
|
60
|
-
this._page = new
|
|
55
|
+
this.rawKeyboard = new import_bidiInput.RawKeyboardImpl(bidiSession);
|
|
56
|
+
this.rawMouse = new import_bidiInput.RawMouseImpl(bidiSession);
|
|
57
|
+
this.rawTouchscreen = new import_bidiInput.RawTouchscreenImpl(bidiSession);
|
|
58
|
+
this._realmToContext = /* @__PURE__ */ new Map();
|
|
59
|
+
this._page = new import_page.Page(this, browserContext);
|
|
61
60
|
this._browserContext = browserContext;
|
|
62
|
-
this._networkManager = new
|
|
63
|
-
this._pdf = new
|
|
64
|
-
this._page.on(
|
|
65
|
-
this._sessionListeners = [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
this._networkManager = new import_bidiNetworkManager.BidiNetworkManager(this._session, this._page, this._onNavigationResponseStarted.bind(this));
|
|
62
|
+
this._pdf = new import_bidiPdf.BidiPDF(this._session);
|
|
63
|
+
this._page.on(import_page.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame, false));
|
|
64
|
+
this._sessionListeners = [
|
|
65
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.realmCreated", this._onRealmCreated.bind(this)),
|
|
66
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "script.message", this._onScriptMessage.bind(this)),
|
|
67
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.contextDestroyed", this._onBrowsingContextDestroyed.bind(this)),
|
|
68
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationStarted", this._onNavigationStarted.bind(this)),
|
|
69
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationAborted", this._onNavigationAborted.bind(this)),
|
|
70
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.navigationFailed", this._onNavigationFailed.bind(this)),
|
|
71
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.fragmentNavigated", this._onFragmentNavigated.bind(this)),
|
|
72
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.domContentLoaded", this._onDomContentLoaded.bind(this)),
|
|
73
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.load", this._onLoad.bind(this)),
|
|
74
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "browsingContext.userPromptOpened", this._onUserPromptOpened.bind(this)),
|
|
75
|
+
import_eventsHelper.eventsHelper.addEventListener(bidiSession, "log.entryAdded", this._onLogEntryAdded.bind(this))
|
|
76
|
+
];
|
|
77
|
+
this._initialize().then(
|
|
78
|
+
() => this._page.reportAsNew(this._opener?._page),
|
|
79
|
+
(error) => this._page.reportAsNew(this._opener?._page, error)
|
|
80
|
+
);
|
|
78
81
|
}
|
|
79
82
|
async _initialize() {
|
|
80
|
-
// Initialize main frame.
|
|
81
83
|
this._onFrameAttached(this._session.sessionId, null);
|
|
82
|
-
await Promise.all([
|
|
84
|
+
await Promise.all([
|
|
85
|
+
this.updateHttpCredentials(),
|
|
86
|
+
this.updateRequestInterception(),
|
|
87
|
+
this._installMainBinding(),
|
|
88
|
+
this._addAllInitScripts()
|
|
89
|
+
]);
|
|
83
90
|
}
|
|
84
91
|
async _addAllInitScripts() {
|
|
85
|
-
return Promise.all(this._page.allInitScripts().map(initScript => this.addInitScript(initScript)));
|
|
86
|
-
}
|
|
87
|
-
potentiallyUninitializedPage() {
|
|
88
|
-
return this._page;
|
|
92
|
+
return Promise.all(this._page.allInitScripts().map((initScript) => this.addInitScript(initScript)));
|
|
89
93
|
}
|
|
90
94
|
didClose() {
|
|
91
95
|
this._session.dispose();
|
|
92
|
-
|
|
96
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._sessionListeners);
|
|
93
97
|
this._page._didClose();
|
|
94
98
|
}
|
|
95
|
-
async pageOrError() {
|
|
96
|
-
// TODO: Wait for first execution context to be created and maybe about:blank navigated.
|
|
97
|
-
return this._pagePromise;
|
|
98
|
-
}
|
|
99
99
|
_onFrameAttached(frameId, parentFrameId) {
|
|
100
100
|
return this._page._frameManager.frameAttached(frameId, parentFrameId);
|
|
101
101
|
}
|
|
@@ -103,34 +103,36 @@ class BidiPage {
|
|
|
103
103
|
for (const [contextId, context] of this._realmToContext) {
|
|
104
104
|
if (context.frame === frame) {
|
|
105
105
|
this._realmToContext.delete(contextId);
|
|
106
|
-
if (notifyFrame)
|
|
106
|
+
if (notifyFrame)
|
|
107
|
+
frame._contextDestroyed(context);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
_onRealmCreated(realmInfo) {
|
|
111
|
-
if (this._realmToContext.has(realmInfo.realm))
|
|
112
|
-
|
|
112
|
+
if (this._realmToContext.has(realmInfo.realm))
|
|
113
|
+
return;
|
|
114
|
+
if (realmInfo.type !== "window")
|
|
115
|
+
return;
|
|
113
116
|
const frame = this._page._frameManager.frame(realmInfo.context);
|
|
114
|
-
if (!frame)
|
|
115
|
-
|
|
117
|
+
if (!frame)
|
|
118
|
+
return;
|
|
116
119
|
let worldName;
|
|
117
120
|
if (!realmInfo.sandbox) {
|
|
118
|
-
worldName =
|
|
119
|
-
// Force creating utility world every time the main world is created (e.g. due to navigation).
|
|
121
|
+
worldName = "main";
|
|
120
122
|
this._touchUtilityWorld(realmInfo.context);
|
|
121
123
|
} else if (realmInfo.sandbox === UTILITY_WORLD_NAME) {
|
|
122
|
-
worldName =
|
|
124
|
+
worldName = "utility";
|
|
123
125
|
} else {
|
|
124
126
|
return;
|
|
125
127
|
}
|
|
128
|
+
const delegate = new import_bidiExecutionContext.BidiExecutionContext(this._session, realmInfo);
|
|
126
129
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
|
127
|
-
context[contextDelegateSymbol] = delegate;
|
|
128
130
|
frame._contextCreated(worldName, context);
|
|
129
131
|
this._realmToContext.set(realmInfo.realm, context);
|
|
130
132
|
}
|
|
131
133
|
async _touchUtilityWorld(context) {
|
|
132
|
-
await this._session.sendMayFail(
|
|
133
|
-
expression:
|
|
134
|
+
await this._session.sendMayFail("script.evaluate", {
|
|
135
|
+
expression: "1 + 1",
|
|
134
136
|
target: {
|
|
135
137
|
context,
|
|
136
138
|
sandbox: UTILITY_WORLD_NAME
|
|
@@ -145,12 +147,12 @@ class BidiPage {
|
|
|
145
147
|
}
|
|
146
148
|
_onRealmDestroyed(params) {
|
|
147
149
|
const context = this._realmToContext.get(params.realm);
|
|
148
|
-
if (!context)
|
|
150
|
+
if (!context)
|
|
151
|
+
return false;
|
|
149
152
|
this._realmToContext.delete(params.realm);
|
|
150
153
|
context.frame._contextDestroyed(context);
|
|
151
154
|
return true;
|
|
152
155
|
}
|
|
153
|
-
|
|
154
156
|
// TODO: route the message directly to the browser
|
|
155
157
|
_onBrowsingContextDestroyed(params) {
|
|
156
158
|
this._browserContext._browser._onBrowsingContextDestroyed(params);
|
|
@@ -159,93 +161,96 @@ class BidiPage {
|
|
|
159
161
|
const frameId = params.context;
|
|
160
162
|
this._page._frameManager.frameRequestedNavigation(frameId, params.navigation);
|
|
161
163
|
const url = params.url.toLowerCase();
|
|
162
|
-
if (url.startsWith(
|
|
163
|
-
// Navigation to file urls doesn't emit network events, so we fire 'commit' event right when navigation is started.
|
|
164
|
-
// Doing it in domcontentload would be too late as we'd clear frame tree.
|
|
164
|
+
if (url.startsWith("file:") || url.startsWith("data:") || url === "about:blank") {
|
|
165
165
|
const frame = this._page._frameManager.frame(frameId);
|
|
166
|
-
if (frame)
|
|
166
|
+
if (frame)
|
|
167
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(
|
|
168
|
+
frameId,
|
|
169
|
+
params.url,
|
|
170
|
+
"",
|
|
171
|
+
params.navigation,
|
|
172
|
+
/* initial */
|
|
173
|
+
false
|
|
174
|
+
);
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
|
-
|
|
170
177
|
// TODO: there is no separate event for committed navigation, so we approximate it with responseStarted.
|
|
171
178
|
_onNavigationResponseStarted(params) {
|
|
172
179
|
const frameId = params.context;
|
|
173
180
|
const frame = this._page._frameManager.frame(frameId);
|
|
174
|
-
(0,
|
|
175
|
-
this._page._frameManager.frameCommittedNewDocumentNavigation(
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
(0, import_utils.assert)(frame);
|
|
182
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(
|
|
183
|
+
frameId,
|
|
184
|
+
params.response.url,
|
|
185
|
+
"",
|
|
186
|
+
params.navigation,
|
|
187
|
+
/* initial */
|
|
188
|
+
false
|
|
189
|
+
);
|
|
178
190
|
}
|
|
179
191
|
_onDomContentLoaded(params) {
|
|
180
192
|
const frameId = params.context;
|
|
181
|
-
this._page._frameManager.frameLifecycleEvent(frameId,
|
|
193
|
+
this._page._frameManager.frameLifecycleEvent(frameId, "domcontentloaded");
|
|
182
194
|
}
|
|
183
195
|
_onLoad(params) {
|
|
184
|
-
this._page._frameManager.frameLifecycleEvent(params.context,
|
|
196
|
+
this._page._frameManager.frameLifecycleEvent(params.context, "load");
|
|
185
197
|
}
|
|
186
198
|
_onNavigationAborted(params) {
|
|
187
|
-
this._page._frameManager.frameAbortedNavigation(params.context,
|
|
199
|
+
this._page._frameManager.frameAbortedNavigation(params.context, "Navigation aborted", params.navigation || void 0);
|
|
188
200
|
}
|
|
189
201
|
_onNavigationFailed(params) {
|
|
190
|
-
this._page._frameManager.frameAbortedNavigation(params.context,
|
|
202
|
+
this._page._frameManager.frameAbortedNavigation(params.context, "Navigation failed", params.navigation || void 0);
|
|
191
203
|
}
|
|
192
204
|
_onFragmentNavigated(params) {
|
|
193
205
|
this._page._frameManager.frameCommittedSameDocumentNavigation(params.context, params.url);
|
|
194
206
|
}
|
|
195
207
|
_onUserPromptOpened(event) {
|
|
196
|
-
this._page.emitOnContext(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
208
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(
|
|
209
|
+
this._page,
|
|
210
|
+
event.type,
|
|
211
|
+
event.message,
|
|
212
|
+
async (accept, userText) => {
|
|
213
|
+
await this._session.send("browsingContext.handleUserPrompt", { context: event.context, accept, userText });
|
|
214
|
+
},
|
|
215
|
+
event.defaultValue
|
|
216
|
+
));
|
|
203
217
|
}
|
|
204
218
|
_onLogEntryAdded(params) {
|
|
205
|
-
|
|
206
|
-
|
|
219
|
+
if (params.type !== "console")
|
|
220
|
+
return;
|
|
207
221
|
const entry = params;
|
|
208
222
|
const context = this._realmToContext.get(params.source.realm);
|
|
209
|
-
if (!context)
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
columnNumber: 1
|
|
215
|
-
};
|
|
216
|
-
this._page._addConsoleMessage(entry.method, entry.args.map(arg => context.createHandle({
|
|
217
|
-
objectId: arg.handle,
|
|
218
|
-
...arg
|
|
219
|
-
})), location, params.text || undefined);
|
|
223
|
+
if (!context)
|
|
224
|
+
return;
|
|
225
|
+
const callFrame = params.stackTrace?.callFrames[0];
|
|
226
|
+
const location = callFrame ?? { url: "", lineNumber: 1, columnNumber: 1 };
|
|
227
|
+
this._page._addConsoleMessage(entry.method, entry.args.map((arg) => (0, import_bidiExecutionContext.createHandle)(context, arg)), location, params.text || void 0);
|
|
220
228
|
}
|
|
221
229
|
async navigateFrame(frame, url, referrer) {
|
|
222
|
-
const {
|
|
223
|
-
navigation
|
|
224
|
-
} = await this._session.send('browsingContext.navigate', {
|
|
230
|
+
const { navigation } = await this._session.send("browsingContext.navigate", {
|
|
225
231
|
context: frame._id,
|
|
226
232
|
url
|
|
227
233
|
});
|
|
228
|
-
return {
|
|
229
|
-
newDocumentId: navigation || undefined
|
|
230
|
-
};
|
|
234
|
+
return { newDocumentId: navigation || void 0 };
|
|
231
235
|
}
|
|
232
|
-
async updateExtraHTTPHeaders() {
|
|
233
|
-
|
|
234
|
-
async
|
|
235
|
-
|
|
236
|
+
async updateExtraHTTPHeaders() {
|
|
237
|
+
}
|
|
238
|
+
async updateEmulateMedia() {
|
|
239
|
+
}
|
|
240
|
+
async updateUserAgent() {
|
|
236
241
|
}
|
|
237
|
-
async updateUserAgent() {}
|
|
238
242
|
async bringToFront() {
|
|
239
|
-
await this._session.send(
|
|
243
|
+
await this._session.send("browsingContext.activate", {
|
|
240
244
|
context: this._session.sessionId
|
|
241
245
|
});
|
|
242
246
|
}
|
|
243
|
-
async
|
|
247
|
+
async updateEmulatedViewportSize() {
|
|
244
248
|
const options = this._browserContext._options;
|
|
245
249
|
const deviceSize = this._page.emulatedSize();
|
|
246
|
-
if (deviceSize === null)
|
|
250
|
+
if (deviceSize === null)
|
|
251
|
+
return;
|
|
247
252
|
const viewportSize = deviceSize.viewport;
|
|
248
|
-
await this._session.send(
|
|
253
|
+
await this._session.send("browsingContext.setViewport", {
|
|
249
254
|
context: this._session.sessionId,
|
|
250
255
|
viewport: {
|
|
251
256
|
width: viewportSize.width,
|
|
@@ -257,50 +262,54 @@ class BidiPage {
|
|
|
257
262
|
async updateRequestInterception() {
|
|
258
263
|
await this._networkManager.setRequestInterception(this._page.needsRequestInterception());
|
|
259
264
|
}
|
|
260
|
-
async updateOffline() {
|
|
265
|
+
async updateOffline() {
|
|
266
|
+
}
|
|
261
267
|
async updateHttpCredentials() {
|
|
262
268
|
await this._networkManager.setCredentials(this._browserContext._options.httpCredentials);
|
|
263
269
|
}
|
|
264
|
-
async updateFileChooserInterception() {
|
|
270
|
+
async updateFileChooserInterception() {
|
|
271
|
+
}
|
|
265
272
|
async reload() {
|
|
266
|
-
await this._session.send(
|
|
273
|
+
await this._session.send("browsingContext.reload", {
|
|
267
274
|
context: this._session.sessionId,
|
|
268
275
|
// ignoreCache: true,
|
|
269
276
|
wait: bidi.BrowsingContext.ReadinessState.Interactive
|
|
270
277
|
});
|
|
271
278
|
}
|
|
272
279
|
async goBack() {
|
|
273
|
-
return await this._session.send(
|
|
280
|
+
return await this._session.send("browsingContext.traverseHistory", {
|
|
274
281
|
context: this._session.sessionId,
|
|
275
282
|
delta: -1
|
|
276
283
|
}).then(() => true).catch(() => false);
|
|
277
284
|
}
|
|
278
285
|
async goForward() {
|
|
279
|
-
return await this._session.send(
|
|
286
|
+
return await this._session.send("browsingContext.traverseHistory", {
|
|
280
287
|
context: this._session.sessionId,
|
|
281
|
-
delta:
|
|
288
|
+
delta: 1
|
|
282
289
|
}).then(() => true).catch(() => false);
|
|
283
290
|
}
|
|
284
291
|
async requestGC() {
|
|
285
|
-
throw new Error(
|
|
292
|
+
throw new Error("Method not implemented.");
|
|
286
293
|
}
|
|
287
|
-
|
|
288
294
|
// TODO: consider calling this only when bindings are added.
|
|
295
|
+
// TODO: delete this method once we can add preload script for persistent context.
|
|
289
296
|
async _installMainBinding() {
|
|
297
|
+
if (this._browserContext._browserContextId)
|
|
298
|
+
return;
|
|
290
299
|
const functionDeclaration = addMainBinding.toString();
|
|
291
300
|
const args = [{
|
|
292
|
-
type:
|
|
301
|
+
type: "channel",
|
|
293
302
|
value: {
|
|
294
303
|
channel: kPlaywrightBindingChannel,
|
|
295
304
|
ownership: bidi.Script.ResultOwnership.Root
|
|
296
305
|
}
|
|
297
306
|
}];
|
|
298
307
|
const promises = [];
|
|
299
|
-
promises.push(this._session.send(
|
|
308
|
+
promises.push(this._session.send("script.addPreloadScript", {
|
|
300
309
|
functionDeclaration,
|
|
301
310
|
arguments: args
|
|
302
311
|
}));
|
|
303
|
-
promises.push(this._session.send(
|
|
312
|
+
promises.push(this._session.send("script.callFunction", {
|
|
304
313
|
functionDeclaration,
|
|
305
314
|
arguments: args,
|
|
306
315
|
target: toBidiExecutionContext(await this._page.mainFrame()._mainContext())._target,
|
|
@@ -310,106 +319,101 @@ class BidiPage {
|
|
|
310
319
|
await Promise.all(promises);
|
|
311
320
|
}
|
|
312
321
|
async _onScriptMessage(event) {
|
|
313
|
-
if (event.channel !== kPlaywrightBindingChannel)
|
|
314
|
-
|
|
315
|
-
|
|
322
|
+
if (event.channel !== kPlaywrightBindingChannel)
|
|
323
|
+
return;
|
|
324
|
+
const pageOrError = await this._page.waitForInitializedOrError();
|
|
325
|
+
if (pageOrError instanceof Error)
|
|
326
|
+
return;
|
|
316
327
|
const context = this._realmToContext.get(event.source.realm);
|
|
317
|
-
if (!context)
|
|
318
|
-
|
|
328
|
+
if (!context)
|
|
329
|
+
return;
|
|
330
|
+
if (event.data.type !== "string")
|
|
331
|
+
return;
|
|
319
332
|
await this._page._onBindingCalled(event.data.value, context);
|
|
320
333
|
}
|
|
321
334
|
async addInitScript(initScript) {
|
|
322
|
-
const {
|
|
323
|
-
script
|
|
324
|
-
} = await this._session.send('script.addPreloadScript', {
|
|
335
|
+
const { script } = await this._session.send("script.addPreloadScript", {
|
|
325
336
|
// TODO: remove function call from the source.
|
|
326
337
|
functionDeclaration: `() => { return ${initScript.source} }`,
|
|
327
338
|
// TODO: push to iframes?
|
|
328
339
|
contexts: [this._session.sessionId]
|
|
329
340
|
});
|
|
330
|
-
if (!initScript.internal)
|
|
341
|
+
if (!initScript.internal)
|
|
342
|
+
this._initScriptIds.push(script);
|
|
331
343
|
}
|
|
332
344
|
async removeNonInternalInitScripts() {
|
|
333
|
-
const promises = this._initScriptIds.map(script => this._session.send(
|
|
334
|
-
script
|
|
335
|
-
}));
|
|
345
|
+
const promises = this._initScriptIds.map((script) => this._session.send("script.removePreloadScript", { script }));
|
|
336
346
|
this._initScriptIds = [];
|
|
337
347
|
await Promise.all(promises);
|
|
338
348
|
}
|
|
339
349
|
async closePage(runBeforeUnload) {
|
|
340
|
-
await this._session.send(
|
|
350
|
+
await this._session.send("browsingContext.close", {
|
|
341
351
|
context: this._session.sessionId,
|
|
342
352
|
promptUnload: runBeforeUnload
|
|
343
353
|
});
|
|
344
354
|
}
|
|
345
|
-
async setBackgroundColor(color) {
|
|
355
|
+
async setBackgroundColor(color) {
|
|
356
|
+
}
|
|
346
357
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
347
358
|
const rect = documentRect || viewportRect;
|
|
348
|
-
const {
|
|
349
|
-
data
|
|
350
|
-
} = await this._session.send('browsingContext.captureScreenshot', {
|
|
359
|
+
const { data } = await this._session.send("browsingContext.captureScreenshot", {
|
|
351
360
|
context: this._session.sessionId,
|
|
352
361
|
format: {
|
|
353
|
-
type: `image/${format ===
|
|
354
|
-
quality: quality
|
|
362
|
+
type: `image/${format === "png" ? "png" : "jpeg"}`,
|
|
363
|
+
quality: quality ? quality / 100 : 0.8
|
|
355
364
|
},
|
|
356
|
-
origin: documentRect ?
|
|
365
|
+
origin: documentRect ? "document" : "viewport",
|
|
357
366
|
clip: {
|
|
358
|
-
type:
|
|
367
|
+
type: "box",
|
|
359
368
|
...rect
|
|
360
369
|
}
|
|
361
370
|
});
|
|
362
|
-
return Buffer.from(data,
|
|
371
|
+
return Buffer.from(data, "base64");
|
|
363
372
|
}
|
|
364
373
|
async getContentFrame(handle) {
|
|
365
374
|
const executionContext = toBidiExecutionContext(handle._context);
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const frameId = contentWindow.value.context;
|
|
371
|
-
const result = this._page._frameManager.frame(frameId);
|
|
372
|
-
return result;
|
|
373
|
-
}
|
|
374
|
-
return null;
|
|
375
|
+
const frameId = await executionContext.contentFrameIdForFrame(handle);
|
|
376
|
+
if (!frameId)
|
|
377
|
+
return null;
|
|
378
|
+
return this._page._frameManager.frame(frameId);
|
|
375
379
|
}
|
|
376
380
|
async getOwnerFrame(handle) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
+
const windowHandle = await handle.evaluateHandle((node) => {
|
|
382
|
+
const doc = node.ownerDocument ?? node;
|
|
383
|
+
return doc.defaultView;
|
|
384
|
+
});
|
|
385
|
+
if (!windowHandle)
|
|
386
|
+
return null;
|
|
387
|
+
const executionContext = toBidiExecutionContext(handle._context);
|
|
388
|
+
return executionContext.frameIdForWindowHandle(windowHandle);
|
|
381
389
|
}
|
|
382
390
|
async getBoundingBox(handle) {
|
|
383
|
-
const box = await handle.evaluate(element => {
|
|
384
|
-
if (!(element instanceof Element))
|
|
391
|
+
const box = await handle.evaluate((element) => {
|
|
392
|
+
if (!(element instanceof Element))
|
|
393
|
+
return null;
|
|
385
394
|
const rect = element.getBoundingClientRect();
|
|
386
|
-
return {
|
|
387
|
-
x: rect.x,
|
|
388
|
-
y: rect.y,
|
|
389
|
-
width: rect.width,
|
|
390
|
-
height: rect.height
|
|
391
|
-
};
|
|
395
|
+
return { x: rect.x, y: rect.y, width: rect.width, height: rect.height };
|
|
392
396
|
});
|
|
393
|
-
if (!box)
|
|
397
|
+
if (!box)
|
|
398
|
+
return null;
|
|
394
399
|
const position = await this._framePosition(handle._frame);
|
|
395
|
-
if (!position)
|
|
400
|
+
if (!position)
|
|
401
|
+
return null;
|
|
396
402
|
box.x += position.x;
|
|
397
403
|
box.y += position.y;
|
|
398
404
|
return box;
|
|
399
405
|
}
|
|
400
|
-
|
|
401
406
|
// TODO: move to Frame.
|
|
402
407
|
async _framePosition(frame) {
|
|
403
|
-
if (frame === this._page.mainFrame())
|
|
404
|
-
x: 0,
|
|
405
|
-
y: 0
|
|
406
|
-
};
|
|
408
|
+
if (frame === this._page.mainFrame())
|
|
409
|
+
return { x: 0, y: 0 };
|
|
407
410
|
const element = await frame.frameElement();
|
|
408
411
|
const box = await element.boundingBox();
|
|
409
|
-
if (!box)
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
412
|
+
if (!box)
|
|
413
|
+
return null;
|
|
414
|
+
const style = await element.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch((e) => "error:notconnected");
|
|
415
|
+
if (style === "error:notconnected" || style === "transformed")
|
|
416
|
+
return null;
|
|
413
417
|
box.x += style.left;
|
|
414
418
|
box.y += style.top;
|
|
415
419
|
return box;
|
|
@@ -417,92 +421,84 @@ class BidiPage {
|
|
|
417
421
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
418
422
|
return await handle.evaluateInUtility(([injected, node]) => {
|
|
419
423
|
node.scrollIntoView({
|
|
420
|
-
block:
|
|
421
|
-
inline:
|
|
422
|
-
behavior:
|
|
424
|
+
block: "center",
|
|
425
|
+
inline: "center",
|
|
426
|
+
behavior: "instant"
|
|
423
427
|
});
|
|
424
|
-
}, null).then(() =>
|
|
425
|
-
if (e instanceof Error && e.message.includes(
|
|
426
|
-
|
|
428
|
+
}, null).then(() => "done").catch((e) => {
|
|
429
|
+
if (e instanceof Error && e.message.includes("Node is detached from document"))
|
|
430
|
+
return "error:notconnected";
|
|
431
|
+
if (e instanceof Error && e.message.includes("Node does not have a layout object"))
|
|
432
|
+
return "error:notvisible";
|
|
427
433
|
throw e;
|
|
428
434
|
});
|
|
429
435
|
}
|
|
430
|
-
async setScreencastOptions(options) {
|
|
436
|
+
async setScreencastOptions(options) {
|
|
437
|
+
}
|
|
431
438
|
rafCountForStablePosition() {
|
|
432
439
|
return 1;
|
|
433
440
|
}
|
|
434
441
|
async getContentQuads(handle) {
|
|
435
442
|
const quads = await handle.evaluateInUtility(([injected, node]) => {
|
|
436
|
-
if (!node.isConnected)
|
|
443
|
+
if (!node.isConnected)
|
|
444
|
+
return "error:notconnected";
|
|
437
445
|
const rects = node.getClientRects();
|
|
438
|
-
if (!rects)
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
y: rect.top
|
|
442
|
-
|
|
443
|
-
x: rect.right,
|
|
444
|
-
y: rect.
|
|
445
|
-
|
|
446
|
-
x: rect.right,
|
|
447
|
-
y: rect.bottom
|
|
448
|
-
}, {
|
|
449
|
-
x: rect.left,
|
|
450
|
-
y: rect.bottom
|
|
451
|
-
}]);
|
|
446
|
+
if (!rects)
|
|
447
|
+
return null;
|
|
448
|
+
return [...rects].map((rect) => [
|
|
449
|
+
{ x: rect.left, y: rect.top },
|
|
450
|
+
{ x: rect.right, y: rect.top },
|
|
451
|
+
{ x: rect.right, y: rect.bottom },
|
|
452
|
+
{ x: rect.left, y: rect.bottom }
|
|
453
|
+
]);
|
|
452
454
|
}, null);
|
|
453
|
-
if (!quads || quads ===
|
|
454
|
-
|
|
455
|
+
if (!quads || quads === "error:notconnected")
|
|
456
|
+
return quads;
|
|
455
457
|
const position = await this._framePosition(handle._frame);
|
|
456
|
-
if (!position)
|
|
457
|
-
|
|
458
|
+
if (!position)
|
|
459
|
+
return null;
|
|
460
|
+
quads.forEach((quad) => quad.forEach((point) => {
|
|
458
461
|
point.x += position.x;
|
|
459
462
|
point.y += position.y;
|
|
460
463
|
}));
|
|
461
464
|
return quads;
|
|
462
465
|
}
|
|
463
|
-
async setInputFiles(handle, files) {
|
|
464
|
-
throw new Error('Method not implemented.');
|
|
465
|
-
}
|
|
466
466
|
async setInputFilePaths(handle, paths) {
|
|
467
|
-
|
|
467
|
+
const fromContext = toBidiExecutionContext(handle._context);
|
|
468
|
+
await this._session.send("input.setFiles", {
|
|
469
|
+
context: this._session.sessionId,
|
|
470
|
+
element: await fromContext.nodeIdForElementHandle(handle),
|
|
471
|
+
files: paths
|
|
472
|
+
});
|
|
468
473
|
}
|
|
469
474
|
async adoptElementHandle(handle, to) {
|
|
470
475
|
const fromContext = toBidiExecutionContext(handle._context);
|
|
471
|
-
const
|
|
472
|
-
handle: handle._objectId
|
|
473
|
-
});
|
|
474
|
-
// TODO: store sharedId in the handle.
|
|
475
|
-
if (!('sharedId' in shared)) throw new Error('Element is not a node');
|
|
476
|
-
const sharedId = shared.sharedId;
|
|
476
|
+
const nodeId = await fromContext.nodeIdForElementHandle(handle);
|
|
477
477
|
const executionContext = toBidiExecutionContext(to);
|
|
478
|
-
|
|
479
|
-
sharedId
|
|
480
|
-
});
|
|
481
|
-
if ('handle' in result) return to.createHandle({
|
|
482
|
-
objectId: result.handle,
|
|
483
|
-
...result
|
|
484
|
-
});
|
|
485
|
-
throw new Error('Failed to adopt element handle.');
|
|
478
|
+
return await executionContext.remoteObjectForNodeId(to, nodeId);
|
|
486
479
|
}
|
|
487
480
|
async getAccessibilityTree(needle) {
|
|
488
|
-
throw new Error(
|
|
481
|
+
throw new Error("Method not implemented.");
|
|
482
|
+
}
|
|
483
|
+
async inputActionEpilogue() {
|
|
484
|
+
}
|
|
485
|
+
async resetForReuse() {
|
|
489
486
|
}
|
|
490
|
-
async inputActionEpilogue() {}
|
|
491
|
-
async resetForReuse() {}
|
|
492
487
|
async pdf(options) {
|
|
493
488
|
return this._pdf.generate(options);
|
|
494
489
|
}
|
|
495
490
|
async getFrameElement(frame) {
|
|
496
491
|
const parent = frame.parentFrame();
|
|
497
|
-
if (!parent)
|
|
492
|
+
if (!parent)
|
|
493
|
+
throw new Error("Frame has been detached.");
|
|
498
494
|
const parentContext = await parent._mainContext();
|
|
499
495
|
const list = await parentContext.evaluateHandle(() => {
|
|
500
|
-
return [...document.querySelectorAll(
|
|
496
|
+
return [...document.querySelectorAll("iframe,frame")];
|
|
501
497
|
});
|
|
502
|
-
const length = await list.evaluate(
|
|
498
|
+
const length = await list.evaluate((list2) => list2.length);
|
|
503
499
|
let foundElement = null;
|
|
504
500
|
for (let i = 0; i < length; i++) {
|
|
505
|
-
const element = await list.evaluateHandle((
|
|
501
|
+
const element = await list.evaluateHandle((list2, i2) => list2[i2], i);
|
|
506
502
|
const candidate = await element.contentFrame();
|
|
507
503
|
if (frame === candidate) {
|
|
508
504
|
foundElement = element;
|
|
@@ -512,18 +508,23 @@ class BidiPage {
|
|
|
512
508
|
}
|
|
513
509
|
}
|
|
514
510
|
list.dispose();
|
|
515
|
-
if (!foundElement)
|
|
511
|
+
if (!foundElement)
|
|
512
|
+
throw new Error("Frame has been detached.");
|
|
516
513
|
return foundElement;
|
|
517
514
|
}
|
|
518
515
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
519
516
|
return true;
|
|
520
517
|
}
|
|
521
518
|
}
|
|
522
|
-
exports.BidiPage = BidiPage;
|
|
523
519
|
function addMainBinding(callback) {
|
|
524
|
-
globalThis[
|
|
520
|
+
globalThis["__playwright__binding__"] = callback;
|
|
525
521
|
}
|
|
526
522
|
function toBidiExecutionContext(executionContext) {
|
|
527
|
-
return executionContext
|
|
523
|
+
return executionContext.delegate;
|
|
528
524
|
}
|
|
529
|
-
|
|
525
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
526
|
+
0 && (module.exports = {
|
|
527
|
+
BidiPage,
|
|
528
|
+
addMainBinding,
|
|
529
|
+
kPlaywrightBindingChannel
|
|
530
|
+
});
|