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
package/lib/client/page.js
CHANGED
|
@@ -1,178 +1,161 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var page_exports = {};
|
|
20
|
+
__export(page_exports, {
|
|
21
|
+
BindingCall: () => BindingCall,
|
|
22
|
+
Page: () => Page
|
|
5
23
|
});
|
|
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
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
35
|
-
* you may not use this file except in compliance with the License.
|
|
36
|
-
* You may obtain a copy of the License at
|
|
37
|
-
*
|
|
38
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
39
|
-
*
|
|
40
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
41
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
42
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
43
|
-
* See the License for the specific language governing permissions and
|
|
44
|
-
* limitations under the License.
|
|
45
|
-
*/
|
|
46
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
47
|
-
_Symbol$asyncDispose = Symbol.asyncDispose;
|
|
48
|
-
class Page extends _channelOwner.ChannelOwner {
|
|
49
|
-
static from(page) {
|
|
50
|
-
return page._object;
|
|
51
|
-
}
|
|
52
|
-
static fromNullable(page) {
|
|
53
|
-
return page ? Page.from(page) : null;
|
|
54
|
-
}
|
|
24
|
+
module.exports = __toCommonJS(page_exports);
|
|
25
|
+
var import_accessibility = require("./accessibility");
|
|
26
|
+
var import_artifact = require("./artifact");
|
|
27
|
+
var import_channelOwner = require("./channelOwner");
|
|
28
|
+
var import_clientHelper = require("./clientHelper");
|
|
29
|
+
var import_coverage = require("./coverage");
|
|
30
|
+
var import_download = require("./download");
|
|
31
|
+
var import_elementHandle = require("./elementHandle");
|
|
32
|
+
var import_errors = require("./errors");
|
|
33
|
+
var import_events = require("./events");
|
|
34
|
+
var import_fileChooser = require("./fileChooser");
|
|
35
|
+
var import_frame = require("./frame");
|
|
36
|
+
var import_harRouter = require("./harRouter");
|
|
37
|
+
var import_input = require("./input");
|
|
38
|
+
var import_jsHandle = require("./jsHandle");
|
|
39
|
+
var import_network = require("./network");
|
|
40
|
+
var import_video = require("./video");
|
|
41
|
+
var import_waiter = require("./waiter");
|
|
42
|
+
var import_worker = require("./worker");
|
|
43
|
+
var import_timeoutSettings = require("./timeoutSettings");
|
|
44
|
+
var import_assert = require("../utils/isomorphic/assert");
|
|
45
|
+
var import_fileUtils = require("./fileUtils");
|
|
46
|
+
var import_headers = require("../utils/isomorphic/headers");
|
|
47
|
+
var import_stringUtils = require("../utils/isomorphic/stringUtils");
|
|
48
|
+
var import_urlMatch = require("../utils/isomorphic/urlMatch");
|
|
49
|
+
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
50
|
+
var import_rtti = require("../utils/isomorphic/rtti");
|
|
51
|
+
class Page extends import_channelOwner.ChannelOwner {
|
|
55
52
|
constructor(parent, type, guid, initializer) {
|
|
56
53
|
super(parent, type, guid, initializer);
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this._mainFrame = void 0;
|
|
60
|
-
this._frames = new Set();
|
|
61
|
-
this._workers = new Set();
|
|
54
|
+
this._frames = /* @__PURE__ */ new Set();
|
|
55
|
+
this._workers = /* @__PURE__ */ new Set();
|
|
62
56
|
this._closed = false;
|
|
63
|
-
this._closedOrCrashedScope = new
|
|
64
|
-
this._viewportSize = void 0;
|
|
57
|
+
this._closedOrCrashedScope = new import_manualPromise.LongStandingScope();
|
|
65
58
|
this._routes = [];
|
|
66
59
|
this._webSocketRoutes = [];
|
|
67
|
-
this.
|
|
68
|
-
this.coverage = void 0;
|
|
69
|
-
this.keyboard = void 0;
|
|
70
|
-
this.mouse = void 0;
|
|
71
|
-
this.request = void 0;
|
|
72
|
-
this.touchscreen = void 0;
|
|
73
|
-
this.clock = void 0;
|
|
74
|
-
this._bindings = new Map();
|
|
75
|
-
this._timeoutSettings = void 0;
|
|
60
|
+
this._bindings = /* @__PURE__ */ new Map();
|
|
76
61
|
this._video = null;
|
|
77
|
-
this._opener = void 0;
|
|
78
|
-
this._closeReason = void 0;
|
|
79
62
|
this._closeWasCalled = false;
|
|
80
63
|
this._harRouters = [];
|
|
81
|
-
this._locatorHandlers = new Map();
|
|
64
|
+
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
82
65
|
this._browserContext = parent;
|
|
83
|
-
this._timeoutSettings = new
|
|
84
|
-
this.accessibility = new
|
|
85
|
-
this.keyboard = new
|
|
86
|
-
this.mouse = new
|
|
66
|
+
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform, this._browserContext._timeoutSettings);
|
|
67
|
+
this.accessibility = new import_accessibility.Accessibility(this._channel);
|
|
68
|
+
this.keyboard = new import_input.Keyboard(this);
|
|
69
|
+
this.mouse = new import_input.Mouse(this);
|
|
87
70
|
this.request = this._browserContext.request;
|
|
88
|
-
this.touchscreen = new
|
|
71
|
+
this.touchscreen = new import_input.Touchscreen(this);
|
|
89
72
|
this.clock = this._browserContext.clock;
|
|
90
|
-
this._mainFrame =
|
|
73
|
+
this._mainFrame = import_frame.Frame.from(initializer.mainFrame);
|
|
91
74
|
this._mainFrame._page = this;
|
|
92
75
|
this._frames.add(this._mainFrame);
|
|
93
76
|
this._viewportSize = initializer.viewportSize || null;
|
|
94
77
|
this._closed = initializer.isClosed;
|
|
95
78
|
this._opener = Page.fromNullable(initializer.opener);
|
|
96
|
-
this._channel.on(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this._channel.on(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
url,
|
|
103
|
-
suggestedFilename,
|
|
104
|
-
artifact
|
|
105
|
-
}) => {
|
|
106
|
-
const artifactObject = _artifact.Artifact.from(artifact);
|
|
107
|
-
this.emit(_events.Events.Page.Download, new _download.Download(this, url, suggestedFilename, artifactObject));
|
|
79
|
+
this._channel.on("bindingCall", ({ binding }) => this._onBinding(BindingCall.from(binding)));
|
|
80
|
+
this._channel.on("close", () => this._onClose());
|
|
81
|
+
this._channel.on("crash", () => this._onCrash());
|
|
82
|
+
this._channel.on("download", ({ url, suggestedFilename, artifact }) => {
|
|
83
|
+
const artifactObject = import_artifact.Artifact.from(artifact);
|
|
84
|
+
this.emit(import_events.Events.Page.Download, new import_download.Download(this, url, suggestedFilename, artifactObject));
|
|
108
85
|
});
|
|
109
|
-
this._channel.on(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this._channel.on(
|
|
114
|
-
|
|
115
|
-
}) =>
|
|
116
|
-
|
|
117
|
-
frame
|
|
118
|
-
}) => this._onFrameDetached(_frame.Frame.from(frame)));
|
|
119
|
-
this._channel.on('locatorHandlerTriggered', ({
|
|
120
|
-
uid
|
|
121
|
-
}) => this._onLocatorHandlerTriggered(uid));
|
|
122
|
-
this._channel.on('route', ({
|
|
123
|
-
route
|
|
124
|
-
}) => this._onRoute(_network.Route.from(route)));
|
|
125
|
-
this._channel.on('webSocketRoute', ({
|
|
126
|
-
webSocketRoute
|
|
127
|
-
}) => this._onWebSocketRoute(_network.WebSocketRoute.from(webSocketRoute)));
|
|
128
|
-
this._channel.on('video', ({
|
|
129
|
-
artifact
|
|
130
|
-
}) => {
|
|
131
|
-
const artifactObject = _artifact.Artifact.from(artifact);
|
|
86
|
+
this._channel.on("fileChooser", ({ element, isMultiple }) => this.emit(import_events.Events.Page.FileChooser, new import_fileChooser.FileChooser(this, import_elementHandle.ElementHandle.from(element), isMultiple)));
|
|
87
|
+
this._channel.on("frameAttached", ({ frame }) => this._onFrameAttached(import_frame.Frame.from(frame)));
|
|
88
|
+
this._channel.on("frameDetached", ({ frame }) => this._onFrameDetached(import_frame.Frame.from(frame)));
|
|
89
|
+
this._channel.on("locatorHandlerTriggered", ({ uid }) => this._onLocatorHandlerTriggered(uid));
|
|
90
|
+
this._channel.on("route", ({ route }) => this._onRoute(import_network.Route.from(route)));
|
|
91
|
+
this._channel.on("webSocketRoute", ({ webSocketRoute }) => this._onWebSocketRoute(import_network.WebSocketRoute.from(webSocketRoute)));
|
|
92
|
+
this._channel.on("video", ({ artifact }) => {
|
|
93
|
+
const artifactObject = import_artifact.Artifact.from(artifact);
|
|
132
94
|
this._forceVideo()._artifactReady(artifactObject);
|
|
133
95
|
});
|
|
134
|
-
this._channel.on(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
96
|
+
this._channel.on("webSocket", ({ webSocket }) => this.emit(import_events.Events.Page.WebSocket, import_network.WebSocket.from(webSocket)));
|
|
97
|
+
this._channel.on("worker", ({ worker }) => this._onWorker(import_worker.Worker.from(worker)));
|
|
98
|
+
this.coverage = new import_coverage.Coverage(this._channel);
|
|
99
|
+
this.once(import_events.Events.Page.Close, () => this._closedOrCrashedScope.close(this._closeErrorWithReason()));
|
|
100
|
+
this.once(import_events.Events.Page.Crash, () => this._closedOrCrashedScope.close(new import_errors.TargetClosedError()));
|
|
101
|
+
this._setEventToSubscriptionMapping(/* @__PURE__ */ new Map([
|
|
102
|
+
[import_events.Events.Page.Console, "console"],
|
|
103
|
+
[import_events.Events.Page.Dialog, "dialog"],
|
|
104
|
+
[import_events.Events.Page.Request, "request"],
|
|
105
|
+
[import_events.Events.Page.Response, "response"],
|
|
106
|
+
[import_events.Events.Page.RequestFinished, "requestFinished"],
|
|
107
|
+
[import_events.Events.Page.RequestFailed, "requestFailed"],
|
|
108
|
+
[import_events.Events.Page.FileChooser, "fileChooser"]
|
|
109
|
+
]));
|
|
110
|
+
}
|
|
111
|
+
static from(page) {
|
|
112
|
+
return page._object;
|
|
113
|
+
}
|
|
114
|
+
static fromNullable(page) {
|
|
115
|
+
return page ? Page.from(page) : null;
|
|
144
116
|
}
|
|
145
117
|
_onFrameAttached(frame) {
|
|
146
118
|
frame._page = this;
|
|
147
119
|
this._frames.add(frame);
|
|
148
|
-
if (frame._parentFrame)
|
|
149
|
-
|
|
120
|
+
if (frame._parentFrame)
|
|
121
|
+
frame._parentFrame._childFrames.add(frame);
|
|
122
|
+
this.emit(import_events.Events.Page.FrameAttached, frame);
|
|
150
123
|
}
|
|
151
124
|
_onFrameDetached(frame) {
|
|
152
125
|
this._frames.delete(frame);
|
|
153
126
|
frame._detached = true;
|
|
154
|
-
if (frame._parentFrame)
|
|
155
|
-
|
|
127
|
+
if (frame._parentFrame)
|
|
128
|
+
frame._parentFrame._childFrames.delete(frame);
|
|
129
|
+
this.emit(import_events.Events.Page.FrameDetached, frame);
|
|
156
130
|
}
|
|
157
131
|
async _onRoute(route) {
|
|
158
132
|
route._context = this.context();
|
|
159
133
|
const routeHandlers = this._routes.slice();
|
|
160
134
|
for (const routeHandler of routeHandlers) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
if (!routeHandler.matches(route.request().url()))
|
|
135
|
+
if (this._closeWasCalled || this._browserContext._closeWasCalled)
|
|
136
|
+
return;
|
|
137
|
+
if (!routeHandler.matches(route.request().url()))
|
|
138
|
+
continue;
|
|
164
139
|
const index = this._routes.indexOf(routeHandler);
|
|
165
|
-
if (index === -1)
|
|
166
|
-
|
|
140
|
+
if (index === -1)
|
|
141
|
+
continue;
|
|
142
|
+
if (routeHandler.willExpire())
|
|
143
|
+
this._routes.splice(index, 1);
|
|
167
144
|
const handled = await routeHandler.handle(route);
|
|
168
|
-
if (!this._routes.length)
|
|
169
|
-
|
|
145
|
+
if (!this._routes.length)
|
|
146
|
+
this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {
|
|
147
|
+
});
|
|
148
|
+
if (handled)
|
|
149
|
+
return;
|
|
170
150
|
}
|
|
171
151
|
await this._browserContext._onRoute(route);
|
|
172
152
|
}
|
|
173
153
|
async _onWebSocketRoute(webSocketRoute) {
|
|
174
|
-
const routeHandler = this._webSocketRoutes.find(route => route.matches(webSocketRoute.url()));
|
|
175
|
-
if (routeHandler)
|
|
154
|
+
const routeHandler = this._webSocketRoutes.find((route) => route.matches(webSocketRoute.url()));
|
|
155
|
+
if (routeHandler)
|
|
156
|
+
await routeHandler.handle(webSocketRoute);
|
|
157
|
+
else
|
|
158
|
+
await this._browserContext._onWebSocketRoute(webSocketRoute);
|
|
176
159
|
}
|
|
177
160
|
async _onBinding(bindingCall) {
|
|
178
161
|
const func = this._bindings.get(bindingCall._initializer.name);
|
|
@@ -185,35 +168,37 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
185
168
|
_onWorker(worker) {
|
|
186
169
|
this._workers.add(worker);
|
|
187
170
|
worker._page = this;
|
|
188
|
-
this.emit(
|
|
171
|
+
this.emit(import_events.Events.Page.Worker, worker);
|
|
189
172
|
}
|
|
190
173
|
_onClose() {
|
|
191
174
|
this._closed = true;
|
|
192
175
|
this._browserContext._pages.delete(this);
|
|
193
176
|
this._browserContext._backgroundPages.delete(this);
|
|
194
177
|
this._disposeHarRouters();
|
|
195
|
-
this.emit(
|
|
178
|
+
this.emit(import_events.Events.Page.Close, this);
|
|
196
179
|
}
|
|
197
180
|
_onCrash() {
|
|
198
|
-
this.emit(
|
|
181
|
+
this.emit(import_events.Events.Page.Crash, this);
|
|
199
182
|
}
|
|
200
183
|
context() {
|
|
201
184
|
return this._browserContext;
|
|
202
185
|
}
|
|
203
186
|
async opener() {
|
|
204
|
-
if (!this._opener || this._opener.isClosed())
|
|
187
|
+
if (!this._opener || this._opener.isClosed())
|
|
188
|
+
return null;
|
|
205
189
|
return this._opener;
|
|
206
190
|
}
|
|
207
191
|
mainFrame() {
|
|
208
192
|
return this._mainFrame;
|
|
209
193
|
}
|
|
210
194
|
frame(frameSelector) {
|
|
211
|
-
const name = (0,
|
|
212
|
-
const url = (0,
|
|
213
|
-
(0,
|
|
214
|
-
return this.frames().find(f => {
|
|
215
|
-
if (name)
|
|
216
|
-
|
|
195
|
+
const name = (0, import_rtti.isString)(frameSelector) ? frameSelector : frameSelector.name;
|
|
196
|
+
const url = (0, import_rtti.isObject)(frameSelector) ? frameSelector.url : void 0;
|
|
197
|
+
(0, import_assert.assert)(name || url, "Either name or url matcher should be specified");
|
|
198
|
+
return this.frames().find((f) => {
|
|
199
|
+
if (name)
|
|
200
|
+
return f.name() === name;
|
|
201
|
+
return (0, import_urlMatch.urlMatches)(this._browserContext._options.baseURL, f.url(), url);
|
|
217
202
|
}) || null;
|
|
218
203
|
}
|
|
219
204
|
frames() {
|
|
@@ -222,28 +207,25 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
222
207
|
setDefaultNavigationTimeout(timeout) {
|
|
223
208
|
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
224
209
|
this._wrapApiCall(async () => {
|
|
225
|
-
this._channel.setDefaultNavigationTimeoutNoReply({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}, true);
|
|
210
|
+
await this._channel.setDefaultNavigationTimeoutNoReply({ timeout });
|
|
211
|
+
}, true).catch(() => {
|
|
212
|
+
});
|
|
229
213
|
}
|
|
230
214
|
setDefaultTimeout(timeout) {
|
|
231
215
|
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
232
216
|
this._wrapApiCall(async () => {
|
|
233
|
-
this._channel.setDefaultTimeoutNoReply({
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
}, true);
|
|
217
|
+
await this._channel.setDefaultTimeoutNoReply({ timeout });
|
|
218
|
+
}, true).catch(() => {
|
|
219
|
+
});
|
|
237
220
|
}
|
|
238
221
|
_forceVideo() {
|
|
239
|
-
if (!this._video)
|
|
222
|
+
if (!this._video)
|
|
223
|
+
this._video = new import_video.Video(this, this._connection);
|
|
240
224
|
return this._video;
|
|
241
225
|
}
|
|
242
226
|
video() {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
// too late during launchPersistentContext.
|
|
246
|
-
if (!this._browserContext._options.recordVideo) return null;
|
|
227
|
+
if (!this._browserContext._options.recordVideo)
|
|
228
|
+
return null;
|
|
247
229
|
return this._forceVideo();
|
|
248
230
|
}
|
|
249
231
|
async $(selector, options) {
|
|
@@ -256,15 +238,15 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
256
238
|
return await this._mainFrame.dispatchEvent(selector, type, eventInit, options);
|
|
257
239
|
}
|
|
258
240
|
async evaluateHandle(pageFunction, arg) {
|
|
259
|
-
(0,
|
|
241
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
260
242
|
return await this._mainFrame.evaluateHandle(pageFunction, arg);
|
|
261
243
|
}
|
|
262
244
|
async $eval(selector, pageFunction, arg) {
|
|
263
|
-
(0,
|
|
245
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
264
246
|
return await this._mainFrame.$eval(selector, pageFunction, arg);
|
|
265
247
|
}
|
|
266
248
|
async $$eval(selector, pageFunction, arg) {
|
|
267
|
-
(0,
|
|
249
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 3);
|
|
268
250
|
return await this._mainFrame.$$eval(selector, pageFunction, arg);
|
|
269
251
|
}
|
|
270
252
|
async $$(selector) {
|
|
@@ -277,24 +259,17 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
277
259
|
return await this._mainFrame.addStyleTag(options);
|
|
278
260
|
}
|
|
279
261
|
async exposeFunction(name, callback) {
|
|
280
|
-
await this._channel.exposeBinding({
|
|
281
|
-
name
|
|
282
|
-
});
|
|
262
|
+
await this._channel.exposeBinding({ name });
|
|
283
263
|
const binding = (source, ...args) => callback(...args);
|
|
284
264
|
this._bindings.set(name, binding);
|
|
285
265
|
}
|
|
286
266
|
async exposeBinding(name, callback, options = {}) {
|
|
287
|
-
await this._channel.exposeBinding({
|
|
288
|
-
name,
|
|
289
|
-
needsHandle: options.handle
|
|
290
|
-
});
|
|
267
|
+
await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
291
268
|
this._bindings.set(name, callback);
|
|
292
269
|
}
|
|
293
270
|
async setExtraHTTPHeaders(headers) {
|
|
294
|
-
(0,
|
|
295
|
-
await this._channel.setExtraHTTPHeaders({
|
|
296
|
-
headers: (0, _utils.headersObjectToArray)(headers)
|
|
297
|
-
});
|
|
271
|
+
(0, import_network.validateHeaders)(headers);
|
|
272
|
+
await this._channel.setExtraHTTPHeaders({ headers: (0, import_headers.headersObjectToArray)(headers) });
|
|
298
273
|
}
|
|
299
274
|
url() {
|
|
300
275
|
return this._mainFrame.url();
|
|
@@ -309,51 +284,40 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
309
284
|
return await this._mainFrame.goto(url, options);
|
|
310
285
|
}
|
|
311
286
|
async reload(options = {}) {
|
|
312
|
-
const waitUntil = (0,
|
|
313
|
-
return
|
|
314
|
-
...options,
|
|
315
|
-
waitUntil
|
|
316
|
-
})).response);
|
|
287
|
+
const waitUntil = (0, import_frame.verifyLoadState)("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
288
|
+
return import_network.Response.fromNullable((await this._channel.reload({ ...options, waitUntil })).response);
|
|
317
289
|
}
|
|
318
290
|
async addLocatorHandler(locator, handler, options = {}) {
|
|
319
|
-
if (locator._frame !== this._mainFrame)
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
} = await this._channel.registerLocatorHandler({
|
|
324
|
-
|
|
325
|
-
noWaitAfter: options.noWaitAfter
|
|
326
|
-
});
|
|
327
|
-
this._locatorHandlers.set(uid, {
|
|
328
|
-
locator,
|
|
329
|
-
handler,
|
|
330
|
-
times: options.times
|
|
331
|
-
});
|
|
291
|
+
if (locator._frame !== this._mainFrame)
|
|
292
|
+
throw new Error(`Locator must belong to the main frame of this page`);
|
|
293
|
+
if (options.times === 0)
|
|
294
|
+
return;
|
|
295
|
+
const { uid } = await this._channel.registerLocatorHandler({ selector: locator._selector, noWaitAfter: options.noWaitAfter });
|
|
296
|
+
this._locatorHandlers.set(uid, { locator, handler, times: options.times });
|
|
332
297
|
}
|
|
333
298
|
async _onLocatorHandlerTriggered(uid) {
|
|
334
299
|
let remove = false;
|
|
335
300
|
try {
|
|
336
301
|
const handler = this._locatorHandlers.get(uid);
|
|
337
302
|
if (handler && handler.times !== 0) {
|
|
338
|
-
if (handler.times !==
|
|
303
|
+
if (handler.times !== void 0)
|
|
304
|
+
handler.times--;
|
|
339
305
|
await handler.handler(handler.locator);
|
|
340
306
|
}
|
|
341
|
-
remove =
|
|
307
|
+
remove = handler?.times === 0;
|
|
342
308
|
} finally {
|
|
343
|
-
if (remove)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
}), true).catch(() => {});
|
|
309
|
+
if (remove)
|
|
310
|
+
this._locatorHandlers.delete(uid);
|
|
311
|
+
this._wrapApiCall(() => this._channel.resolveLocatorHandlerNoReply({ uid, remove }), true).catch(() => {
|
|
312
|
+
});
|
|
348
313
|
}
|
|
349
314
|
}
|
|
350
315
|
async removeLocatorHandler(locator) {
|
|
351
316
|
for (const [uid, data] of this._locatorHandlers) {
|
|
352
317
|
if (data.locator._equals(locator)) {
|
|
353
318
|
this._locatorHandlers.delete(uid);
|
|
354
|
-
await this._channel.unregisterLocatorHandler({
|
|
355
|
-
|
|
356
|
-
}).catch(() => {});
|
|
319
|
+
await this._channel.unregisterLocatorHandler({ uid }).catch(() => {
|
|
320
|
+
});
|
|
357
321
|
}
|
|
358
322
|
}
|
|
359
323
|
}
|
|
@@ -367,175 +331,165 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
367
331
|
return await this._mainFrame.waitForURL(url, options);
|
|
368
332
|
}
|
|
369
333
|
async waitForRequest(urlOrPredicate, options = {}) {
|
|
370
|
-
const predicate = async request => {
|
|
371
|
-
if ((0,
|
|
334
|
+
const predicate = async (request) => {
|
|
335
|
+
if ((0, import_rtti.isString)(urlOrPredicate) || (0, import_rtti.isRegExp)(urlOrPredicate))
|
|
336
|
+
return (0, import_urlMatch.urlMatches)(this._browserContext._options.baseURL, request.url(), urlOrPredicate);
|
|
372
337
|
return await urlOrPredicate(request);
|
|
373
338
|
};
|
|
374
339
|
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
375
|
-
const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` :
|
|
376
|
-
return await this._waitForEvent(
|
|
377
|
-
predicate,
|
|
378
|
-
timeout: options.timeout
|
|
379
|
-
}, logLine);
|
|
340
|
+
const logLine = trimmedUrl ? `waiting for request ${trimmedUrl}` : void 0;
|
|
341
|
+
return await this._waitForEvent(import_events.Events.Page.Request, { predicate, timeout: options.timeout }, logLine);
|
|
380
342
|
}
|
|
381
343
|
async waitForResponse(urlOrPredicate, options = {}) {
|
|
382
|
-
const predicate = async response => {
|
|
383
|
-
if ((0,
|
|
344
|
+
const predicate = async (response) => {
|
|
345
|
+
if ((0, import_rtti.isString)(urlOrPredicate) || (0, import_rtti.isRegExp)(urlOrPredicate))
|
|
346
|
+
return (0, import_urlMatch.urlMatches)(this._browserContext._options.baseURL, response.url(), urlOrPredicate);
|
|
384
347
|
return await urlOrPredicate(response);
|
|
385
348
|
};
|
|
386
349
|
const trimmedUrl = trimUrl(urlOrPredicate);
|
|
387
|
-
const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` :
|
|
388
|
-
return await this._waitForEvent(
|
|
389
|
-
predicate,
|
|
390
|
-
timeout: options.timeout
|
|
391
|
-
}, logLine);
|
|
350
|
+
const logLine = trimmedUrl ? `waiting for response ${trimmedUrl}` : void 0;
|
|
351
|
+
return await this._waitForEvent(import_events.Events.Page.Response, { predicate, timeout: options.timeout }, logLine);
|
|
392
352
|
}
|
|
393
353
|
async waitForEvent(event, optionsOrPredicate = {}) {
|
|
394
354
|
return await this._waitForEvent(event, optionsOrPredicate, `waiting for event "${event}"`);
|
|
395
355
|
}
|
|
396
356
|
_closeErrorWithReason() {
|
|
397
|
-
return new
|
|
357
|
+
return new import_errors.TargetClosedError(this._closeReason || this._browserContext._effectiveCloseReason());
|
|
398
358
|
}
|
|
399
359
|
async _waitForEvent(event, optionsOrPredicate, logLine) {
|
|
400
360
|
return await this._wrapApiCall(async () => {
|
|
401
|
-
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate ===
|
|
402
|
-
const predicate = typeof optionsOrPredicate ===
|
|
403
|
-
const waiter =
|
|
404
|
-
if (logLine)
|
|
361
|
+
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === "function" ? {} : optionsOrPredicate);
|
|
362
|
+
const predicate = typeof optionsOrPredicate === "function" ? optionsOrPredicate : optionsOrPredicate.predicate;
|
|
363
|
+
const waiter = import_waiter.Waiter.createForEvent(this, event);
|
|
364
|
+
if (logLine)
|
|
365
|
+
waiter.log(logLine);
|
|
405
366
|
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
|
406
|
-
if (event !==
|
|
407
|
-
|
|
367
|
+
if (event !== import_events.Events.Page.Crash)
|
|
368
|
+
waiter.rejectOnEvent(this, import_events.Events.Page.Crash, new Error("Page crashed"));
|
|
369
|
+
if (event !== import_events.Events.Page.Close)
|
|
370
|
+
waiter.rejectOnEvent(this, import_events.Events.Page.Close, () => this._closeErrorWithReason());
|
|
408
371
|
const result = await waiter.waitForEvent(this, event, predicate);
|
|
409
372
|
waiter.dispose();
|
|
410
373
|
return result;
|
|
411
374
|
});
|
|
412
375
|
}
|
|
413
376
|
async goBack(options = {}) {
|
|
414
|
-
const waitUntil = (0,
|
|
415
|
-
return
|
|
416
|
-
...options,
|
|
417
|
-
waitUntil
|
|
418
|
-
})).response);
|
|
377
|
+
const waitUntil = (0, import_frame.verifyLoadState)("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
378
|
+
return import_network.Response.fromNullable((await this._channel.goBack({ ...options, waitUntil })).response);
|
|
419
379
|
}
|
|
420
380
|
async goForward(options = {}) {
|
|
421
|
-
const waitUntil = (0,
|
|
422
|
-
return
|
|
423
|
-
...options,
|
|
424
|
-
waitUntil
|
|
425
|
-
})).response);
|
|
381
|
+
const waitUntil = (0, import_frame.verifyLoadState)("waitUntil", options.waitUntil === void 0 ? "load" : options.waitUntil);
|
|
382
|
+
return import_network.Response.fromNullable((await this._channel.goForward({ ...options, waitUntil })).response);
|
|
426
383
|
}
|
|
427
384
|
async requestGC() {
|
|
428
385
|
await this._channel.requestGC();
|
|
429
386
|
}
|
|
430
387
|
async emulateMedia(options = {}) {
|
|
431
388
|
await this._channel.emulateMedia({
|
|
432
|
-
media: options.media === null ?
|
|
433
|
-
colorScheme: options.colorScheme === null ?
|
|
434
|
-
reducedMotion: options.reducedMotion === null ?
|
|
435
|
-
forcedColors: options.forcedColors === null ?
|
|
389
|
+
media: options.media === null ? "no-override" : options.media,
|
|
390
|
+
colorScheme: options.colorScheme === null ? "no-override" : options.colorScheme,
|
|
391
|
+
reducedMotion: options.reducedMotion === null ? "no-override" : options.reducedMotion,
|
|
392
|
+
forcedColors: options.forcedColors === null ? "no-override" : options.forcedColors,
|
|
393
|
+
contrast: options.contrast === null ? "no-override" : options.contrast
|
|
436
394
|
});
|
|
437
395
|
}
|
|
438
396
|
async setViewportSize(viewportSize) {
|
|
439
397
|
this._viewportSize = viewportSize;
|
|
440
|
-
await this._channel.setViewportSize({
|
|
441
|
-
viewportSize
|
|
442
|
-
});
|
|
398
|
+
await this._channel.setViewportSize({ viewportSize });
|
|
443
399
|
}
|
|
444
400
|
viewportSize() {
|
|
445
401
|
return this._viewportSize;
|
|
446
402
|
}
|
|
447
403
|
async evaluate(pageFunction, arg) {
|
|
448
|
-
(0,
|
|
404
|
+
(0, import_jsHandle.assertMaxArguments)(arguments.length, 2);
|
|
449
405
|
return await this._mainFrame.evaluate(pageFunction, arg);
|
|
450
406
|
}
|
|
451
407
|
async addInitScript(script, arg) {
|
|
452
|
-
const source = await (0,
|
|
453
|
-
await this._channel.addInitScript({
|
|
454
|
-
source
|
|
455
|
-
});
|
|
408
|
+
const source = await (0, import_clientHelper.evaluationScript)(this._platform, script, arg);
|
|
409
|
+
await this._channel.addInitScript({ source });
|
|
456
410
|
}
|
|
457
411
|
async route(url, handler, options = {}) {
|
|
458
|
-
this._routes.unshift(new
|
|
412
|
+
this._routes.unshift(new import_network.RouteHandler(this._platform, this._browserContext._options.baseURL, url, handler, options.times));
|
|
459
413
|
await this._updateInterceptionPatterns();
|
|
460
414
|
}
|
|
461
415
|
async routeFromHAR(har, options = {}) {
|
|
416
|
+
const localUtils = this._connection.localUtils();
|
|
417
|
+
if (!localUtils)
|
|
418
|
+
throw new Error("Route from har is not supported in thin clients");
|
|
462
419
|
if (options.update) {
|
|
463
420
|
await this._browserContext._recordIntoHAR(har, this, options);
|
|
464
421
|
return;
|
|
465
422
|
}
|
|
466
|
-
const harRouter = await
|
|
467
|
-
urlMatch: options.url
|
|
468
|
-
});
|
|
423
|
+
const harRouter = await import_harRouter.HarRouter.create(localUtils, har, options.notFound || "abort", { urlMatch: options.url });
|
|
469
424
|
this._harRouters.push(harRouter);
|
|
470
425
|
await harRouter.addPageRoute(this);
|
|
471
426
|
}
|
|
472
427
|
async routeWebSocket(url, handler) {
|
|
473
|
-
this._webSocketRoutes.unshift(new
|
|
428
|
+
this._webSocketRoutes.unshift(new import_network.WebSocketRouteHandler(this._browserContext._options.baseURL, url, handler));
|
|
474
429
|
await this._updateWebSocketInterceptionPatterns();
|
|
475
430
|
}
|
|
476
431
|
_disposeHarRouters() {
|
|
477
|
-
this._harRouters.forEach(router => router.dispose());
|
|
432
|
+
this._harRouters.forEach((router) => router.dispose());
|
|
478
433
|
this._harRouters = [];
|
|
479
434
|
}
|
|
480
435
|
async unrouteAll(options) {
|
|
481
|
-
await this._unrouteInternal(this._routes, [], options
|
|
436
|
+
await this._unrouteInternal(this._routes, [], options?.behavior);
|
|
482
437
|
this._disposeHarRouters();
|
|
483
438
|
}
|
|
484
439
|
async unroute(url, handler) {
|
|
485
440
|
const removed = [];
|
|
486
441
|
const remaining = [];
|
|
487
442
|
for (const route of this._routes) {
|
|
488
|
-
if ((0,
|
|
443
|
+
if ((0, import_urlMatch.urlMatchesEqual)(route.url, url) && (!handler || route.handler === handler))
|
|
444
|
+
removed.push(route);
|
|
445
|
+
else
|
|
446
|
+
remaining.push(route);
|
|
489
447
|
}
|
|
490
|
-
await this._unrouteInternal(removed, remaining,
|
|
448
|
+
await this._unrouteInternal(removed, remaining, "default");
|
|
491
449
|
}
|
|
492
450
|
async _unrouteInternal(removed, remaining, behavior) {
|
|
493
451
|
this._routes = remaining;
|
|
494
452
|
await this._updateInterceptionPatterns();
|
|
495
|
-
if (!behavior || behavior ===
|
|
496
|
-
|
|
453
|
+
if (!behavior || behavior === "default")
|
|
454
|
+
return;
|
|
455
|
+
const promises = removed.map((routeHandler) => routeHandler.stop(behavior));
|
|
497
456
|
await Promise.all(promises);
|
|
498
457
|
}
|
|
499
458
|
async _updateInterceptionPatterns() {
|
|
500
|
-
const patterns =
|
|
501
|
-
await this._channel.setNetworkInterceptionPatterns({
|
|
502
|
-
patterns
|
|
503
|
-
});
|
|
459
|
+
const patterns = import_network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
|
460
|
+
await this._channel.setNetworkInterceptionPatterns({ patterns });
|
|
504
461
|
}
|
|
505
462
|
async _updateWebSocketInterceptionPatterns() {
|
|
506
|
-
const patterns =
|
|
507
|
-
await this._channel.setWebSocketInterceptionPatterns({
|
|
508
|
-
patterns
|
|
509
|
-
});
|
|
463
|
+
const patterns = import_network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes);
|
|
464
|
+
await this._channel.setWebSocketInterceptionPatterns({ patterns });
|
|
510
465
|
}
|
|
511
466
|
async screenshot(options = {}) {
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
if (
|
|
517
|
-
|
|
518
|
-
copy.mask = options.mask.map(locator => ({
|
|
467
|
+
const mask = options.mask;
|
|
468
|
+
const copy = { ...options, mask: void 0 };
|
|
469
|
+
if (!copy.type)
|
|
470
|
+
copy.type = (0, import_elementHandle.determineScreenshotType)(options);
|
|
471
|
+
if (mask) {
|
|
472
|
+
copy.mask = mask.map((locator) => ({
|
|
519
473
|
frame: locator._frame._channel,
|
|
520
474
|
selector: locator._selector
|
|
521
475
|
}));
|
|
522
476
|
}
|
|
523
477
|
const result = await this._channel.screenshot(copy);
|
|
524
478
|
if (options.path) {
|
|
525
|
-
await (0,
|
|
526
|
-
await
|
|
479
|
+
await (0, import_fileUtils.mkdirIfNeeded)(this._platform, options.path);
|
|
480
|
+
await this._platform.fs().promises.writeFile(options.path, result.binary);
|
|
527
481
|
}
|
|
528
482
|
return result.binary;
|
|
529
483
|
}
|
|
530
484
|
async _expectScreenshot(options) {
|
|
531
|
-
const mask = options
|
|
532
|
-
frame:
|
|
533
|
-
selector:
|
|
534
|
-
})) :
|
|
485
|
+
const mask = options?.mask ? options?.mask.map((locator2) => ({
|
|
486
|
+
frame: locator2._frame._channel,
|
|
487
|
+
selector: locator2._selector
|
|
488
|
+
})) : void 0;
|
|
535
489
|
const locator = options.locator ? {
|
|
536
490
|
frame: options.locator._frame._channel,
|
|
537
491
|
selector: options.locator._selector
|
|
538
|
-
} :
|
|
492
|
+
} : void 0;
|
|
539
493
|
return await this._channel.expectScreenshot({
|
|
540
494
|
...options,
|
|
541
495
|
isNot: !!options.isNot,
|
|
@@ -549,16 +503,20 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
549
503
|
async bringToFront() {
|
|
550
504
|
await this._channel.bringToFront();
|
|
551
505
|
}
|
|
552
|
-
async [
|
|
506
|
+
async [Symbol.asyncDispose]() {
|
|
553
507
|
await this.close();
|
|
554
508
|
}
|
|
555
509
|
async close(options = {}) {
|
|
556
510
|
this._closeReason = options.reason;
|
|
557
511
|
this._closeWasCalled = true;
|
|
558
512
|
try {
|
|
559
|
-
if (this._ownedContext)
|
|
513
|
+
if (this._ownedContext)
|
|
514
|
+
await this._ownedContext.close();
|
|
515
|
+
else
|
|
516
|
+
await this._channel.close(options);
|
|
560
517
|
} catch (e) {
|
|
561
|
-
if ((0,
|
|
518
|
+
if ((0, import_errors.isTargetClosedError)(e) && !options.runBeforeUnload)
|
|
519
|
+
return;
|
|
562
520
|
throw e;
|
|
563
521
|
}
|
|
564
522
|
}
|
|
@@ -677,44 +635,40 @@ class Page extends _channelOwner.ChannelOwner {
|
|
|
677
635
|
return [...this._workers];
|
|
678
636
|
}
|
|
679
637
|
async pause(_options) {
|
|
680
|
-
|
|
681
|
-
|
|
638
|
+
if (this._platform.isJSDebuggerAttached())
|
|
639
|
+
return;
|
|
682
640
|
const defaultNavigationTimeout = this._browserContext._timeoutSettings.defaultNavigationTimeout();
|
|
683
641
|
const defaultTimeout = this._browserContext._timeoutSettings.defaultTimeout();
|
|
684
642
|
this._browserContext.setDefaultNavigationTimeout(0);
|
|
685
643
|
this._browserContext.setDefaultTimeout(0);
|
|
686
|
-
|
|
687
|
-
keepTestTimeout: !!(_options !== null && _options !== void 0 && _options.__testHookKeepTestTimeout)
|
|
688
|
-
});
|
|
644
|
+
this._instrumentation?.onWillPause({ keepTestTimeout: !!_options?.__testHookKeepTestTimeout });
|
|
689
645
|
await this._closedOrCrashedScope.safeRace(this.context()._channel.pause());
|
|
690
646
|
this._browserContext.setDefaultNavigationTimeout(defaultNavigationTimeout);
|
|
691
647
|
this._browserContext.setDefaultTimeout(defaultTimeout);
|
|
692
648
|
}
|
|
693
649
|
async pdf(options = {}) {
|
|
694
|
-
const transportOptions = {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
if (
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
for (const margin of ['top', 'right', 'bottom', 'left']) {
|
|
650
|
+
const transportOptions = { ...options };
|
|
651
|
+
if (transportOptions.margin)
|
|
652
|
+
transportOptions.margin = { ...transportOptions.margin };
|
|
653
|
+
if (typeof options.width === "number")
|
|
654
|
+
transportOptions.width = options.width + "px";
|
|
655
|
+
if (typeof options.height === "number")
|
|
656
|
+
transportOptions.height = options.height + "px";
|
|
657
|
+
for (const margin of ["top", "right", "bottom", "left"]) {
|
|
703
658
|
const index = margin;
|
|
704
|
-
if (options.margin && typeof options.margin[index] ===
|
|
659
|
+
if (options.margin && typeof options.margin[index] === "number")
|
|
660
|
+
transportOptions.margin[index] = transportOptions.margin[index] + "px";
|
|
705
661
|
}
|
|
706
662
|
const result = await this._channel.pdf(transportOptions);
|
|
707
663
|
if (options.path) {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
await _fs.default.promises.writeFile(options.path, result.pdf);
|
|
664
|
+
const platform = this._platform;
|
|
665
|
+
await platform.fs().promises.mkdir(platform.path().dirname(options.path), { recursive: true });
|
|
666
|
+
await platform.fs().promises.writeFile(options.path, result.pdf);
|
|
712
667
|
}
|
|
713
668
|
return result.pdf;
|
|
714
669
|
}
|
|
715
670
|
}
|
|
716
|
-
|
|
717
|
-
class BindingCall extends _channelOwner.ChannelOwner {
|
|
671
|
+
class BindingCall extends import_channelOwner.ChannelOwner {
|
|
718
672
|
static from(channel) {
|
|
719
673
|
return channel._object;
|
|
720
674
|
}
|
|
@@ -723,26 +677,33 @@ class BindingCall extends _channelOwner.ChannelOwner {
|
|
|
723
677
|
}
|
|
724
678
|
async call(func) {
|
|
725
679
|
try {
|
|
726
|
-
const frame =
|
|
680
|
+
const frame = import_frame.Frame.from(this._initializer.frame);
|
|
727
681
|
const source = {
|
|
728
682
|
context: frame._page.context(),
|
|
729
683
|
page: frame._page,
|
|
730
684
|
frame
|
|
731
685
|
};
|
|
732
686
|
let result;
|
|
733
|
-
if (this._initializer.handle)
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
687
|
+
if (this._initializer.handle)
|
|
688
|
+
result = await func(source, import_jsHandle.JSHandle.from(this._initializer.handle));
|
|
689
|
+
else
|
|
690
|
+
result = await func(source, ...this._initializer.args.map(import_jsHandle.parseResult));
|
|
691
|
+
this._channel.resolve({ result: (0, import_jsHandle.serializeArgument)(result) }).catch(() => {
|
|
692
|
+
});
|
|
737
693
|
} catch (e) {
|
|
738
|
-
this._channel.reject({
|
|
739
|
-
|
|
740
|
-
}).catch(() => {});
|
|
694
|
+
this._channel.reject({ error: (0, import_errors.serializeError)(e) }).catch(() => {
|
|
695
|
+
});
|
|
741
696
|
}
|
|
742
697
|
}
|
|
743
698
|
}
|
|
744
|
-
exports.BindingCall = BindingCall;
|
|
745
699
|
function trimUrl(param) {
|
|
746
|
-
if ((0,
|
|
747
|
-
|
|
748
|
-
|
|
700
|
+
if ((0, import_rtti.isRegExp)(param))
|
|
701
|
+
return `/${(0, import_stringUtils.trimStringWithEllipsis)(param.source, 50)}/${param.flags}`;
|
|
702
|
+
if ((0, import_rtti.isString)(param))
|
|
703
|
+
return `"${(0, import_stringUtils.trimStringWithEllipsis)(param, 50)}"`;
|
|
704
|
+
}
|
|
705
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
706
|
+
0 && (module.exports = {
|
|
707
|
+
BindingCall,
|
|
708
|
+
Page
|
|
709
|
+
});
|