@checkly/playwright-core 1.51.17-beta.2 → 1.54.2-beta.1
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 -35
- 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 +89 -112
- 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-B9YMkrwa.js +0 -24
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/recorder/index.html +0 -29
- package/lib/vite/recorder/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/assets/codeMirrorModule-gU1OOCQO.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-B5n_FjMx.js +0 -1
- package/lib/vite/traceViewer/assets/inspectorTab-6Tru8Mn_.js +0 -235
- package/lib/vite/traceViewer/assets/workbench-B_Nj4NA2.js +0 -25
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.CO3FR0CX.css +0 -1
- package/lib/vite/traceViewer/embedded.DpNPH6mk.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.mLhjB5IF.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.CuE3SYGw.js +0 -2
- package/lib/vite/traceViewer/index.html +0 -47
- package/lib/vite/traceViewer/inspectorTab.CXDulcFG.css +0 -1
- package/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/recorder.BD-uZJs7.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/recorder.tn0RQdqM.css +0 -0
- package/lib/vite/traceViewer/snapshot.html +0 -21
- package/lib/vite/traceViewer/sw.bundle.js +0 -3
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.DHrNgddz.js +0 -5
- package/lib/vite/traceViewer/uiMode.html +0 -21
- package/lib/vite/traceViewer/workbench.B9vIAzH9.css +0 -1
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
|
@@ -1,97 +1,98 @@
|
|
|
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 ffBrowser_exports = {};
|
|
30
|
+
__export(ffBrowser_exports, {
|
|
31
|
+
FFBrowser: () => FFBrowser,
|
|
32
|
+
FFBrowserContext: () => FFBrowserContext
|
|
5
33
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var network =
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* limitations under the License.
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
class FFBrowser extends _browser.Browser {
|
|
34
|
+
module.exports = __toCommonJS(ffBrowser_exports);
|
|
35
|
+
var import_utils = require("../../utils");
|
|
36
|
+
var import_browser = require("../browser");
|
|
37
|
+
var import_browserContext = require("../browserContext");
|
|
38
|
+
var import_errors = require("../errors");
|
|
39
|
+
var network = __toESM(require("../network"));
|
|
40
|
+
var import_ffConnection = require("./ffConnection");
|
|
41
|
+
var import_ffPage = require("./ffPage");
|
|
42
|
+
var import_page = require("../page");
|
|
43
|
+
class FFBrowser extends import_browser.Browser {
|
|
44
|
+
constructor(parent, connection, options) {
|
|
45
|
+
super(parent, options);
|
|
46
|
+
this._version = "";
|
|
47
|
+
this._userAgent = "";
|
|
48
|
+
this._connection = connection;
|
|
49
|
+
this.session = connection.rootSession;
|
|
50
|
+
this._ffPages = /* @__PURE__ */ new Map();
|
|
51
|
+
this._contexts = /* @__PURE__ */ new Map();
|
|
52
|
+
this._connection.on(import_ffConnection.ConnectionEvents.Disconnected, () => this._onDisconnect());
|
|
53
|
+
this.session.on("Browser.attachedToTarget", this._onAttachedToTarget.bind(this));
|
|
54
|
+
this.session.on("Browser.detachedFromTarget", this._onDetachedFromTarget.bind(this));
|
|
55
|
+
this.session.on("Browser.downloadCreated", this._onDownloadCreated.bind(this));
|
|
56
|
+
this.session.on("Browser.downloadFinished", this._onDownloadFinished.bind(this));
|
|
57
|
+
this.session.on("Browser.videoRecordingFinished", this._onVideoRecordingFinished.bind(this));
|
|
58
|
+
}
|
|
35
59
|
static async connect(parent, transport, options) {
|
|
36
|
-
|
|
37
|
-
const connection = new _ffConnection.FFConnection(transport, options.protocolLogger, options.browserLogsCollector);
|
|
60
|
+
const connection = new import_ffConnection.FFConnection(transport, options.protocolLogger, options.browserLogsCollector);
|
|
38
61
|
const browser = new FFBrowser(parent, connection, options);
|
|
39
|
-
if (options.__testHookOnConnectToBrowser)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
...firefoxUserPrefs
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}), browser._initVersion()];
|
|
62
|
+
if (options.__testHookOnConnectToBrowser)
|
|
63
|
+
await options.__testHookOnConnectToBrowser();
|
|
64
|
+
let firefoxUserPrefs = options.originalLaunchOptions.firefoxUserPrefs ?? {};
|
|
65
|
+
if (Object.keys(kBandaidFirefoxUserPrefs).length)
|
|
66
|
+
firefoxUserPrefs = { ...kBandaidFirefoxUserPrefs, ...firefoxUserPrefs };
|
|
67
|
+
const promises = [
|
|
68
|
+
browser.session.send("Browser.enable", {
|
|
69
|
+
attachToDefaultContext: !!options.persistent,
|
|
70
|
+
userPrefs: Object.entries(firefoxUserPrefs).map(([name, value]) => ({ name, value }))
|
|
71
|
+
}),
|
|
72
|
+
browser._initVersion()
|
|
73
|
+
];
|
|
52
74
|
if (options.persistent) {
|
|
53
|
-
browser._defaultContext = new FFBrowserContext(browser,
|
|
75
|
+
browser._defaultContext = new FFBrowserContext(browser, void 0, options.persistent);
|
|
54
76
|
promises.push(browser._defaultContext._initialize());
|
|
55
77
|
}
|
|
56
78
|
const proxy = options.originalLaunchOptions.proxyOverride || options.proxy;
|
|
57
|
-
if (proxy)
|
|
79
|
+
if (proxy)
|
|
80
|
+
promises.push(browser.session.send("Browser.setBrowserProxy", toJugglerProxyOptions(proxy)));
|
|
58
81
|
await Promise.all(promises);
|
|
59
82
|
return browser;
|
|
60
83
|
}
|
|
61
|
-
constructor(parent, connection, options) {
|
|
62
|
-
super(parent, options);
|
|
63
|
-
this._connection = void 0;
|
|
64
|
-
this.session = void 0;
|
|
65
|
-
this._ffPages = void 0;
|
|
66
|
-
this._contexts = void 0;
|
|
67
|
-
this._version = '';
|
|
68
|
-
this._userAgent = '';
|
|
69
|
-
this._connection = connection;
|
|
70
|
-
this.session = connection.rootSession;
|
|
71
|
-
this._ffPages = new Map();
|
|
72
|
-
this._contexts = new Map();
|
|
73
|
-
this._connection.on(_ffConnection.ConnectionEvents.Disconnected, () => this._onDisconnect());
|
|
74
|
-
this.session.on('Browser.attachedToTarget', this._onAttachedToTarget.bind(this));
|
|
75
|
-
this.session.on('Browser.detachedFromTarget', this._onDetachedFromTarget.bind(this));
|
|
76
|
-
this.session.on('Browser.downloadCreated', this._onDownloadCreated.bind(this));
|
|
77
|
-
this.session.on('Browser.downloadFinished', this._onDownloadFinished.bind(this));
|
|
78
|
-
this.session.on('Browser.videoRecordingFinished', this._onVideoRecordingFinished.bind(this));
|
|
79
|
-
}
|
|
80
84
|
async _initVersion() {
|
|
81
|
-
const result = await this.session.send(
|
|
82
|
-
this._version = result.version.substring(result.version.indexOf(
|
|
85
|
+
const result = await this.session.send("Browser.getInfo");
|
|
86
|
+
this._version = result.version.substring(result.version.indexOf("/") + 1);
|
|
83
87
|
this._userAgent = result.userAgent;
|
|
84
88
|
}
|
|
85
89
|
isConnected() {
|
|
86
90
|
return !this._connection._closed;
|
|
87
91
|
}
|
|
88
92
|
async doCreateNewContext(options) {
|
|
89
|
-
if (options.isMobile)
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
} = await this.session.send('Browser.createBrowserContext', {
|
|
93
|
-
removeOnDetach: true
|
|
94
|
-
});
|
|
93
|
+
if (options.isMobile)
|
|
94
|
+
throw new Error("options.isMobile is not supported in Firefox");
|
|
95
|
+
const { browserContextId } = await this.session.send("Browser.createBrowserContext", { removeOnDetach: true });
|
|
95
96
|
const context = new FFBrowserContext(this, browserContextId, options);
|
|
96
97
|
await context._initialize();
|
|
97
98
|
this._contexts.set(browserContextId, context);
|
|
@@ -112,147 +113,94 @@ class FFBrowser extends _browser.Browser {
|
|
|
112
113
|
ffPage.didClose();
|
|
113
114
|
}
|
|
114
115
|
_onAttachedToTarget(payload) {
|
|
115
|
-
const {
|
|
116
|
-
|
|
117
|
-
browserContextId,
|
|
118
|
-
openerId,
|
|
119
|
-
type
|
|
120
|
-
} = payload.targetInfo;
|
|
121
|
-
(0, _utils.assert)(type === 'page');
|
|
116
|
+
const { targetId, browserContextId, openerId, type } = payload.targetInfo;
|
|
117
|
+
(0, import_utils.assert)(type === "page");
|
|
122
118
|
const context = browserContextId ? this._contexts.get(browserContextId) : this._defaultContext;
|
|
123
|
-
(0,
|
|
119
|
+
(0, import_utils.assert)(context, `Unknown context id:${browserContextId}, _defaultContext: ${this._defaultContext}`);
|
|
124
120
|
const session = this._connection.createSession(payload.sessionId);
|
|
125
121
|
const opener = openerId ? this._ffPages.get(openerId) : null;
|
|
126
|
-
const ffPage = new
|
|
122
|
+
const ffPage = new import_ffPage.FFPage(session, context, opener);
|
|
127
123
|
this._ffPages.set(targetId, ffPage);
|
|
128
124
|
}
|
|
129
125
|
_onDownloadCreated(payload) {
|
|
130
126
|
const ffPage = this._ffPages.get(payload.pageTargetId);
|
|
131
|
-
if (!ffPage)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
ffPage._page._frameManager.frameAbortedNavigation(payload.frameId, 'Download is starting');
|
|
127
|
+
if (!ffPage)
|
|
128
|
+
return;
|
|
129
|
+
ffPage._page.frameManager.frameAbortedNavigation(payload.frameId, "Download is starting");
|
|
135
130
|
let originPage = ffPage._page.initializedOrUndefined();
|
|
136
|
-
// If it's a new window download, report it on the opener page.
|
|
137
131
|
if (!originPage) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (ffPage._opener) originPage = ffPage._opener._page.initializedOrUndefined();
|
|
132
|
+
ffPage._markAsError(new Error("Starting new page download"));
|
|
133
|
+
if (ffPage._opener)
|
|
134
|
+
originPage = ffPage._opener._page.initializedOrUndefined();
|
|
142
135
|
}
|
|
143
|
-
if (!originPage)
|
|
136
|
+
if (!originPage)
|
|
137
|
+
return;
|
|
144
138
|
this._downloadCreated(originPage, payload.uuid, payload.url, payload.suggestedFileName);
|
|
145
139
|
}
|
|
146
140
|
_onDownloadFinished(payload) {
|
|
147
|
-
const error = payload.canceled ?
|
|
141
|
+
const error = payload.canceled ? "canceled" : payload.error;
|
|
148
142
|
this._downloadFinished(payload.uuid, error);
|
|
149
143
|
}
|
|
150
144
|
_onVideoRecordingFinished(payload) {
|
|
151
|
-
|
|
152
|
-
(_this$_takeVideo = this._takeVideo(payload.screencastId)) === null || _this$_takeVideo === void 0 || _this$_takeVideo.reportFinished();
|
|
145
|
+
this._takeVideo(payload.screencastId)?.reportFinished();
|
|
153
146
|
}
|
|
154
147
|
_onDisconnect() {
|
|
155
|
-
for (const video of this._idToVideo.values())
|
|
148
|
+
for (const video of this._idToVideo.values())
|
|
149
|
+
video.artifact.reportFinished(new import_errors.TargetClosedError());
|
|
156
150
|
this._idToVideo.clear();
|
|
157
|
-
for (const ffPage of this._ffPages.values())
|
|
151
|
+
for (const ffPage of this._ffPages.values())
|
|
152
|
+
ffPage.didClose();
|
|
158
153
|
this._ffPages.clear();
|
|
159
154
|
this._didClose();
|
|
160
155
|
}
|
|
161
156
|
}
|
|
162
|
-
|
|
163
|
-
class FFBrowserContext extends _browserContext.BrowserContext {
|
|
157
|
+
class FFBrowserContext extends import_browserContext.BrowserContext {
|
|
164
158
|
constructor(browser, browserContextId, options) {
|
|
165
159
|
super(browser, options, browserContextId);
|
|
166
160
|
}
|
|
167
161
|
async _initialize() {
|
|
168
|
-
(0,
|
|
162
|
+
(0, import_utils.assert)(!this._ffPages().length);
|
|
169
163
|
const browserContextId = this._browserContextId;
|
|
170
|
-
const promises = [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
promises.push(this._browser.session.send('Browser.setDownloadOptions', {
|
|
164
|
+
const promises = [
|
|
165
|
+
super._initialize(),
|
|
166
|
+
this._updateInitScripts()
|
|
167
|
+
];
|
|
168
|
+
if (this._options.acceptDownloads !== "internal-browser-default") {
|
|
169
|
+
promises.push(this._browser.session.send("Browser.setDownloadOptions", {
|
|
177
170
|
browserContextId,
|
|
178
171
|
downloadOptions: {
|
|
179
|
-
behavior: this._options.acceptDownloads ===
|
|
172
|
+
behavior: this._options.acceptDownloads === "accept" ? "saveToDisk" : "cancel",
|
|
180
173
|
downloadsDir: this._browser.options.downloadsPath
|
|
181
174
|
}
|
|
182
175
|
}));
|
|
183
176
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
promises.push(this._browser.session.send(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
if (this._options.
|
|
198
|
-
browserContextId,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
if (this._options.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
if (this._options.
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}));
|
|
209
|
-
if (this._options.ignoreHTTPSErrors || this._options.internalIgnoreHTTPSErrors) promises.push(this._browser.session.send('Browser.setIgnoreHTTPSErrors', {
|
|
210
|
-
browserContextId,
|
|
211
|
-
ignoreHTTPSErrors: true
|
|
212
|
-
}));
|
|
213
|
-
if (this._options.javaScriptEnabled === false) promises.push(this._browser.session.send('Browser.setJavaScriptDisabled', {
|
|
214
|
-
browserContextId,
|
|
215
|
-
javaScriptDisabled: true
|
|
216
|
-
}));
|
|
217
|
-
if (this._options.locale) promises.push(this._browser.session.send('Browser.setLocaleOverride', {
|
|
218
|
-
browserContextId,
|
|
219
|
-
locale: this._options.locale
|
|
220
|
-
}));
|
|
221
|
-
if (this._options.timezoneId) promises.push(this._browser.session.send('Browser.setTimezoneOverride', {
|
|
222
|
-
browserContextId,
|
|
223
|
-
timezoneId: this._options.timezoneId
|
|
224
|
-
}));
|
|
225
|
-
if (this._options.extraHTTPHeaders || this._options.locale) promises.push(this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || []));
|
|
226
|
-
if (this._options.httpCredentials) promises.push(this.setHTTPCredentials(this._options.httpCredentials));
|
|
227
|
-
if (this._options.geolocation) promises.push(this.setGeolocation(this._options.geolocation));
|
|
228
|
-
if (this._options.offline) promises.push(this.setOffline(this._options.offline));
|
|
229
|
-
if (this._options.colorScheme !== 'no-override') {
|
|
230
|
-
promises.push(this._browser.session.send('Browser.setColorScheme', {
|
|
231
|
-
browserContextId,
|
|
232
|
-
colorScheme: this._options.colorScheme !== undefined ? this._options.colorScheme : 'light'
|
|
233
|
-
}));
|
|
234
|
-
}
|
|
235
|
-
if (this._options.reducedMotion !== 'no-override') {
|
|
236
|
-
promises.push(this._browser.session.send('Browser.setReducedMotion', {
|
|
237
|
-
browserContextId,
|
|
238
|
-
reducedMotion: this._options.reducedMotion !== undefined ? this._options.reducedMotion : 'no-preference'
|
|
239
|
-
}));
|
|
240
|
-
}
|
|
241
|
-
if (this._options.forcedColors !== 'no-override') {
|
|
242
|
-
promises.push(this._browser.session.send('Browser.setForcedColors', {
|
|
243
|
-
browserContextId,
|
|
244
|
-
forcedColors: this._options.forcedColors !== undefined ? this._options.forcedColors : 'none'
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
|
-
if (this._options.contrast !== 'no-override') {
|
|
248
|
-
promises.push(this._browser.session.send('Browser.setContrast', {
|
|
249
|
-
browserContextId,
|
|
250
|
-
contrast: this._options.contrast !== undefined ? this._options.contrast : 'no-preference'
|
|
251
|
-
}));
|
|
252
|
-
}
|
|
177
|
+
promises.push(this.doUpdateDefaultViewport());
|
|
178
|
+
if (this._options.hasTouch)
|
|
179
|
+
promises.push(this._browser.session.send("Browser.setTouchOverride", { browserContextId, hasTouch: true }));
|
|
180
|
+
if (this._options.userAgent)
|
|
181
|
+
promises.push(this._browser.session.send("Browser.setUserAgentOverride", { browserContextId, userAgent: this._options.userAgent }));
|
|
182
|
+
if (this._options.bypassCSP)
|
|
183
|
+
promises.push(this._browser.session.send("Browser.setBypassCSP", { browserContextId, bypassCSP: true }));
|
|
184
|
+
if (this._options.ignoreHTTPSErrors || this._options.internalIgnoreHTTPSErrors)
|
|
185
|
+
promises.push(this._browser.session.send("Browser.setIgnoreHTTPSErrors", { browserContextId, ignoreHTTPSErrors: true }));
|
|
186
|
+
if (this._options.javaScriptEnabled === false)
|
|
187
|
+
promises.push(this._browser.session.send("Browser.setJavaScriptDisabled", { browserContextId, javaScriptDisabled: true }));
|
|
188
|
+
if (this._options.locale)
|
|
189
|
+
promises.push(this._browser.session.send("Browser.setLocaleOverride", { browserContextId, locale: this._options.locale }));
|
|
190
|
+
if (this._options.timezoneId)
|
|
191
|
+
promises.push(this._browser.session.send("Browser.setTimezoneOverride", { browserContextId, timezoneId: this._options.timezoneId }));
|
|
192
|
+
if (this._options.extraHTTPHeaders || this._options.locale)
|
|
193
|
+
promises.push(this.doUpdateExtraHTTPHeaders());
|
|
194
|
+
if (this._options.httpCredentials)
|
|
195
|
+
promises.push(this.setHTTPCredentials(this._options.httpCredentials));
|
|
196
|
+
if (this._options.geolocation)
|
|
197
|
+
promises.push(this.setGeolocation(this._options.geolocation));
|
|
198
|
+
if (this._options.offline)
|
|
199
|
+
promises.push(this.doUpdateOffline());
|
|
200
|
+
promises.push(this.doUpdateDefaultEmulatedMedia());
|
|
253
201
|
if (this._options.recordVideo) {
|
|
254
202
|
promises.push(this._ensureVideosPath().then(() => {
|
|
255
|
-
return this._browser.session.send(
|
|
203
|
+
return this._browser.session.send("Browser.setVideoRecordingOptions", {
|
|
256
204
|
// validateBrowserContextOptions ensures correct video size.
|
|
257
205
|
options: {
|
|
258
206
|
...this._options.recordVideo.size,
|
|
@@ -264,7 +212,7 @@ class FFBrowserContext extends _browserContext.BrowserContext {
|
|
|
264
212
|
}
|
|
265
213
|
const proxy = this._options.proxyOverride || this._options.proxy;
|
|
266
214
|
if (proxy) {
|
|
267
|
-
promises.push(this._browser.session.send(
|
|
215
|
+
promises.push(this._browser.session.send("Browser.setContextProxy", {
|
|
268
216
|
browserContextId: this._browserContextId,
|
|
269
217
|
...toJugglerProxyOptions(proxy)
|
|
270
218
|
}));
|
|
@@ -272,197 +220,212 @@ class FFBrowserContext extends _browserContext.BrowserContext {
|
|
|
272
220
|
await Promise.all(promises);
|
|
273
221
|
}
|
|
274
222
|
_ffPages() {
|
|
275
|
-
return Array.from(this._browser._ffPages.values()).filter(ffPage => ffPage._browserContext === this);
|
|
223
|
+
return Array.from(this._browser._ffPages.values()).filter((ffPage) => ffPage._browserContext === this);
|
|
276
224
|
}
|
|
277
225
|
possiblyUninitializedPages() {
|
|
278
|
-
return this._ffPages().map(ffPage => ffPage._page);
|
|
226
|
+
return this._ffPages().map((ffPage) => ffPage._page);
|
|
279
227
|
}
|
|
280
|
-
async doCreateNewPage() {
|
|
281
|
-
(
|
|
282
|
-
const {
|
|
283
|
-
targetId
|
|
284
|
-
} = await this._browser.session.send('Browser.newPage', {
|
|
228
|
+
async doCreateNewPage(markAsServerSideOnly) {
|
|
229
|
+
const { targetId } = await this._browser.session.send("Browser.newPage", {
|
|
285
230
|
browserContextId: this._browserContextId
|
|
286
|
-
}).catch(e => {
|
|
287
|
-
if (e.message.includes(
|
|
231
|
+
}).catch((e) => {
|
|
232
|
+
if (e.message.includes("Failed to override timezone"))
|
|
233
|
+
throw new Error(`Invalid timezone ID: ${this._options.timezoneId}`);
|
|
288
234
|
throw e;
|
|
289
235
|
});
|
|
290
|
-
|
|
236
|
+
const page = this._browser._ffPages.get(targetId)._page;
|
|
237
|
+
if (markAsServerSideOnly)
|
|
238
|
+
page.markAsServerSideOnly();
|
|
239
|
+
return page;
|
|
291
240
|
}
|
|
292
241
|
async doGetCookies(urls) {
|
|
293
|
-
const {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
242
|
+
const { cookies } = await this._browser.session.send("Browser.getCookies", { browserContextId: this._browserContextId });
|
|
243
|
+
return network.filterCookies(cookies.map((c) => {
|
|
244
|
+
const { name, value, domain, path, expires, httpOnly, secure, sameSite } = c;
|
|
245
|
+
return {
|
|
246
|
+
name,
|
|
247
|
+
value,
|
|
248
|
+
domain,
|
|
249
|
+
path,
|
|
250
|
+
expires,
|
|
251
|
+
httpOnly,
|
|
252
|
+
secure,
|
|
253
|
+
sameSite
|
|
301
254
|
};
|
|
302
|
-
delete copy.size;
|
|
303
|
-
delete copy.session;
|
|
304
|
-
return copy;
|
|
305
255
|
}), urls);
|
|
306
256
|
}
|
|
307
257
|
async addCookies(cookies) {
|
|
308
|
-
const cc = network.rewriteCookies(cookies).map(c =>
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
258
|
+
const cc = network.rewriteCookies(cookies).map((c) => {
|
|
259
|
+
const { name, value, url, domain, path, expires, httpOnly, secure, sameSite } = c;
|
|
260
|
+
return {
|
|
261
|
+
name,
|
|
262
|
+
value,
|
|
263
|
+
url,
|
|
264
|
+
domain,
|
|
265
|
+
path,
|
|
266
|
+
expires: expires === -1 ? void 0 : expires,
|
|
267
|
+
httpOnly,
|
|
268
|
+
secure,
|
|
269
|
+
sameSite
|
|
270
|
+
};
|
|
315
271
|
});
|
|
272
|
+
await this._browser.session.send("Browser.setCookies", { browserContextId: this._browserContextId, cookies: cc });
|
|
316
273
|
}
|
|
317
274
|
async doClearCookies() {
|
|
318
|
-
await this._browser.session.send(
|
|
319
|
-
browserContextId: this._browserContextId
|
|
320
|
-
});
|
|
275
|
+
await this._browser.session.send("Browser.clearCookies", { browserContextId: this._browserContextId });
|
|
321
276
|
}
|
|
322
277
|
async doGrantPermissions(origin, permissions) {
|
|
323
|
-
const webPermissionToProtocol = new Map([
|
|
324
|
-
|
|
278
|
+
const webPermissionToProtocol = /* @__PURE__ */ new Map([
|
|
279
|
+
["geolocation", "geo"],
|
|
280
|
+
["persistent-storage", "persistent-storage"],
|
|
281
|
+
["push", "push"],
|
|
282
|
+
["notifications", "desktop-notification"]
|
|
283
|
+
]);
|
|
284
|
+
const filtered = permissions.map((permission) => {
|
|
325
285
|
const protocolPermission = webPermissionToProtocol.get(permission);
|
|
326
|
-
if (!protocolPermission)
|
|
286
|
+
if (!protocolPermission)
|
|
287
|
+
throw new Error("Unknown permission: " + permission);
|
|
327
288
|
return protocolPermission;
|
|
328
289
|
});
|
|
329
|
-
await this._browser.session.send(
|
|
330
|
-
origin: origin,
|
|
331
|
-
browserContextId: this._browserContextId,
|
|
332
|
-
permissions: filtered
|
|
333
|
-
});
|
|
290
|
+
await this._browser.session.send("Browser.grantPermissions", { origin, browserContextId: this._browserContextId, permissions: filtered });
|
|
334
291
|
}
|
|
335
292
|
async doClearPermissions() {
|
|
336
|
-
await this._browser.session.send(
|
|
337
|
-
browserContextId: this._browserContextId
|
|
338
|
-
});
|
|
293
|
+
await this._browser.session.send("Browser.resetPermissions", { browserContextId: this._browserContextId });
|
|
339
294
|
}
|
|
340
295
|
async setGeolocation(geolocation) {
|
|
341
|
-
(0,
|
|
296
|
+
(0, import_browserContext.verifyGeolocation)(geolocation);
|
|
342
297
|
this._options.geolocation = geolocation;
|
|
343
|
-
await this._browser.session.send(
|
|
344
|
-
browserContextId: this._browserContextId,
|
|
345
|
-
geolocation: geolocation || null
|
|
346
|
-
});
|
|
298
|
+
await this._browser.session.send("Browser.setGeolocationOverride", { browserContextId: this._browserContextId, geolocation: geolocation || null });
|
|
347
299
|
}
|
|
348
|
-
async
|
|
349
|
-
this._options.extraHTTPHeaders
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
await this._browser.session.send(
|
|
353
|
-
browserContextId: this._browserContextId,
|
|
354
|
-
headers: allHeaders
|
|
355
|
-
});
|
|
300
|
+
async doUpdateExtraHTTPHeaders() {
|
|
301
|
+
let allHeaders = this._options.extraHTTPHeaders || [];
|
|
302
|
+
if (this._options.locale)
|
|
303
|
+
allHeaders = network.mergeHeaders([allHeaders, network.singleHeader("Accept-Language", this._options.locale)]);
|
|
304
|
+
await this._browser.session.send("Browser.setExtraHTTPHeaders", { browserContextId: this._browserContextId, headers: allHeaders });
|
|
356
305
|
}
|
|
357
306
|
async setUserAgent(userAgent) {
|
|
358
|
-
await this._browser.session.send(
|
|
359
|
-
browserContextId: this._browserContextId,
|
|
360
|
-
userAgent: userAgent || null
|
|
361
|
-
});
|
|
307
|
+
await this._browser.session.send("Browser.setUserAgentOverride", { browserContextId: this._browserContextId, userAgent: userAgent || null });
|
|
362
308
|
}
|
|
363
|
-
async
|
|
364
|
-
this._options.offline
|
|
365
|
-
await this._browser.session.send('Browser.setOnlineOverride', {
|
|
366
|
-
browserContextId: this._browserContextId,
|
|
367
|
-
override: offline ? 'offline' : 'online'
|
|
368
|
-
});
|
|
309
|
+
async doUpdateOffline() {
|
|
310
|
+
await this._browser.session.send("Browser.setOnlineOverride", { browserContextId: this._browserContextId, override: this._options.offline ? "offline" : "online" });
|
|
369
311
|
}
|
|
370
312
|
async doSetHTTPCredentials(httpCredentials) {
|
|
371
313
|
this._options.httpCredentials = httpCredentials;
|
|
372
314
|
let credentials = null;
|
|
373
315
|
if (httpCredentials) {
|
|
374
|
-
const {
|
|
375
|
-
|
|
376
|
-
password,
|
|
377
|
-
origin
|
|
378
|
-
} = httpCredentials;
|
|
379
|
-
credentials = {
|
|
380
|
-
username,
|
|
381
|
-
password,
|
|
382
|
-
origin
|
|
383
|
-
};
|
|
316
|
+
const { username, password, origin } = httpCredentials;
|
|
317
|
+
credentials = { username, password, origin };
|
|
384
318
|
}
|
|
385
|
-
await this._browser.session.send(
|
|
386
|
-
browserContextId: this._browserContextId,
|
|
387
|
-
credentials
|
|
388
|
-
});
|
|
319
|
+
await this._browser.session.send("Browser.setHTTPCredentials", { browserContextId: this._browserContextId, credentials });
|
|
389
320
|
}
|
|
390
321
|
async doAddInitScript(initScript) {
|
|
391
322
|
await this._updateInitScripts();
|
|
392
323
|
}
|
|
393
|
-
async
|
|
324
|
+
async doRemoveInitScripts(initScripts) {
|
|
394
325
|
await this._updateInitScripts();
|
|
395
326
|
}
|
|
396
327
|
async _updateInitScripts() {
|
|
397
|
-
const bindingScripts = [...this._pageBindings.values()].map(binding => binding.initScript.source);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
script
|
|
403
|
-
}))
|
|
404
|
-
});
|
|
328
|
+
const bindingScripts = [...this._pageBindings.values()].map((binding) => binding.initScript.source);
|
|
329
|
+
if (this.bindingsInitScript)
|
|
330
|
+
bindingScripts.unshift(this.bindingsInitScript.source);
|
|
331
|
+
const initScripts = this.initScripts.map((script) => script.source);
|
|
332
|
+
await this._browser.session.send("Browser.setInitScripts", { browserContextId: this._browserContextId, scripts: [...bindingScripts, ...initScripts].map((script) => ({ script })) });
|
|
405
333
|
}
|
|
406
334
|
async doUpdateRequestInterception() {
|
|
407
|
-
await Promise.all([
|
|
408
|
-
browserContextId: this._browserContextId,
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
335
|
+
await Promise.all([
|
|
336
|
+
this._browser.session.send("Browser.setRequestInterception", { browserContextId: this._browserContextId, enabled: this.requestInterceptors.length > 0 }),
|
|
337
|
+
this._browser.session.send("Browser.setCacheDisabled", { browserContextId: this._browserContextId, cacheDisabled: this.requestInterceptors.length > 0 })
|
|
338
|
+
]);
|
|
339
|
+
}
|
|
340
|
+
async doUpdateDefaultViewport() {
|
|
341
|
+
if (!this._options.viewport)
|
|
342
|
+
return;
|
|
343
|
+
const viewport = {
|
|
344
|
+
viewportSize: { width: this._options.viewport.width, height: this._options.viewport.height },
|
|
345
|
+
deviceScaleFactor: this._options.deviceScaleFactor || 1
|
|
346
|
+
};
|
|
347
|
+
await this._browser.session.send("Browser.setDefaultViewport", { browserContextId: this._browserContextId, viewport });
|
|
348
|
+
}
|
|
349
|
+
async doUpdateDefaultEmulatedMedia() {
|
|
350
|
+
if (this._options.colorScheme !== "no-override") {
|
|
351
|
+
await this._browser.session.send("Browser.setColorScheme", {
|
|
352
|
+
browserContextId: this._browserContextId,
|
|
353
|
+
colorScheme: this._options.colorScheme !== void 0 ? this._options.colorScheme : "light"
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
if (this._options.reducedMotion !== "no-override") {
|
|
357
|
+
await this._browser.session.send("Browser.setReducedMotion", {
|
|
358
|
+
browserContextId: this._browserContextId,
|
|
359
|
+
reducedMotion: this._options.reducedMotion !== void 0 ? this._options.reducedMotion : "no-preference"
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
if (this._options.forcedColors !== "no-override") {
|
|
363
|
+
await this._browser.session.send("Browser.setForcedColors", {
|
|
364
|
+
browserContextId: this._browserContextId,
|
|
365
|
+
forcedColors: this._options.forcedColors !== void 0 ? this._options.forcedColors : "none"
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
if (this._options.contrast !== "no-override") {
|
|
369
|
+
await this._browser.session.send("Browser.setContrast", {
|
|
370
|
+
browserContextId: this._browserContextId,
|
|
371
|
+
contrast: this._options.contrast !== void 0 ? this._options.contrast : "no-preference"
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
async doExposePlaywrightBinding() {
|
|
376
|
+
this._browser.session.send("Browser.addBinding", { browserContextId: this._browserContextId, name: import_page.PageBinding.kBindingName, script: "" });
|
|
377
|
+
}
|
|
378
|
+
onClosePersistent() {
|
|
379
|
+
}
|
|
416
380
|
async clearCache() {
|
|
417
|
-
|
|
418
|
-
await this._browser.session.send('Browser.clearCache');
|
|
381
|
+
await this._browser.session.send("Browser.clearCache");
|
|
419
382
|
}
|
|
420
383
|
async doClose(reason) {
|
|
421
384
|
if (!this._browserContextId) {
|
|
422
385
|
if (this._options.recordVideo) {
|
|
423
|
-
await this._browser.session.send(
|
|
424
|
-
options:
|
|
386
|
+
await this._browser.session.send("Browser.setVideoRecordingOptions", {
|
|
387
|
+
options: void 0,
|
|
425
388
|
browserContextId: this._browserContextId
|
|
426
389
|
});
|
|
427
390
|
}
|
|
428
|
-
|
|
429
|
-
await this._browser.close({
|
|
430
|
-
reason
|
|
431
|
-
});
|
|
391
|
+
await this._browser.close({ reason });
|
|
432
392
|
} else {
|
|
433
|
-
await this._browser.session.send(
|
|
434
|
-
browserContextId: this._browserContextId
|
|
435
|
-
});
|
|
393
|
+
await this._browser.session.send("Browser.removeBrowserContext", { browserContextId: this._browserContextId });
|
|
436
394
|
this._browser._contexts.delete(this._browserContextId);
|
|
437
395
|
}
|
|
438
396
|
}
|
|
439
397
|
async cancelDownload(uuid) {
|
|
440
|
-
await this._browser.session.send(
|
|
441
|
-
uuid
|
|
442
|
-
});
|
|
398
|
+
await this._browser.session.send("Browser.cancelDownload", { uuid });
|
|
443
399
|
}
|
|
444
400
|
}
|
|
445
|
-
exports.FFBrowserContext = FFBrowserContext;
|
|
446
401
|
function toJugglerProxyOptions(proxy) {
|
|
447
402
|
const proxyServer = new URL(proxy.server);
|
|
448
403
|
let port = parseInt(proxyServer.port, 10);
|
|
449
|
-
let type =
|
|
450
|
-
if (proxyServer.protocol ===
|
|
451
|
-
|
|
452
|
-
|
|
404
|
+
let type = "http";
|
|
405
|
+
if (proxyServer.protocol === "socks5:")
|
|
406
|
+
type = "socks";
|
|
407
|
+
else if (proxyServer.protocol === "socks4:")
|
|
408
|
+
type = "socks4";
|
|
409
|
+
else if (proxyServer.protocol === "https:")
|
|
410
|
+
type = "https";
|
|
411
|
+
if (proxyServer.port === "") {
|
|
412
|
+
if (proxyServer.protocol === "http:")
|
|
413
|
+
port = 80;
|
|
414
|
+
else if (proxyServer.protocol === "https:")
|
|
415
|
+
port = 443;
|
|
453
416
|
}
|
|
454
417
|
return {
|
|
455
418
|
type,
|
|
456
|
-
bypass: proxy.bypass ? proxy.bypass.split(
|
|
419
|
+
bypass: proxy.bypass ? proxy.bypass.split(",").map((domain) => domain.trim()) : [],
|
|
457
420
|
host: proxyServer.hostname,
|
|
458
421
|
port,
|
|
459
422
|
username: proxy.username,
|
|
460
423
|
password: proxy.password
|
|
461
424
|
};
|
|
462
425
|
}
|
|
463
|
-
|
|
464
|
-
//
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
};
|
|
426
|
+
const kBandaidFirefoxUserPrefs = {};
|
|
427
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
428
|
+
0 && (module.exports = {
|
|
429
|
+
FFBrowser,
|
|
430
|
+
FFBrowserContext
|
|
431
|
+
});
|