rebrowser-playwright-core 1.52.0 → 1.64.100
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 +7 -1554
- package/bin/install_webkit_wsl.ps1 +33 -0
- package/bin/reinstall_chrome_beta_linux.sh +1 -1
- package/bin/reinstall_chrome_beta_mac.sh +1 -1
- package/bin/reinstall_chrome_stable_linux.sh +1 -1
- package/bin/reinstall_chrome_stable_mac.sh +1 -1
- package/bin/reinstall_msedge_beta_linux.sh +1 -1
- package/bin/reinstall_msedge_beta_mac.sh +1 -1
- package/bin/reinstall_msedge_dev_linux.sh +1 -1
- package/bin/reinstall_msedge_dev_mac.sh +1 -1
- package/bin/reinstall_msedge_stable_linux.sh +1 -1
- package/bin/reinstall_msedge_stable_mac.sh +1 -1
- package/browsers.json +16 -44
- package/cli.js +5 -1
- package/index.js +2 -17
- package/lib/bootstrap.js +149 -0
- package/lib/coreBundle.js +78322 -0
- package/lib/entry/cliDaemon.js +5 -0
- package/lib/entry/dashboardApp.js +3 -0
- package/lib/entry/mcp.js +10 -0
- package/lib/entry/oopBrowserDownload.js +3 -0
- package/lib/{server/deviceDescriptors.js → package.js} +18 -7
- package/lib/server/electron/loader.js +108 -14
- package/lib/serverRegistry.js +1939 -0
- package/lib/serverRegistry.js.LICENSE +65 -0
- package/lib/tools/cli-client/channelSessions.js +141 -0
- package/lib/tools/cli-client/cli.js +7 -0
- package/lib/tools/cli-client/help.json +808 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/output.js +352 -0
- package/lib/tools/cli-client/program.js +422 -0
- package/lib/tools/cli-client/registry.js +180 -0
- package/lib/tools/cli-client/session.js +261 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/skills/playwright-cli/SKILL.md +493 -0
- package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- package/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
- package/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
- package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- package/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
- package/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
- package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- package/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
- package/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
- package/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
- package/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
- package/lib/tools/skills/playwright-trace/SKILL.md +174 -0
- package/lib/tools/utils/extension.js +112 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utilsBundle.js +86038 -66
- package/lib/utilsBundle.js.LICENSE +1890 -0
- package/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
- package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- package/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
- package/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
- package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- package/lib/vite/dashboard/index.html +29 -0
- package/lib/vite/dashboard/playwright-logo.svg +24 -0
- package/lib/vite/htmlReport/index.html +2 -61
- package/lib/vite/htmlReport/report.css +2 -0
- package/lib/vite/htmlReport/report.js +32 -0
- package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
- package/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
- package/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
- package/lib/vite/recorder/index.html +3 -3
- package/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
- package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- package/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
- package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- package/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
- package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- package/lib/vite/traceViewer/index.html +9 -8
- package/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
- package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- package/lib/vite/traceViewer/snapshot.html +4 -15
- package/lib/vite/traceViewer/sw.bundle.js +4 -3
- package/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
- package/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
- package/lib/vite/traceViewer/uiMode.html +6 -5
- package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- package/lib/webp_codec.LICENSE +173 -0
- package/lib/webp_codec.wasm +0 -0
- package/lib/{utilsBundleImpl/xdg-open → xdg-open} +338 -137
- package/package.json +6 -16
- package/types/protocol.d.ts +10495 -8030
- package/types/structs.d.ts +8 -1
- package/types/types.d.ts +9256 -4825
- package/lib/androidServerImpl.js +0 -63
- package/lib/browserServerImpl.js +0 -88
- package/lib/cli/driver.js +0 -97
- package/lib/cli/program.js +0 -567
- package/lib/cli/programWithTestStub.js +0 -74
- package/lib/client/accessibility.js +0 -49
- package/lib/client/android.js +0 -365
- package/lib/client/api.js +0 -137
- package/lib/client/artifact.js +0 -79
- package/lib/client/browser.js +0 -136
- package/lib/client/browserContext.js +0 -539
- package/lib/client/browserType.js +0 -193
- package/lib/client/cdpSession.js +0 -51
- package/lib/client/channelOwner.js +0 -205
- package/lib/client/clientHelper.js +0 -64
- package/lib/client/clientInstrumentation.js +0 -55
- package/lib/client/clientStackTrace.js +0 -69
- package/lib/client/clock.js +0 -68
- package/lib/client/connection.js +0 -318
- package/lib/client/consoleMessage.js +0 -55
- package/lib/client/coverage.js +0 -44
- package/lib/client/dialog.js +0 -56
- package/lib/client/download.js +0 -62
- package/lib/client/electron.js +0 -133
- package/lib/client/elementHandle.js +0 -284
- package/lib/client/errors.js +0 -77
- package/lib/client/eventEmitter.js +0 -314
- package/lib/client/events.js +0 -98
- package/lib/client/fetch.js +0 -367
- package/lib/client/fileChooser.js +0 -46
- package/lib/client/fileUtils.js +0 -34
- package/lib/client/frame.js +0 -386
- package/lib/client/harRouter.js +0 -87
- package/lib/client/input.js +0 -82
- package/lib/client/jsHandle.js +0 -105
- package/lib/client/jsonPipe.js +0 -39
- package/lib/client/localUtils.js +0 -61
- package/lib/client/locator.js +0 -362
- package/lib/client/network.js +0 -751
- package/lib/client/page.js +0 -709
- package/lib/client/platform.js +0 -74
- package/lib/client/playwright.js +0 -85
- package/lib/client/selectors.js +0 -75
- package/lib/client/stream.js +0 -39
- package/lib/client/timeoutSettings.js +0 -75
- package/lib/client/tracing.js +0 -114
- package/lib/client/types.js +0 -28
- package/lib/client/video.js +0 -59
- package/lib/client/waiter.js +0 -142
- package/lib/client/webError.js +0 -39
- package/lib/client/webSocket.js +0 -111
- package/lib/client/worker.js +0 -63
- package/lib/client/writableStream.js +0 -39
- package/lib/generated/clockSource.js +0 -28
- package/lib/generated/consoleApiSource.js +0 -28
- package/lib/generated/injectedScriptSource.js +0 -28
- package/lib/generated/pollingRecorderSource.js +0 -28
- package/lib/generated/utilityScriptSource.js +0 -28
- package/lib/generated/webSocketMockSource.js +0 -378
- package/lib/inProcessFactory.js +0 -59
- package/lib/inprocess.js +0 -3
- package/lib/outofprocess.js +0 -78
- package/lib/protocol/debug.js +0 -211
- package/lib/protocol/serializers.js +0 -192
- package/lib/protocol/validator.js +0 -2825
- package/lib/protocol/validatorPrimitives.js +0 -179
- package/lib/remote/playwrightConnection.js +0 -266
- package/lib/remote/playwrightServer.js +0 -139
- package/lib/server/accessibility.js +0 -69
- package/lib/server/android/android.js +0 -451
- package/lib/server/android/backendAdb.js +0 -179
- package/lib/server/artifact.js +0 -127
- package/lib/server/bidi/bidiBrowser.js +0 -380
- package/lib/server/bidi/bidiChromium.js +0 -152
- package/lib/server/bidi/bidiConnection.js +0 -187
- package/lib/server/bidi/bidiExecutionContext.js +0 -220
- package/lib/server/bidi/bidiFirefox.js +0 -112
- package/lib/server/bidi/bidiInput.js +0 -146
- package/lib/server/bidi/bidiNetworkManager.js +0 -320
- package/lib/server/bidi/bidiOverCdp.js +0 -102
- package/lib/server/bidi/bidiPage.js +0 -530
- package/lib/server/bidi/bidiPdf.js +0 -106
- package/lib/server/bidi/third_party/bidiCommands.d.js +0 -22
- package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
- package/lib/server/bidi/third_party/bidiKeyboard.js +0 -256
- package/lib/server/bidi/third_party/bidiProtocol.js +0 -152
- package/lib/server/bidi/third_party/bidiSerializer.js +0 -148
- package/lib/server/bidi/third_party/firefoxPrefs.js +0 -259
- package/lib/server/browser.js +0 -140
- package/lib/server/browserContext.js +0 -650
- package/lib/server/browserType.js +0 -326
- package/lib/server/callLog.js +0 -82
- package/lib/server/chromium/chromium.js +0 -376
- package/lib/server/chromium/chromiumSwitches.js +0 -101
- package/lib/server/chromium/crAccessibility.js +0 -263
- package/lib/server/chromium/crBrowser.js +0 -498
- package/lib/server/chromium/crConnection.js +0 -324
- package/lib/server/chromium/crCoverage.js +0 -232
- package/lib/server/chromium/crDevTools.js +0 -117
- package/lib/server/chromium/crDragDrop.js +0 -126
- package/lib/server/chromium/crExecutionContext.js +0 -145
- package/lib/server/chromium/crInput.js +0 -184
- package/lib/server/chromium/crNetworkManager.js +0 -666
- package/lib/server/chromium/crPage.js +0 -1055
- package/lib/server/chromium/crPdf.js +0 -121
- package/lib/server/chromium/crProtocolHelper.js +0 -145
- package/lib/server/chromium/crServiceWorker.js +0 -130
- package/lib/server/chromium/defaultFontFamilies.js +0 -162
- package/lib/server/chromium/protocol.d.js +0 -16
- package/lib/server/chromium/videoRecorder.js +0 -121
- package/lib/server/clock.js +0 -137
- package/lib/server/codegen/csharp.js +0 -329
- package/lib/server/codegen/java.js +0 -270
- package/lib/server/codegen/javascript.js +0 -268
- package/lib/server/codegen/jsonl.js +0 -51
- package/lib/server/codegen/language.js +0 -111
- package/lib/server/codegen/languages.js +0 -68
- package/lib/server/codegen/python.js +0 -277
- package/lib/server/codegen/types.js +0 -16
- package/lib/server/console.js +0 -53
- package/lib/server/cookieStore.js +0 -204
- package/lib/server/debugController.js +0 -185
- package/lib/server/debugger.js +0 -136
- package/lib/server/deviceDescriptorsSource.json +0 -1669
- package/lib/server/dialog.js +0 -72
- package/lib/server/dispatchers/androidDispatcher.js +0 -293
- package/lib/server/dispatchers/artifactDispatcher.js +0 -118
- package/lib/server/dispatchers/browserContextDispatcher.js +0 -328
- package/lib/server/dispatchers/browserDispatcher.js +0 -151
- package/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
- package/lib/server/dispatchers/cdpSessionDispatcher.js +0 -44
- package/lib/server/dispatchers/debugControllerDispatcher.js +0 -87
- package/lib/server/dispatchers/dialogDispatcher.js +0 -47
- package/lib/server/dispatchers/dispatcher.js +0 -346
- package/lib/server/dispatchers/electronDispatcher.js +0 -90
- package/lib/server/dispatchers/elementHandlerDispatcher.js +0 -191
- package/lib/server/dispatchers/frameDispatcher.js +0 -224
- package/lib/server/dispatchers/jsHandleDispatcher.js +0 -80
- package/lib/server/dispatchers/jsonPipeDispatcher.js +0 -58
- package/lib/server/dispatchers/localUtilsDispatcher.js +0 -155
- package/lib/server/dispatchers/networkDispatchers.js +0 -204
- package/lib/server/dispatchers/pageDispatcher.js +0 -328
- package/lib/server/dispatchers/playwrightDispatcher.js +0 -100
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -40
- package/lib/server/dispatchers/streamDispatcher.js +0 -60
- package/lib/server/dispatchers/tracingDispatcher.js +0 -59
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +0 -154
- package/lib/server/dispatchers/writableStreamDispatcher.js +0 -73
- package/lib/server/dom.js +0 -869
- package/lib/server/download.js +0 -70
- package/lib/server/electron/electron.js +0 -277
- package/lib/server/errors.js +0 -69
- package/lib/server/fetch.js +0 -640
- package/lib/server/fileChooser.js +0 -43
- package/lib/server/fileUploadUtils.js +0 -84
- package/lib/server/firefox/ffAccessibility.js +0 -238
- package/lib/server/firefox/ffBrowser.js +0 -404
- package/lib/server/firefox/ffConnection.js +0 -147
- package/lib/server/firefox/ffExecutionContext.js +0 -149
- package/lib/server/firefox/ffInput.js +0 -159
- package/lib/server/firefox/ffNetworkManager.js +0 -254
- package/lib/server/firefox/ffPage.js +0 -501
- package/lib/server/firefox/firefox.js +0 -106
- package/lib/server/firefox/protocol.d.js +0 -16
- package/lib/server/formData.js +0 -147
- package/lib/server/frameSelectors.js +0 -137
- package/lib/server/frames.js +0 -1555
- package/lib/server/har/harRecorder.js +0 -147
- package/lib/server/har/harTracer.js +0 -606
- package/lib/server/harBackend.js +0 -157
- package/lib/server/helper.js +0 -100
- package/lib/server/index.js +0 -61
- package/lib/server/input.js +0 -280
- package/lib/server/instrumentation.js +0 -75
- package/lib/server/javascript.js +0 -299
- package/lib/server/launchApp.js +0 -110
- package/lib/server/localUtils.js +0 -211
- package/lib/server/macEditingCommands.js +0 -143
- package/lib/server/network.js +0 -583
- package/lib/server/page.js +0 -790
- package/lib/server/pageBinding.js +0 -88
- package/lib/server/pipeTransport.js +0 -89
- package/lib/server/playwright.js +0 -81
- package/lib/server/progress.js +0 -104
- package/lib/server/protocolError.js +0 -52
- package/lib/server/recorder/chat.js +0 -161
- package/lib/server/recorder/contextRecorder.js +0 -286
- package/lib/server/recorder/recorderApp.js +0 -184
- package/lib/server/recorder/recorderCollection.js +0 -116
- package/lib/server/recorder/recorderFrontend.js +0 -16
- package/lib/server/recorder/recorderRunner.js +0 -135
- package/lib/server/recorder/recorderUtils.js +0 -100
- package/lib/server/recorder/throttledFile.js +0 -57
- package/lib/server/recorder.js +0 -360
- package/lib/server/registry/browserFetcher.js +0 -175
- package/lib/server/registry/dependencies.js +0 -371
- package/lib/server/registry/index.js +0 -1271
- package/lib/server/registry/nativeDeps.js +0 -1105
- package/lib/server/registry/oopDownloadBrowserMain.js +0 -120
- package/lib/server/screenshotter.js +0 -332
- package/lib/server/selectors.js +0 -112
- package/lib/server/socksClientCertificatesInterceptor.js +0 -321
- package/lib/server/socksInterceptor.js +0 -95
- package/lib/server/storageScript.js +0 -154
- package/lib/server/timeoutSettings.js +0 -89
- package/lib/server/trace/recorder/snapshotter.js +0 -143
- package/lib/server/trace/recorder/snapshotterInjected.js +0 -539
- package/lib/server/trace/recorder/tracing.js +0 -593
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
- package/lib/server/trace/viewer/traceViewer.js +0 -249
- package/lib/server/transport.js +0 -183
- package/lib/server/types.js +0 -28
- package/lib/server/usKeyboardLayout.js +0 -145
- package/lib/server/utils/ascii.js +0 -44
- package/lib/server/utils/comparators.js +0 -161
- package/lib/server/utils/crypto.js +0 -216
- package/lib/server/utils/debug.js +0 -47
- package/lib/server/utils/debugLogger.js +0 -114
- package/lib/server/utils/env.js +0 -68
- package/lib/server/utils/eventsHelper.js +0 -39
- package/lib/server/utils/expectUtils.js +0 -38
- package/lib/server/utils/fileUtils.js +0 -191
- package/lib/server/utils/happyEyeballs.js +0 -207
- package/lib/server/utils/hostPlatform.js +0 -109
- package/lib/server/utils/httpServer.js +0 -218
- package/lib/server/utils/image_tools/colorUtils.js +0 -89
- package/lib/server/utils/image_tools/compare.js +0 -109
- package/lib/server/utils/image_tools/imageChannel.js +0 -78
- package/lib/server/utils/image_tools/stats.js +0 -102
- package/lib/server/utils/linuxUtils.js +0 -71
- package/lib/server/utils/network.js +0 -217
- package/lib/server/utils/nodePlatform.js +0 -148
- package/lib/server/utils/pipeTransport.js +0 -84
- package/lib/server/utils/processLauncher.js +0 -238
- package/lib/server/utils/profiler.js +0 -65
- package/lib/server/utils/socksProxy.js +0 -511
- package/lib/server/utils/spawnAsync.js +0 -41
- package/lib/server/utils/task.js +0 -51
- package/lib/server/utils/userAgent.js +0 -98
- package/lib/server/utils/wsServer.js +0 -132
- package/lib/server/utils/zipFile.js +0 -74
- package/lib/server/utils/zones.js +0 -57
- package/lib/server/webkit/protocol.d.js +0 -16
- package/lib/server/webkit/webkit.js +0 -100
- package/lib/server/webkit/wkAccessibility.js +0 -237
- package/lib/server/webkit/wkBrowser.js +0 -312
- package/lib/server/webkit/wkConnection.js +0 -149
- package/lib/server/webkit/wkExecutionContext.js +0 -153
- package/lib/server/webkit/wkInput.js +0 -181
- package/lib/server/webkit/wkInterceptableRequest.js +0 -169
- package/lib/server/webkit/wkPage.js +0 -1114
- package/lib/server/webkit/wkProvisionalPage.js +0 -83
- package/lib/server/webkit/wkWorkers.js +0 -104
- package/lib/third_party/pixelmatch.js +0 -255
- package/lib/utils/isomorphic/ariaSnapshot.js +0 -384
- package/lib/utils/isomorphic/assert.js +0 -31
- package/lib/utils/isomorphic/builtins.js +0 -90
- package/lib/utils/isomorphic/colors.js +0 -72
- package/lib/utils/isomorphic/cssParser.js +0 -246
- package/lib/utils/isomorphic/cssTokenizer.js +0 -1051
- package/lib/utils/isomorphic/headers.js +0 -53
- package/lib/utils/isomorphic/locatorGenerators.js +0 -655
- package/lib/utils/isomorphic/locatorParser.js +0 -176
- package/lib/utils/isomorphic/locatorUtils.js +0 -81
- package/lib/utils/isomorphic/manualPromise.js +0 -115
- package/lib/utils/isomorphic/mimeType.js +0 -460
- package/lib/utils/isomorphic/multimap.js +0 -81
- package/lib/utils/isomorphic/rtti.js +0 -43
- package/lib/utils/isomorphic/selectorParser.js +0 -387
- package/lib/utils/isomorphic/semaphore.js +0 -54
- package/lib/utils/isomorphic/stackTrace.js +0 -158
- package/lib/utils/isomorphic/stringUtils.js +0 -176
- package/lib/utils/isomorphic/time.js +0 -44
- package/lib/utils/isomorphic/timeoutRunner.js +0 -67
- package/lib/utils/isomorphic/traceUtils.js +0 -59
- package/lib/utils/isomorphic/types.js +0 -16
- package/lib/utils/isomorphic/urlMatch.js +0 -167
- package/lib/utils/isomorphic/utilityScriptSerializers.js +0 -248
- package/lib/utils.js +0 -101
- package/lib/utilsBundleImpl/index.js +0 -208
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +0 -24
- package/lib/vite/recorder/assets/index-97EUAAbk.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +0 -265
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.DvtSwn6E.js +0 -2
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +0 -5
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
- package/lib/zipBundle.js +0 -34
- package/lib/zipBundleImpl.js +0 -5
|
@@ -1,650 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
|
37
|
-
});
|
|
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 {
|
|
62
|
-
constructor(browser, options, browserContextId) {
|
|
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();
|
|
72
|
-
this._tempDirs = [];
|
|
73
|
-
this._settingStorageState = false;
|
|
74
|
-
this.initScripts = [];
|
|
75
|
-
this._routesInFlight = /* @__PURE__ */ new Set();
|
|
76
|
-
this.attribution.context = this;
|
|
77
|
-
this._browser = browser;
|
|
78
|
-
this._options = options;
|
|
79
|
-
this._browserContextId = browserContextId;
|
|
80
|
-
this._isPersistentContext = !browserContextId;
|
|
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
|
-
};
|
|
107
|
-
}
|
|
108
|
-
isPersistentContext() {
|
|
109
|
-
return this._isPersistentContext;
|
|
110
|
-
}
|
|
111
|
-
setSelectors(selectors) {
|
|
112
|
-
this._selectors = selectors;
|
|
113
|
-
}
|
|
114
|
-
selectors() {
|
|
115
|
-
return this._selectors || this.attribution.playwright.selectors;
|
|
116
|
-
}
|
|
117
|
-
async _initialize() {
|
|
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));
|
|
128
|
-
});
|
|
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);
|
|
137
|
-
}
|
|
138
|
-
debugger() {
|
|
139
|
-
return this._debugger;
|
|
140
|
-
}
|
|
141
|
-
async _ensureVideosPath() {
|
|
142
|
-
if (this._options.recordVideo)
|
|
143
|
-
await (0, import_fileUtils.mkdirIfNeeded)(import_path.default.join(this._options.recordVideo.dir, "dummy"));
|
|
144
|
-
}
|
|
145
|
-
canResetForReuse() {
|
|
146
|
-
if (this._closedStatus !== "open")
|
|
147
|
-
return false;
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
async stopPendingOperations(reason) {
|
|
151
|
-
for (const controller of this._activeProgressControllers)
|
|
152
|
-
controller.abort(new Error(reason));
|
|
153
|
-
await new Promise((f) => setTimeout(f, 0));
|
|
154
|
-
}
|
|
155
|
-
static reusableContextHash(params) {
|
|
156
|
-
const paramsCopy = { ...params };
|
|
157
|
-
for (const k of Object.keys(paramsCopy)) {
|
|
158
|
-
const key = k;
|
|
159
|
-
if (paramsCopy[key] === defaultNewContextParamValues[key])
|
|
160
|
-
delete paramsCopy[key];
|
|
161
|
-
}
|
|
162
|
-
for (const key of paramsThatAllowContextReuse)
|
|
163
|
-
delete paramsCopy[key];
|
|
164
|
-
return JSON.stringify(paramsCopy);
|
|
165
|
-
}
|
|
166
|
-
async resetForReuse(metadata, params) {
|
|
167
|
-
this.setDefaultNavigationTimeout(void 0);
|
|
168
|
-
this.setDefaultTimeout(void 0);
|
|
169
|
-
this.tracing.resetForReuse();
|
|
170
|
-
if (params) {
|
|
171
|
-
for (const key of paramsThatAllowContextReuse)
|
|
172
|
-
this._options[key] = params[key];
|
|
173
|
-
}
|
|
174
|
-
await this._cancelAllRoutesInFlight();
|
|
175
|
-
let page = this.pages()[0];
|
|
176
|
-
const [, ...otherPages] = this.pages();
|
|
177
|
-
for (const p of otherPages)
|
|
178
|
-
await p.close(metadata);
|
|
179
|
-
if (page && page.hasCrashed()) {
|
|
180
|
-
await page.close(metadata);
|
|
181
|
-
page = void 0;
|
|
182
|
-
}
|
|
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);
|
|
187
|
-
await this._resetStorage();
|
|
188
|
-
await this._removeExposedBindings();
|
|
189
|
-
await this._removeInitScripts();
|
|
190
|
-
this.clock.markAsUninstalled();
|
|
191
|
-
if (this._options.permissions)
|
|
192
|
-
await this.grantPermissions(this._options.permissions);
|
|
193
|
-
else
|
|
194
|
-
await this.clearPermissions();
|
|
195
|
-
await this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || []);
|
|
196
|
-
await this.setGeolocation(this._options.geolocation);
|
|
197
|
-
await this.setOffline(!!this._options.offline);
|
|
198
|
-
await this.setUserAgent(this._options.userAgent);
|
|
199
|
-
await this.clearCache();
|
|
200
|
-
await this._resetCookies();
|
|
201
|
-
await page?.resetForReuse(metadata);
|
|
202
|
-
}
|
|
203
|
-
_browserClosed() {
|
|
204
|
-
for (const page of this.pages())
|
|
205
|
-
page._didClose();
|
|
206
|
-
this._didCloseInternal();
|
|
207
|
-
}
|
|
208
|
-
_didCloseInternal() {
|
|
209
|
-
if (this._closedStatus === "closed") {
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
this._clientCertificatesProxy?.close().catch(() => {
|
|
213
|
-
});
|
|
214
|
-
this.tracing.abort();
|
|
215
|
-
if (this._isPersistentContext)
|
|
216
|
-
this.onClosePersistent();
|
|
217
|
-
this._closePromiseFulfill(new Error("Context closed"));
|
|
218
|
-
this.emit(BrowserContext.Events.Close);
|
|
219
|
-
}
|
|
220
|
-
pages() {
|
|
221
|
-
return this.possiblyUninitializedPages().filter((page) => page.initializedOrUndefined());
|
|
222
|
-
}
|
|
223
|
-
async cookies(urls = []) {
|
|
224
|
-
if (urls && !Array.isArray(urls))
|
|
225
|
-
urls = [urls];
|
|
226
|
-
return await this.doGetCookies(urls);
|
|
227
|
-
}
|
|
228
|
-
async clearCookies(options) {
|
|
229
|
-
const currentCookies = await this.cookies();
|
|
230
|
-
await this.doClearCookies();
|
|
231
|
-
const matches = (cookie, prop, value) => {
|
|
232
|
-
if (!value)
|
|
233
|
-
return true;
|
|
234
|
-
if (value instanceof RegExp) {
|
|
235
|
-
value.lastIndex = 0;
|
|
236
|
-
return value.test(cookie[prop]);
|
|
237
|
-
}
|
|
238
|
-
return cookie[prop] === value;
|
|
239
|
-
};
|
|
240
|
-
const cookiesToReadd = currentCookies.filter((cookie) => {
|
|
241
|
-
return !matches(cookie, "name", options.name) || !matches(cookie, "domain", options.domain) || !matches(cookie, "path", options.path);
|
|
242
|
-
});
|
|
243
|
-
await this.addCookies(cookiesToReadd);
|
|
244
|
-
}
|
|
245
|
-
setHTTPCredentials(httpCredentials) {
|
|
246
|
-
return this.doSetHTTPCredentials(httpCredentials);
|
|
247
|
-
}
|
|
248
|
-
hasBinding(name) {
|
|
249
|
-
return this._pageBindings.has(name);
|
|
250
|
-
}
|
|
251
|
-
async exposeBinding(name, needsHandle, playwrightBinding) {
|
|
252
|
-
if (this._pageBindings.has(name))
|
|
253
|
-
throw new Error(`Function "${name}" has been already registered`);
|
|
254
|
-
for (const page of this.pages()) {
|
|
255
|
-
if (page.getBinding(name))
|
|
256
|
-
throw new Error(`Function "${name}" has been already registered in one of the pages`);
|
|
257
|
-
}
|
|
258
|
-
const binding = new import_page2.PageBinding(name, playwrightBinding, needsHandle);
|
|
259
|
-
this._pageBindings.set(name, binding);
|
|
260
|
-
await this.doAddInitScript(binding.initScript);
|
|
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
|
-
})));
|
|
264
|
-
}
|
|
265
|
-
async _removeExposedBindings() {
|
|
266
|
-
for (const [key, binding] of this._pageBindings) {
|
|
267
|
-
if (!binding.internal)
|
|
268
|
-
this._pageBindings.delete(key);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
async grantPermissions(permissions, origin) {
|
|
272
|
-
let resolvedOrigin = "*";
|
|
273
|
-
if (origin) {
|
|
274
|
-
const url = new URL(origin);
|
|
275
|
-
resolvedOrigin = url.origin;
|
|
276
|
-
}
|
|
277
|
-
const existing = new Set(this._permissions.get(resolvedOrigin) || []);
|
|
278
|
-
permissions.forEach((p) => existing.add(p));
|
|
279
|
-
const list = [...existing.values()];
|
|
280
|
-
this._permissions.set(resolvedOrigin, list);
|
|
281
|
-
await this.doGrantPermissions(resolvedOrigin, list);
|
|
282
|
-
}
|
|
283
|
-
async clearPermissions() {
|
|
284
|
-
this._permissions.clear();
|
|
285
|
-
await this.doClearPermissions();
|
|
286
|
-
}
|
|
287
|
-
setDefaultNavigationTimeout(timeout) {
|
|
288
|
-
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
289
|
-
}
|
|
290
|
-
setDefaultTimeout(timeout) {
|
|
291
|
-
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
292
|
-
}
|
|
293
|
-
async _loadDefaultContextAsIs(progress) {
|
|
294
|
-
if (!this.possiblyUninitializedPages().length) {
|
|
295
|
-
const waitForEvent = import_helper.helper.waitForEvent(progress, this, BrowserContext.Events.Page);
|
|
296
|
-
progress.cleanupWhenAborted(() => waitForEvent.dispose);
|
|
297
|
-
await Promise.race([waitForEvent.promise, this._closePromise]);
|
|
298
|
-
}
|
|
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;
|
|
307
|
-
}
|
|
308
|
-
async _loadDefaultContext(progress) {
|
|
309
|
-
const defaultPage = await this._loadDefaultContextAsIs(progress);
|
|
310
|
-
if (!defaultPage)
|
|
311
|
-
return;
|
|
312
|
-
const browserName = this._browser.options.name;
|
|
313
|
-
if (this._options.isMobile && browserName === "chromium" || this._options.locale && browserName === "webkit") {
|
|
314
|
-
await this.newPage(progress.metadata);
|
|
315
|
-
await defaultPage.close(progress.metadata);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
_authenticateProxyViaHeader() {
|
|
319
|
-
const proxy = this._options.proxy || this._browser.options.proxy || { username: void 0, password: void 0 };
|
|
320
|
-
const { username, password } = proxy;
|
|
321
|
-
if (username) {
|
|
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
|
-
]);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
_authenticateProxyViaCredentials() {
|
|
331
|
-
const proxy = this._options.proxy || this._browser.options.proxy;
|
|
332
|
-
if (!proxy)
|
|
333
|
-
return;
|
|
334
|
-
const { username, password } = proxy;
|
|
335
|
-
if (username)
|
|
336
|
-
this._options.httpCredentials = { username, password: password || "" };
|
|
337
|
-
}
|
|
338
|
-
async addInitScript(source, name) {
|
|
339
|
-
const initScript = new import_page.InitScript(source, false, name);
|
|
340
|
-
this.initScripts.push(initScript);
|
|
341
|
-
await this.doAddInitScript(initScript);
|
|
342
|
-
}
|
|
343
|
-
async _removeInitScripts() {
|
|
344
|
-
this.initScripts = this.initScripts.filter((script) => script.internal);
|
|
345
|
-
await this.doRemoveNonInternalInitScripts();
|
|
346
|
-
}
|
|
347
|
-
async setRequestInterceptor(handler) {
|
|
348
|
-
this._requestInterceptor = handler;
|
|
349
|
-
await this.doUpdateRequestInterception();
|
|
350
|
-
}
|
|
351
|
-
isClosingOrClosed() {
|
|
352
|
-
return this._closedStatus !== "open";
|
|
353
|
-
}
|
|
354
|
-
async _deleteAllDownloads() {
|
|
355
|
-
await Promise.all(Array.from(this._downloads).map((download) => download.artifact.deleteOnContextClose()));
|
|
356
|
-
}
|
|
357
|
-
async _deleteAllTempDirs() {
|
|
358
|
-
await Promise.all(this._tempDirs.map(async (dir) => await import_fs.default.promises.unlink(dir).catch((e) => {
|
|
359
|
-
})));
|
|
360
|
-
}
|
|
361
|
-
setCustomCloseHandler(handler) {
|
|
362
|
-
this._customCloseHandler = handler;
|
|
363
|
-
}
|
|
364
|
-
async close(options) {
|
|
365
|
-
if (this._closedStatus === "open") {
|
|
366
|
-
if (options.reason)
|
|
367
|
-
this._closeReason = options.reason;
|
|
368
|
-
this.emit(BrowserContext.Events.BeforeClose);
|
|
369
|
-
this._closedStatus = "closing";
|
|
370
|
-
for (const harRecorder of this._harRecorders.values())
|
|
371
|
-
await harRecorder.flush();
|
|
372
|
-
await this.tracing.flush();
|
|
373
|
-
const promises = [];
|
|
374
|
-
for (const { context, artifact } of this._browser._idToVideo.values()) {
|
|
375
|
-
if (context === this)
|
|
376
|
-
promises.push(artifact.finishedPromise());
|
|
377
|
-
}
|
|
378
|
-
if (this._customCloseHandler) {
|
|
379
|
-
await this._customCloseHandler();
|
|
380
|
-
} else {
|
|
381
|
-
await this.doClose(options.reason);
|
|
382
|
-
}
|
|
383
|
-
promises.push(this._deleteAllDownloads());
|
|
384
|
-
promises.push(this._deleteAllTempDirs());
|
|
385
|
-
await Promise.all(promises);
|
|
386
|
-
if (!this._customCloseHandler)
|
|
387
|
-
this._didCloseInternal();
|
|
388
|
-
}
|
|
389
|
-
await this._closePromise;
|
|
390
|
-
}
|
|
391
|
-
async newPage(metadata) {
|
|
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.");
|
|
399
|
-
return pageOrError;
|
|
400
|
-
}
|
|
401
|
-
throw pageOrError;
|
|
402
|
-
}
|
|
403
|
-
addVisitedOrigin(origin) {
|
|
404
|
-
this._origins.add(origin);
|
|
405
|
-
}
|
|
406
|
-
async storageState(indexedDB = false) {
|
|
407
|
-
const result = {
|
|
408
|
-
cookies: await this.cookies(),
|
|
409
|
-
origins: []
|
|
410
|
-
};
|
|
411
|
-
const originsToSave = new Set(this._origins);
|
|
412
|
-
const collectScript = `(${storageScript.collect})(${utilityScriptSerializers.source}, (${import_builtins.builtins})(), ${this._browser.options.name === "firefox"}, ${indexedDB})`;
|
|
413
|
-
for (const page of this.pages()) {
|
|
414
|
-
const origin = page.mainFrame().origin();
|
|
415
|
-
if (!origin || !originsToSave.has(origin))
|
|
416
|
-
continue;
|
|
417
|
-
try {
|
|
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 });
|
|
421
|
-
originsToSave.delete(origin);
|
|
422
|
-
} catch {
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
if (originsToSave.size) {
|
|
426
|
-
const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
|
|
427
|
-
const page = await this.newPage(internalMetadata);
|
|
428
|
-
await page._setServerRequestInterceptor((handler) => {
|
|
429
|
-
handler.fulfill({ body: "<html></html>" }).catch(() => {
|
|
430
|
-
});
|
|
431
|
-
return true;
|
|
432
|
-
});
|
|
433
|
-
for (const origin of originsToSave) {
|
|
434
|
-
const frame = page.mainFrame();
|
|
435
|
-
await frame.goto(internalMetadata, origin);
|
|
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 });
|
|
439
|
-
}
|
|
440
|
-
await page.close(internalMetadata);
|
|
441
|
-
}
|
|
442
|
-
return result;
|
|
443
|
-
}
|
|
444
|
-
async _resetStorage() {
|
|
445
|
-
const oldOrigins = this._origins;
|
|
446
|
-
const newOrigins = new Map(this._options.storageState?.origins?.map((p) => [p.origin, p]) || []);
|
|
447
|
-
if (!oldOrigins.size && !newOrigins.size)
|
|
448
|
-
return;
|
|
449
|
-
let page = this.pages()[0];
|
|
450
|
-
const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
|
|
451
|
-
page = page || await this.newPage({
|
|
452
|
-
...internalMetadata,
|
|
453
|
-
// Do not mark this page as internal, because we will leave it for later reuse
|
|
454
|
-
// as a user-visible page.
|
|
455
|
-
isServerSide: false
|
|
456
|
-
});
|
|
457
|
-
await page._setServerRequestInterceptor((handler) => {
|
|
458
|
-
handler.fulfill({ body: "<html></html>" }).catch(() => {
|
|
459
|
-
});
|
|
460
|
-
return true;
|
|
461
|
-
});
|
|
462
|
-
for (const origin of /* @__PURE__ */ new Set([...oldOrigins, ...newOrigins.keys()])) {
|
|
463
|
-
const frame = page.mainFrame();
|
|
464
|
-
await frame.goto(internalMetadata, origin);
|
|
465
|
-
await frame.resetStorageForCurrentOriginBestEffort(newOrigins.get(origin));
|
|
466
|
-
}
|
|
467
|
-
await page._setServerRequestInterceptor(void 0);
|
|
468
|
-
this._origins = /* @__PURE__ */ new Set([...newOrigins.keys()]);
|
|
469
|
-
}
|
|
470
|
-
async _resetCookies() {
|
|
471
|
-
await this.doClearCookies();
|
|
472
|
-
if (this._options.storageState?.cookies)
|
|
473
|
-
await this.addCookies(this._options.storageState?.cookies);
|
|
474
|
-
}
|
|
475
|
-
isSettingStorageState() {
|
|
476
|
-
return this._settingStorageState;
|
|
477
|
-
}
|
|
478
|
-
async setStorageState(metadata, state) {
|
|
479
|
-
this._settingStorageState = true;
|
|
480
|
-
try {
|
|
481
|
-
if (state.cookies)
|
|
482
|
-
await this.addCookies(state.cookies);
|
|
483
|
-
if (state.origins && state.origins.length) {
|
|
484
|
-
const internalMetadata = (0, import_instrumentation.serverSideCallMetadata)();
|
|
485
|
-
const page = await this.newPage(internalMetadata);
|
|
486
|
-
await page._setServerRequestInterceptor((handler) => {
|
|
487
|
-
handler.fulfill({ body: "<html></html>" }).catch(() => {
|
|
488
|
-
});
|
|
489
|
-
return true;
|
|
490
|
-
});
|
|
491
|
-
for (const originState of state.origins) {
|
|
492
|
-
const frame = page.mainFrame();
|
|
493
|
-
await frame.goto(metadata, originState.origin);
|
|
494
|
-
await frame.evaluateExpression(`(${storageScript.restore})(${utilityScriptSerializers.source}, (${import_builtins.builtins})(), ${JSON.stringify(originState)})`, { world: "utility" });
|
|
495
|
-
}
|
|
496
|
-
await page.close(internalMetadata);
|
|
497
|
-
}
|
|
498
|
-
} finally {
|
|
499
|
-
this._settingStorageState = false;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
async extendInjectedScript(source, arg) {
|
|
503
|
-
const installInFrame = (frame) => frame.extendInjectedScript(source, arg).catch(() => {
|
|
504
|
-
});
|
|
505
|
-
const installInPage = (page) => {
|
|
506
|
-
page.on(import_page2.Page.Events.InternalFrameNavigatedToNewDocument, installInFrame);
|
|
507
|
-
return Promise.all(page.frames().map(installInFrame));
|
|
508
|
-
};
|
|
509
|
-
this.on(BrowserContext.Events.Page, installInPage);
|
|
510
|
-
return Promise.all(this.pages().map(installInPage));
|
|
511
|
-
}
|
|
512
|
-
async safeNonStallingEvaluateInAllFrames(expression, world, options = {}) {
|
|
513
|
-
await Promise.all(this.pages().map((page) => page.safeNonStallingEvaluateInAllFrames(expression, world, options)));
|
|
514
|
-
}
|
|
515
|
-
async _harStart(page, options) {
|
|
516
|
-
const harId = (0, import_crypto.createGuid)();
|
|
517
|
-
this._harRecorders.set(harId, new import_harRecorder.HarRecorder(this, page, options));
|
|
518
|
-
return harId;
|
|
519
|
-
}
|
|
520
|
-
async _harExport(harId) {
|
|
521
|
-
const recorder = this._harRecorders.get(harId || "");
|
|
522
|
-
return recorder.export();
|
|
523
|
-
}
|
|
524
|
-
addRouteInFlight(route) {
|
|
525
|
-
this._routesInFlight.add(route);
|
|
526
|
-
}
|
|
527
|
-
removeRouteInFlight(route) {
|
|
528
|
-
this._routesInFlight.delete(route);
|
|
529
|
-
}
|
|
530
|
-
async _cancelAllRoutesInFlight() {
|
|
531
|
-
await Promise.all([...this._routesInFlight].map((r) => r.abort())).catch(() => {
|
|
532
|
-
});
|
|
533
|
-
this._routesInFlight.clear();
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
function assertBrowserContextIsNotOwned(context) {
|
|
537
|
-
for (const page of context.pages()) {
|
|
538
|
-
if (page._ownedContext)
|
|
539
|
-
throw new Error("Please use browser.newContext() for multi-page scripts that share the context.");
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
function validateBrowserContextOptions(options, browserOptions) {
|
|
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 };
|
|
553
|
-
if (options.recordVideo) {
|
|
554
|
-
if (!options.recordVideo.size) {
|
|
555
|
-
if (options.noDefaultViewport) {
|
|
556
|
-
options.recordVideo.size = { width: 800, height: 600 };
|
|
557
|
-
} else {
|
|
558
|
-
const size = options.viewport;
|
|
559
|
-
const scale = Math.min(1, 800 / Math.max(size.width, size.height));
|
|
560
|
-
options.recordVideo.size = {
|
|
561
|
-
width: Math.floor(size.width * scale),
|
|
562
|
-
height: Math.floor(size.height * scale)
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
options.recordVideo.size.width &= ~1;
|
|
567
|
-
options.recordVideo.size.height &= ~1;
|
|
568
|
-
}
|
|
569
|
-
if (options.proxy)
|
|
570
|
-
options.proxy = normalizeProxySettings(options.proxy);
|
|
571
|
-
verifyGeolocation(options.geolocation);
|
|
572
|
-
}
|
|
573
|
-
function verifyGeolocation(geolocation) {
|
|
574
|
-
if (!geolocation)
|
|
575
|
-
return;
|
|
576
|
-
geolocation.accuracy = geolocation.accuracy || 0;
|
|
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.`);
|
|
584
|
-
}
|
|
585
|
-
function verifyClientCertificates(clientCertificates) {
|
|
586
|
-
if (!clientCertificates)
|
|
587
|
-
return;
|
|
588
|
-
for (const cert of clientCertificates) {
|
|
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");
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
function normalizeProxySettings(proxy) {
|
|
602
|
-
let { server, bypass } = proxy;
|
|
603
|
-
let url;
|
|
604
|
-
try {
|
|
605
|
-
url = new URL(server);
|
|
606
|
-
if (!url.host || !url.protocol)
|
|
607
|
-
url = new URL("http://" + server);
|
|
608
|
-
} catch (e) {
|
|
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 };
|
|
619
|
-
}
|
|
620
|
-
const paramsThatAllowContextReuse = [
|
|
621
|
-
"colorScheme",
|
|
622
|
-
"forcedColors",
|
|
623
|
-
"reducedMotion",
|
|
624
|
-
"contrast",
|
|
625
|
-
"screen",
|
|
626
|
-
"userAgent",
|
|
627
|
-
"viewport"
|
|
628
|
-
];
|
|
629
|
-
const defaultNewContextParamValues = {
|
|
630
|
-
noDefaultViewport: false,
|
|
631
|
-
ignoreHTTPSErrors: false,
|
|
632
|
-
javaScriptEnabled: true,
|
|
633
|
-
bypassCSP: false,
|
|
634
|
-
offline: false,
|
|
635
|
-
isMobile: false,
|
|
636
|
-
hasTouch: false,
|
|
637
|
-
acceptDownloads: "accept",
|
|
638
|
-
strictSelectors: false,
|
|
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
|
-
});
|