rebrowser-playwright-core 1.49.0 → 1.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +381 -55
- package/bin/reinstall_msedge_beta_linux.sh +6 -0
- package/bin/reinstall_msedge_dev_linux.sh +6 -0
- package/bin/reinstall_msedge_stable_linux.sh +6 -0
- package/browsers.json +28 -13
- package/index.js +0 -1
- package/lib/androidServerImpl.js +42 -48
- package/lib/browserServerImpl.js +60 -64
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +314 -354
- package/lib/cli/programWithTestStub.js +51 -44
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +146 -254
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -39
- package/lib/client/browser.js +59 -68
- package/lib/client/browserContext.js +302 -322
- package/lib/client/browserType.js +95 -143
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +109 -139
- package/lib/client/clientHelper.js +49 -42
- package/lib/client/clientInstrumentation.js +40 -35
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +203 -218
- package/lib/client/consoleMessage.js +33 -33
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +74 -76
- package/lib/client/elementHandle.js +126 -163
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +127 -127
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +154 -178
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +189 -307
- package/lib/client/harRouter.js +44 -56
- package/lib/client/input.js +40 -69
- package/lib/client/jsHandle.js +55 -71
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +53 -28
- package/lib/client/locator.js +144 -230
- package/lib/client/network.js +285 -301
- package/lib/client/page.js +273 -312
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +62 -57
- package/lib/client/selectors.js +51 -43
- package/lib/client/stream.js +30 -45
- package/lib/client/timeoutSettings.js +75 -0
- package/lib/client/tracing.js +49 -82
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +71 -91
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +111 -0
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +28 -43
- package/lib/generated/clockSource.js +26 -5
- package/lib/generated/consoleApiSource.js +26 -5
- package/lib/generated/injectedScriptSource.js +26 -5
- package/lib/generated/pollingRecorderSource.js +26 -5
- package/lib/generated/utilityScriptSource.js +26 -5
- package/lib/generated/webSocketMockSource.js +375 -4
- package/lib/inProcessFactory.js +53 -48
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +53 -42
- package/lib/protocol/debug.js +209 -25
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2712 -2667
- package/lib/protocol/validatorPrimitives.js +115 -75
- package/lib/remote/playwrightConnection.js +144 -152
- package/lib/remote/playwrightServer.js +106 -77
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +216 -206
- package/lib/server/android/backendAdb.js +89 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +227 -158
- package/lib/server/bidi/bidiChromium.js +106 -78
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +161 -97
- package/lib/server/bidi/bidiFirefox.js +76 -68
- package/lib/server/bidi/bidiInput.js +90 -102
- package/lib/server/bidi/bidiNetworkManager.js +141 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +262 -261
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +241 -223
- package/lib/server/bidi/third_party/bidiProtocol.js +144 -131
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +149 -111
- package/lib/server/browser.js +76 -84
- package/lib/server/browserContext.js +343 -360
- package/lib/server/browserType.js +169 -181
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/chromium.js +212 -190
- package/lib/server/chromium/chromiumSwitches.js +99 -44
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +262 -280
- package/lib/server/chromium/crConnection.js +121 -178
- package/lib/server/chromium/crCoverage.js +113 -127
- package/lib/server/chromium/crDevTools.js +64 -55
- package/lib/server/chromium/crDragDrop.js +62 -79
- package/lib/server/chromium/crExecutionContext.js +100 -91
- package/lib/server/chromium/crInput.js +101 -88
- package/lib/server/chromium/crNetworkManager.js +269 -370
- package/lib/server/chromium/crPage.js +509 -595
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +85 -69
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +65 -99
- package/lib/server/clock.js +58 -46
- package/lib/server/codegen/csharp.js +191 -156
- package/lib/server/codegen/java.js +163 -125
- package/lib/server/codegen/javascript.js +166 -143
- package/lib/server/codegen/jsonl.js +33 -29
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -125
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +105 -86
- package/lib/server/debugController.js +102 -154
- package/lib/server/debugger.js +82 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +131 -131
- package/lib/server/dialog.js +36 -35
- package/lib/server/dispatchers/androidDispatcher.js +196 -107
- package/lib/server/dispatchers/artifactDispatcher.js +62 -62
- package/lib/server/dispatchers/browserContextDispatcher.js +177 -217
- package/lib/server/dispatchers/browserDispatcher.js +78 -97
- package/lib/server/dispatchers/browserTypeDispatcher.js +35 -35
- package/lib/server/dispatchers/cdpSessionDispatcher.js +32 -36
- package/lib/server/dispatchers/debugControllerDispatcher.js +48 -64
- package/lib/server/dispatchers/dialogDispatcher.js +30 -27
- package/lib/server/dispatchers/dispatcher.js +180 -229
- package/lib/server/dispatchers/electronDispatcher.js +54 -57
- package/lib/server/dispatchers/elementHandlerDispatcher.js +79 -116
- package/lib/server/dispatchers/frameDispatcher.js +93 -162
- package/lib/server/dispatchers/jsHandleDispatcher.js +49 -66
- package/lib/server/dispatchers/jsonPipeDispatcher.js +35 -36
- package/lib/server/dispatchers/localUtilsDispatcher.js +107 -365
- package/lib/server/dispatchers/networkDispatchers.js +92 -109
- package/lib/server/dispatchers/pageDispatcher.js +130 -169
- package/lib/server/dispatchers/playwrightDispatcher.js +69 -76
- package/lib/server/dispatchers/selectorsDispatcher.js +28 -24
- package/lib/server/dispatchers/streamDispatcher.js +42 -44
- package/lib/server/dispatchers/tracingDispatcher.js +36 -41
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +100 -135
- package/lib/server/dispatchers/writableStreamDispatcher.js +54 -39
- package/lib/server/dom.js +424 -443
- package/lib/server/download.js +45 -35
- package/lib/server/electron/electron.js +156 -175
- package/lib/server/electron/loader.js +8 -36
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +302 -331
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -57
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +218 -274
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +103 -77
- package/lib/server/firefox/ffInput.js +72 -63
- package/lib/server/firefox/ffNetworkManager.js +131 -110
- package/lib/server/firefox/ffPage.js +244 -302
- package/lib/server/firefox/firefox.js +76 -69
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +77 -111
- package/lib/server/frames.js +719 -855
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +288 -224
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +56 -59
- package/lib/server/index.js +59 -106
- package/lib/server/input.js +136 -166
- package/lib/server/instrumentation.js +49 -44
- package/lib/server/javascript.js +157 -151
- package/lib/server/launchApp.js +92 -73
- package/lib/server/localUtils.js +211 -0
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +263 -297
- package/lib/server/page.js +353 -432
- package/lib/server/pageBinding.js +88 -0
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +60 -67
- package/lib/server/progress.js +56 -51
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/contextRecorder.js +135 -148
- package/lib/server/recorder/recorderApp.js +129 -132
- package/lib/server/recorder/recorderCollection.js +57 -57
- package/lib/server/recorder/recorderFrontend.js +15 -4
- package/lib/server/recorder/recorderRunner.js +80 -100
- package/lib/server/recorder/recorderUtils.js +59 -72
- package/lib/server/recorder/throttledFile.js +42 -31
- package/lib/server/recorder.js +186 -190
- package/lib/server/registry/browserFetcher.js +107 -100
- package/lib/server/registry/dependencies.js +247 -198
- package/lib/server/registry/index.js +928 -709
- package/lib/server/registry/nativeDeps.js +1073 -461
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +166 -182
- package/lib/server/selectors.js +85 -46
- package/lib/server/socksClientCertificatesInterceptor.js +166 -185
- package/lib/server/socksInterceptor.js +62 -67
- package/lib/server/storageScript.js +154 -0
- package/lib/server/timeoutSettings.js +89 -0
- package/lib/server/trace/recorder/snapshotter.js +70 -88
- package/lib/server/trace/recorder/snapshotterInjected.js +246 -218
- package/lib/server/trace/recorder/tracing.js +324 -327
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +172 -137
- package/lib/server/transport.js +125 -133
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +47 -0
- package/lib/server/utils/debugLogger.js +114 -0
- package/lib/server/utils/env.js +68 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +109 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/{image_tools → server/utils/image_tools}/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/{image_tools → server/utils/image_tools}/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +217 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +238 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +132 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +76 -63
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +163 -180
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +96 -73
- package/lib/server/webkit/wkInput.js +87 -75
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +536 -645
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +77 -77
- package/lib/utils/isomorphic/ariaSnapshot.js +245 -128
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/builtins.js +90 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +123 -127
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +344 -349
- package/lib/utils/isomorphic/locatorParser.js +103 -106
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +115 -0
- package/lib/utils/isomorphic/mimeType.js +453 -22
- package/lib/utils/isomorphic/multimap.js +81 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +183 -193
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +113 -106
- package/lib/utils/isomorphic/time.js +44 -0
- package/lib/utils/isomorphic/timeoutRunner.js +67 -0
- package/lib/utils/isomorphic/traceUtils.js +52 -32
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +114 -71
- package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
- package/lib/utils.js +101 -0
- package/lib/utilsBundle.js +101 -76
- package/lib/utilsBundleImpl/index.js +114 -116
- package/lib/vite/htmlReport/index.html +26 -20
- package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +24 -0
- package/lib/vite/recorder/assets/index-97EUAAbk.js +184 -0
- package/lib/vite/recorder/assets/{index-iA1aAGZg.css → index-eHBmevrY.css} +1 -1
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +265 -0
- package/lib/vite/traceViewer/assets/{xtermModule-BeNbaIVa.js → xtermModule-BoAIEibi.js} +7 -7
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +1 -0
- package/lib/vite/traceViewer/index.DvtSwn6E.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -7
- package/lib/vite/traceViewer/sw.bundle.js +3 -3
- package/lib/vite/traceViewer/{uiMode.voC1ZiOQ.css → uiMode.BatfzHMG.css} +1 -1
- package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +4 -7
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +7 -7
- package/types/protocol.d.ts +819 -127
- package/types/types.d.ts +196 -75
- package/bin/PrintDeps.exe +0 -0
- package/bin/README.md +0 -2
- package/lib/common/socksProxy.js +0 -569
- package/lib/common/timeoutSettings.js +0 -73
- package/lib/common/types.js +0 -5
- package/lib/image_tools/colorUtils.js +0 -98
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/protocol/transport.js +0 -82
- package/lib/server/ariaSnapshot.js +0 -33
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -226
- package/lib/server/recorder/recorderInTraceViewer.js +0 -144
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -153
- package/lib/utils/crypto.js +0 -171
- package/lib/utils/debug.js +0 -46
- package/lib/utils/debugLogger.js +0 -91
- package/lib/utils/env.js +0 -49
- package/lib/utils/eventsHelper.js +0 -38
- package/lib/utils/expectUtils.js +0 -33
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -194
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -139
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/isomorphic/recorderUtils.js +0 -227
- package/lib/utils/linuxUtils.js +0 -78
- package/lib/utils/manualPromise.js +0 -109
- package/lib/utils/multimap.js +0 -75
- package/lib/utils/network.js +0 -160
- package/lib/utils/processLauncher.js +0 -248
- package/lib/utils/profiler.js +0 -53
- package/lib/utils/rtti.js +0 -44
- package/lib/utils/semaphore.js +0 -51
- package/lib/utils/sequence.js +0 -64
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -134
- package/lib/utils/task.js +0 -58
- package/lib/utils/time.js +0 -37
- package/lib/utils/timeoutRunner.js +0 -66
- package/lib/utils/traceUtils.js +0 -44
- package/lib/utils/userAgent.js +0 -105
- package/lib/utils/wsServer.js +0 -127
- package/lib/utils/zipFile.js +0 -75
- package/lib/utils/zones.js +0 -71
- package/lib/vite/recorder/assets/codeMirrorModule-AFvV6hAs.js +0 -24
- package/lib/vite/recorder/assets/index-_cTWgVuJ.js +0 -184
- package/lib/vite/traceViewer/assets/codeMirrorModule-KatbITLF.js +0 -24
- package/lib/vite/traceViewer/assets/inspectorTab-DdpLd2bb.js +0 -68
- package/lib/vite/traceViewer/assets/testServerConnection-DeE2kSzz.js +0 -1
- package/lib/vite/traceViewer/assets/workbench-CdYbzWFD.js +0 -9
- package/lib/vite/traceViewer/embedded.6m3UZh7r.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.w7WN2u1R.css +0 -1
- package/lib/vite/traceViewer/index.WUV-8boJ.js +0 -2
- package/lib/vite/traceViewer/inspectorTab.DEOUW62d.css +0 -1
- package/lib/vite/traceViewer/recorder.B_SY1GJM.css +0 -0
- package/lib/vite/traceViewer/recorder.OT2tVHgn.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/uiMode.BZBTyvGn.js +0 -5
- package/lib/vite/traceViewer/workbench.C-zR9ysA.css +0 -1
- /package/lib/vite/recorder/assets/{codeMirrorModule-ez37Vkbh.css → codeMirrorModule-C3UTv-Ge.css} +0 -0
- /package/lib/vite/traceViewer/{codeMirrorModule.ez37Vkbh.css → codeMirrorModule.C3UTv-Ge.css} +0 -0
- /package/lib/vite/traceViewer/{index.CrbWWHbf.css → index.CFOW-Ezb.css} +0 -0
- /package/lib/vite/traceViewer/{xtermModule.DSXBckUd.css → xtermModule.Beg8tuEN.css} +0 -0
|
@@ -1,250 +1,244 @@
|
|
|
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 browserContext_exports = {};
|
|
30
|
+
__export(browserContext_exports, {
|
|
31
|
+
BrowserContext: () => BrowserContext,
|
|
32
|
+
prepareBrowserContextParams: () => prepareBrowserContextParams,
|
|
33
|
+
toClientCertificatesProtocol: () => toClientCertificatesProtocol
|
|
5
34
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
let _Symbol$asyncDispose;
|
|
34
|
-
/**
|
|
35
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
36
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
37
|
-
*
|
|
38
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
39
|
-
* you may not use this file except in compliance with the License.
|
|
40
|
-
* You may obtain a copy of the License at
|
|
41
|
-
*
|
|
42
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
43
|
-
*
|
|
44
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
45
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
46
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
47
|
-
* See the License for the specific language governing permissions and
|
|
48
|
-
* limitations under the License.
|
|
49
|
-
*/
|
|
50
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
51
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
52
|
-
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; }
|
|
53
|
-
_Symbol$asyncDispose = Symbol.asyncDispose;
|
|
54
|
-
class BrowserContext extends _channelOwner.ChannelOwner {
|
|
55
|
-
static from(context) {
|
|
56
|
-
return context._object;
|
|
57
|
-
}
|
|
58
|
-
static fromNullable(context) {
|
|
59
|
-
return context ? BrowserContext.from(context) : null;
|
|
60
|
-
}
|
|
35
|
+
module.exports = __toCommonJS(browserContext_exports);
|
|
36
|
+
var import_artifact = require("./artifact");
|
|
37
|
+
var import_browser = require("./browser");
|
|
38
|
+
var import_cdpSession = require("./cdpSession");
|
|
39
|
+
var import_channelOwner = require("./channelOwner");
|
|
40
|
+
var import_clientHelper = require("./clientHelper");
|
|
41
|
+
var import_clock = require("./clock");
|
|
42
|
+
var import_consoleMessage = require("./consoleMessage");
|
|
43
|
+
var import_dialog = require("./dialog");
|
|
44
|
+
var import_errors = require("./errors");
|
|
45
|
+
var import_events = require("./events");
|
|
46
|
+
var import_fetch = require("./fetch");
|
|
47
|
+
var import_frame = require("./frame");
|
|
48
|
+
var import_harRouter = require("./harRouter");
|
|
49
|
+
var network = __toESM(require("./network"));
|
|
50
|
+
var import_page = require("./page");
|
|
51
|
+
var import_tracing = require("./tracing");
|
|
52
|
+
var import_waiter = require("./waiter");
|
|
53
|
+
var import_webError = require("./webError");
|
|
54
|
+
var import_worker = require("./worker");
|
|
55
|
+
var import_timeoutSettings = require("./timeoutSettings");
|
|
56
|
+
var import_fileUtils = require("./fileUtils");
|
|
57
|
+
var import_headers = require("../utils/isomorphic/headers");
|
|
58
|
+
var import_urlMatch = require("../utils/isomorphic/urlMatch");
|
|
59
|
+
var import_rtti = require("../utils/isomorphic/rtti");
|
|
60
|
+
var import_stackTrace = require("../utils/isomorphic/stackTrace");
|
|
61
|
+
class BrowserContext extends import_channelOwner.ChannelOwner {
|
|
61
62
|
constructor(parent, type, guid, initializer) {
|
|
62
|
-
var _this$_browser, _this$_browser2;
|
|
63
63
|
super(parent, type, guid, initializer);
|
|
64
|
-
this._pages = new Set();
|
|
64
|
+
this._pages = /* @__PURE__ */ new Set();
|
|
65
65
|
this._routes = [];
|
|
66
66
|
this._webSocketRoutes = [];
|
|
67
67
|
this._browser = null;
|
|
68
|
-
this.
|
|
69
|
-
this._bindings = new Map();
|
|
70
|
-
this._timeoutSettings = new _timeoutSettings.TimeoutSettings();
|
|
71
|
-
this._ownerPage = void 0;
|
|
72
|
-
this._closedPromise = void 0;
|
|
68
|
+
this._bindings = /* @__PURE__ */ new Map();
|
|
73
69
|
this._options = {};
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
this._backgroundPages = new Set();
|
|
78
|
-
this._serviceWorkers = new Set();
|
|
79
|
-
this._isChromium = void 0;
|
|
80
|
-
this._harRecorders = new Map();
|
|
70
|
+
this._backgroundPages = /* @__PURE__ */ new Set();
|
|
71
|
+
this._serviceWorkers = /* @__PURE__ */ new Set();
|
|
72
|
+
this._harRecorders = /* @__PURE__ */ new Map();
|
|
81
73
|
this._closeWasCalled = false;
|
|
82
|
-
this._closeReason = void 0;
|
|
83
74
|
this._harRouters = [];
|
|
84
|
-
|
|
85
|
-
(
|
|
86
|
-
|
|
87
|
-
this.
|
|
88
|
-
this.
|
|
89
|
-
this.
|
|
90
|
-
this.
|
|
91
|
-
|
|
92
|
-
}) => this._onBinding(
|
|
93
|
-
this._channel.on(
|
|
94
|
-
this._channel.on(
|
|
95
|
-
|
|
96
|
-
}) => this.
|
|
97
|
-
this._channel.on(
|
|
98
|
-
|
|
99
|
-
}) => this._onRoute(network.Route.from(route)));
|
|
100
|
-
this._channel.on('webSocketRoute', ({
|
|
101
|
-
webSocketRoute
|
|
102
|
-
}) => this._onWebSocketRoute(network.WebSocketRoute.from(webSocketRoute)));
|
|
103
|
-
this._channel.on('backgroundPage', ({
|
|
104
|
-
page
|
|
105
|
-
}) => {
|
|
106
|
-
const backgroundPage = _page.Page.from(page);
|
|
75
|
+
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(this._platform);
|
|
76
|
+
if (parent instanceof import_browser.Browser)
|
|
77
|
+
this._browser = parent;
|
|
78
|
+
this._browser?._contexts.add(this);
|
|
79
|
+
this._isChromium = this._browser?._name === "chromium";
|
|
80
|
+
this.tracing = import_tracing.Tracing.from(initializer.tracing);
|
|
81
|
+
this.request = import_fetch.APIRequestContext.from(initializer.requestContext);
|
|
82
|
+
this.clock = new import_clock.Clock(this);
|
|
83
|
+
this._channel.on("bindingCall", ({ binding }) => this._onBinding(import_page.BindingCall.from(binding)));
|
|
84
|
+
this._channel.on("close", () => this._onClose());
|
|
85
|
+
this._channel.on("page", ({ page }) => this._onPage(import_page.Page.from(page)));
|
|
86
|
+
this._channel.on("route", ({ route }) => this._onRoute(network.Route.from(route)));
|
|
87
|
+
this._channel.on("webSocketRoute", ({ webSocketRoute }) => this._onWebSocketRoute(network.WebSocketRoute.from(webSocketRoute)));
|
|
88
|
+
this._channel.on("backgroundPage", ({ page }) => {
|
|
89
|
+
const backgroundPage = import_page.Page.from(page);
|
|
107
90
|
this._backgroundPages.add(backgroundPage);
|
|
108
|
-
this.emit(
|
|
91
|
+
this.emit(import_events.Events.BrowserContext.BackgroundPage, backgroundPage);
|
|
109
92
|
});
|
|
110
|
-
this._channel.on(
|
|
111
|
-
worker
|
|
112
|
-
}) => {
|
|
113
|
-
const serviceWorker = _worker.Worker.from(worker);
|
|
93
|
+
this._channel.on("serviceWorker", ({ worker }) => {
|
|
94
|
+
const serviceWorker = import_worker.Worker.from(worker);
|
|
114
95
|
serviceWorker._context = this;
|
|
115
96
|
this._serviceWorkers.add(serviceWorker);
|
|
116
|
-
this.emit(
|
|
97
|
+
this.emit(import_events.Events.BrowserContext.ServiceWorker, serviceWorker);
|
|
117
98
|
});
|
|
118
|
-
this._channel.on(
|
|
119
|
-
const consoleMessage = new
|
|
120
|
-
this.emit(
|
|
99
|
+
this._channel.on("console", (event) => {
|
|
100
|
+
const consoleMessage = new import_consoleMessage.ConsoleMessage(this._platform, event);
|
|
101
|
+
this.emit(import_events.Events.BrowserContext.Console, consoleMessage);
|
|
121
102
|
const page = consoleMessage.page();
|
|
122
|
-
if (page)
|
|
103
|
+
if (page)
|
|
104
|
+
page.emit(import_events.Events.Page.Console, consoleMessage);
|
|
123
105
|
});
|
|
124
|
-
this._channel.on(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.emit(_events.Events.BrowserContext.WebError, new _webError.WebError(pageObject, parsedError));
|
|
131
|
-
if (pageObject) pageObject.emit(_events.Events.Page.PageError, parsedError);
|
|
106
|
+
this._channel.on("pageError", ({ error, page }) => {
|
|
107
|
+
const pageObject = import_page.Page.from(page);
|
|
108
|
+
const parsedError = (0, import_errors.parseError)(error);
|
|
109
|
+
this.emit(import_events.Events.BrowserContext.WebError, new import_webError.WebError(pageObject, parsedError));
|
|
110
|
+
if (pageObject)
|
|
111
|
+
pageObject.emit(import_events.Events.Page.PageError, parsedError);
|
|
132
112
|
});
|
|
133
|
-
this._channel.on(
|
|
134
|
-
dialog
|
|
135
|
-
|
|
136
|
-
const dialogObject = _dialog.Dialog.from(dialog);
|
|
137
|
-
let hasListeners = this.emit(_events.Events.BrowserContext.Dialog, dialogObject);
|
|
113
|
+
this._channel.on("dialog", ({ dialog }) => {
|
|
114
|
+
const dialogObject = import_dialog.Dialog.from(dialog);
|
|
115
|
+
let hasListeners = this.emit(import_events.Events.BrowserContext.Dialog, dialogObject);
|
|
138
116
|
const page = dialogObject.page();
|
|
139
|
-
if (page)
|
|
117
|
+
if (page)
|
|
118
|
+
hasListeners = page.emit(import_events.Events.Page.Dialog, dialogObject) || hasListeners;
|
|
140
119
|
if (!hasListeners) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
120
|
+
if (dialogObject.type() === "beforeunload")
|
|
121
|
+
dialog.accept({}).catch(() => {
|
|
122
|
+
});
|
|
123
|
+
else
|
|
124
|
+
dialog.dismiss().catch(() => {
|
|
125
|
+
});
|
|
146
126
|
}
|
|
147
127
|
});
|
|
148
|
-
this._channel.on(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}) => this.
|
|
152
|
-
this.
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
128
|
+
this._channel.on("request", ({ request, page }) => this._onRequest(network.Request.from(request), import_page.Page.fromNullable(page)));
|
|
129
|
+
this._channel.on("requestFailed", ({ request, failureText, responseEndTiming, page }) => this._onRequestFailed(network.Request.from(request), responseEndTiming, failureText, import_page.Page.fromNullable(page)));
|
|
130
|
+
this._channel.on("requestFinished", (params) => this._onRequestFinished(params));
|
|
131
|
+
this._channel.on("response", ({ response, page }) => this._onResponse(network.Response.from(response), import_page.Page.fromNullable(page)));
|
|
132
|
+
this._closedPromise = new Promise((f) => this.once(import_events.Events.BrowserContext.Close, f));
|
|
133
|
+
this._setEventToSubscriptionMapping(/* @__PURE__ */ new Map([
|
|
134
|
+
[import_events.Events.BrowserContext.Console, "console"],
|
|
135
|
+
[import_events.Events.BrowserContext.Dialog, "dialog"],
|
|
136
|
+
[import_events.Events.BrowserContext.Request, "request"],
|
|
137
|
+
[import_events.Events.BrowserContext.Response, "response"],
|
|
138
|
+
[import_events.Events.BrowserContext.RequestFinished, "requestFinished"],
|
|
139
|
+
[import_events.Events.BrowserContext.RequestFailed, "requestFailed"]
|
|
140
|
+
]));
|
|
141
|
+
}
|
|
142
|
+
static from(context) {
|
|
143
|
+
return context._object;
|
|
144
|
+
}
|
|
145
|
+
static fromNullable(context) {
|
|
146
|
+
return context ? BrowserContext.from(context) : null;
|
|
165
147
|
}
|
|
166
148
|
_setOptions(contextOptions, browserOptions) {
|
|
167
149
|
this._options = contextOptions;
|
|
168
|
-
if (this._options.recordHar)
|
|
169
|
-
path: this._options.recordHar.path,
|
|
170
|
-
content: this._options.recordHar.content
|
|
171
|
-
});
|
|
150
|
+
if (this._options.recordHar)
|
|
151
|
+
this._harRecorders.set("", { path: this._options.recordHar.path, content: this._options.recordHar.content });
|
|
172
152
|
this.tracing._tracesDir = browserOptions.tracesDir;
|
|
173
153
|
}
|
|
174
154
|
_onPage(page) {
|
|
175
155
|
this._pages.add(page);
|
|
176
|
-
this.emit(
|
|
177
|
-
if (page._opener && !page._opener.isClosed())
|
|
156
|
+
this.emit(import_events.Events.BrowserContext.Page, page);
|
|
157
|
+
if (page._opener && !page._opener.isClosed())
|
|
158
|
+
page._opener.emit(import_events.Events.Page.Popup, page);
|
|
178
159
|
}
|
|
179
160
|
_onRequest(request, page) {
|
|
180
|
-
this.emit(
|
|
181
|
-
if (page)
|
|
161
|
+
this.emit(import_events.Events.BrowserContext.Request, request);
|
|
162
|
+
if (page)
|
|
163
|
+
page.emit(import_events.Events.Page.Request, request);
|
|
182
164
|
}
|
|
183
165
|
_onResponse(response, page) {
|
|
184
|
-
this.emit(
|
|
185
|
-
if (page)
|
|
166
|
+
this.emit(import_events.Events.BrowserContext.Response, response);
|
|
167
|
+
if (page)
|
|
168
|
+
page.emit(import_events.Events.Page.Response, response);
|
|
186
169
|
}
|
|
187
170
|
_onRequestFailed(request, responseEndTiming, failureText, page) {
|
|
188
171
|
request._failureText = failureText || null;
|
|
189
172
|
request._setResponseEndTiming(responseEndTiming);
|
|
190
|
-
this.emit(
|
|
191
|
-
if (page)
|
|
173
|
+
this.emit(import_events.Events.BrowserContext.RequestFailed, request);
|
|
174
|
+
if (page)
|
|
175
|
+
page.emit(import_events.Events.Page.RequestFailed, request);
|
|
192
176
|
}
|
|
193
177
|
_onRequestFinished(params) {
|
|
194
|
-
const {
|
|
195
|
-
responseEndTiming
|
|
196
|
-
} = params;
|
|
178
|
+
const { responseEndTiming } = params;
|
|
197
179
|
const request = network.Request.from(params.request);
|
|
198
180
|
const response = network.Response.fromNullable(params.response);
|
|
199
|
-
const page =
|
|
181
|
+
const page = import_page.Page.fromNullable(params.page);
|
|
200
182
|
request._setResponseEndTiming(responseEndTiming);
|
|
201
|
-
this.emit(
|
|
202
|
-
if (page)
|
|
203
|
-
|
|
183
|
+
this.emit(import_events.Events.BrowserContext.RequestFinished, request);
|
|
184
|
+
if (page)
|
|
185
|
+
page.emit(import_events.Events.Page.RequestFinished, request);
|
|
186
|
+
if (response)
|
|
187
|
+
response._finishedPromise.resolve(null);
|
|
204
188
|
}
|
|
205
189
|
async _onRoute(route) {
|
|
206
190
|
route._context = this;
|
|
207
191
|
const page = route.request()._safePage();
|
|
208
192
|
const routeHandlers = this._routes.slice();
|
|
209
193
|
for (const routeHandler of routeHandlers) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
if (!routeHandler.matches(route.request().url()))
|
|
194
|
+
if (page?._closeWasCalled || this._closeWasCalled)
|
|
195
|
+
return;
|
|
196
|
+
if (!routeHandler.matches(route.request().url()))
|
|
197
|
+
continue;
|
|
213
198
|
const index = this._routes.indexOf(routeHandler);
|
|
214
|
-
if (index === -1)
|
|
215
|
-
|
|
199
|
+
if (index === -1)
|
|
200
|
+
continue;
|
|
201
|
+
if (routeHandler.willExpire())
|
|
202
|
+
this._routes.splice(index, 1);
|
|
216
203
|
const handled = await routeHandler.handle(route);
|
|
217
|
-
if (!this._routes.length)
|
|
218
|
-
|
|
204
|
+
if (!this._routes.length)
|
|
205
|
+
this._wrapApiCall(() => this._updateInterceptionPatterns(), true).catch(() => {
|
|
206
|
+
});
|
|
207
|
+
if (handled)
|
|
208
|
+
return;
|
|
219
209
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
210
|
+
await route._innerContinue(
|
|
211
|
+
true
|
|
212
|
+
/* isFallback */
|
|
213
|
+
).catch(() => {
|
|
214
|
+
});
|
|
223
215
|
}
|
|
224
216
|
async _onWebSocketRoute(webSocketRoute) {
|
|
225
|
-
const routeHandler = this._webSocketRoutes.find(route => route.matches(webSocketRoute.url()));
|
|
226
|
-
if (routeHandler)
|
|
217
|
+
const routeHandler = this._webSocketRoutes.find((route) => route.matches(webSocketRoute.url()));
|
|
218
|
+
if (routeHandler)
|
|
219
|
+
await routeHandler.handle(webSocketRoute);
|
|
220
|
+
else
|
|
221
|
+
webSocketRoute.connectToServer();
|
|
227
222
|
}
|
|
228
223
|
async _onBinding(bindingCall) {
|
|
229
224
|
const func = this._bindings.get(bindingCall._initializer.name);
|
|
230
|
-
if (!func)
|
|
225
|
+
if (!func)
|
|
226
|
+
return;
|
|
231
227
|
await bindingCall.call(func);
|
|
232
228
|
}
|
|
233
229
|
setDefaultNavigationTimeout(timeout) {
|
|
234
230
|
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
235
231
|
this._wrapApiCall(async () => {
|
|
236
|
-
this._channel.setDefaultNavigationTimeoutNoReply({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
}, true);
|
|
232
|
+
await this._channel.setDefaultNavigationTimeoutNoReply({ timeout });
|
|
233
|
+
}, true).catch(() => {
|
|
234
|
+
});
|
|
240
235
|
}
|
|
241
236
|
setDefaultTimeout(timeout) {
|
|
242
237
|
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
243
238
|
this._wrapApiCall(async () => {
|
|
244
|
-
this._channel.setDefaultTimeoutNoReply({
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
}, true);
|
|
239
|
+
await this._channel.setDefaultTimeoutNoReply({ timeout });
|
|
240
|
+
}, true).catch(() => {
|
|
241
|
+
});
|
|
248
242
|
}
|
|
249
243
|
browser() {
|
|
250
244
|
return this._browser;
|
|
@@ -253,86 +247,67 @@ class BrowserContext extends _channelOwner.ChannelOwner {
|
|
|
253
247
|
return [...this._pages];
|
|
254
248
|
}
|
|
255
249
|
async newPage() {
|
|
256
|
-
if (this._ownerPage)
|
|
257
|
-
|
|
250
|
+
if (this._ownerPage)
|
|
251
|
+
throw new Error("Please use browser.newContext()");
|
|
252
|
+
return import_page.Page.from((await this._channel.newPage()).page);
|
|
258
253
|
}
|
|
259
254
|
async cookies(urls) {
|
|
260
|
-
if (!urls)
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
urls
|
|
264
|
-
})).cookies;
|
|
255
|
+
if (!urls)
|
|
256
|
+
urls = [];
|
|
257
|
+
if (urls && typeof urls === "string")
|
|
258
|
+
urls = [urls];
|
|
259
|
+
return (await this._channel.cookies({ urls })).cookies;
|
|
265
260
|
}
|
|
266
261
|
async addCookies(cookies) {
|
|
267
|
-
await this._channel.addCookies({
|
|
268
|
-
cookies
|
|
269
|
-
});
|
|
262
|
+
await this._channel.addCookies({ cookies });
|
|
270
263
|
}
|
|
271
264
|
async clearCookies(options = {}) {
|
|
272
265
|
await this._channel.clearCookies({
|
|
273
|
-
name: (0,
|
|
274
|
-
nameRegexSource: (0,
|
|
275
|
-
nameRegexFlags: (0,
|
|
276
|
-
domain: (0,
|
|
277
|
-
domainRegexSource: (0,
|
|
278
|
-
domainRegexFlags: (0,
|
|
279
|
-
path: (0,
|
|
280
|
-
pathRegexSource: (0,
|
|
281
|
-
pathRegexFlags: (0,
|
|
266
|
+
name: (0, import_rtti.isString)(options.name) ? options.name : void 0,
|
|
267
|
+
nameRegexSource: (0, import_rtti.isRegExp)(options.name) ? options.name.source : void 0,
|
|
268
|
+
nameRegexFlags: (0, import_rtti.isRegExp)(options.name) ? options.name.flags : void 0,
|
|
269
|
+
domain: (0, import_rtti.isString)(options.domain) ? options.domain : void 0,
|
|
270
|
+
domainRegexSource: (0, import_rtti.isRegExp)(options.domain) ? options.domain.source : void 0,
|
|
271
|
+
domainRegexFlags: (0, import_rtti.isRegExp)(options.domain) ? options.domain.flags : void 0,
|
|
272
|
+
path: (0, import_rtti.isString)(options.path) ? options.path : void 0,
|
|
273
|
+
pathRegexSource: (0, import_rtti.isRegExp)(options.path) ? options.path.source : void 0,
|
|
274
|
+
pathRegexFlags: (0, import_rtti.isRegExp)(options.path) ? options.path.flags : void 0
|
|
282
275
|
});
|
|
283
276
|
}
|
|
284
277
|
async grantPermissions(permissions, options) {
|
|
285
|
-
await this._channel.grantPermissions({
|
|
286
|
-
permissions,
|
|
287
|
-
...options
|
|
288
|
-
});
|
|
278
|
+
await this._channel.grantPermissions({ permissions, ...options });
|
|
289
279
|
}
|
|
290
280
|
async clearPermissions() {
|
|
291
281
|
await this._channel.clearPermissions();
|
|
292
282
|
}
|
|
293
283
|
async setGeolocation(geolocation) {
|
|
294
|
-
await this._channel.setGeolocation({
|
|
295
|
-
geolocation: geolocation || undefined
|
|
296
|
-
});
|
|
284
|
+
await this._channel.setGeolocation({ geolocation: geolocation || void 0 });
|
|
297
285
|
}
|
|
298
286
|
async setExtraHTTPHeaders(headers) {
|
|
299
287
|
network.validateHeaders(headers);
|
|
300
|
-
await this._channel.setExtraHTTPHeaders({
|
|
301
|
-
headers: (0, _utils.headersObjectToArray)(headers)
|
|
302
|
-
});
|
|
288
|
+
await this._channel.setExtraHTTPHeaders({ headers: (0, import_headers.headersObjectToArray)(headers) });
|
|
303
289
|
}
|
|
304
290
|
async setOffline(offline) {
|
|
305
|
-
await this._channel.setOffline({
|
|
306
|
-
offline
|
|
307
|
-
});
|
|
291
|
+
await this._channel.setOffline({ offline });
|
|
308
292
|
}
|
|
309
293
|
async setHTTPCredentials(httpCredentials) {
|
|
310
|
-
await this._channel.setHTTPCredentials({
|
|
311
|
-
httpCredentials: httpCredentials || undefined
|
|
312
|
-
});
|
|
294
|
+
await this._channel.setHTTPCredentials({ httpCredentials: httpCredentials || void 0 });
|
|
313
295
|
}
|
|
314
296
|
async addInitScript(script, arg) {
|
|
315
|
-
const source = await (0,
|
|
316
|
-
await this._channel.addInitScript({
|
|
317
|
-
source
|
|
318
|
-
});
|
|
297
|
+
const source = await (0, import_clientHelper.evaluationScript)(this._platform, script, arg);
|
|
298
|
+
await this._channel.addInitScript({ source });
|
|
319
299
|
}
|
|
320
300
|
async exposeBinding(name, callback, options = {}) {
|
|
321
|
-
await this._channel.exposeBinding({
|
|
322
|
-
name,
|
|
323
|
-
needsHandle: options.handle
|
|
324
|
-
});
|
|
301
|
+
await this._channel.exposeBinding({ name, needsHandle: options.handle });
|
|
325
302
|
this._bindings.set(name, callback);
|
|
326
303
|
}
|
|
327
304
|
async exposeFunction(name, callback) {
|
|
328
|
-
await this._channel.exposeBinding({
|
|
329
|
-
name
|
|
330
|
-
});
|
|
305
|
+
await this._channel.exposeBinding({ name });
|
|
331
306
|
const binding = (source, ...args) => callback(...args);
|
|
332
307
|
this._bindings.set(name, binding);
|
|
333
308
|
}
|
|
334
309
|
async route(url, handler, options = {}) {
|
|
335
|
-
this._routes.unshift(new network.RouteHandler(this._options.baseURL, url, handler, options.times));
|
|
310
|
+
this._routes.unshift(new network.RouteHandler(this._platform, this._options.baseURL, url, handler, options.times));
|
|
336
311
|
await this._updateInterceptionPatterns();
|
|
337
312
|
}
|
|
338
313
|
async routeWebSocket(url, handler) {
|
|
@@ -340,90 +315,85 @@ class BrowserContext extends _channelOwner.ChannelOwner {
|
|
|
340
315
|
await this._updateWebSocketInterceptionPatterns();
|
|
341
316
|
}
|
|
342
317
|
async _recordIntoHAR(har, page, options = {}) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
harId
|
|
346
|
-
} = await this._channel.harStart({
|
|
347
|
-
page: page === null || page === void 0 ? void 0 : page._channel,
|
|
318
|
+
const { harId } = await this._channel.harStart({
|
|
319
|
+
page: page?._channel,
|
|
348
320
|
options: prepareRecordHarOptions({
|
|
349
321
|
path: har,
|
|
350
|
-
content:
|
|
351
|
-
mode:
|
|
322
|
+
content: options.updateContent ?? "attach",
|
|
323
|
+
mode: options.updateMode ?? "minimal",
|
|
352
324
|
urlFilter: options.url
|
|
353
325
|
})
|
|
354
326
|
});
|
|
355
|
-
this._harRecorders.set(harId, {
|
|
356
|
-
path: har,
|
|
357
|
-
content: (_options$updateConten2 = options.updateContent) !== null && _options$updateConten2 !== void 0 ? _options$updateConten2 : 'attach'
|
|
358
|
-
});
|
|
327
|
+
this._harRecorders.set(harId, { path: har, content: options.updateContent ?? "attach" });
|
|
359
328
|
}
|
|
360
329
|
async routeFromHAR(har, options = {}) {
|
|
330
|
+
const localUtils = this._connection.localUtils();
|
|
331
|
+
if (!localUtils)
|
|
332
|
+
throw new Error("Route from har is not supported in thin clients");
|
|
361
333
|
if (options.update) {
|
|
362
334
|
await this._recordIntoHAR(har, null, options);
|
|
363
335
|
return;
|
|
364
336
|
}
|
|
365
|
-
const harRouter = await
|
|
366
|
-
urlMatch: options.url
|
|
367
|
-
});
|
|
337
|
+
const harRouter = await import_harRouter.HarRouter.create(localUtils, har, options.notFound || "abort", { urlMatch: options.url });
|
|
368
338
|
this._harRouters.push(harRouter);
|
|
369
339
|
await harRouter.addContextRoute(this);
|
|
370
340
|
}
|
|
371
341
|
_disposeHarRouters() {
|
|
372
|
-
this._harRouters.forEach(router => router.dispose());
|
|
342
|
+
this._harRouters.forEach((router) => router.dispose());
|
|
373
343
|
this._harRouters = [];
|
|
374
344
|
}
|
|
375
345
|
async unrouteAll(options) {
|
|
376
|
-
await this._unrouteInternal(this._routes, [], options
|
|
346
|
+
await this._unrouteInternal(this._routes, [], options?.behavior);
|
|
377
347
|
this._disposeHarRouters();
|
|
378
348
|
}
|
|
379
349
|
async unroute(url, handler) {
|
|
380
350
|
const removed = [];
|
|
381
351
|
const remaining = [];
|
|
382
352
|
for (const route of this._routes) {
|
|
383
|
-
if ((0,
|
|
353
|
+
if ((0, import_urlMatch.urlMatchesEqual)(route.url, url) && (!handler || route.handler === handler))
|
|
354
|
+
removed.push(route);
|
|
355
|
+
else
|
|
356
|
+
remaining.push(route);
|
|
384
357
|
}
|
|
385
|
-
await this._unrouteInternal(removed, remaining,
|
|
358
|
+
await this._unrouteInternal(removed, remaining, "default");
|
|
386
359
|
}
|
|
387
360
|
async _unrouteInternal(removed, remaining, behavior) {
|
|
388
361
|
this._routes = remaining;
|
|
389
362
|
await this._updateInterceptionPatterns();
|
|
390
|
-
if (!behavior || behavior ===
|
|
391
|
-
|
|
363
|
+
if (!behavior || behavior === "default")
|
|
364
|
+
return;
|
|
365
|
+
const promises = removed.map((routeHandler) => routeHandler.stop(behavior));
|
|
392
366
|
await Promise.all(promises);
|
|
393
367
|
}
|
|
394
368
|
async _updateInterceptionPatterns() {
|
|
395
369
|
const patterns = network.RouteHandler.prepareInterceptionPatterns(this._routes);
|
|
396
|
-
await this._channel.setNetworkInterceptionPatterns({
|
|
397
|
-
patterns
|
|
398
|
-
});
|
|
370
|
+
await this._channel.setNetworkInterceptionPatterns({ patterns });
|
|
399
371
|
}
|
|
400
372
|
async _updateWebSocketInterceptionPatterns() {
|
|
401
373
|
const patterns = network.WebSocketRouteHandler.prepareInterceptionPatterns(this._webSocketRoutes);
|
|
402
|
-
await this._channel.setWebSocketInterceptionPatterns({
|
|
403
|
-
patterns
|
|
404
|
-
});
|
|
374
|
+
await this._channel.setWebSocketInterceptionPatterns({ patterns });
|
|
405
375
|
}
|
|
406
376
|
_effectiveCloseReason() {
|
|
407
|
-
|
|
408
|
-
return this._closeReason || ((_this$_browser3 = this._browser) === null || _this$_browser3 === void 0 ? void 0 : _this$_browser3._closeReason);
|
|
377
|
+
return this._closeReason || this._browser?._closeReason;
|
|
409
378
|
}
|
|
410
379
|
async waitForEvent(event, optionsOrPredicate = {}) {
|
|
411
380
|
return await this._wrapApiCall(async () => {
|
|
412
|
-
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate ===
|
|
413
|
-
const predicate = typeof optionsOrPredicate ===
|
|
414
|
-
const waiter =
|
|
381
|
+
const timeout = this._timeoutSettings.timeout(typeof optionsOrPredicate === "function" ? {} : optionsOrPredicate);
|
|
382
|
+
const predicate = typeof optionsOrPredicate === "function" ? optionsOrPredicate : optionsOrPredicate.predicate;
|
|
383
|
+
const waiter = import_waiter.Waiter.createForEvent(this, event);
|
|
415
384
|
waiter.rejectOnTimeout(timeout, `Timeout ${timeout}ms exceeded while waiting for event "${event}"`);
|
|
416
|
-
if (event !==
|
|
385
|
+
if (event !== import_events.Events.BrowserContext.Close)
|
|
386
|
+
waiter.rejectOnEvent(this, import_events.Events.BrowserContext.Close, () => new import_errors.TargetClosedError(this._effectiveCloseReason()));
|
|
417
387
|
const result = await waiter.waitForEvent(this, event, predicate);
|
|
418
388
|
waiter.dispose();
|
|
419
389
|
return result;
|
|
420
390
|
});
|
|
421
391
|
}
|
|
422
392
|
async storageState(options = {}) {
|
|
423
|
-
const state = await this._channel.storageState();
|
|
393
|
+
const state = await this._channel.storageState({ indexedDB: options.indexedDB });
|
|
424
394
|
if (options.path) {
|
|
425
|
-
await (0,
|
|
426
|
-
await
|
|
395
|
+
await (0, import_fileUtils.mkdirIfNeeded)(this._platform, options.path);
|
|
396
|
+
await this._platform.fs().promises.writeFile(options.path, JSON.stringify(state, void 0, 2), "utf8");
|
|
427
397
|
}
|
|
428
398
|
return state;
|
|
429
399
|
}
|
|
@@ -434,50 +404,43 @@ class BrowserContext extends _channelOwner.ChannelOwner {
|
|
|
434
404
|
return [...this._serviceWorkers];
|
|
435
405
|
}
|
|
436
406
|
async newCDPSession(page) {
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
const result = await this._channel.newCDPSession(page instanceof
|
|
440
|
-
|
|
441
|
-
} : {
|
|
442
|
-
frame: page._channel
|
|
443
|
-
});
|
|
444
|
-
return _cdpSession.CDPSession.from(result.session);
|
|
407
|
+
if (!(page instanceof import_page.Page) && !(page instanceof import_frame.Frame))
|
|
408
|
+
throw new Error("page: expected Page or Frame");
|
|
409
|
+
const result = await this._channel.newCDPSession(page instanceof import_page.Page ? { page: page._channel } : { frame: page._channel });
|
|
410
|
+
return import_cdpSession.CDPSession.from(result.session);
|
|
445
411
|
}
|
|
446
412
|
_onClose() {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
413
|
+
if (this._browser)
|
|
414
|
+
this._browser._contexts.delete(this);
|
|
415
|
+
this._browserType?._contexts?.delete(this);
|
|
450
416
|
this._disposeHarRouters();
|
|
451
417
|
this.tracing._resetStackCounter();
|
|
452
|
-
this.emit(
|
|
418
|
+
this.emit(import_events.Events.BrowserContext.Close, this);
|
|
453
419
|
}
|
|
454
|
-
async [
|
|
420
|
+
async [Symbol.asyncDispose]() {
|
|
455
421
|
await this.close();
|
|
456
422
|
}
|
|
457
423
|
async close(options = {}) {
|
|
458
|
-
if (this._closeWasCalled)
|
|
424
|
+
if (this._closeWasCalled)
|
|
425
|
+
return;
|
|
459
426
|
this._closeReason = options.reason;
|
|
460
427
|
this._closeWasCalled = true;
|
|
461
428
|
await this._wrapApiCall(async () => {
|
|
462
429
|
await this.request.dispose(options);
|
|
463
430
|
}, true);
|
|
464
431
|
await this._wrapApiCall(async () => {
|
|
465
|
-
|
|
466
|
-
await ((_this$_browserType2 = this._browserType) === null || _this$_browserType2 === void 0 ? void 0 : _this$_browserType2._willCloseContext(this));
|
|
432
|
+
await this._browserType?._willCloseContext(this);
|
|
467
433
|
for (const [harId, harParams] of this._harRecorders) {
|
|
468
|
-
const har = await this._channel.harExport({
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
// Server side will compress artifact if content is attach or if file is .zip.
|
|
473
|
-
const isCompressed = harParams.content === 'attach' || harParams.path.endsWith('.zip');
|
|
474
|
-
const needCompressed = harParams.path.endsWith('.zip');
|
|
434
|
+
const har = await this._channel.harExport({ harId });
|
|
435
|
+
const artifact = import_artifact.Artifact.from(har.artifact);
|
|
436
|
+
const isCompressed = harParams.content === "attach" || harParams.path.endsWith(".zip");
|
|
437
|
+
const needCompressed = harParams.path.endsWith(".zip");
|
|
475
438
|
if (isCompressed && !needCompressed) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
});
|
|
439
|
+
const localUtils = this._connection.localUtils();
|
|
440
|
+
if (!localUtils)
|
|
441
|
+
throw new Error("Uncompressed har is not supported in thin clients");
|
|
442
|
+
await artifact.saveAs(harParams.path + ".tmp");
|
|
443
|
+
await localUtils.harUnzip({ zipFile: harParams.path + ".tmp", harFile: harParams.path });
|
|
481
444
|
} else {
|
|
482
445
|
await artifact.saveAs(harParams.path);
|
|
483
446
|
}
|
|
@@ -491,43 +454,48 @@ class BrowserContext extends _channelOwner.ChannelOwner {
|
|
|
491
454
|
await this._channel.enableRecorder(params);
|
|
492
455
|
}
|
|
493
456
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
457
|
+
async function prepareStorageState(platform, options) {
|
|
458
|
+
if (typeof options.storageState !== "string")
|
|
459
|
+
return options.storageState;
|
|
497
460
|
try {
|
|
498
|
-
return JSON.parse(await
|
|
461
|
+
return JSON.parse(await platform.fs().promises.readFile(options.storageState, "utf8"));
|
|
499
462
|
} catch (e) {
|
|
500
|
-
(0,
|
|
463
|
+
(0, import_stackTrace.rewriteErrorMessage)(e, `Error reading storage state from ${options.storageState}:
|
|
464
|
+
` + e.message);
|
|
501
465
|
throw e;
|
|
502
466
|
}
|
|
503
467
|
}
|
|
504
468
|
function prepareRecordHarOptions(options) {
|
|
505
|
-
if (!options)
|
|
469
|
+
if (!options)
|
|
470
|
+
return;
|
|
506
471
|
return {
|
|
507
472
|
path: options.path,
|
|
508
|
-
content: options.content || (options.omitContent ?
|
|
509
|
-
urlGlob: (0,
|
|
510
|
-
urlRegexSource: (0,
|
|
511
|
-
urlRegexFlags: (0,
|
|
473
|
+
content: options.content || (options.omitContent ? "omit" : void 0),
|
|
474
|
+
urlGlob: (0, import_rtti.isString)(options.urlFilter) ? options.urlFilter : void 0,
|
|
475
|
+
urlRegexSource: (0, import_rtti.isRegExp)(options.urlFilter) ? options.urlFilter.source : void 0,
|
|
476
|
+
urlRegexFlags: (0, import_rtti.isRegExp)(options.urlFilter) ? options.urlFilter.flags : void 0,
|
|
512
477
|
mode: options.mode
|
|
513
478
|
};
|
|
514
479
|
}
|
|
515
|
-
async function prepareBrowserContextParams(options) {
|
|
516
|
-
if (options.videoSize && !options.videosPath)
|
|
517
|
-
|
|
480
|
+
async function prepareBrowserContextParams(platform, options) {
|
|
481
|
+
if (options.videoSize && !options.videosPath)
|
|
482
|
+
throw new Error(`"videoSize" option requires "videosPath" to be specified`);
|
|
483
|
+
if (options.extraHTTPHeaders)
|
|
484
|
+
network.validateHeaders(options.extraHTTPHeaders);
|
|
518
485
|
const contextParams = {
|
|
519
486
|
...options,
|
|
520
|
-
viewport: options.viewport === null ?
|
|
487
|
+
viewport: options.viewport === null ? void 0 : options.viewport,
|
|
521
488
|
noDefaultViewport: options.viewport === null,
|
|
522
|
-
extraHTTPHeaders: options.extraHTTPHeaders ? (0,
|
|
523
|
-
storageState: await prepareStorageState(options),
|
|
489
|
+
extraHTTPHeaders: options.extraHTTPHeaders ? (0, import_headers.headersObjectToArray)(options.extraHTTPHeaders) : void 0,
|
|
490
|
+
storageState: await prepareStorageState(platform, options),
|
|
524
491
|
serviceWorkers: options.serviceWorkers,
|
|
525
492
|
recordHar: prepareRecordHarOptions(options.recordHar),
|
|
526
|
-
colorScheme: options.colorScheme === null ?
|
|
527
|
-
reducedMotion: options.reducedMotion === null ?
|
|
528
|
-
forcedColors: options.forcedColors === null ?
|
|
493
|
+
colorScheme: options.colorScheme === null ? "no-override" : options.colorScheme,
|
|
494
|
+
reducedMotion: options.reducedMotion === null ? "no-override" : options.reducedMotion,
|
|
495
|
+
forcedColors: options.forcedColors === null ? "no-override" : options.forcedColors,
|
|
496
|
+
contrast: options.contrast === null ? "no-override" : options.contrast,
|
|
529
497
|
acceptDownloads: toAcceptDownloadsProtocol(options.acceptDownloads),
|
|
530
|
-
clientCertificates: await toClientCertificatesProtocol(options.clientCertificates)
|
|
498
|
+
clientCertificates: await toClientCertificatesProtocol(platform, options.clientCertificates)
|
|
531
499
|
};
|
|
532
500
|
if (!contextParams.recordVideo && options.videosPath) {
|
|
533
501
|
contextParams.recordVideo = {
|
|
@@ -535,25 +503,37 @@ async function prepareBrowserContextParams(options) {
|
|
|
535
503
|
size: options.videoSize
|
|
536
504
|
};
|
|
537
505
|
}
|
|
538
|
-
if (contextParams.recordVideo && contextParams.recordVideo.dir)
|
|
506
|
+
if (contextParams.recordVideo && contextParams.recordVideo.dir)
|
|
507
|
+
contextParams.recordVideo.dir = platform.path().resolve(contextParams.recordVideo.dir);
|
|
539
508
|
return contextParams;
|
|
540
509
|
}
|
|
541
510
|
function toAcceptDownloadsProtocol(acceptDownloads) {
|
|
542
|
-
if (acceptDownloads ===
|
|
543
|
-
|
|
544
|
-
|
|
511
|
+
if (acceptDownloads === void 0)
|
|
512
|
+
return void 0;
|
|
513
|
+
if (acceptDownloads)
|
|
514
|
+
return "accept";
|
|
515
|
+
return "deny";
|
|
545
516
|
}
|
|
546
|
-
async function toClientCertificatesProtocol(certs) {
|
|
547
|
-
if (!certs)
|
|
517
|
+
async function toClientCertificatesProtocol(platform, certs) {
|
|
518
|
+
if (!certs)
|
|
519
|
+
return void 0;
|
|
548
520
|
const bufferizeContent = async (value, path) => {
|
|
549
|
-
if (value)
|
|
550
|
-
|
|
521
|
+
if (value)
|
|
522
|
+
return value;
|
|
523
|
+
if (path)
|
|
524
|
+
return await platform.fs().promises.readFile(path);
|
|
551
525
|
};
|
|
552
|
-
return await Promise.all(certs.map(async cert => ({
|
|
526
|
+
return await Promise.all(certs.map(async (cert) => ({
|
|
553
527
|
origin: cert.origin,
|
|
554
528
|
cert: await bufferizeContent(cert.cert, cert.certPath),
|
|
555
529
|
key: await bufferizeContent(cert.key, cert.keyPath),
|
|
556
530
|
pfx: await bufferizeContent(cert.pfx, cert.pfxPath),
|
|
557
531
|
passphrase: cert.passphrase
|
|
558
532
|
})));
|
|
559
|
-
}
|
|
533
|
+
}
|
|
534
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
535
|
+
0 && (module.exports = {
|
|
536
|
+
BrowserContext,
|
|
537
|
+
prepareBrowserContextParams,
|
|
538
|
+
toClientCertificatesProtocol
|
|
539
|
+
});
|