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