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,91 +1,109 @@
|
|
|
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
|
+
assertBrowserContextIsNotOwned: () => assertBrowserContextIsNotOwned,
|
|
33
|
+
normalizeProxySettings: () => normalizeProxySettings,
|
|
34
|
+
validateBrowserContextOptions: () => validateBrowserContextOptions,
|
|
35
|
+
verifyClientCertificates: () => verifyClientCertificates,
|
|
36
|
+
verifyGeolocation: () => verifyGeolocation
|
|
5
37
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
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); }
|
|
31
|
-
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; }
|
|
32
|
-
/**
|
|
33
|
-
* Copyright 2017 Google Inc. All rights reserved.
|
|
34
|
-
* Modifications copyright (c) Microsoft Corporation.
|
|
35
|
-
*
|
|
36
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
37
|
-
* you may not use this file except in compliance with the License.
|
|
38
|
-
* You may obtain a copy of the License at
|
|
39
|
-
*
|
|
40
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
41
|
-
*
|
|
42
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
43
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
44
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
45
|
-
* See the License for the specific language governing permissions and
|
|
46
|
-
* limitations under the License.
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
class BrowserContext extends _instrumentation.SdkObject {
|
|
38
|
+
module.exports = __toCommonJS(browserContext_exports);
|
|
39
|
+
var import_fs = __toESM(require("fs"));
|
|
40
|
+
var import_path = __toESM(require("path"));
|
|
41
|
+
var import_timeoutSettings = require("./timeoutSettings");
|
|
42
|
+
var import_crypto = require("./utils/crypto");
|
|
43
|
+
var import_debug = require("./utils/debug");
|
|
44
|
+
var import_clock = require("./clock");
|
|
45
|
+
var import_debugger = require("./debugger");
|
|
46
|
+
var import_fetch = require("./fetch");
|
|
47
|
+
var import_fileUtils = require("./utils/fileUtils");
|
|
48
|
+
var import_harRecorder = require("./har/harRecorder");
|
|
49
|
+
var import_helper = require("./helper");
|
|
50
|
+
var import_instrumentation = require("./instrumentation");
|
|
51
|
+
var import_builtins = require("../utils/isomorphic/builtins");
|
|
52
|
+
var utilityScriptSerializers = __toESM(require("../utils/isomorphic/utilityScriptSerializers"));
|
|
53
|
+
var network = __toESM(require("./network"));
|
|
54
|
+
var import_page = require("./page");
|
|
55
|
+
var import_page2 = require("./page");
|
|
56
|
+
var import_recorder = require("./recorder");
|
|
57
|
+
var import_recorderApp = require("./recorder/recorderApp");
|
|
58
|
+
var storageScript = __toESM(require("./storageScript"));
|
|
59
|
+
var consoleApiSource = __toESM(require("../generated/consoleApiSource"));
|
|
60
|
+
var import_tracing = require("./trace/recorder/tracing");
|
|
61
|
+
class BrowserContext extends import_instrumentation.SdkObject {
|
|
50
62
|
constructor(browser, options, browserContextId) {
|
|
51
|
-
super(browser,
|
|
52
|
-
this._timeoutSettings = new
|
|
53
|
-
this._pageBindings = new Map();
|
|
54
|
-
this._activeProgressControllers = new Set();
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
59
|
-
this.
|
|
60
|
-
this._closePromiseFulfill = void 0;
|
|
61
|
-
this._permissions = new Map();
|
|
62
|
-
this._downloads = new Set();
|
|
63
|
-
this._browser = void 0;
|
|
64
|
-
this._browserContextId = void 0;
|
|
65
|
-
this._selectors = void 0;
|
|
66
|
-
this._origins = new Set();
|
|
67
|
-
this._harRecorders = new Map();
|
|
68
|
-
this.tracing = void 0;
|
|
69
|
-
this.fetchRequest = void 0;
|
|
70
|
-
this._customCloseHandler = void 0;
|
|
63
|
+
super(browser, "browser-context");
|
|
64
|
+
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings();
|
|
65
|
+
this._pageBindings = /* @__PURE__ */ new Map();
|
|
66
|
+
this._activeProgressControllers = /* @__PURE__ */ new Set();
|
|
67
|
+
this._closedStatus = "open";
|
|
68
|
+
this._permissions = /* @__PURE__ */ new Map();
|
|
69
|
+
this._downloads = /* @__PURE__ */ new Set();
|
|
70
|
+
this._origins = /* @__PURE__ */ new Set();
|
|
71
|
+
this._harRecorders = /* @__PURE__ */ new Map();
|
|
71
72
|
this._tempDirs = [];
|
|
72
73
|
this._settingStorageState = false;
|
|
73
74
|
this.initScripts = [];
|
|
74
|
-
this._routesInFlight = new Set();
|
|
75
|
-
this._debugger = void 0;
|
|
76
|
-
this._closeReason = void 0;
|
|
77
|
-
this.clock = void 0;
|
|
78
|
-
this._clientCertificatesProxy = void 0;
|
|
75
|
+
this._routesInFlight = /* @__PURE__ */ new Set();
|
|
79
76
|
this.attribution.context = this;
|
|
80
77
|
this._browser = browser;
|
|
81
78
|
this._options = options;
|
|
82
79
|
this._browserContextId = browserContextId;
|
|
83
80
|
this._isPersistentContext = !browserContextId;
|
|
84
|
-
this._closePromise = new Promise(fulfill => this._closePromiseFulfill = fulfill);
|
|
85
|
-
this.fetchRequest = new
|
|
86
|
-
if (this._options.recordHar)
|
|
87
|
-
|
|
88
|
-
this.
|
|
81
|
+
this._closePromise = new Promise((fulfill) => this._closePromiseFulfill = fulfill);
|
|
82
|
+
this.fetchRequest = new import_fetch.BrowserContextAPIRequestContext(this);
|
|
83
|
+
if (this._options.recordHar)
|
|
84
|
+
this._harRecorders.set("", new import_harRecorder.HarRecorder(this, null, this._options.recordHar));
|
|
85
|
+
this.tracing = new import_tracing.Tracing(this, browser.options.tracesDir);
|
|
86
|
+
this.clock = new import_clock.Clock(this);
|
|
87
|
+
}
|
|
88
|
+
static {
|
|
89
|
+
this.Events = {
|
|
90
|
+
Console: "console",
|
|
91
|
+
Close: "close",
|
|
92
|
+
Dialog: "dialog",
|
|
93
|
+
Page: "page",
|
|
94
|
+
// Can't use just 'error' due to node.js special treatment of error events.
|
|
95
|
+
// @see https://nodejs.org/api/events.html#events_error_events
|
|
96
|
+
PageError: "pageerror",
|
|
97
|
+
Request: "request",
|
|
98
|
+
Response: "response",
|
|
99
|
+
RequestFailed: "requestfailed",
|
|
100
|
+
RequestFinished: "requestfinished",
|
|
101
|
+
RequestAborted: "requestaborted",
|
|
102
|
+
RequestFulfilled: "requestfulfilled",
|
|
103
|
+
RequestContinued: "requestcontinued",
|
|
104
|
+
BeforeClose: "beforeclose",
|
|
105
|
+
VideoStarted: "videostarted"
|
|
106
|
+
};
|
|
89
107
|
}
|
|
90
108
|
isPersistentContext() {
|
|
91
109
|
return this._isPersistentContext;
|
|
@@ -97,160 +115,167 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
97
115
|
return this._selectors || this.attribution.playwright.selectors;
|
|
98
116
|
}
|
|
99
117
|
async _initialize() {
|
|
100
|
-
if (this.attribution.playwright.options.isInternalPlaywright)
|
|
101
|
-
|
|
102
|
-
this._debugger = new
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
if (this._debugger.isPaused()) _recorder.Recorder.showInspectorNoReply(this, _recorderApp.RecorderApp.factory(this));
|
|
111
|
-
this._debugger.on(_debugger.Debugger.Events.PausedStateChanged, () => {
|
|
112
|
-
if (this._debugger.isPaused()) _recorder.Recorder.showInspectorNoReply(this, _recorderApp.RecorderApp.factory(this));
|
|
118
|
+
if (this.attribution.playwright.options.isInternalPlaywright)
|
|
119
|
+
return;
|
|
120
|
+
this._debugger = new import_debugger.Debugger(this);
|
|
121
|
+
if ((0, import_debug.debugMode)() === "inspector")
|
|
122
|
+
await import_recorder.Recorder.show(this, import_recorderApp.RecorderApp.factory(this), { pauseOnNextStatement: true });
|
|
123
|
+
if (this._debugger.isPaused())
|
|
124
|
+
import_recorder.Recorder.showInspectorNoReply(this, import_recorderApp.RecorderApp.factory(this));
|
|
125
|
+
this._debugger.on(import_debugger.Debugger.Events.PausedStateChanged, () => {
|
|
126
|
+
if (this._debugger.isPaused())
|
|
127
|
+
import_recorder.Recorder.showInspectorNoReply(this, import_recorderApp.RecorderApp.factory(this));
|
|
113
128
|
});
|
|
114
|
-
if ((0,
|
|
115
|
-
|
|
116
|
-
if (this._options.
|
|
129
|
+
if ((0, import_debug.debugMode)() === "console")
|
|
130
|
+
await this.extendInjectedScript(consoleApiSource.source);
|
|
131
|
+
if (this._options.serviceWorkers === "block")
|
|
132
|
+
await this.addInitScript(`
|
|
133
|
+
if (navigator.serviceWorker) navigator.serviceWorker.register = async () => { console.warn('Service Worker registration blocked by Playwright'); };
|
|
134
|
+
`);
|
|
135
|
+
if (this._options.permissions)
|
|
136
|
+
await this.grantPermissions(this._options.permissions);
|
|
117
137
|
}
|
|
118
138
|
debugger() {
|
|
119
139
|
return this._debugger;
|
|
120
140
|
}
|
|
121
141
|
async _ensureVideosPath() {
|
|
122
|
-
if (this._options.recordVideo)
|
|
142
|
+
if (this._options.recordVideo)
|
|
143
|
+
await (0, import_fileUtils.mkdirIfNeeded)(import_path.default.join(this._options.recordVideo.dir, "dummy"));
|
|
123
144
|
}
|
|
124
145
|
canResetForReuse() {
|
|
125
|
-
if (this._closedStatus !==
|
|
146
|
+
if (this._closedStatus !== "open")
|
|
147
|
+
return false;
|
|
126
148
|
return true;
|
|
127
149
|
}
|
|
128
150
|
async stopPendingOperations(reason) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
// Let rejections in microtask generate events before returning.
|
|
133
|
-
await new Promise(f => setTimeout(f, 0));
|
|
151
|
+
for (const controller of this._activeProgressControllers)
|
|
152
|
+
controller.abort(new Error(reason));
|
|
153
|
+
await new Promise((f) => setTimeout(f, 0));
|
|
134
154
|
}
|
|
135
155
|
static reusableContextHash(params) {
|
|
136
|
-
const paramsCopy = {
|
|
137
|
-
...params
|
|
138
|
-
};
|
|
156
|
+
const paramsCopy = { ...params };
|
|
139
157
|
for (const k of Object.keys(paramsCopy)) {
|
|
140
158
|
const key = k;
|
|
141
|
-
if (paramsCopy[key] === defaultNewContextParamValues[key])
|
|
159
|
+
if (paramsCopy[key] === defaultNewContextParamValues[key])
|
|
160
|
+
delete paramsCopy[key];
|
|
142
161
|
}
|
|
143
|
-
for (const key of paramsThatAllowContextReuse)
|
|
162
|
+
for (const key of paramsThatAllowContextReuse)
|
|
163
|
+
delete paramsCopy[key];
|
|
144
164
|
return JSON.stringify(paramsCopy);
|
|
145
165
|
}
|
|
146
166
|
async resetForReuse(metadata, params) {
|
|
147
|
-
|
|
148
|
-
this.
|
|
149
|
-
this.setDefaultTimeout(undefined);
|
|
167
|
+
this.setDefaultNavigationTimeout(void 0);
|
|
168
|
+
this.setDefaultTimeout(void 0);
|
|
150
169
|
this.tracing.resetForReuse();
|
|
151
170
|
if (params) {
|
|
152
|
-
for (const key of paramsThatAllowContextReuse)
|
|
171
|
+
for (const key of paramsThatAllowContextReuse)
|
|
172
|
+
this._options[key] = params[key];
|
|
153
173
|
}
|
|
154
174
|
await this._cancelAllRoutesInFlight();
|
|
155
|
-
|
|
156
|
-
// Close extra pages early.
|
|
157
175
|
let page = this.pages()[0];
|
|
158
176
|
const [, ...otherPages] = this.pages();
|
|
159
|
-
for (const p of otherPages)
|
|
177
|
+
for (const p of otherPages)
|
|
178
|
+
await p.close(metadata);
|
|
160
179
|
if (page && page.hasCrashed()) {
|
|
161
180
|
await page.close(metadata);
|
|
162
|
-
page =
|
|
181
|
+
page = void 0;
|
|
163
182
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
// Navigate to about:blank first to ensure no page scripts are running after this point.
|
|
169
|
-
await ((_page3 = page) === null || _page3 === void 0 ? void 0 : _page3.mainFrame().goto(metadata, 'about:blank', {
|
|
170
|
-
timeout: 0
|
|
171
|
-
}));
|
|
172
|
-
(_page4 = page) === null || _page4 === void 0 || _page4._frameManager.setCloseAllOpeningDialogs(false);
|
|
183
|
+
page?._frameManager.setCloseAllOpeningDialogs(true);
|
|
184
|
+
await page?._frameManager.closeOpenDialogs();
|
|
185
|
+
await page?.mainFrame().goto(metadata, "about:blank", { timeout: 0 });
|
|
186
|
+
page?._frameManager.setCloseAllOpeningDialogs(false);
|
|
173
187
|
await this._resetStorage();
|
|
174
188
|
await this._removeExposedBindings();
|
|
175
189
|
await this._removeInitScripts();
|
|
176
190
|
this.clock.markAsUninstalled();
|
|
177
|
-
|
|
178
|
-
|
|
191
|
+
if (this._options.permissions)
|
|
192
|
+
await this.grantPermissions(this._options.permissions);
|
|
193
|
+
else
|
|
194
|
+
await this.clearPermissions();
|
|
179
195
|
await this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || []);
|
|
180
196
|
await this.setGeolocation(this._options.geolocation);
|
|
181
197
|
await this.setOffline(!!this._options.offline);
|
|
182
198
|
await this.setUserAgent(this._options.userAgent);
|
|
183
199
|
await this.clearCache();
|
|
184
200
|
await this._resetCookies();
|
|
185
|
-
await
|
|
201
|
+
await page?.resetForReuse(metadata);
|
|
186
202
|
}
|
|
187
203
|
_browserClosed() {
|
|
188
|
-
for (const page of this.pages())
|
|
204
|
+
for (const page of this.pages())
|
|
205
|
+
page._didClose();
|
|
189
206
|
this._didCloseInternal();
|
|
190
207
|
}
|
|
191
208
|
_didCloseInternal() {
|
|
192
|
-
|
|
193
|
-
if (this._closedStatus === 'closed') {
|
|
194
|
-
// We can come here twice if we close browser context and browser
|
|
195
|
-
// at the same time.
|
|
209
|
+
if (this._closedStatus === "closed") {
|
|
196
210
|
return;
|
|
197
211
|
}
|
|
198
|
-
|
|
212
|
+
this._clientCertificatesProxy?.close().catch(() => {
|
|
213
|
+
});
|
|
199
214
|
this.tracing.abort();
|
|
200
|
-
if (this._isPersistentContext)
|
|
201
|
-
|
|
215
|
+
if (this._isPersistentContext)
|
|
216
|
+
this.onClosePersistent();
|
|
217
|
+
this._closePromiseFulfill(new Error("Context closed"));
|
|
202
218
|
this.emit(BrowserContext.Events.Close);
|
|
203
219
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
220
|
+
pages() {
|
|
221
|
+
return this.possiblyUninitializedPages().filter((page) => page.initializedOrUndefined());
|
|
222
|
+
}
|
|
207
223
|
async cookies(urls = []) {
|
|
208
|
-
if (urls && !Array.isArray(urls))
|
|
224
|
+
if (urls && !Array.isArray(urls))
|
|
225
|
+
urls = [urls];
|
|
209
226
|
return await this.doGetCookies(urls);
|
|
210
227
|
}
|
|
211
228
|
async clearCookies(options) {
|
|
212
229
|
const currentCookies = await this.cookies();
|
|
213
230
|
await this.doClearCookies();
|
|
214
231
|
const matches = (cookie, prop, value) => {
|
|
215
|
-
if (!value)
|
|
232
|
+
if (!value)
|
|
233
|
+
return true;
|
|
216
234
|
if (value instanceof RegExp) {
|
|
217
235
|
value.lastIndex = 0;
|
|
218
236
|
return value.test(cookie[prop]);
|
|
219
237
|
}
|
|
220
238
|
return cookie[prop] === value;
|
|
221
239
|
};
|
|
222
|
-
const cookiesToReadd = currentCookies.filter(cookie => {
|
|
223
|
-
return !matches(cookie,
|
|
240
|
+
const cookiesToReadd = currentCookies.filter((cookie) => {
|
|
241
|
+
return !matches(cookie, "name", options.name) || !matches(cookie, "domain", options.domain) || !matches(cookie, "path", options.path);
|
|
224
242
|
});
|
|
225
243
|
await this.addCookies(cookiesToReadd);
|
|
226
244
|
}
|
|
227
245
|
setHTTPCredentials(httpCredentials) {
|
|
228
246
|
return this.doSetHTTPCredentials(httpCredentials);
|
|
229
247
|
}
|
|
248
|
+
hasBinding(name) {
|
|
249
|
+
return this._pageBindings.has(name);
|
|
250
|
+
}
|
|
230
251
|
async exposeBinding(name, needsHandle, playwrightBinding) {
|
|
231
|
-
if (this._pageBindings.has(name))
|
|
252
|
+
if (this._pageBindings.has(name))
|
|
253
|
+
throw new Error(`Function "${name}" has been already registered`);
|
|
232
254
|
for (const page of this.pages()) {
|
|
233
|
-
if (page.getBinding(name))
|
|
255
|
+
if (page.getBinding(name))
|
|
256
|
+
throw new Error(`Function "${name}" has been already registered in one of the pages`);
|
|
234
257
|
}
|
|
235
|
-
const binding = new
|
|
258
|
+
const binding = new import_page2.PageBinding(name, playwrightBinding, needsHandle);
|
|
236
259
|
this._pageBindings.set(name, binding);
|
|
237
260
|
await this.doAddInitScript(binding.initScript);
|
|
238
|
-
const frames = this.pages().map(page => page.frames()).flat();
|
|
239
|
-
await Promise.all(frames.map(frame => frame.evaluateExpression(binding.initScript.source).catch(e => {
|
|
261
|
+
const frames = this.pages().map((page) => page.frames()).flat();
|
|
262
|
+
await Promise.all(frames.map((frame) => frame.evaluateExpression(binding.initScript.source).catch((e) => {
|
|
263
|
+
})));
|
|
240
264
|
}
|
|
241
265
|
async _removeExposedBindings() {
|
|
242
266
|
for (const [key, binding] of this._pageBindings) {
|
|
243
|
-
if (!binding.internal)
|
|
267
|
+
if (!binding.internal)
|
|
268
|
+
this._pageBindings.delete(key);
|
|
244
269
|
}
|
|
245
270
|
}
|
|
246
271
|
async grantPermissions(permissions, origin) {
|
|
247
|
-
let resolvedOrigin =
|
|
272
|
+
let resolvedOrigin = "*";
|
|
248
273
|
if (origin) {
|
|
249
274
|
const url = new URL(origin);
|
|
250
275
|
resolvedOrigin = url.origin;
|
|
251
276
|
}
|
|
252
277
|
const existing = new Set(this._permissions.get(resolvedOrigin) || []);
|
|
253
|
-
permissions.forEach(p => existing.add(p));
|
|
278
|
+
permissions.forEach((p) => existing.add(p));
|
|
254
279
|
const list = [...existing.values()];
|
|
255
280
|
this._permissions.set(resolvedOrigin, list);
|
|
256
281
|
await this.doGrantPermissions(resolvedOrigin, list);
|
|
@@ -266,66 +291,57 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
266
291
|
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
267
292
|
}
|
|
268
293
|
async _loadDefaultContextAsIs(progress) {
|
|
269
|
-
if (!this.
|
|
270
|
-
const waitForEvent =
|
|
294
|
+
if (!this.possiblyUninitializedPages().length) {
|
|
295
|
+
const waitForEvent = import_helper.helper.waitForEvent(progress, this, BrowserContext.Events.Page);
|
|
271
296
|
progress.cleanupWhenAborted(() => waitForEvent.dispose);
|
|
272
|
-
|
|
273
|
-
if (page._pageIsError) throw page._pageIsError;
|
|
297
|
+
await Promise.race([waitForEvent.promise, this._closePromise]);
|
|
274
298
|
}
|
|
275
|
-
const
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
299
|
+
const page = this.possiblyUninitializedPages()[0];
|
|
300
|
+
if (!page)
|
|
301
|
+
return;
|
|
302
|
+
const pageOrError = await page.waitForInitializedOrError();
|
|
303
|
+
if (pageOrError instanceof Error)
|
|
304
|
+
throw pageOrError;
|
|
305
|
+
await page.mainFrame()._waitForLoadState(progress, "load");
|
|
306
|
+
return page;
|
|
279
307
|
}
|
|
280
308
|
async _loadDefaultContext(progress) {
|
|
281
|
-
const
|
|
309
|
+
const defaultPage = await this._loadDefaultContextAsIs(progress);
|
|
310
|
+
if (!defaultPage)
|
|
311
|
+
return;
|
|
282
312
|
const browserName = this._browser.options.name;
|
|
283
|
-
if (this._options.isMobile && browserName ===
|
|
284
|
-
// Workaround for:
|
|
285
|
-
// - chromium fails to change isMobile for existing page;
|
|
286
|
-
// - webkit fails to change locale for existing page.
|
|
287
|
-
const oldPage = pages[0];
|
|
313
|
+
if (this._options.isMobile && browserName === "chromium" || this._options.locale && browserName === "webkit") {
|
|
288
314
|
await this.newPage(progress.metadata);
|
|
289
|
-
await
|
|
315
|
+
await defaultPage.close(progress.metadata);
|
|
290
316
|
}
|
|
291
317
|
}
|
|
292
318
|
_authenticateProxyViaHeader() {
|
|
293
|
-
const proxy = this._options.proxy || this._browser.options.proxy || {
|
|
294
|
-
|
|
295
|
-
password: undefined
|
|
296
|
-
};
|
|
297
|
-
const {
|
|
298
|
-
username,
|
|
299
|
-
password
|
|
300
|
-
} = proxy;
|
|
319
|
+
const proxy = this._options.proxy || this._browser.options.proxy || { username: void 0, password: void 0 };
|
|
320
|
+
const { username, password } = proxy;
|
|
301
321
|
if (username) {
|
|
302
|
-
this._options.httpCredentials = {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
322
|
+
this._options.httpCredentials = { username, password };
|
|
323
|
+
const token = Buffer.from(`${username}:${password}`).toString("base64");
|
|
324
|
+
this._options.extraHTTPHeaders = network.mergeHeaders([
|
|
325
|
+
this._options.extraHTTPHeaders,
|
|
326
|
+
network.singleHeader("Proxy-Authorization", `Basic ${token}`)
|
|
327
|
+
]);
|
|
308
328
|
}
|
|
309
329
|
}
|
|
310
330
|
_authenticateProxyViaCredentials() {
|
|
311
331
|
const proxy = this._options.proxy || this._browser.options.proxy;
|
|
312
|
-
if (!proxy)
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (username) this._options.httpCredentials = {
|
|
318
|
-
username,
|
|
319
|
-
password: password || ''
|
|
320
|
-
};
|
|
332
|
+
if (!proxy)
|
|
333
|
+
return;
|
|
334
|
+
const { username, password } = proxy;
|
|
335
|
+
if (username)
|
|
336
|
+
this._options.httpCredentials = { username, password: password || "" };
|
|
321
337
|
}
|
|
322
|
-
async addInitScript(source) {
|
|
323
|
-
const initScript = new
|
|
338
|
+
async addInitScript(source, name) {
|
|
339
|
+
const initScript = new import_page.InitScript(source, false, name);
|
|
324
340
|
this.initScripts.push(initScript);
|
|
325
341
|
await this.doAddInitScript(initScript);
|
|
326
342
|
}
|
|
327
343
|
async _removeInitScripts() {
|
|
328
|
-
this.initScripts = this.initScripts.filter(script => script.internal);
|
|
344
|
+
this.initScripts = this.initScripts.filter((script) => script.internal);
|
|
329
345
|
await this.doRemoveNonInternalInitScripts();
|
|
330
346
|
}
|
|
331
347
|
async setRequestInterceptor(handler) {
|
|
@@ -333,58 +349,53 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
333
349
|
await this.doUpdateRequestInterception();
|
|
334
350
|
}
|
|
335
351
|
isClosingOrClosed() {
|
|
336
|
-
return this._closedStatus !==
|
|
352
|
+
return this._closedStatus !== "open";
|
|
337
353
|
}
|
|
338
354
|
async _deleteAllDownloads() {
|
|
339
|
-
await Promise.all(Array.from(this._downloads).map(download => download.artifact.deleteOnContextClose()));
|
|
355
|
+
await Promise.all(Array.from(this._downloads).map((download) => download.artifact.deleteOnContextClose()));
|
|
340
356
|
}
|
|
341
357
|
async _deleteAllTempDirs() {
|
|
342
|
-
await Promise.all(this._tempDirs.map(async dir => await
|
|
358
|
+
await Promise.all(this._tempDirs.map(async (dir) => await import_fs.default.promises.unlink(dir).catch((e) => {
|
|
359
|
+
})));
|
|
343
360
|
}
|
|
344
361
|
setCustomCloseHandler(handler) {
|
|
345
362
|
this._customCloseHandler = handler;
|
|
346
363
|
}
|
|
347
364
|
async close(options) {
|
|
348
|
-
if (this._closedStatus ===
|
|
349
|
-
if (options.reason)
|
|
365
|
+
if (this._closedStatus === "open") {
|
|
366
|
+
if (options.reason)
|
|
367
|
+
this._closeReason = options.reason;
|
|
350
368
|
this.emit(BrowserContext.Events.BeforeClose);
|
|
351
|
-
this._closedStatus =
|
|
352
|
-
for (const harRecorder of this._harRecorders.values())
|
|
369
|
+
this._closedStatus = "closing";
|
|
370
|
+
for (const harRecorder of this._harRecorders.values())
|
|
371
|
+
await harRecorder.flush();
|
|
353
372
|
await this.tracing.flush();
|
|
354
|
-
|
|
355
|
-
// Cleanup.
|
|
356
373
|
const promises = [];
|
|
357
|
-
for (const {
|
|
358
|
-
context
|
|
359
|
-
|
|
360
|
-
} of this._browser._idToVideo.values()) {
|
|
361
|
-
// Wait for the videos to finish.
|
|
362
|
-
if (context === this) promises.push(artifact.finishedPromise());
|
|
374
|
+
for (const { context, artifact } of this._browser._idToVideo.values()) {
|
|
375
|
+
if (context === this)
|
|
376
|
+
promises.push(artifact.finishedPromise());
|
|
363
377
|
}
|
|
364
378
|
if (this._customCloseHandler) {
|
|
365
379
|
await this._customCloseHandler();
|
|
366
380
|
} else {
|
|
367
|
-
// Close the context.
|
|
368
381
|
await this.doClose(options.reason);
|
|
369
382
|
}
|
|
370
|
-
|
|
371
|
-
// We delete downloads after context closure
|
|
372
|
-
// so that browser does not write to the download file anymore.
|
|
373
383
|
promises.push(this._deleteAllDownloads());
|
|
374
384
|
promises.push(this._deleteAllTempDirs());
|
|
375
385
|
await Promise.all(promises);
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
if (!this._customCloseHandler) this._didCloseInternal();
|
|
386
|
+
if (!this._customCloseHandler)
|
|
387
|
+
this._didCloseInternal();
|
|
379
388
|
}
|
|
380
389
|
await this._closePromise;
|
|
381
390
|
}
|
|
382
391
|
async newPage(metadata) {
|
|
383
|
-
const
|
|
384
|
-
if (metadata.isServerSide)
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
392
|
+
const page = await this.doCreateNewPage();
|
|
393
|
+
if (metadata.isServerSide)
|
|
394
|
+
page.markAsServerSideOnly();
|
|
395
|
+
const pageOrError = await page.waitForInitializedOrError();
|
|
396
|
+
if (pageOrError instanceof import_page2.Page) {
|
|
397
|
+
if (pageOrError.isClosed())
|
|
398
|
+
throw new Error("Page has been closed.");
|
|
388
399
|
return pageOrError;
|
|
389
400
|
}
|
|
390
401
|
throw pageOrError;
|
|
@@ -392,92 +403,74 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
392
403
|
addVisitedOrigin(origin) {
|
|
393
404
|
this._origins.add(origin);
|
|
394
405
|
}
|
|
395
|
-
async storageState() {
|
|
406
|
+
async storageState(indexedDB = false) {
|
|
396
407
|
const result = {
|
|
397
408
|
cookies: await this.cookies(),
|
|
398
409
|
origins: []
|
|
399
410
|
};
|
|
400
411
|
const originsToSave = new Set(this._origins);
|
|
401
|
-
|
|
402
|
-
// First try collecting storage stage from existing pages.
|
|
412
|
+
const collectScript = `(${storageScript.collect})(${utilityScriptSerializers.source}, (${import_builtins.builtins})(), ${this._browser.options.name === "firefox"}, ${indexedDB})`;
|
|
403
413
|
for (const page of this.pages()) {
|
|
404
414
|
const origin = page.mainFrame().origin();
|
|
405
|
-
if (!origin || !originsToSave.has(origin))
|
|
415
|
+
if (!origin || !originsToSave.has(origin))
|
|
416
|
+
continue;
|
|
406
417
|
try {
|
|
407
|
-
const storage = await page.mainFrame().nonStallingEvaluateInExistingContext(
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
if (storage.localStorage.length) result.origins.push({
|
|
411
|
-
origin,
|
|
412
|
-
localStorage: storage.localStorage
|
|
413
|
-
});
|
|
418
|
+
const storage = await page.mainFrame().nonStallingEvaluateInExistingContext(collectScript, "utility");
|
|
419
|
+
if (storage.localStorage.length || storage.indexedDB?.length)
|
|
420
|
+
result.origins.push({ origin, localStorage: storage.localStorage, indexedDB: storage.indexedDB });
|
|
414
421
|
originsToSave.delete(origin);
|
|
415
422
|
} catch {
|
|
416
|
-
// When failed on the live page, we'll retry on the blank page below.
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
|
-
|
|
420
|
-
// If there are still origins to save, create a blank page to iterate over origins.
|
|
421
425
|
if (originsToSave.size) {
|
|
422
|
-
const internalMetadata = (0,
|
|
426
|
+
const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
|
|
423
427
|
const page = await this.newPage(internalMetadata);
|
|
424
|
-
await page._setServerRequestInterceptor(handler => {
|
|
425
|
-
handler.fulfill({
|
|
426
|
-
|
|
427
|
-
}).catch(() => {});
|
|
428
|
+
await page._setServerRequestInterceptor((handler) => {
|
|
429
|
+
handler.fulfill({ body: "<html></html>" }).catch(() => {
|
|
430
|
+
});
|
|
428
431
|
return true;
|
|
429
432
|
});
|
|
430
433
|
for (const origin of originsToSave) {
|
|
431
|
-
const originStorage = {
|
|
432
|
-
origin,
|
|
433
|
-
localStorage: []
|
|
434
|
-
};
|
|
435
434
|
const frame = page.mainFrame();
|
|
436
435
|
await frame.goto(internalMetadata, origin);
|
|
437
|
-
const storage = await frame.evaluateExpression(
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
world: 'utility'
|
|
441
|
-
});
|
|
442
|
-
originStorage.localStorage = storage.localStorage;
|
|
443
|
-
if (storage.localStorage.length) result.origins.push(originStorage);
|
|
436
|
+
const storage = await frame.evaluateExpression(collectScript, { world: "utility" });
|
|
437
|
+
if (storage.localStorage.length || storage.indexedDB?.length)
|
|
438
|
+
result.origins.push({ origin, localStorage: storage.localStorage, indexedDB: storage.indexedDB });
|
|
444
439
|
}
|
|
445
440
|
await page.close(internalMetadata);
|
|
446
441
|
}
|
|
447
442
|
return result;
|
|
448
443
|
}
|
|
449
444
|
async _resetStorage() {
|
|
450
|
-
var _this$_options$storag;
|
|
451
445
|
const oldOrigins = this._origins;
|
|
452
|
-
const newOrigins = new Map(
|
|
453
|
-
if (!oldOrigins.size && !newOrigins.size)
|
|
446
|
+
const newOrigins = new Map(this._options.storageState?.origins?.map((p) => [p.origin, p]) || []);
|
|
447
|
+
if (!oldOrigins.size && !newOrigins.size)
|
|
448
|
+
return;
|
|
454
449
|
let page = this.pages()[0];
|
|
455
|
-
const internalMetadata = (0,
|
|
456
|
-
page = page ||
|
|
450
|
+
const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
|
|
451
|
+
page = page || await this.newPage({
|
|
457
452
|
...internalMetadata,
|
|
458
453
|
// Do not mark this page as internal, because we will leave it for later reuse
|
|
459
454
|
// as a user-visible page.
|
|
460
455
|
isServerSide: false
|
|
461
|
-
})
|
|
462
|
-
await page._setServerRequestInterceptor(handler => {
|
|
463
|
-
handler.fulfill({
|
|
464
|
-
|
|
465
|
-
}).catch(() => {});
|
|
456
|
+
});
|
|
457
|
+
await page._setServerRequestInterceptor((handler) => {
|
|
458
|
+
handler.fulfill({ body: "<html></html>" }).catch(() => {
|
|
459
|
+
});
|
|
466
460
|
return true;
|
|
467
461
|
});
|
|
468
|
-
for (const origin of new Set([...oldOrigins, ...newOrigins.keys()])) {
|
|
462
|
+
for (const origin of /* @__PURE__ */ new Set([...oldOrigins, ...newOrigins.keys()])) {
|
|
469
463
|
const frame = page.mainFrame();
|
|
470
464
|
await frame.goto(internalMetadata, origin);
|
|
471
465
|
await frame.resetStorageForCurrentOriginBestEffort(newOrigins.get(origin));
|
|
472
466
|
}
|
|
473
|
-
await page._setServerRequestInterceptor(
|
|
474
|
-
this._origins = new Set([...newOrigins.keys()]);
|
|
475
|
-
// It is safe to not restore the URL to about:blank since we are doing it in Page::resetForReuse.
|
|
467
|
+
await page._setServerRequestInterceptor(void 0);
|
|
468
|
+
this._origins = /* @__PURE__ */ new Set([...newOrigins.keys()]);
|
|
476
469
|
}
|
|
477
470
|
async _resetCookies() {
|
|
478
|
-
var _this$_options$storag2, _this$_options$storag3;
|
|
479
471
|
await this.doClearCookies();
|
|
480
|
-
if (
|
|
472
|
+
if (this._options.storageState?.cookies)
|
|
473
|
+
await this.addCookies(this._options.storageState?.cookies);
|
|
481
474
|
}
|
|
482
475
|
isSettingStorageState() {
|
|
483
476
|
return this._settingStorageState;
|
|
@@ -485,27 +478,20 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
485
478
|
async setStorageState(metadata, state) {
|
|
486
479
|
this._settingStorageState = true;
|
|
487
480
|
try {
|
|
488
|
-
if (state.cookies)
|
|
481
|
+
if (state.cookies)
|
|
482
|
+
await this.addCookies(state.cookies);
|
|
489
483
|
if (state.origins && state.origins.length) {
|
|
490
|
-
const internalMetadata = (0,
|
|
484
|
+
const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
|
|
491
485
|
const page = await this.newPage(internalMetadata);
|
|
492
|
-
await page._setServerRequestInterceptor(handler => {
|
|
493
|
-
handler.fulfill({
|
|
494
|
-
|
|
495
|
-
}).catch(() => {});
|
|
486
|
+
await page._setServerRequestInterceptor((handler) => {
|
|
487
|
+
handler.fulfill({ body: "<html></html>" }).catch(() => {
|
|
488
|
+
});
|
|
496
489
|
return true;
|
|
497
490
|
});
|
|
498
491
|
for (const originState of state.origins) {
|
|
499
492
|
const frame = page.mainFrame();
|
|
500
493
|
await frame.goto(metadata, originState.origin);
|
|
501
|
-
await frame.evaluateExpression(`
|
|
502
|
-
originState => {
|
|
503
|
-
for (const { name, value } of (originState.localStorage || []))
|
|
504
|
-
localStorage.setItem(name, value);
|
|
505
|
-
}`, {
|
|
506
|
-
isFunction: true,
|
|
507
|
-
world: 'utility'
|
|
508
|
-
}, originState);
|
|
494
|
+
await frame.evaluateExpression(`(${storageScript.restore})(${utilityScriptSerializers.source}, (${import_builtins.builtins})(), ${JSON.stringify(originState)})`, { world: "utility" });
|
|
509
495
|
}
|
|
510
496
|
await page.close(internalMetadata);
|
|
511
497
|
}
|
|
@@ -514,24 +500,25 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
514
500
|
}
|
|
515
501
|
}
|
|
516
502
|
async extendInjectedScript(source, arg) {
|
|
517
|
-
const installInFrame = frame => frame.extendInjectedScript(source, arg).catch(() => {
|
|
518
|
-
|
|
519
|
-
|
|
503
|
+
const installInFrame = (frame) => frame.extendInjectedScript(source, arg).catch(() => {
|
|
504
|
+
});
|
|
505
|
+
const installInPage = (page) => {
|
|
506
|
+
page.on(import_page2.Page.Events.InternalFrameNavigatedToNewDocument, installInFrame);
|
|
520
507
|
return Promise.all(page.frames().map(installInFrame));
|
|
521
508
|
};
|
|
522
509
|
this.on(BrowserContext.Events.Page, installInPage);
|
|
523
510
|
return Promise.all(this.pages().map(installInPage));
|
|
524
511
|
}
|
|
525
512
|
async safeNonStallingEvaluateInAllFrames(expression, world, options = {}) {
|
|
526
|
-
await Promise.all(this.pages().map(page => page.safeNonStallingEvaluateInAllFrames(expression, world, options)));
|
|
513
|
+
await Promise.all(this.pages().map((page) => page.safeNonStallingEvaluateInAllFrames(expression, world, options)));
|
|
527
514
|
}
|
|
528
515
|
async _harStart(page, options) {
|
|
529
|
-
const harId = (0,
|
|
530
|
-
this._harRecorders.set(harId, new
|
|
516
|
+
const harId = (0, import_crypto.createGuid)();
|
|
517
|
+
this._harRecorders.set(harId, new import_harRecorder.HarRecorder(this, page, options));
|
|
531
518
|
return harId;
|
|
532
519
|
}
|
|
533
520
|
async _harExport(harId) {
|
|
534
|
-
const recorder = this._harRecorders.get(harId ||
|
|
521
|
+
const recorder = this._harRecorders.get(harId || "");
|
|
535
522
|
return recorder.export();
|
|
536
523
|
}
|
|
537
524
|
addRouteInFlight(route) {
|
|
@@ -541,53 +528,32 @@ class BrowserContext extends _instrumentation.SdkObject {
|
|
|
541
528
|
this._routesInFlight.delete(route);
|
|
542
529
|
}
|
|
543
530
|
async _cancelAllRoutesInFlight() {
|
|
544
|
-
await Promise.all([...this._routesInFlight].map(r => r.abort())).catch(() => {
|
|
531
|
+
await Promise.all([...this._routesInFlight].map((r) => r.abort())).catch(() => {
|
|
532
|
+
});
|
|
545
533
|
this._routesInFlight.clear();
|
|
546
534
|
}
|
|
547
535
|
}
|
|
548
|
-
exports.BrowserContext = BrowserContext;
|
|
549
|
-
BrowserContext.Events = {
|
|
550
|
-
Console: 'console',
|
|
551
|
-
Close: 'close',
|
|
552
|
-
Dialog: 'dialog',
|
|
553
|
-
Page: 'page',
|
|
554
|
-
// Can't use just 'error' due to node.js special treatment of error events.
|
|
555
|
-
// @see https://nodejs.org/api/events.html#events_error_events
|
|
556
|
-
PageError: 'pageerror',
|
|
557
|
-
Request: 'request',
|
|
558
|
-
Response: 'response',
|
|
559
|
-
RequestFailed: 'requestfailed',
|
|
560
|
-
RequestFinished: 'requestfinished',
|
|
561
|
-
RequestAborted: 'requestaborted',
|
|
562
|
-
RequestFulfilled: 'requestfulfilled',
|
|
563
|
-
RequestContinued: 'requestcontinued',
|
|
564
|
-
BeforeClose: 'beforeclose',
|
|
565
|
-
VideoStarted: 'videostarted'
|
|
566
|
-
};
|
|
567
536
|
function assertBrowserContextIsNotOwned(context) {
|
|
568
537
|
for (const page of context.pages()) {
|
|
569
|
-
if (page._ownedContext)
|
|
538
|
+
if (page._ownedContext)
|
|
539
|
+
throw new Error("Please use browser.newContext() for multi-page scripts that share the context.");
|
|
570
540
|
}
|
|
571
541
|
}
|
|
572
542
|
function validateBrowserContextOptions(options, browserOptions) {
|
|
573
|
-
if (options.noDefaultViewport && options.deviceScaleFactor !==
|
|
574
|
-
|
|
575
|
-
if (options.
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
else if (options.acceptDownloads ===
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
height: 720
|
|
583
|
-
};
|
|
543
|
+
if (options.noDefaultViewport && options.deviceScaleFactor !== void 0)
|
|
544
|
+
throw new Error(`"deviceScaleFactor" option is not supported with null "viewport"`);
|
|
545
|
+
if (options.noDefaultViewport && !!options.isMobile)
|
|
546
|
+
throw new Error(`"isMobile" option is not supported with null "viewport"`);
|
|
547
|
+
if (options.acceptDownloads === void 0 && browserOptions.name !== "electron")
|
|
548
|
+
options.acceptDownloads = "accept";
|
|
549
|
+
else if (options.acceptDownloads === void 0 && browserOptions.name === "electron")
|
|
550
|
+
options.acceptDownloads = "internal-browser-default";
|
|
551
|
+
if (!options.viewport && !options.noDefaultViewport)
|
|
552
|
+
options.viewport = { width: 1280, height: 720 };
|
|
584
553
|
if (options.recordVideo) {
|
|
585
554
|
if (!options.recordVideo.size) {
|
|
586
555
|
if (options.noDefaultViewport) {
|
|
587
|
-
options.recordVideo.size = {
|
|
588
|
-
width: 800,
|
|
589
|
-
height: 600
|
|
590
|
-
};
|
|
556
|
+
options.recordVideo.size = { width: 800, height: 600 };
|
|
591
557
|
} else {
|
|
592
558
|
const size = options.viewport;
|
|
593
559
|
const scale = Math.min(1, 800 / Math.max(size.width, size.height));
|
|
@@ -597,61 +563,69 @@ function validateBrowserContextOptions(options, browserOptions) {
|
|
|
597
563
|
};
|
|
598
564
|
}
|
|
599
565
|
}
|
|
600
|
-
// Make sure both dimensions are odd, this is required for vp8
|
|
601
566
|
options.recordVideo.size.width &= ~1;
|
|
602
567
|
options.recordVideo.size.height &= ~1;
|
|
603
568
|
}
|
|
604
|
-
if (options.proxy)
|
|
569
|
+
if (options.proxy)
|
|
570
|
+
options.proxy = normalizeProxySettings(options.proxy);
|
|
605
571
|
verifyGeolocation(options.geolocation);
|
|
606
572
|
}
|
|
607
573
|
function verifyGeolocation(geolocation) {
|
|
608
|
-
if (!geolocation)
|
|
574
|
+
if (!geolocation)
|
|
575
|
+
return;
|
|
609
576
|
geolocation.accuracy = geolocation.accuracy || 0;
|
|
610
|
-
const {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
if (
|
|
616
|
-
|
|
617
|
-
if (accuracy < 0) throw new Error(`geolocation.accuracy: precondition 0 <= ACCURACY failed.`);
|
|
577
|
+
const { longitude, latitude, accuracy } = geolocation;
|
|
578
|
+
if (longitude < -180 || longitude > 180)
|
|
579
|
+
throw new Error(`geolocation.longitude: precondition -180 <= LONGITUDE <= 180 failed.`);
|
|
580
|
+
if (latitude < -90 || latitude > 90)
|
|
581
|
+
throw new Error(`geolocation.latitude: precondition -90 <= LATITUDE <= 90 failed.`);
|
|
582
|
+
if (accuracy < 0)
|
|
583
|
+
throw new Error(`geolocation.accuracy: precondition 0 <= ACCURACY failed.`);
|
|
618
584
|
}
|
|
619
585
|
function verifyClientCertificates(clientCertificates) {
|
|
620
|
-
if (!clientCertificates)
|
|
586
|
+
if (!clientCertificates)
|
|
587
|
+
return;
|
|
621
588
|
for (const cert of clientCertificates) {
|
|
622
|
-
if (!cert.origin)
|
|
623
|
-
|
|
624
|
-
if (cert.cert && !cert.key
|
|
625
|
-
|
|
626
|
-
if (cert.
|
|
589
|
+
if (!cert.origin)
|
|
590
|
+
throw new Error(`clientCertificates.origin is required`);
|
|
591
|
+
if (!cert.cert && !cert.key && !cert.passphrase && !cert.pfx)
|
|
592
|
+
throw new Error("None of cert, key, passphrase or pfx is specified");
|
|
593
|
+
if (cert.cert && !cert.key)
|
|
594
|
+
throw new Error("cert is specified without key");
|
|
595
|
+
if (!cert.cert && cert.key)
|
|
596
|
+
throw new Error("key is specified without cert");
|
|
597
|
+
if (cert.pfx && (cert.cert || cert.key))
|
|
598
|
+
throw new Error("pfx is specified together with cert, key or passphrase");
|
|
627
599
|
}
|
|
628
600
|
}
|
|
629
601
|
function normalizeProxySettings(proxy) {
|
|
630
|
-
let {
|
|
631
|
-
server,
|
|
632
|
-
bypass
|
|
633
|
-
} = proxy;
|
|
602
|
+
let { server, bypass } = proxy;
|
|
634
603
|
let url;
|
|
635
604
|
try {
|
|
636
|
-
// new URL('127.0.0.1:8080') throws
|
|
637
|
-
// new URL('localhost:8080') fails to parse host or protocol
|
|
638
|
-
// In both of these cases, we need to try re-parse URL with `http://` prefix.
|
|
639
605
|
url = new URL(server);
|
|
640
|
-
if (!url.host || !url.protocol)
|
|
606
|
+
if (!url.host || !url.protocol)
|
|
607
|
+
url = new URL("http://" + server);
|
|
641
608
|
} catch (e) {
|
|
642
|
-
url = new URL(
|
|
643
|
-
}
|
|
644
|
-
if (url.protocol ===
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
};
|
|
609
|
+
url = new URL("http://" + server);
|
|
610
|
+
}
|
|
611
|
+
if (url.protocol === "socks4:" && (proxy.username || proxy.password))
|
|
612
|
+
throw new Error(`Socks4 proxy protocol does not support authentication`);
|
|
613
|
+
if (url.protocol === "socks5:" && (proxy.username || proxy.password))
|
|
614
|
+
throw new Error(`Browser does not support socks5 proxy authentication`);
|
|
615
|
+
server = url.protocol + "//" + url.host;
|
|
616
|
+
if (bypass)
|
|
617
|
+
bypass = bypass.split(",").map((t) => t.trim()).join(",");
|
|
618
|
+
return { ...proxy, server, bypass };
|
|
653
619
|
}
|
|
654
|
-
const paramsThatAllowContextReuse = [
|
|
620
|
+
const paramsThatAllowContextReuse = [
|
|
621
|
+
"colorScheme",
|
|
622
|
+
"forcedColors",
|
|
623
|
+
"reducedMotion",
|
|
624
|
+
"contrast",
|
|
625
|
+
"screen",
|
|
626
|
+
"userAgent",
|
|
627
|
+
"viewport"
|
|
628
|
+
];
|
|
655
629
|
const defaultNewContextParamValues = {
|
|
656
630
|
noDefaultViewport: false,
|
|
657
631
|
ignoreHTTPSErrors: false,
|
|
@@ -660,8 +634,17 @@ const defaultNewContextParamValues = {
|
|
|
660
634
|
offline: false,
|
|
661
635
|
isMobile: false,
|
|
662
636
|
hasTouch: false,
|
|
663
|
-
acceptDownloads:
|
|
637
|
+
acceptDownloads: "accept",
|
|
664
638
|
strictSelectors: false,
|
|
665
|
-
serviceWorkers:
|
|
666
|
-
locale:
|
|
667
|
-
};
|
|
639
|
+
serviceWorkers: "allow",
|
|
640
|
+
locale: "en-US"
|
|
641
|
+
};
|
|
642
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
643
|
+
0 && (module.exports = {
|
|
644
|
+
BrowserContext,
|
|
645
|
+
assertBrowserContextIsNotOwned,
|
|
646
|
+
normalizeProxySettings,
|
|
647
|
+
validateBrowserContextOptions,
|
|
648
|
+
verifyClientCertificates,
|
|
649
|
+
verifyGeolocation
|
|
650
|
+
});
|