rebrowser-playwright-core 1.49.1 → 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 -597
- 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 +351 -434
- 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 -647
- 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-C5j27SYZ.js → codeMirrorModule-DVQi6prl.js} +13 -13
- 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 +181 -69
- 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/index-m0XdVJHe.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-BBCX0spr.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-B4Iw34Ow.js +0 -68
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
- package/lib/vite/traceViewer/assets/workbench-DFlGYqou.js +0 -9
- package/lib/vite/traceViewer/embedded.CmarehFk.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.FBucu_gE.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.CW_rzcEp.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/uiMode.CDUVjusr.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,110 +1,118 @@
|
|
|
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 ffPage_exports = {};
|
|
30
|
+
__export(ffPage_exports, {
|
|
31
|
+
FFPage: () => FFPage,
|
|
32
|
+
UTILITY_WORLD_NAME: () => UTILITY_WORLD_NAME
|
|
5
33
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
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 && Object.prototype.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; }
|
|
23
|
-
/**
|
|
24
|
-
* Copyright 2019 Google Inc. All rights reserved.
|
|
25
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
26
|
-
*
|
|
27
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
28
|
-
* you may not use this file except in compliance with the License.
|
|
29
|
-
* You may obtain a copy of the License at
|
|
30
|
-
*
|
|
31
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
32
|
-
*
|
|
33
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
34
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
35
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
36
|
-
* See the License for the specific language governing permissions and
|
|
37
|
-
* limitations under the License.
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
const UTILITY_WORLD_NAME = exports.UTILITY_WORLD_NAME = '__playwright_utility_world__';
|
|
34
|
+
module.exports = __toCommonJS(ffPage_exports);
|
|
35
|
+
var import_eventsHelper = require("../utils/eventsHelper");
|
|
36
|
+
var dialog = __toESM(require("../dialog"));
|
|
37
|
+
var dom = __toESM(require("../dom"));
|
|
38
|
+
var import_page = require("../page");
|
|
39
|
+
var import_page2 = require("../page");
|
|
40
|
+
var import_ffAccessibility = require("./ffAccessibility");
|
|
41
|
+
var import_ffConnection = require("./ffConnection");
|
|
42
|
+
var import_ffExecutionContext = require("./ffExecutionContext");
|
|
43
|
+
var import_ffInput = require("./ffInput");
|
|
44
|
+
var import_ffNetworkManager = require("./ffNetworkManager");
|
|
45
|
+
var import_debugLogger = require("../utils/debugLogger");
|
|
46
|
+
var import_stackTrace = require("../../utils/isomorphic/stackTrace");
|
|
47
|
+
var import_browserContext = require("../browserContext");
|
|
48
|
+
var import_errors = require("../errors");
|
|
49
|
+
const UTILITY_WORLD_NAME = "__playwright_utility_world__";
|
|
41
50
|
class FFPage {
|
|
42
51
|
constructor(session, browserContext, opener) {
|
|
43
52
|
this.cspErrorsAsynchronousForInlineScripts = true;
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.rawTouchscreen = void 0;
|
|
47
|
-
this._session = void 0;
|
|
48
|
-
this._page = void 0;
|
|
49
|
-
this._networkManager = void 0;
|
|
50
|
-
this._browserContext = void 0;
|
|
51
|
-
this._pagePromise = new _manualPromise.ManualPromise();
|
|
52
|
-
this._initializedPage = null;
|
|
53
|
-
this._initializationFailed = false;
|
|
54
|
-
this._opener = void 0;
|
|
55
|
-
this._contextIdToContext = void 0;
|
|
56
|
-
this._eventListeners = void 0;
|
|
57
|
-
this._workers = new Map();
|
|
58
|
-
this._screencastId = void 0;
|
|
53
|
+
this._reportedAsNew = false;
|
|
54
|
+
this._workers = /* @__PURE__ */ new Map();
|
|
59
55
|
this._initScripts = [];
|
|
60
56
|
this._session = session;
|
|
61
57
|
this._opener = opener;
|
|
62
|
-
this.rawKeyboard = new
|
|
63
|
-
this.rawMouse = new
|
|
64
|
-
this.rawTouchscreen = new
|
|
65
|
-
this._contextIdToContext = new Map();
|
|
58
|
+
this.rawKeyboard = new import_ffInput.RawKeyboardImpl(session);
|
|
59
|
+
this.rawMouse = new import_ffInput.RawMouseImpl(session);
|
|
60
|
+
this.rawTouchscreen = new import_ffInput.RawTouchscreenImpl(session);
|
|
61
|
+
this._contextIdToContext = /* @__PURE__ */ new Map();
|
|
66
62
|
this._browserContext = browserContext;
|
|
67
|
-
this._page = new
|
|
63
|
+
this._page = new import_page2.Page(this, browserContext);
|
|
68
64
|
this.rawMouse.setPage(this._page);
|
|
69
|
-
this._networkManager = new
|
|
70
|
-
this._page.on(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
this.
|
|
65
|
+
this._networkManager = new import_ffNetworkManager.FFNetworkManager(session, this._page);
|
|
66
|
+
this._page.on(import_page2.Page.Events.FrameDetached, (frame) => this._removeContextsForFrame(frame));
|
|
67
|
+
this._eventListeners = [
|
|
68
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.eventFired", this._onEventFired.bind(this)),
|
|
69
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameAttached", this._onFrameAttached.bind(this)),
|
|
70
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.frameDetached", this._onFrameDetached.bind(this)),
|
|
71
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigationAborted", this._onNavigationAborted.bind(this)),
|
|
72
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigationCommitted", this._onNavigationCommitted.bind(this)),
|
|
73
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.navigationStarted", this._onNavigationStarted.bind(this)),
|
|
74
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.sameDocumentNavigation", this._onSameDocumentNavigation.bind(this)),
|
|
75
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextCreated", this._onExecutionContextCreated.bind(this)),
|
|
76
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextDestroyed", this._onExecutionContextDestroyed.bind(this)),
|
|
77
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.executionContextsCleared", this._onExecutionContextsCleared.bind(this)),
|
|
78
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.linkClicked", (event) => this._onLinkClicked(event.phase)),
|
|
79
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.uncaughtError", this._onUncaughtError.bind(this)),
|
|
80
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Runtime.console", this._onConsole.bind(this)),
|
|
81
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.dialogOpened", this._onDialogOpened.bind(this)),
|
|
82
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.bindingCalled", this._onBindingCalled.bind(this)),
|
|
83
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.fileChooserOpened", this._onFileChooserOpened.bind(this)),
|
|
84
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.workerCreated", this._onWorkerCreated.bind(this)),
|
|
85
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.workerDestroyed", this._onWorkerDestroyed.bind(this)),
|
|
86
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.dispatchMessageFromWorker", this._onDispatchMessageFromWorker.bind(this)),
|
|
87
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.crashed", this._onCrashed.bind(this)),
|
|
88
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.videoRecordingStarted", this._onVideoRecordingStarted.bind(this)),
|
|
89
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketCreated", this._onWebSocketCreated.bind(this)),
|
|
90
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketClosed", this._onWebSocketClosed.bind(this)),
|
|
91
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketFrameReceived", this._onWebSocketFrameReceived.bind(this)),
|
|
92
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.webSocketFrameSent", this._onWebSocketFrameSent.bind(this)),
|
|
93
|
+
import_eventsHelper.eventsHelper.addEventListener(this._session, "Page.screencastFrame", this._onScreencastFrame.bind(this))
|
|
94
|
+
];
|
|
95
|
+
this._session.once("Page.ready", () => {
|
|
96
|
+
if (this._reportedAsNew)
|
|
97
|
+
return;
|
|
98
|
+
this._reportedAsNew = true;
|
|
99
|
+
this._page.reportAsNew(this._opener?._page);
|
|
81
100
|
});
|
|
82
|
-
|
|
83
|
-
// Therefore, we can end up with an initialized page without utility world, although very unlikely.
|
|
84
|
-
this.addInitScript(new _page.InitScript('', true), UTILITY_WORLD_NAME).catch(e => this._markAsError(e));
|
|
85
|
-
}
|
|
86
|
-
potentiallyUninitializedPage() {
|
|
87
|
-
return this._page;
|
|
101
|
+
this.addInitScript(new import_page.InitScript("", true), UTILITY_WORLD_NAME).catch((e) => this._markAsError(e));
|
|
88
102
|
}
|
|
89
103
|
async _markAsError(error) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
await this._page.initOpener(this._opener);
|
|
95
|
-
this._page.reportAsNew(error);
|
|
96
|
-
this._pagePromise.resolve(error);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async pageOrError() {
|
|
100
|
-
return this._pagePromise;
|
|
104
|
+
if (this._reportedAsNew)
|
|
105
|
+
return;
|
|
106
|
+
this._reportedAsNew = true;
|
|
107
|
+
this._page.reportAsNew(this._opener?._page, error);
|
|
101
108
|
}
|
|
102
109
|
_onWebSocketCreated(event) {
|
|
103
110
|
this._page._frameManager.onWebSocketCreated(webSocketId(event.frameId, event.wsid), event.requestURL);
|
|
104
111
|
this._page._frameManager.onWebSocketRequest(webSocketId(event.frameId, event.wsid));
|
|
105
112
|
}
|
|
106
113
|
_onWebSocketClosed(event) {
|
|
107
|
-
if (event.error)
|
|
114
|
+
if (event.error)
|
|
115
|
+
this._page._frameManager.webSocketError(webSocketId(event.frameId, event.wsid), event.error);
|
|
108
116
|
this._page._frameManager.webSocketClosed(webSocketId(event.frameId, event.wsid));
|
|
109
117
|
}
|
|
110
118
|
_onWebSocketFrameReceived(event) {
|
|
@@ -114,41 +122,44 @@ class FFPage {
|
|
|
114
122
|
this._page._frameManager.onWebSocketFrameSent(webSocketId(event.frameId, event.wsid), event.opcode, event.data);
|
|
115
123
|
}
|
|
116
124
|
_onExecutionContextCreated(payload) {
|
|
117
|
-
const {
|
|
118
|
-
executionContextId,
|
|
119
|
-
auxData
|
|
120
|
-
} = payload;
|
|
125
|
+
const { executionContextId, auxData } = payload;
|
|
121
126
|
const frame = this._page._frameManager.frame(auxData.frameId);
|
|
122
|
-
if (!frame)
|
|
123
|
-
|
|
127
|
+
if (!frame)
|
|
128
|
+
return;
|
|
129
|
+
const delegate = new import_ffExecutionContext.FFExecutionContext(this._session, executionContextId);
|
|
124
130
|
let worldName = null;
|
|
125
|
-
if (auxData.name === UTILITY_WORLD_NAME)
|
|
131
|
+
if (auxData.name === UTILITY_WORLD_NAME)
|
|
132
|
+
worldName = "utility";
|
|
133
|
+
else if (!auxData.name)
|
|
134
|
+
worldName = "main";
|
|
126
135
|
const context = new dom.FrameExecutionContext(delegate, frame, worldName);
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
if (worldName)
|
|
137
|
+
frame._contextCreated(worldName, context);
|
|
129
138
|
this._contextIdToContext.set(executionContextId, context);
|
|
130
139
|
}
|
|
131
140
|
_onExecutionContextDestroyed(payload) {
|
|
132
|
-
const {
|
|
133
|
-
executionContextId
|
|
134
|
-
} = payload;
|
|
141
|
+
const { executionContextId } = payload;
|
|
135
142
|
const context = this._contextIdToContext.get(executionContextId);
|
|
136
|
-
if (!context)
|
|
143
|
+
if (!context)
|
|
144
|
+
return;
|
|
137
145
|
this._contextIdToContext.delete(executionContextId);
|
|
138
146
|
context.frame._contextDestroyed(context);
|
|
139
147
|
}
|
|
140
148
|
_onExecutionContextsCleared() {
|
|
141
|
-
for (const executionContextId of Array.from(this._contextIdToContext.keys()))
|
|
142
|
-
executionContextId
|
|
143
|
-
});
|
|
149
|
+
for (const executionContextId of Array.from(this._contextIdToContext.keys()))
|
|
150
|
+
this._onExecutionContextDestroyed({ executionContextId });
|
|
144
151
|
}
|
|
145
152
|
_removeContextsForFrame(frame) {
|
|
146
153
|
for (const [contextId, context] of this._contextIdToContext) {
|
|
147
|
-
if (context.frame === frame)
|
|
154
|
+
if (context.frame === frame)
|
|
155
|
+
this._contextIdToContext.delete(contextId);
|
|
148
156
|
}
|
|
149
157
|
}
|
|
150
158
|
_onLinkClicked(phase) {
|
|
151
|
-
if (phase ===
|
|
159
|
+
if (phase === "before")
|
|
160
|
+
this._page._frameManager.frameWillPotentiallyRequestNavigation();
|
|
161
|
+
else
|
|
162
|
+
this._page._frameManager.frameDidPotentiallyRequestNavigation();
|
|
152
163
|
}
|
|
153
164
|
_onNavigationStarted(params) {
|
|
154
165
|
this._page._frameManager.frameRequestedNavigation(params.frameId, params.navigationId);
|
|
@@ -158,11 +169,10 @@ class FFPage {
|
|
|
158
169
|
}
|
|
159
170
|
_onNavigationCommitted(params) {
|
|
160
171
|
for (const [workerId, worker] of this._workers) {
|
|
161
|
-
if (worker.frameId === params.frameId)
|
|
162
|
-
workerId
|
|
163
|
-
});
|
|
172
|
+
if (worker.frameId === params.frameId)
|
|
173
|
+
this._onWorkerDestroyed({ workerId });
|
|
164
174
|
}
|
|
165
|
-
this._page._frameManager.frameCommittedNewDocumentNavigation(params.frameId, params.url, params.name ||
|
|
175
|
+
this._page._frameManager.frameCommittedNewDocumentNavigation(params.frameId, params.url, params.name || "", params.navigationId || "", false);
|
|
166
176
|
}
|
|
167
177
|
_onSameDocumentNavigation(params) {
|
|
168
178
|
this._page._frameManager.frameCommittedSameDocumentNavigation(params.frameId, params.url);
|
|
@@ -174,111 +184,89 @@ class FFPage {
|
|
|
174
184
|
this._page._frameManager.frameDetached(params.frameId);
|
|
175
185
|
}
|
|
176
186
|
_onEventFired(payload) {
|
|
177
|
-
const {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (name === 'DOMContentLoaded') this._page._frameManager.frameLifecycleEvent(frameId, 'domcontentloaded');
|
|
187
|
+
const { frameId, name } = payload;
|
|
188
|
+
if (name === "load")
|
|
189
|
+
this._page._frameManager.frameLifecycleEvent(frameId, "load");
|
|
190
|
+
if (name === "DOMContentLoaded")
|
|
191
|
+
this._page._frameManager.frameLifecycleEvent(frameId, "domcontentloaded");
|
|
183
192
|
}
|
|
184
193
|
_onUncaughtError(params) {
|
|
185
|
-
const {
|
|
186
|
-
name,
|
|
187
|
-
message
|
|
188
|
-
} = (0, _stackTrace.splitErrorMessage)(params.message);
|
|
194
|
+
const { name, message } = (0, import_stackTrace.splitErrorMessage)(params.message);
|
|
189
195
|
const error = new Error(message);
|
|
190
|
-
error.stack = params.message +
|
|
196
|
+
error.stack = params.message + "\n" + params.stack.split("\n").filter(Boolean).map((a) => a.replace(/([^@]*)@(.*)/, " at $1 ($2)")).join("\n");
|
|
191
197
|
error.name = name;
|
|
192
|
-
this._page.emitOnContextOnceInitialized(
|
|
198
|
+
this._page.emitOnContextOnceInitialized(import_browserContext.BrowserContext.Events.PageError, error, this._page);
|
|
193
199
|
}
|
|
194
200
|
_onConsole(payload) {
|
|
195
|
-
const {
|
|
196
|
-
type,
|
|
197
|
-
args,
|
|
198
|
-
executionContextId,
|
|
199
|
-
location
|
|
200
|
-
} = payload;
|
|
201
|
+
const { type, args, executionContextId, location } = payload;
|
|
201
202
|
const context = this._contextIdToContext.get(executionContextId);
|
|
202
|
-
if (!context)
|
|
203
|
-
|
|
204
|
-
this._page._addConsoleMessage(type ===
|
|
203
|
+
if (!context)
|
|
204
|
+
return;
|
|
205
|
+
this._page._addConsoleMessage(type === "warn" ? "warning" : type, args.map((arg) => (0, import_ffExecutionContext.createHandle)(context, arg)), location);
|
|
205
206
|
}
|
|
206
207
|
_onDialogOpened(params) {
|
|
207
|
-
this._page.emitOnContext(
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
208
|
+
this._page.emitOnContext(import_browserContext.BrowserContext.Events.Dialog, new dialog.Dialog(
|
|
209
|
+
this._page,
|
|
210
|
+
params.type,
|
|
211
|
+
params.message,
|
|
212
|
+
async (accept, promptText) => {
|
|
213
|
+
await this._session.sendMayFail("Page.handleDialog", { dialogId: params.dialogId, accept, promptText });
|
|
214
|
+
},
|
|
215
|
+
params.defaultValue
|
|
216
|
+
));
|
|
214
217
|
}
|
|
215
218
|
async _onBindingCalled(event) {
|
|
216
|
-
const pageOrError = await this.
|
|
219
|
+
const pageOrError = await this._page.waitForInitializedOrError();
|
|
217
220
|
if (!(pageOrError instanceof Error)) {
|
|
218
221
|
const context = this._contextIdToContext.get(event.executionContextId);
|
|
219
|
-
if (context)
|
|
222
|
+
if (context)
|
|
223
|
+
await this._page._onBindingCalled(event.payload, context);
|
|
220
224
|
}
|
|
221
225
|
}
|
|
222
226
|
async _onFileChooserOpened(payload) {
|
|
223
|
-
const {
|
|
224
|
-
executionContextId,
|
|
225
|
-
element
|
|
226
|
-
} = payload;
|
|
227
|
+
const { executionContextId, element } = payload;
|
|
227
228
|
const context = this._contextIdToContext.get(executionContextId);
|
|
228
|
-
if (!context)
|
|
229
|
-
|
|
229
|
+
if (!context)
|
|
230
|
+
return;
|
|
231
|
+
const handle = (0, import_ffExecutionContext.createHandle)(context, element).asElement();
|
|
230
232
|
await this._page._onFileChooserOpened(handle);
|
|
231
233
|
}
|
|
232
234
|
async _onWorkerCreated(event) {
|
|
233
235
|
const workerId = event.workerId;
|
|
234
|
-
const worker = new
|
|
235
|
-
const workerSession = new
|
|
236
|
-
this._session.send(
|
|
236
|
+
const worker = new import_page2.Worker(this._page, event.url);
|
|
237
|
+
const workerSession = new import_ffConnection.FFSession(this._session._connection, workerId, (message) => {
|
|
238
|
+
this._session.send("Page.sendMessageToWorker", {
|
|
237
239
|
frameId: event.frameId,
|
|
238
|
-
workerId
|
|
240
|
+
workerId,
|
|
239
241
|
message: JSON.stringify(message)
|
|
240
|
-
}).catch(e => {
|
|
241
|
-
workerSession.dispatchMessage({
|
|
242
|
-
id: message.id,
|
|
243
|
-
method: '',
|
|
244
|
-
params: {},
|
|
245
|
-
error: {
|
|
246
|
-
message: e.message,
|
|
247
|
-
data: undefined
|
|
248
|
-
}
|
|
249
|
-
});
|
|
242
|
+
}).catch((e) => {
|
|
243
|
+
workerSession.dispatchMessage({ id: message.id, method: "", params: {}, error: { message: e.message, data: void 0 } });
|
|
250
244
|
});
|
|
251
245
|
});
|
|
252
|
-
this._workers.set(workerId, {
|
|
253
|
-
session: workerSession,
|
|
254
|
-
frameId: event.frameId
|
|
255
|
-
});
|
|
246
|
+
this._workers.set(workerId, { session: workerSession, frameId: event.frameId });
|
|
256
247
|
this._page._addWorker(workerId, worker);
|
|
257
|
-
workerSession.once(
|
|
258
|
-
worker._createExecutionContext(new
|
|
248
|
+
workerSession.once("Runtime.executionContextCreated", (event2) => {
|
|
249
|
+
worker._createExecutionContext(new import_ffExecutionContext.FFExecutionContext(workerSession, event2.executionContextId));
|
|
259
250
|
});
|
|
260
|
-
workerSession.on(
|
|
261
|
-
const {
|
|
262
|
-
type,
|
|
263
|
-
args,
|
|
264
|
-
location
|
|
265
|
-
} = event;
|
|
251
|
+
workerSession.on("Runtime.console", (event2) => {
|
|
252
|
+
const { type, args, location } = event2;
|
|
266
253
|
const context = worker._existingExecutionContext;
|
|
267
|
-
this._page._addConsoleMessage(type, args.map(arg =>
|
|
254
|
+
this._page._addConsoleMessage(type, args.map((arg) => (0, import_ffExecutionContext.createHandle)(context, arg)), location);
|
|
268
255
|
});
|
|
269
|
-
// Note: we receive worker exceptions directly from the page.
|
|
270
256
|
}
|
|
271
257
|
_onWorkerDestroyed(event) {
|
|
272
258
|
const workerId = event.workerId;
|
|
273
259
|
const worker = this._workers.get(workerId);
|
|
274
|
-
if (!worker)
|
|
260
|
+
if (!worker)
|
|
261
|
+
return;
|
|
275
262
|
worker.session.dispose();
|
|
276
263
|
this._workers.delete(workerId);
|
|
277
264
|
this._page._removeWorker(workerId);
|
|
278
265
|
}
|
|
279
266
|
async _onDispatchMessageFromWorker(event) {
|
|
280
267
|
const worker = this._workers.get(event.workerId);
|
|
281
|
-
if (!worker)
|
|
268
|
+
if (!worker)
|
|
269
|
+
return;
|
|
282
270
|
worker.session.dispatchMessage(JSON.parse(event.message));
|
|
283
271
|
}
|
|
284
272
|
async _onCrashed(event) {
|
|
@@ -286,50 +274,42 @@ class FFPage {
|
|
|
286
274
|
this._page._didCrash();
|
|
287
275
|
}
|
|
288
276
|
_onVideoRecordingStarted(event) {
|
|
289
|
-
this._browserContext._browser._videoStarted(this._browserContext, event.screencastId, event.file, this.
|
|
277
|
+
this._browserContext._browser._videoStarted(this._browserContext, event.screencastId, event.file, this._page.waitForInitializedOrError());
|
|
290
278
|
}
|
|
291
279
|
didClose() {
|
|
292
|
-
this._markAsError(new
|
|
280
|
+
this._markAsError(new import_errors.TargetClosedError());
|
|
293
281
|
this._session.dispose();
|
|
294
|
-
|
|
282
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
|
295
283
|
this._networkManager.dispose();
|
|
296
284
|
this._page._didClose();
|
|
297
285
|
}
|
|
298
286
|
async navigateFrame(frame, url, referer) {
|
|
299
|
-
const response = await this._session.send(
|
|
300
|
-
|
|
301
|
-
referer,
|
|
302
|
-
frameId: frame._id
|
|
303
|
-
});
|
|
304
|
-
return {
|
|
305
|
-
newDocumentId: response.navigationId || undefined
|
|
306
|
-
};
|
|
287
|
+
const response = await this._session.send("Page.navigate", { url, referer, frameId: frame._id });
|
|
288
|
+
return { newDocumentId: response.navigationId || void 0 };
|
|
307
289
|
}
|
|
308
290
|
async updateExtraHTTPHeaders() {
|
|
309
|
-
await this._session.send(
|
|
310
|
-
headers: this._page.extraHTTPHeaders() || []
|
|
311
|
-
});
|
|
291
|
+
await this._session.send("Network.setExtraHTTPHeaders", { headers: this._page.extraHTTPHeaders() || [] });
|
|
312
292
|
}
|
|
313
293
|
async updateEmulatedViewportSize() {
|
|
314
294
|
const viewportSize = this._page.viewportSize();
|
|
315
|
-
await this._session.send(
|
|
316
|
-
viewportSize
|
|
317
|
-
});
|
|
295
|
+
await this._session.send("Page.setViewportSize", { viewportSize });
|
|
318
296
|
}
|
|
319
297
|
async bringToFront() {
|
|
320
|
-
await this._session.send(
|
|
298
|
+
await this._session.send("Page.bringToFront", {});
|
|
321
299
|
}
|
|
322
300
|
async updateEmulateMedia() {
|
|
323
301
|
const emulatedMedia = this._page.emulatedMedia();
|
|
324
|
-
const colorScheme = emulatedMedia.colorScheme ===
|
|
325
|
-
const reducedMotion = emulatedMedia.reducedMotion ===
|
|
326
|
-
const forcedColors = emulatedMedia.forcedColors ===
|
|
327
|
-
|
|
302
|
+
const colorScheme = emulatedMedia.colorScheme === "no-override" ? void 0 : emulatedMedia.colorScheme;
|
|
303
|
+
const reducedMotion = emulatedMedia.reducedMotion === "no-override" ? void 0 : emulatedMedia.reducedMotion;
|
|
304
|
+
const forcedColors = emulatedMedia.forcedColors === "no-override" ? void 0 : emulatedMedia.forcedColors;
|
|
305
|
+
const contrast = emulatedMedia.contrast === "no-override" ? void 0 : emulatedMedia.contrast;
|
|
306
|
+
await this._session.send("Page.setEmulatedMedia", {
|
|
328
307
|
// Empty string means reset.
|
|
329
|
-
type: emulatedMedia.media ===
|
|
308
|
+
type: emulatedMedia.media === "no-override" ? "" : emulatedMedia.media,
|
|
330
309
|
colorScheme,
|
|
331
310
|
reducedMotion,
|
|
332
|
-
forcedColors
|
|
311
|
+
forcedColors,
|
|
312
|
+
contrast
|
|
333
313
|
});
|
|
334
314
|
}
|
|
335
315
|
async updateRequestInterception() {
|
|
@@ -337,67 +317,41 @@ class FFPage {
|
|
|
337
317
|
}
|
|
338
318
|
async updateFileChooserInterception() {
|
|
339
319
|
const enabled = this._page.fileChooserIntercepted();
|
|
340
|
-
await this._session.send(
|
|
341
|
-
|
|
342
|
-
}).catch(() => {}); // target can be closed.
|
|
320
|
+
await this._session.send("Page.setInterceptFileChooserDialog", { enabled }).catch(() => {
|
|
321
|
+
});
|
|
343
322
|
}
|
|
344
323
|
async reload() {
|
|
345
|
-
await this._session.send(
|
|
324
|
+
await this._session.send("Page.reload");
|
|
346
325
|
}
|
|
347
326
|
async goBack() {
|
|
348
|
-
const {
|
|
349
|
-
success
|
|
350
|
-
} = await this._session.send('Page.goBack', {
|
|
351
|
-
frameId: this._page.mainFrame()._id
|
|
352
|
-
});
|
|
327
|
+
const { success } = await this._session.send("Page.goBack", { frameId: this._page.mainFrame()._id });
|
|
353
328
|
return success;
|
|
354
329
|
}
|
|
355
330
|
async goForward() {
|
|
356
|
-
const {
|
|
357
|
-
success
|
|
358
|
-
} = await this._session.send('Page.goForward', {
|
|
359
|
-
frameId: this._page.mainFrame()._id
|
|
360
|
-
});
|
|
331
|
+
const { success } = await this._session.send("Page.goForward", { frameId: this._page.mainFrame()._id });
|
|
361
332
|
return success;
|
|
362
333
|
}
|
|
363
334
|
async requestGC() {
|
|
364
|
-
await this._session.send(
|
|
335
|
+
await this._session.send("Heap.collectGarbage");
|
|
365
336
|
}
|
|
366
337
|
async addInitScript(initScript, worldName) {
|
|
367
|
-
this._initScripts.push({
|
|
368
|
-
|
|
369
|
-
worldName
|
|
370
|
-
});
|
|
371
|
-
await this._session.send('Page.setInitScripts', {
|
|
372
|
-
scripts: this._initScripts.map(s => ({
|
|
373
|
-
script: s.initScript.source,
|
|
374
|
-
worldName: s.worldName
|
|
375
|
-
}))
|
|
376
|
-
});
|
|
338
|
+
this._initScripts.push({ initScript, worldName });
|
|
339
|
+
await this._session.send("Page.setInitScripts", { scripts: this._initScripts.map((s) => ({ script: s.initScript.source, worldName: s.worldName })) });
|
|
377
340
|
}
|
|
378
341
|
async removeNonInternalInitScripts() {
|
|
379
|
-
this._initScripts = this._initScripts.filter(s => s.initScript.internal);
|
|
380
|
-
await this._session.send(
|
|
381
|
-
scripts: this._initScripts.map(s => ({
|
|
382
|
-
script: s.initScript.source,
|
|
383
|
-
worldName: s.worldName
|
|
384
|
-
}))
|
|
385
|
-
});
|
|
342
|
+
this._initScripts = this._initScripts.filter((s) => s.initScript.internal);
|
|
343
|
+
await this._session.send("Page.setInitScripts", { scripts: this._initScripts.map((s) => ({ script: s.initScript.source, worldName: s.worldName })) });
|
|
386
344
|
}
|
|
387
345
|
async closePage(runBeforeUnload) {
|
|
388
|
-
await this._session.send(
|
|
389
|
-
runBeforeUnload
|
|
390
|
-
});
|
|
346
|
+
await this._session.send("Page.close", { runBeforeUnload });
|
|
391
347
|
}
|
|
392
348
|
async setBackgroundColor(color) {
|
|
393
|
-
if (color)
|
|
349
|
+
if (color)
|
|
350
|
+
throw new Error("Not implemented");
|
|
394
351
|
}
|
|
395
352
|
async takeScreenshot(progress, format, documentRect, viewportRect, quality, fitsViewport, scale) {
|
|
396
353
|
if (!documentRect) {
|
|
397
|
-
const scrollOffset = await this._page.mainFrame().waitForFunctionValueInUtility(progress, () => ({
|
|
398
|
-
x: window.scrollX,
|
|
399
|
-
y: window.scrollY
|
|
400
|
-
}));
|
|
354
|
+
const scrollOffset = await this._page.mainFrame().waitForFunctionValueInUtility(progress, () => ({ x: window.scrollX, y: window.scrollY }));
|
|
401
355
|
documentRect = {
|
|
402
356
|
x: viewportRect.x + scrollOffset.x,
|
|
403
357
|
y: viewportRect.y + scrollOffset.y,
|
|
@@ -406,41 +360,34 @@ class FFPage {
|
|
|
406
360
|
};
|
|
407
361
|
}
|
|
408
362
|
progress.throwIfAborted();
|
|
409
|
-
const {
|
|
410
|
-
|
|
411
|
-
} = await this._session.send('Page.screenshot', {
|
|
412
|
-
mimeType: 'image/' + format,
|
|
363
|
+
const { data } = await this._session.send("Page.screenshot", {
|
|
364
|
+
mimeType: "image/" + format,
|
|
413
365
|
clip: documentRect,
|
|
414
366
|
quality,
|
|
415
|
-
omitDeviceScaleFactor: scale ===
|
|
367
|
+
omitDeviceScaleFactor: scale === "css"
|
|
416
368
|
});
|
|
417
|
-
return Buffer.from(data,
|
|
369
|
+
return Buffer.from(data, "base64");
|
|
418
370
|
}
|
|
419
371
|
async getContentFrame(handle) {
|
|
420
|
-
const {
|
|
421
|
-
contentFrameId
|
|
422
|
-
} = await this._session.send('Page.describeNode', {
|
|
372
|
+
const { contentFrameId } = await this._session.send("Page.describeNode", {
|
|
423
373
|
frameId: handle._context.frame._id,
|
|
424
374
|
objectId: handle._objectId
|
|
425
375
|
});
|
|
426
|
-
if (!contentFrameId)
|
|
376
|
+
if (!contentFrameId)
|
|
377
|
+
return null;
|
|
427
378
|
return this._page._frameManager.frame(contentFrameId);
|
|
428
379
|
}
|
|
429
380
|
async getOwnerFrame(handle) {
|
|
430
|
-
const {
|
|
431
|
-
ownerFrameId
|
|
432
|
-
} = await this._session.send('Page.describeNode', {
|
|
381
|
+
const { ownerFrameId } = await this._session.send("Page.describeNode", {
|
|
433
382
|
frameId: handle._context.frame._id,
|
|
434
383
|
objectId: handle._objectId
|
|
435
384
|
});
|
|
436
385
|
return ownerFrameId || null;
|
|
437
386
|
}
|
|
438
|
-
isElementHandle(remoteObject) {
|
|
439
|
-
return remoteObject.subtype === 'node';
|
|
440
|
-
}
|
|
441
387
|
async getBoundingBox(handle) {
|
|
442
388
|
const quads = await this.getContentQuads(handle);
|
|
443
|
-
if (!quads || !quads.length)
|
|
389
|
+
if (!quads || !quads.length)
|
|
390
|
+
return null;
|
|
444
391
|
let minX = Infinity;
|
|
445
392
|
let maxX = -Infinity;
|
|
446
393
|
let minY = Infinity;
|
|
@@ -453,44 +400,38 @@ class FFPage {
|
|
|
453
400
|
maxY = Math.max(maxY, point.y);
|
|
454
401
|
}
|
|
455
402
|
}
|
|
456
|
-
return {
|
|
457
|
-
x: minX,
|
|
458
|
-
y: minY,
|
|
459
|
-
width: maxX - minX,
|
|
460
|
-
height: maxY - minY
|
|
461
|
-
};
|
|
403
|
+
return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };
|
|
462
404
|
}
|
|
463
405
|
async scrollRectIntoViewIfNeeded(handle, rect) {
|
|
464
|
-
return await this._session.send(
|
|
406
|
+
return await this._session.send("Page.scrollIntoViewIfNeeded", {
|
|
465
407
|
frameId: handle._context.frame._id,
|
|
466
408
|
objectId: handle._objectId,
|
|
467
409
|
rect
|
|
468
|
-
}).then(() =>
|
|
469
|
-
if (e instanceof Error && e.message.includes(
|
|
470
|
-
|
|
410
|
+
}).then(() => "done").catch((e) => {
|
|
411
|
+
if (e instanceof Error && e.message.includes("Node is detached from document"))
|
|
412
|
+
return "error:notconnected";
|
|
413
|
+
if (e instanceof Error && e.message.includes("Node does not have a layout object"))
|
|
414
|
+
return "error:notvisible";
|
|
471
415
|
throw e;
|
|
472
416
|
});
|
|
473
417
|
}
|
|
474
418
|
async setScreencastOptions(options) {
|
|
475
419
|
if (options) {
|
|
476
|
-
const {
|
|
477
|
-
screencastId
|
|
478
|
-
} = await this._session.send('Page.startScreencast', options);
|
|
420
|
+
const { screencastId } = await this._session.send("Page.startScreencast", options);
|
|
479
421
|
this._screencastId = screencastId;
|
|
480
422
|
} else {
|
|
481
|
-
await this._session.send(
|
|
423
|
+
await this._session.send("Page.stopScreencast");
|
|
482
424
|
}
|
|
483
425
|
}
|
|
484
426
|
_onScreencastFrame(event) {
|
|
485
|
-
if (!this._screencastId)
|
|
427
|
+
if (!this._screencastId)
|
|
428
|
+
return;
|
|
486
429
|
const screencastId = this._screencastId;
|
|
487
430
|
this._page.throttleScreencastFrameAck(() => {
|
|
488
|
-
this._session.send(
|
|
489
|
-
screencastId
|
|
490
|
-
}).catch(e => _debugLogger.debugLogger.log('error', e));
|
|
431
|
+
this._session.send("Page.screencastFrameAck", { screencastId }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
491
432
|
});
|
|
492
|
-
const buffer = Buffer.from(event.data,
|
|
493
|
-
this._page.emit(
|
|
433
|
+
const buffer = Buffer.from(event.data, "base64");
|
|
434
|
+
this._page.emit(import_page2.Page.Events.ScreencastFrame, {
|
|
494
435
|
buffer,
|
|
495
436
|
width: event.deviceWidth,
|
|
496
437
|
height: event.deviceHeight
|
|
@@ -500,60 +441,61 @@ class FFPage {
|
|
|
500
441
|
return 1;
|
|
501
442
|
}
|
|
502
443
|
async getContentQuads(handle) {
|
|
503
|
-
const result = await this._session.sendMayFail(
|
|
444
|
+
const result = await this._session.sendMayFail("Page.getContentQuads", {
|
|
504
445
|
frameId: handle._context.frame._id,
|
|
505
446
|
objectId: handle._objectId
|
|
506
447
|
});
|
|
507
|
-
if (!result)
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
async setInputFiles(handle, files) {
|
|
511
|
-
await handle.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), files);
|
|
448
|
+
if (!result)
|
|
449
|
+
return null;
|
|
450
|
+
return result.quads.map((quad) => [quad.p1, quad.p2, quad.p3, quad.p4]);
|
|
512
451
|
}
|
|
513
452
|
async setInputFilePaths(handle, files) {
|
|
514
|
-
await this._session.send(
|
|
453
|
+
await this._session.send("Page.setFileInputFiles", {
|
|
515
454
|
frameId: handle._context.frame._id,
|
|
516
455
|
objectId: handle._objectId,
|
|
517
456
|
files
|
|
518
457
|
});
|
|
519
458
|
}
|
|
520
459
|
async adoptElementHandle(handle, to) {
|
|
521
|
-
const result = await this._session.send(
|
|
460
|
+
const result = await this._session.send("Page.adoptNode", {
|
|
522
461
|
frameId: handle._context.frame._id,
|
|
523
462
|
objectId: handle._objectId,
|
|
524
|
-
executionContextId: to
|
|
463
|
+
executionContextId: to.delegate._executionContextId
|
|
525
464
|
});
|
|
526
|
-
if (!result.remoteObject)
|
|
527
|
-
|
|
465
|
+
if (!result.remoteObject)
|
|
466
|
+
throw new Error(dom.kUnableToAdoptErrorMessage);
|
|
467
|
+
return (0, import_ffExecutionContext.createHandle)(to, result.remoteObject);
|
|
528
468
|
}
|
|
529
469
|
async getAccessibilityTree(needle) {
|
|
530
|
-
return (0,
|
|
470
|
+
return (0, import_ffAccessibility.getAccessibilityTree)(this._session, needle);
|
|
471
|
+
}
|
|
472
|
+
async inputActionEpilogue() {
|
|
531
473
|
}
|
|
532
|
-
async inputActionEpilogue() {}
|
|
533
474
|
async resetForReuse() {
|
|
534
|
-
|
|
535
|
-
// which affects things like hovered state.
|
|
536
|
-
// See https://github.com/microsoft/playwright/issues/22432.
|
|
537
|
-
// Move mouse to (-1, -1) to avoid anything being hovered.
|
|
538
|
-
await this.rawMouse.move(-1, -1, 'none', new Set(), new Set(), false);
|
|
475
|
+
await this.rawMouse.move(-1, -1, "none", /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), false);
|
|
539
476
|
}
|
|
540
477
|
async getFrameElement(frame) {
|
|
541
478
|
const parent = frame.parentFrame();
|
|
542
|
-
if (!parent)
|
|
479
|
+
if (!parent)
|
|
480
|
+
throw new Error("Frame has been detached.");
|
|
543
481
|
const context = await parent._mainContext();
|
|
544
|
-
const result = await this._session.send(
|
|
482
|
+
const result = await this._session.send("Page.adoptNode", {
|
|
545
483
|
frameId: frame._id,
|
|
546
|
-
executionContextId: context
|
|
484
|
+
executionContextId: context.delegate._executionContextId
|
|
547
485
|
});
|
|
548
|
-
if (!result.remoteObject)
|
|
549
|
-
|
|
486
|
+
if (!result.remoteObject)
|
|
487
|
+
throw new Error("Frame has been detached.");
|
|
488
|
+
return (0, import_ffExecutionContext.createHandle)(context, result.remoteObject);
|
|
550
489
|
}
|
|
551
490
|
shouldToggleStyleSheetToSyncAnimations() {
|
|
552
491
|
return false;
|
|
553
492
|
}
|
|
554
493
|
}
|
|
555
|
-
exports.FFPage = FFPage;
|
|
556
494
|
function webSocketId(frameId, wsid) {
|
|
557
495
|
return `${frameId}---${wsid}`;
|
|
558
496
|
}
|
|
559
|
-
|
|
497
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
498
|
+
0 && (module.exports = {
|
|
499
|
+
FFPage,
|
|
500
|
+
UTILITY_WORLD_NAME
|
|
501
|
+
});
|