rebrowser-playwright-core 1.52.0 → 1.64.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 +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 +78218 -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
package/lib/server/page.js
DELETED
|
@@ -1,790 +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 page_exports = {};
|
|
30
|
-
__export(page_exports, {
|
|
31
|
-
InitScript: () => InitScript,
|
|
32
|
-
Page: () => Page,
|
|
33
|
-
PageBinding: () => PageBinding,
|
|
34
|
-
Worker: () => Worker,
|
|
35
|
-
kBuiltinsScript: () => kBuiltinsScript
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(page_exports);
|
|
38
|
-
var accessibility = __toESM(require("./accessibility"));
|
|
39
|
-
var import_browserContext = require("./browserContext");
|
|
40
|
-
var import_console = require("./console");
|
|
41
|
-
var import_errors = require("./errors");
|
|
42
|
-
var import_fileChooser = require("./fileChooser");
|
|
43
|
-
var frames = __toESM(require("./frames"));
|
|
44
|
-
var import_helper = require("./helper");
|
|
45
|
-
var input = __toESM(require("./input"));
|
|
46
|
-
var import_instrumentation = require("./instrumentation");
|
|
47
|
-
var import_builtins = require("../utils/isomorphic/builtins");
|
|
48
|
-
var import_pageBinding = require("./pageBinding");
|
|
49
|
-
var js = __toESM(require("./javascript"));
|
|
50
|
-
var import_progress = require("./progress");
|
|
51
|
-
var import_screenshotter = require("./screenshotter");
|
|
52
|
-
var import_timeoutSettings = require("./timeoutSettings");
|
|
53
|
-
var import_utils = require("../utils");
|
|
54
|
-
var import_crypto = require("./utils/crypto");
|
|
55
|
-
var import_utils2 = require("../utils");
|
|
56
|
-
var import_comparators = require("./utils/comparators");
|
|
57
|
-
var import_debugLogger = require("./utils/debugLogger");
|
|
58
|
-
var import_selectorParser = require("../utils/isomorphic/selectorParser");
|
|
59
|
-
var import_manualPromise = require("../utils/isomorphic/manualPromise");
|
|
60
|
-
var import_callLog = require("./callLog");
|
|
61
|
-
class Page extends import_instrumentation.SdkObject {
|
|
62
|
-
constructor(delegate, browserContext) {
|
|
63
|
-
super(browserContext, "page");
|
|
64
|
-
this._closedState = "open";
|
|
65
|
-
this._closedPromise = new import_manualPromise.ManualPromise();
|
|
66
|
-
this._initializedPromise = new import_manualPromise.ManualPromise();
|
|
67
|
-
this._eventsToEmitAfterInitialized = [];
|
|
68
|
-
this._crashed = false;
|
|
69
|
-
this.openScope = new import_utils.LongStandingScope();
|
|
70
|
-
this._emulatedMedia = {};
|
|
71
|
-
this._interceptFileChooser = false;
|
|
72
|
-
this._pageBindings = /* @__PURE__ */ new Map();
|
|
73
|
-
this.initScripts = [];
|
|
74
|
-
this._workers = /* @__PURE__ */ new Map();
|
|
75
|
-
this._video = null;
|
|
76
|
-
this._isServerSideOnly = false;
|
|
77
|
-
this._locatorHandlers = /* @__PURE__ */ new Map();
|
|
78
|
-
this._lastLocatorHandlerUid = 0;
|
|
79
|
-
this._locatorHandlerRunningCounter = 0;
|
|
80
|
-
// Aiming at 25 fps by default - each frame is 40ms, but we give some slack with 35ms.
|
|
81
|
-
// When throttling for tracing, 200ms between frames, except for 10 frames around the action.
|
|
82
|
-
this._frameThrottler = new FrameThrottler(10, 35, 200);
|
|
83
|
-
this.attribution.page = this;
|
|
84
|
-
this._delegate = delegate;
|
|
85
|
-
this._browserContext = browserContext;
|
|
86
|
-
this.accessibility = new accessibility.Accessibility(delegate.getAccessibilityTree.bind(delegate));
|
|
87
|
-
this.keyboard = new input.Keyboard(delegate.rawKeyboard);
|
|
88
|
-
this.mouse = new input.Mouse(delegate.rawMouse, this);
|
|
89
|
-
this.touchscreen = new input.Touchscreen(delegate.rawTouchscreen, this);
|
|
90
|
-
this._timeoutSettings = new import_timeoutSettings.TimeoutSettings(browserContext._timeoutSettings);
|
|
91
|
-
this._screenshotter = new import_screenshotter.Screenshotter(this);
|
|
92
|
-
this._frameManager = new frames.FrameManager(this);
|
|
93
|
-
if (delegate.pdf)
|
|
94
|
-
this.pdf = delegate.pdf.bind(delegate);
|
|
95
|
-
this.coverage = delegate.coverage ? delegate.coverage() : null;
|
|
96
|
-
}
|
|
97
|
-
static {
|
|
98
|
-
this.Events = {
|
|
99
|
-
Close: "close",
|
|
100
|
-
Crash: "crash",
|
|
101
|
-
Download: "download",
|
|
102
|
-
FileChooser: "filechooser",
|
|
103
|
-
FrameAttached: "frameattached",
|
|
104
|
-
FrameDetached: "framedetached",
|
|
105
|
-
InternalFrameNavigatedToNewDocument: "internalframenavigatedtonewdocument",
|
|
106
|
-
LocatorHandlerTriggered: "locatorhandlertriggered",
|
|
107
|
-
ScreencastFrame: "screencastframe",
|
|
108
|
-
Video: "video",
|
|
109
|
-
WebSocket: "websocket",
|
|
110
|
-
Worker: "worker"
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
async reportAsNew(opener, error = void 0, contextEvent = import_browserContext.BrowserContext.Events.Page) {
|
|
114
|
-
if (opener) {
|
|
115
|
-
const openerPageOrError = await opener.waitForInitializedOrError();
|
|
116
|
-
if (openerPageOrError instanceof Page && !openerPageOrError.isClosed())
|
|
117
|
-
this._opener = openerPageOrError;
|
|
118
|
-
}
|
|
119
|
-
this._markInitialized(error, contextEvent);
|
|
120
|
-
}
|
|
121
|
-
_markInitialized(error = void 0, contextEvent = import_browserContext.BrowserContext.Events.Page) {
|
|
122
|
-
if (error) {
|
|
123
|
-
if (this._browserContext.isClosingOrClosed())
|
|
124
|
-
return;
|
|
125
|
-
this._frameManager.createDummyMainFrameIfNeeded();
|
|
126
|
-
}
|
|
127
|
-
this._initialized = error || this;
|
|
128
|
-
this.emitOnContext(contextEvent, this);
|
|
129
|
-
for (const { event, args } of this._eventsToEmitAfterInitialized)
|
|
130
|
-
this._browserContext.emit(event, ...args);
|
|
131
|
-
this._eventsToEmitAfterInitialized = [];
|
|
132
|
-
if (this.isClosed())
|
|
133
|
-
this.emit(Page.Events.Close);
|
|
134
|
-
else
|
|
135
|
-
this.instrumentation.onPageOpen(this);
|
|
136
|
-
this._initializedPromise.resolve(this._initialized);
|
|
137
|
-
}
|
|
138
|
-
initializedOrUndefined() {
|
|
139
|
-
return this._initialized ? this : void 0;
|
|
140
|
-
}
|
|
141
|
-
waitForInitializedOrError() {
|
|
142
|
-
return this._initializedPromise;
|
|
143
|
-
}
|
|
144
|
-
emitOnContext(event, ...args) {
|
|
145
|
-
if (this._isServerSideOnly)
|
|
146
|
-
return;
|
|
147
|
-
this._browserContext.emit(event, ...args);
|
|
148
|
-
}
|
|
149
|
-
emitOnContextOnceInitialized(event, ...args) {
|
|
150
|
-
if (this._isServerSideOnly)
|
|
151
|
-
return;
|
|
152
|
-
if (this._initialized)
|
|
153
|
-
this._browserContext.emit(event, ...args);
|
|
154
|
-
else
|
|
155
|
-
this._eventsToEmitAfterInitialized.push({ event, args });
|
|
156
|
-
}
|
|
157
|
-
async resetForReuse(metadata) {
|
|
158
|
-
this.setDefaultNavigationTimeout(void 0);
|
|
159
|
-
this.setDefaultTimeout(void 0);
|
|
160
|
-
this._locatorHandlers.clear();
|
|
161
|
-
await this._removeExposedBindings();
|
|
162
|
-
await this._removeInitScripts();
|
|
163
|
-
await this.setClientRequestInterceptor(void 0);
|
|
164
|
-
await this._setServerRequestInterceptor(void 0);
|
|
165
|
-
await this.setFileChooserIntercepted(false);
|
|
166
|
-
await this.mainFrame().goto(metadata, "about:blank");
|
|
167
|
-
this._emulatedSize = void 0;
|
|
168
|
-
this._emulatedMedia = {};
|
|
169
|
-
this._extraHTTPHeaders = void 0;
|
|
170
|
-
this._interceptFileChooser = false;
|
|
171
|
-
await Promise.all([
|
|
172
|
-
this._delegate.updateEmulatedViewportSize(),
|
|
173
|
-
this._delegate.updateEmulateMedia(),
|
|
174
|
-
this._delegate.updateFileChooserInterception()
|
|
175
|
-
]);
|
|
176
|
-
await this._delegate.resetForReuse();
|
|
177
|
-
}
|
|
178
|
-
_didClose() {
|
|
179
|
-
this._frameManager.dispose();
|
|
180
|
-
this._frameThrottler.dispose();
|
|
181
|
-
(0, import_utils.assert)(this._closedState !== "closed", "Page closed twice");
|
|
182
|
-
this._closedState = "closed";
|
|
183
|
-
this.emit(Page.Events.Close);
|
|
184
|
-
this._closedPromise.resolve();
|
|
185
|
-
this.instrumentation.onPageClose(this);
|
|
186
|
-
this.openScope.close(new import_errors.TargetClosedError());
|
|
187
|
-
}
|
|
188
|
-
_didCrash() {
|
|
189
|
-
this._frameManager.dispose();
|
|
190
|
-
this._frameThrottler.dispose();
|
|
191
|
-
this.emit(Page.Events.Crash);
|
|
192
|
-
this._crashed = true;
|
|
193
|
-
this.instrumentation.onPageClose(this);
|
|
194
|
-
this.openScope.close(new Error("Page crashed"));
|
|
195
|
-
}
|
|
196
|
-
async _onFileChooserOpened(handle) {
|
|
197
|
-
let multiple;
|
|
198
|
-
try {
|
|
199
|
-
multiple = await handle.evaluate((element) => !!element.multiple);
|
|
200
|
-
} catch (e) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (!this.listenerCount(Page.Events.FileChooser)) {
|
|
204
|
-
handle.dispose();
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const fileChooser = new import_fileChooser.FileChooser(this, handle, multiple);
|
|
208
|
-
this.emit(Page.Events.FileChooser, fileChooser);
|
|
209
|
-
}
|
|
210
|
-
context() {
|
|
211
|
-
return this._browserContext;
|
|
212
|
-
}
|
|
213
|
-
opener() {
|
|
214
|
-
return this._opener;
|
|
215
|
-
}
|
|
216
|
-
mainFrame() {
|
|
217
|
-
return this._frameManager.mainFrame();
|
|
218
|
-
}
|
|
219
|
-
frames() {
|
|
220
|
-
return this._frameManager.frames();
|
|
221
|
-
}
|
|
222
|
-
setDefaultNavigationTimeout(timeout) {
|
|
223
|
-
this._timeoutSettings.setDefaultNavigationTimeout(timeout);
|
|
224
|
-
}
|
|
225
|
-
setDefaultTimeout(timeout) {
|
|
226
|
-
this._timeoutSettings.setDefaultTimeout(timeout);
|
|
227
|
-
}
|
|
228
|
-
async exposeBinding(name, needsHandle, playwrightBinding) {
|
|
229
|
-
if (this._pageBindings.has(name))
|
|
230
|
-
throw new Error(`Function "${name}" has been already registered`);
|
|
231
|
-
if (this._browserContext._pageBindings.has(name))
|
|
232
|
-
throw new Error(`Function "${name}" has been already registered in the browser context`);
|
|
233
|
-
const binding = new PageBinding(name, playwrightBinding, needsHandle);
|
|
234
|
-
this._pageBindings.set(name, binding);
|
|
235
|
-
await this._delegate.addInitScript(binding.initScript);
|
|
236
|
-
await Promise.all(this.frames().map((frame) => frame.evaluateExpression(binding.initScript.source).catch((e) => {
|
|
237
|
-
})));
|
|
238
|
-
}
|
|
239
|
-
async _removeExposedBindings() {
|
|
240
|
-
for (const [key, binding] of this._pageBindings) {
|
|
241
|
-
if (!binding.internal)
|
|
242
|
-
this._pageBindings.delete(key);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
setExtraHTTPHeaders(headers) {
|
|
246
|
-
this._extraHTTPHeaders = headers;
|
|
247
|
-
return this._delegate.updateExtraHTTPHeaders();
|
|
248
|
-
}
|
|
249
|
-
extraHTTPHeaders() {
|
|
250
|
-
return this._extraHTTPHeaders;
|
|
251
|
-
}
|
|
252
|
-
async _onBindingCalled(payload, context) {
|
|
253
|
-
if (this._closedState === "closed")
|
|
254
|
-
return;
|
|
255
|
-
await PageBinding.dispatch(this, payload, context);
|
|
256
|
-
}
|
|
257
|
-
_addConsoleMessage(type, args, location, text) {
|
|
258
|
-
const message = new import_console.ConsoleMessage(this, type, text, args, location);
|
|
259
|
-
const intercepted = this._frameManager.interceptConsoleMessage(message);
|
|
260
|
-
if (intercepted) {
|
|
261
|
-
args.forEach((arg) => arg.dispose());
|
|
262
|
-
return;
|
|
263
|
-
}
|
|
264
|
-
this.emitOnContextOnceInitialized(import_browserContext.BrowserContext.Events.Console, message);
|
|
265
|
-
}
|
|
266
|
-
async reload(metadata, options) {
|
|
267
|
-
const controller = new import_progress.ProgressController(metadata, this);
|
|
268
|
-
return controller.run((progress) => this.mainFrame().raceNavigationAction(progress, options, async () => {
|
|
269
|
-
const [response] = await Promise.all([
|
|
270
|
-
// Reload must be a new document, and should not be confused with a stray pushState.
|
|
271
|
-
this.mainFrame()._waitForNavigation(progress, true, options),
|
|
272
|
-
this._delegate.reload()
|
|
273
|
-
]);
|
|
274
|
-
return response;
|
|
275
|
-
}), this._timeoutSettings.navigationTimeout(options));
|
|
276
|
-
}
|
|
277
|
-
async goBack(metadata, options) {
|
|
278
|
-
const controller = new import_progress.ProgressController(metadata, this);
|
|
279
|
-
return controller.run((progress) => this.mainFrame().raceNavigationAction(progress, options, async () => {
|
|
280
|
-
let error;
|
|
281
|
-
const waitPromise = this.mainFrame()._waitForNavigation(progress, false, options).catch((e) => {
|
|
282
|
-
error = e;
|
|
283
|
-
return null;
|
|
284
|
-
});
|
|
285
|
-
const result = await this._delegate.goBack();
|
|
286
|
-
if (!result)
|
|
287
|
-
return null;
|
|
288
|
-
const response = await waitPromise;
|
|
289
|
-
if (error)
|
|
290
|
-
throw error;
|
|
291
|
-
return response;
|
|
292
|
-
}), this._timeoutSettings.navigationTimeout(options));
|
|
293
|
-
}
|
|
294
|
-
async goForward(metadata, options) {
|
|
295
|
-
const controller = new import_progress.ProgressController(metadata, this);
|
|
296
|
-
return controller.run((progress) => this.mainFrame().raceNavigationAction(progress, options, async () => {
|
|
297
|
-
let error;
|
|
298
|
-
const waitPromise = this.mainFrame()._waitForNavigation(progress, false, options).catch((e) => {
|
|
299
|
-
error = e;
|
|
300
|
-
return null;
|
|
301
|
-
});
|
|
302
|
-
const result = await this._delegate.goForward();
|
|
303
|
-
if (!result)
|
|
304
|
-
return null;
|
|
305
|
-
const response = await waitPromise;
|
|
306
|
-
if (error)
|
|
307
|
-
throw error;
|
|
308
|
-
return response;
|
|
309
|
-
}), this._timeoutSettings.navigationTimeout(options));
|
|
310
|
-
}
|
|
311
|
-
requestGC() {
|
|
312
|
-
return this._delegate.requestGC();
|
|
313
|
-
}
|
|
314
|
-
registerLocatorHandler(selector, noWaitAfter) {
|
|
315
|
-
const uid = ++this._lastLocatorHandlerUid;
|
|
316
|
-
this._locatorHandlers.set(uid, { selector, noWaitAfter });
|
|
317
|
-
return uid;
|
|
318
|
-
}
|
|
319
|
-
resolveLocatorHandler(uid, remove) {
|
|
320
|
-
const handler = this._locatorHandlers.get(uid);
|
|
321
|
-
if (remove)
|
|
322
|
-
this._locatorHandlers.delete(uid);
|
|
323
|
-
if (handler) {
|
|
324
|
-
handler.resolved?.resolve();
|
|
325
|
-
handler.resolved = void 0;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
unregisterLocatorHandler(uid) {
|
|
329
|
-
this._locatorHandlers.delete(uid);
|
|
330
|
-
}
|
|
331
|
-
async performActionPreChecks(progress) {
|
|
332
|
-
await this._performWaitForNavigationCheck(progress);
|
|
333
|
-
progress.throwIfAborted();
|
|
334
|
-
await this._performLocatorHandlersCheckpoint(progress);
|
|
335
|
-
progress.throwIfAborted();
|
|
336
|
-
await this._performWaitForNavigationCheck(progress);
|
|
337
|
-
}
|
|
338
|
-
async _performWaitForNavigationCheck(progress) {
|
|
339
|
-
if (process.env.PLAYWRIGHT_SKIP_NAVIGATION_CHECK)
|
|
340
|
-
return;
|
|
341
|
-
const mainFrame = this._frameManager.mainFrame();
|
|
342
|
-
if (!mainFrame || !mainFrame.pendingDocument())
|
|
343
|
-
return;
|
|
344
|
-
const url = mainFrame.pendingDocument()?.request?.url();
|
|
345
|
-
const toUrl = url ? `" ${(0, import_utils.trimStringWithEllipsis)(url, 200)}"` : "";
|
|
346
|
-
progress.log(` waiting for${toUrl} navigation to finish...`);
|
|
347
|
-
await import_helper.helper.waitForEvent(progress, mainFrame, frames.Frame.Events.InternalNavigation, (e) => {
|
|
348
|
-
if (!e.isPublic)
|
|
349
|
-
return false;
|
|
350
|
-
if (!e.error)
|
|
351
|
-
progress.log(` navigated to "${(0, import_utils.trimStringWithEllipsis)(mainFrame.url(), 200)}"`);
|
|
352
|
-
return true;
|
|
353
|
-
}).promise;
|
|
354
|
-
}
|
|
355
|
-
async _performLocatorHandlersCheckpoint(progress) {
|
|
356
|
-
if (this._locatorHandlerRunningCounter)
|
|
357
|
-
return;
|
|
358
|
-
for (const [uid, handler] of this._locatorHandlers) {
|
|
359
|
-
if (!handler.resolved) {
|
|
360
|
-
if (await this.mainFrame().isVisibleInternal(handler.selector, { strict: true })) {
|
|
361
|
-
handler.resolved = new import_manualPromise.ManualPromise();
|
|
362
|
-
this.emit(Page.Events.LocatorHandlerTriggered, uid);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
if (handler.resolved) {
|
|
366
|
-
++this._locatorHandlerRunningCounter;
|
|
367
|
-
progress.log(` found ${(0, import_utils2.asLocator)(this.attribution.playwright.options.sdkLanguage, handler.selector)}, intercepting action to run the handler`);
|
|
368
|
-
const promise = handler.resolved.then(async () => {
|
|
369
|
-
progress.throwIfAborted();
|
|
370
|
-
if (!handler.noWaitAfter) {
|
|
371
|
-
progress.log(` locator handler has finished, waiting for ${(0, import_utils2.asLocator)(this.attribution.playwright.options.sdkLanguage, handler.selector)} to be hidden`);
|
|
372
|
-
await this.mainFrame().waitForSelectorInternal(progress, handler.selector, false, { state: "hidden" });
|
|
373
|
-
} else {
|
|
374
|
-
progress.log(` locator handler has finished`);
|
|
375
|
-
}
|
|
376
|
-
});
|
|
377
|
-
await this.openScope.race(promise).finally(() => --this._locatorHandlerRunningCounter);
|
|
378
|
-
progress.throwIfAborted();
|
|
379
|
-
progress.log(` interception handler has finished, continuing`);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
async emulateMedia(options) {
|
|
384
|
-
if (options.media !== void 0)
|
|
385
|
-
this._emulatedMedia.media = options.media;
|
|
386
|
-
if (options.colorScheme !== void 0)
|
|
387
|
-
this._emulatedMedia.colorScheme = options.colorScheme;
|
|
388
|
-
if (options.reducedMotion !== void 0)
|
|
389
|
-
this._emulatedMedia.reducedMotion = options.reducedMotion;
|
|
390
|
-
if (options.forcedColors !== void 0)
|
|
391
|
-
this._emulatedMedia.forcedColors = options.forcedColors;
|
|
392
|
-
if (options.contrast !== void 0)
|
|
393
|
-
this._emulatedMedia.contrast = options.contrast;
|
|
394
|
-
await this._delegate.updateEmulateMedia();
|
|
395
|
-
}
|
|
396
|
-
emulatedMedia() {
|
|
397
|
-
const contextOptions = this._browserContext._options;
|
|
398
|
-
return {
|
|
399
|
-
media: this._emulatedMedia.media || "no-override",
|
|
400
|
-
colorScheme: this._emulatedMedia.colorScheme !== void 0 ? this._emulatedMedia.colorScheme : contextOptions.colorScheme ?? "light",
|
|
401
|
-
reducedMotion: this._emulatedMedia.reducedMotion !== void 0 ? this._emulatedMedia.reducedMotion : contextOptions.reducedMotion ?? "no-preference",
|
|
402
|
-
forcedColors: this._emulatedMedia.forcedColors !== void 0 ? this._emulatedMedia.forcedColors : contextOptions.forcedColors ?? "none",
|
|
403
|
-
contrast: this._emulatedMedia.contrast !== void 0 ? this._emulatedMedia.contrast : contextOptions.contrast ?? "no-preference"
|
|
404
|
-
};
|
|
405
|
-
}
|
|
406
|
-
async setViewportSize(viewportSize) {
|
|
407
|
-
this._emulatedSize = { viewport: { ...viewportSize }, screen: { ...viewportSize } };
|
|
408
|
-
await this._delegate.updateEmulatedViewportSize();
|
|
409
|
-
}
|
|
410
|
-
viewportSize() {
|
|
411
|
-
return this.emulatedSize()?.viewport || null;
|
|
412
|
-
}
|
|
413
|
-
emulatedSize() {
|
|
414
|
-
if (this._emulatedSize)
|
|
415
|
-
return this._emulatedSize;
|
|
416
|
-
const contextOptions = this._browserContext._options;
|
|
417
|
-
return contextOptions.viewport ? { viewport: contextOptions.viewport, screen: contextOptions.screen || contextOptions.viewport } : null;
|
|
418
|
-
}
|
|
419
|
-
async bringToFront() {
|
|
420
|
-
await this._delegate.bringToFront();
|
|
421
|
-
}
|
|
422
|
-
async addInitScript(source, name) {
|
|
423
|
-
const initScript = new InitScript(source, false, name);
|
|
424
|
-
this.initScripts.push(initScript);
|
|
425
|
-
await this._delegate.addInitScript(initScript);
|
|
426
|
-
}
|
|
427
|
-
async _removeInitScripts() {
|
|
428
|
-
this.initScripts = this.initScripts.filter((script) => script.internal);
|
|
429
|
-
await this._delegate.removeNonInternalInitScripts();
|
|
430
|
-
}
|
|
431
|
-
needsRequestInterception() {
|
|
432
|
-
return !!this._clientRequestInterceptor || !!this._serverRequestInterceptor || !!this._browserContext._requestInterceptor;
|
|
433
|
-
}
|
|
434
|
-
async setClientRequestInterceptor(handler) {
|
|
435
|
-
this._clientRequestInterceptor = handler;
|
|
436
|
-
await this._delegate.updateRequestInterception();
|
|
437
|
-
}
|
|
438
|
-
async _setServerRequestInterceptor(handler) {
|
|
439
|
-
this._serverRequestInterceptor = handler;
|
|
440
|
-
await this._delegate.updateRequestInterception();
|
|
441
|
-
}
|
|
442
|
-
async expectScreenshot(metadata, options = {}) {
|
|
443
|
-
const locator = options.locator;
|
|
444
|
-
const rafrafScreenshot = locator ? async (progress, timeout) => {
|
|
445
|
-
return await locator.frame.rafrafTimeoutScreenshotElementWithProgress(progress, locator.selector, timeout, options || {});
|
|
446
|
-
} : async (progress, timeout) => {
|
|
447
|
-
await this.performActionPreChecks(progress);
|
|
448
|
-
await this.mainFrame().rafrafTimeout(timeout);
|
|
449
|
-
return await this._screenshotter.screenshotPage(progress, options || {});
|
|
450
|
-
};
|
|
451
|
-
const comparator = (0, import_comparators.getComparator)("image/png");
|
|
452
|
-
const controller = new import_progress.ProgressController(metadata, this);
|
|
453
|
-
if (!options.expected && options.isNot)
|
|
454
|
-
return { errorMessage: '"not" matcher requires expected result' };
|
|
455
|
-
try {
|
|
456
|
-
const format = (0, import_screenshotter.validateScreenshotOptions)(options || {});
|
|
457
|
-
if (format !== "png")
|
|
458
|
-
throw new Error("Only PNG screenshots are supported");
|
|
459
|
-
} catch (error) {
|
|
460
|
-
return { errorMessage: error.message };
|
|
461
|
-
}
|
|
462
|
-
let intermediateResult = void 0;
|
|
463
|
-
const areEqualScreenshots = (actual, expected, previous) => {
|
|
464
|
-
const comparatorResult = actual && expected ? comparator(actual, expected, options) : void 0;
|
|
465
|
-
if (comparatorResult !== void 0 && !!comparatorResult === !!options.isNot)
|
|
466
|
-
return true;
|
|
467
|
-
if (comparatorResult)
|
|
468
|
-
intermediateResult = { errorMessage: comparatorResult.errorMessage, diff: comparatorResult.diff, actual, previous };
|
|
469
|
-
return false;
|
|
470
|
-
};
|
|
471
|
-
const callTimeout = this._timeoutSettings.timeout(options);
|
|
472
|
-
return controller.run(async (progress) => {
|
|
473
|
-
let actual;
|
|
474
|
-
let previous;
|
|
475
|
-
const pollIntervals = [0, 100, 250, 500];
|
|
476
|
-
progress.log(`${metadata.apiName}${callTimeout ? ` with timeout ${callTimeout}ms` : ""}`);
|
|
477
|
-
if (options.expected)
|
|
478
|
-
progress.log(` verifying given screenshot expectation`);
|
|
479
|
-
else
|
|
480
|
-
progress.log(` generating new stable screenshot expectation`);
|
|
481
|
-
let isFirstIteration = true;
|
|
482
|
-
while (true) {
|
|
483
|
-
progress.throwIfAborted();
|
|
484
|
-
if (this.isClosed())
|
|
485
|
-
throw new Error("The page has closed");
|
|
486
|
-
const screenshotTimeout = pollIntervals.shift() ?? 1e3;
|
|
487
|
-
if (screenshotTimeout)
|
|
488
|
-
progress.log(`waiting ${screenshotTimeout}ms before taking screenshot`);
|
|
489
|
-
previous = actual;
|
|
490
|
-
actual = await rafrafScreenshot(progress, screenshotTimeout).catch((e) => {
|
|
491
|
-
progress.log(`failed to take screenshot - ` + e.message);
|
|
492
|
-
return void 0;
|
|
493
|
-
});
|
|
494
|
-
if (!actual)
|
|
495
|
-
continue;
|
|
496
|
-
const expectation = options.expected && isFirstIteration ? options.expected : previous;
|
|
497
|
-
if (areEqualScreenshots(actual, expectation, previous))
|
|
498
|
-
break;
|
|
499
|
-
if (intermediateResult)
|
|
500
|
-
progress.log(intermediateResult.errorMessage);
|
|
501
|
-
isFirstIteration = false;
|
|
502
|
-
}
|
|
503
|
-
if (!isFirstIteration)
|
|
504
|
-
progress.log(`captured a stable screenshot`);
|
|
505
|
-
if (!options.expected)
|
|
506
|
-
return { actual };
|
|
507
|
-
if (isFirstIteration) {
|
|
508
|
-
progress.log(`screenshot matched expectation`);
|
|
509
|
-
return {};
|
|
510
|
-
}
|
|
511
|
-
if (areEqualScreenshots(actual, options.expected, void 0)) {
|
|
512
|
-
progress.log(`screenshot matched expectation`);
|
|
513
|
-
return {};
|
|
514
|
-
}
|
|
515
|
-
throw new Error(intermediateResult.errorMessage);
|
|
516
|
-
}, callTimeout).catch((e) => {
|
|
517
|
-
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
|
|
518
|
-
throw e;
|
|
519
|
-
let errorMessage = e.message;
|
|
520
|
-
if (e instanceof import_errors.TimeoutError && intermediateResult?.previous)
|
|
521
|
-
errorMessage = `Failed to take two consecutive stable screenshots.`;
|
|
522
|
-
return {
|
|
523
|
-
log: (0, import_callLog.compressCallLog)(e.message ? [...metadata.log, e.message] : metadata.log),
|
|
524
|
-
...intermediateResult,
|
|
525
|
-
errorMessage,
|
|
526
|
-
timedOut: e instanceof import_errors.TimeoutError
|
|
527
|
-
};
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
async screenshot(metadata, options = {}) {
|
|
531
|
-
const controller = new import_progress.ProgressController(metadata, this);
|
|
532
|
-
return controller.run(
|
|
533
|
-
(progress) => this._screenshotter.screenshotPage(progress, options),
|
|
534
|
-
this._timeoutSettings.timeout(options)
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
async close(metadata, options = {}) {
|
|
538
|
-
if (this._closedState === "closed")
|
|
539
|
-
return;
|
|
540
|
-
if (options.reason)
|
|
541
|
-
this._closeReason = options.reason;
|
|
542
|
-
const runBeforeUnload = !!options.runBeforeUnload;
|
|
543
|
-
if (this._closedState !== "closing") {
|
|
544
|
-
this._closedState = "closing";
|
|
545
|
-
await this._delegate.closePage(runBeforeUnload).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
546
|
-
}
|
|
547
|
-
if (!runBeforeUnload)
|
|
548
|
-
await this._closedPromise;
|
|
549
|
-
if (this._ownedContext)
|
|
550
|
-
await this._ownedContext.close(options);
|
|
551
|
-
}
|
|
552
|
-
isClosed() {
|
|
553
|
-
return this._closedState === "closed";
|
|
554
|
-
}
|
|
555
|
-
hasCrashed() {
|
|
556
|
-
return this._crashed;
|
|
557
|
-
}
|
|
558
|
-
isClosedOrClosingOrCrashed() {
|
|
559
|
-
return this._closedState !== "open" || this._crashed;
|
|
560
|
-
}
|
|
561
|
-
_addWorker(workerId, worker) {
|
|
562
|
-
this._workers.set(workerId, worker);
|
|
563
|
-
this.emit(Page.Events.Worker, worker);
|
|
564
|
-
}
|
|
565
|
-
_removeWorker(workerId) {
|
|
566
|
-
const worker = this._workers.get(workerId);
|
|
567
|
-
if (!worker)
|
|
568
|
-
return;
|
|
569
|
-
worker.didClose();
|
|
570
|
-
this._workers.delete(workerId);
|
|
571
|
-
}
|
|
572
|
-
_clearWorkers() {
|
|
573
|
-
for (const [workerId, worker] of this._workers) {
|
|
574
|
-
worker.didClose();
|
|
575
|
-
this._workers.delete(workerId);
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
async setFileChooserIntercepted(enabled) {
|
|
579
|
-
this._interceptFileChooser = enabled;
|
|
580
|
-
await this._delegate.updateFileChooserInterception();
|
|
581
|
-
}
|
|
582
|
-
fileChooserIntercepted() {
|
|
583
|
-
return this._interceptFileChooser;
|
|
584
|
-
}
|
|
585
|
-
frameNavigatedToNewDocument(frame) {
|
|
586
|
-
this.emit(Page.Events.InternalFrameNavigatedToNewDocument, frame);
|
|
587
|
-
const origin = frame.origin();
|
|
588
|
-
if (origin)
|
|
589
|
-
this._browserContext.addVisitedOrigin(origin);
|
|
590
|
-
}
|
|
591
|
-
allInitScripts() {
|
|
592
|
-
const bindings = [...this._browserContext._pageBindings.values(), ...this._pageBindings.values()];
|
|
593
|
-
return [kBuiltinsScript, ...bindings.map((binding) => binding.initScript), ...this._browserContext.initScripts, ...this.initScripts];
|
|
594
|
-
}
|
|
595
|
-
getBinding(name) {
|
|
596
|
-
return this._pageBindings.get(name) || this._browserContext._pageBindings.get(name);
|
|
597
|
-
}
|
|
598
|
-
setScreencastOptions(options) {
|
|
599
|
-
this._delegate.setScreencastOptions(options).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
600
|
-
this._frameThrottler.setThrottlingEnabled(!!options);
|
|
601
|
-
}
|
|
602
|
-
throttleScreencastFrameAck(ack) {
|
|
603
|
-
this._frameThrottler.ack(ack);
|
|
604
|
-
}
|
|
605
|
-
temporarilyDisableTracingScreencastThrottling() {
|
|
606
|
-
this._frameThrottler.recharge();
|
|
607
|
-
}
|
|
608
|
-
async safeNonStallingEvaluateInAllFrames(expression, world, options = {}) {
|
|
609
|
-
await Promise.all(this.frames().map(async (frame) => {
|
|
610
|
-
try {
|
|
611
|
-
await frame.nonStallingEvaluateInExistingContext(expression, world);
|
|
612
|
-
} catch (e) {
|
|
613
|
-
if (options.throwOnJSErrors && js.isJavaScriptErrorInEvaluate(e))
|
|
614
|
-
throw e;
|
|
615
|
-
}
|
|
616
|
-
}));
|
|
617
|
-
}
|
|
618
|
-
async hideHighlight() {
|
|
619
|
-
await Promise.all(this.frames().map((frame) => frame.hideHighlight().catch(() => {
|
|
620
|
-
})));
|
|
621
|
-
}
|
|
622
|
-
markAsServerSideOnly() {
|
|
623
|
-
this._isServerSideOnly = true;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
class Worker extends import_instrumentation.SdkObject {
|
|
627
|
-
constructor(parent, url, targetId, session) {
|
|
628
|
-
super(parent, "worker");
|
|
629
|
-
this._existingExecutionContext = null;
|
|
630
|
-
this.openScope = new import_utils.LongStandingScope();
|
|
631
|
-
this._url = url;
|
|
632
|
-
this._executionContextCallback = () => {
|
|
633
|
-
};
|
|
634
|
-
this._executionContextPromise = new Promise((x) => this._executionContextCallback = x);
|
|
635
|
-
this._targetId = targetId;
|
|
636
|
-
this._session = session;
|
|
637
|
-
}
|
|
638
|
-
static {
|
|
639
|
-
this.Events = {
|
|
640
|
-
Close: "close"
|
|
641
|
-
};
|
|
642
|
-
}
|
|
643
|
-
_createExecutionContext(delegate) {
|
|
644
|
-
this._existingExecutionContext = new js.ExecutionContext(this, delegate, "worker");
|
|
645
|
-
this._executionContextCallback(this._existingExecutionContext);
|
|
646
|
-
return this._existingExecutionContext;
|
|
647
|
-
}
|
|
648
|
-
url() {
|
|
649
|
-
return this._url;
|
|
650
|
-
}
|
|
651
|
-
didClose() {
|
|
652
|
-
if (this._existingExecutionContext)
|
|
653
|
-
this._existingExecutionContext.contextDestroyed("Worker was closed");
|
|
654
|
-
this.emit(Worker.Events.Close, this);
|
|
655
|
-
this.openScope.close(new Error("Worker closed"));
|
|
656
|
-
}
|
|
657
|
-
async getExecutionContext() {
|
|
658
|
-
if (process.env["REBROWSER_PATCHES_RUNTIME_FIX_MODE"] !== "0" && !this._existingExecutionContext) {
|
|
659
|
-
await this._session.__re__emitExecutionContext({
|
|
660
|
-
world: "main",
|
|
661
|
-
targetId: this._targetId
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
return this._executionContextPromise;
|
|
665
|
-
}
|
|
666
|
-
async evaluateExpression(expression, isFunction, arg) {
|
|
667
|
-
return js.evaluateExpression(await this.getExecutionContext(), expression, { returnByValue: true, isFunction }, arg);
|
|
668
|
-
}
|
|
669
|
-
async evaluateExpressionHandle(expression, isFunction, arg) {
|
|
670
|
-
return js.evaluateExpression(await this.getExecutionContext(), expression, { returnByValue: false, isFunction }, arg);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
class PageBinding {
|
|
674
|
-
static {
|
|
675
|
-
this.kPlaywrightBinding = "__playwright__binding__";
|
|
676
|
-
}
|
|
677
|
-
constructor(name, playwrightFunction, needsHandle) {
|
|
678
|
-
this.name = name;
|
|
679
|
-
this.playwrightFunction = playwrightFunction;
|
|
680
|
-
this.initScript = new InitScript(
|
|
681
|
-
(0, import_pageBinding.createPageBindingScript)(PageBinding.kPlaywrightBinding, name, needsHandle),
|
|
682
|
-
true
|
|
683
|
-
/* internal */
|
|
684
|
-
);
|
|
685
|
-
this.needsHandle = needsHandle;
|
|
686
|
-
this.internal = name.startsWith("__pw");
|
|
687
|
-
}
|
|
688
|
-
static async dispatch(page, payload, context) {
|
|
689
|
-
if (process.env["REBROWSER_PATCHES_RUNTIME_FIX_MODE"] !== "0" && !payload.includes("{")) {
|
|
690
|
-
return;
|
|
691
|
-
}
|
|
692
|
-
const { name, seq, serializedArgs } = JSON.parse(payload);
|
|
693
|
-
try {
|
|
694
|
-
(0, import_utils.assert)(context.world);
|
|
695
|
-
const binding = page.getBinding(name);
|
|
696
|
-
if (!binding)
|
|
697
|
-
throw new Error(`Function "${name}" is not exposed`);
|
|
698
|
-
let result;
|
|
699
|
-
if (binding.needsHandle) {
|
|
700
|
-
const handle = await context.evaluateHandle(import_pageBinding.takeBindingHandle, { name, seq }).catch((e) => null);
|
|
701
|
-
result = await binding.playwrightFunction({ frame: context.frame, page, context: page._browserContext }, handle);
|
|
702
|
-
} else {
|
|
703
|
-
if (!Array.isArray(serializedArgs))
|
|
704
|
-
throw new Error(`serializedArgs is not an array. This can happen when Array.prototype.toJSON is defined incorrectly`);
|
|
705
|
-
const args = serializedArgs.map((a) => js.parseEvaluationResultValue(a));
|
|
706
|
-
result = await binding.playwrightFunction({ frame: context.frame, page, context: page._browserContext }, ...args);
|
|
707
|
-
}
|
|
708
|
-
context.evaluate(import_pageBinding.deliverBindingResult, { name, seq, result }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
709
|
-
} catch (error) {
|
|
710
|
-
context.evaluate(import_pageBinding.deliverBindingResult, { name, seq, error }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
class InitScript {
|
|
715
|
-
constructor(source, internal, name) {
|
|
716
|
-
const guid = (0, import_crypto.createGuid)();
|
|
717
|
-
this.source = `(() => {
|
|
718
|
-
globalThis.__pwInitScripts = globalThis.__pwInitScripts || {};
|
|
719
|
-
const hasInitScript = globalThis.__pwInitScripts[${JSON.stringify(guid)}];
|
|
720
|
-
if (hasInitScript)
|
|
721
|
-
return;
|
|
722
|
-
globalThis.__pwInitScripts[${JSON.stringify(guid)}] = true;
|
|
723
|
-
${source}
|
|
724
|
-
})();`;
|
|
725
|
-
this.internal = !!internal;
|
|
726
|
-
this.name = name;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
const kBuiltinsScript = new InitScript(
|
|
730
|
-
`(${import_builtins.builtins})()`,
|
|
731
|
-
true
|
|
732
|
-
/* internal */
|
|
733
|
-
);
|
|
734
|
-
class FrameThrottler {
|
|
735
|
-
constructor(nonThrottledFrames, defaultInterval, throttlingInterval) {
|
|
736
|
-
this._acks = [];
|
|
737
|
-
this._throttlingEnabled = false;
|
|
738
|
-
this._nonThrottledFrames = nonThrottledFrames;
|
|
739
|
-
this._budget = nonThrottledFrames;
|
|
740
|
-
this._defaultInterval = defaultInterval;
|
|
741
|
-
this._throttlingInterval = throttlingInterval;
|
|
742
|
-
this._tick();
|
|
743
|
-
}
|
|
744
|
-
dispose() {
|
|
745
|
-
if (this._timeoutId) {
|
|
746
|
-
clearTimeout(this._timeoutId);
|
|
747
|
-
this._timeoutId = void 0;
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
setThrottlingEnabled(enabled) {
|
|
751
|
-
this._throttlingEnabled = enabled;
|
|
752
|
-
}
|
|
753
|
-
recharge() {
|
|
754
|
-
for (const ack of this._acks)
|
|
755
|
-
ack();
|
|
756
|
-
this._acks = [];
|
|
757
|
-
this._budget = this._nonThrottledFrames;
|
|
758
|
-
if (this._timeoutId) {
|
|
759
|
-
clearTimeout(this._timeoutId);
|
|
760
|
-
this._tick();
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
ack(ack) {
|
|
764
|
-
if (!this._timeoutId) {
|
|
765
|
-
ack();
|
|
766
|
-
return;
|
|
767
|
-
}
|
|
768
|
-
this._acks.push(ack);
|
|
769
|
-
}
|
|
770
|
-
_tick() {
|
|
771
|
-
const ack = this._acks.shift();
|
|
772
|
-
if (ack) {
|
|
773
|
-
--this._budget;
|
|
774
|
-
ack();
|
|
775
|
-
}
|
|
776
|
-
if (this._throttlingEnabled && this._budget <= 0) {
|
|
777
|
-
this._timeoutId = setTimeout(() => this._tick(), this._throttlingInterval);
|
|
778
|
-
} else {
|
|
779
|
-
this._timeoutId = setTimeout(() => this._tick(), this._defaultInterval);
|
|
780
|
-
}
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
784
|
-
0 && (module.exports = {
|
|
785
|
-
InitScript,
|
|
786
|
-
Page,
|
|
787
|
-
PageBinding,
|
|
788
|
-
Worker,
|
|
789
|
-
kBuiltinsScript
|
|
790
|
-
});
|