pure-patchright 1.52.5__py3-none-any.whl
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.
- patchright/__init__.py +5 -0
- patchright/__main__.py +18 -0
- patchright/_impl/__init__.py +0 -0
- patchright/_impl/__pyinstaller/__init__.py +20 -0
- patchright/_impl/__pyinstaller/hook-playwright.async_api.py +3 -0
- patchright/_impl/__pyinstaller/hook-playwright.sync_api.py +3 -0
- patchright/_impl/_accessibility.py +50 -0
- patchright/_impl/_api_structures.py +277 -0
- patchright/_impl/_artifact.py +45 -0
- patchright/_impl/_assertions.py +867 -0
- patchright/_impl/_async_base.py +92 -0
- patchright/_impl/_browser.py +248 -0
- patchright/_impl/_browser_context.py +743 -0
- patchright/_impl/_browser_type.py +276 -0
- patchright/_impl/_cdp_session.py +21 -0
- patchright/_impl/_clock.py +57 -0
- patchright/_impl/_connection.py +562 -0
- patchright/_impl/_console_message.py +45 -0
- patchright/_impl/_dialog.py +40 -0
- patchright/_impl/_download.py +50 -0
- patchright/_impl/_driver.py +24 -0
- patchright/_impl/_element_handle.py +376 -0
- patchright/_impl/_errors.py +44 -0
- patchright/_impl/_event_context_manager.py +20 -0
- patchright/_impl/_fetch.py +518 -0
- patchright/_impl/_file_chooser.py +43 -0
- patchright/_impl/_frame.py +779 -0
- patchright/_impl/_glob.py +46 -0
- patchright/_impl/_greenlets.py +39 -0
- patchright/_impl/_har_router.py +99 -0
- patchright/_impl/_helper.py +481 -0
- patchright/_impl/_impl_to_api_mapping.py +123 -0
- patchright/_impl/_input.py +71 -0
- patchright/_impl/_js_handle.py +300 -0
- patchright/_impl/_json_pipe.py +56 -0
- patchright/_impl/_local_utils.py +73 -0
- patchright/_impl/_locator.py +814 -0
- patchright/_impl/_map.py +19 -0
- patchright/_impl/_network.py +958 -0
- patchright/_impl/_object_factory.py +91 -0
- patchright/_impl/_page.py +1485 -0
- patchright/_impl/_path_utils.py +11 -0
- patchright/_impl/_playwright.py +51 -0
- patchright/_impl/_selectors.py +62 -0
- patchright/_impl/_set_input_files_helpers.py +135 -0
- patchright/_impl/_str_utils.py +57 -0
- patchright/_impl/_stream.py +32 -0
- patchright/_impl/_sync_base.py +134 -0
- patchright/_impl/_tracing.py +110 -0
- patchright/_impl/_transport.py +150 -0
- patchright/_impl/_video.py +57 -0
- patchright/_impl/_waiter.py +142 -0
- patchright/_impl/_web_error.py +27 -0
- patchright/_impl/_writable_stream.py +27 -0
- patchright/_repo_version.py +1 -0
- patchright/async_api/__init__.py +179 -0
- patchright/async_api/_context_manager.py +39 -0
- patchright/async_api/_generated.py +20416 -0
- patchright/driver/README.md +1 -0
- patchright/driver/package/README.md +3 -0
- patchright/driver/package/ThirdPartyNotices.txt +1560 -0
- patchright/driver/package/bin/install_media_pack.ps1 +5 -0
- patchright/driver/package/bin/reinstall_chrome_beta_linux.sh +42 -0
- patchright/driver/package/bin/reinstall_chrome_beta_mac.sh +13 -0
- patchright/driver/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- patchright/driver/package/bin/reinstall_chrome_stable_linux.sh +42 -0
- patchright/driver/package/bin/reinstall_chrome_stable_mac.sh +12 -0
- patchright/driver/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- patchright/driver/package/bin/reinstall_msedge_beta_linux.sh +48 -0
- patchright/driver/package/bin/reinstall_msedge_beta_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- patchright/driver/package/bin/reinstall_msedge_dev_linux.sh +48 -0
- patchright/driver/package/bin/reinstall_msedge_dev_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- patchright/driver/package/bin/reinstall_msedge_stable_linux.sh +48 -0
- patchright/driver/package/bin/reinstall_msedge_stable_mac.sh +11 -0
- patchright/driver/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- patchright/driver/package/browsers.json +80 -0
- patchright/driver/package/cli.js +18 -0
- patchright/driver/package/index.js +32 -0
- patchright/driver/package/index.mjs +28 -0
- patchright/driver/package/lib/androidServerImpl.js +63 -0
- patchright/driver/package/lib/browserServerImpl.js +88 -0
- patchright/driver/package/lib/cli/driver.js +97 -0
- patchright/driver/package/lib/cli/program.js +567 -0
- patchright/driver/package/lib/cli/programWithTestStub.js +74 -0
- patchright/driver/package/lib/client/accessibility.js +49 -0
- patchright/driver/package/lib/client/android.js +365 -0
- patchright/driver/package/lib/client/api.js +137 -0
- patchright/driver/package/lib/client/artifact.js +79 -0
- patchright/driver/package/lib/client/browser.js +136 -0
- patchright/driver/package/lib/client/browserContext.js +539 -0
- patchright/driver/package/lib/client/browserType.js +193 -0
- patchright/driver/package/lib/client/cdpSession.js +51 -0
- patchright/driver/package/lib/client/channelOwner.js +205 -0
- patchright/driver/package/lib/client/clientHelper.js +64 -0
- patchright/driver/package/lib/client/clientInstrumentation.js +55 -0
- patchright/driver/package/lib/client/clientStackTrace.js +69 -0
- patchright/driver/package/lib/client/clock.js +68 -0
- patchright/driver/package/lib/client/connection.js +318 -0
- patchright/driver/package/lib/client/consoleMessage.js +55 -0
- patchright/driver/package/lib/client/coverage.js +44 -0
- patchright/driver/package/lib/client/dialog.js +56 -0
- patchright/driver/package/lib/client/download.js +62 -0
- patchright/driver/package/lib/client/electron.js +133 -0
- patchright/driver/package/lib/client/elementHandle.js +284 -0
- patchright/driver/package/lib/client/errors.js +77 -0
- patchright/driver/package/lib/client/eventEmitter.js +314 -0
- patchright/driver/package/lib/client/events.js +98 -0
- patchright/driver/package/lib/client/fetch.js +367 -0
- patchright/driver/package/lib/client/fileChooser.js +46 -0
- patchright/driver/package/lib/client/fileUtils.js +34 -0
- patchright/driver/package/lib/client/frame.js +386 -0
- patchright/driver/package/lib/client/harRouter.js +87 -0
- patchright/driver/package/lib/client/input.js +82 -0
- patchright/driver/package/lib/client/jsHandle.js +105 -0
- patchright/driver/package/lib/client/jsonPipe.js +39 -0
- patchright/driver/package/lib/client/localUtils.js +61 -0
- patchright/driver/package/lib/client/locator.js +362 -0
- patchright/driver/package/lib/client/network.js +751 -0
- patchright/driver/package/lib/client/page.js +709 -0
- patchright/driver/package/lib/client/platform.js +74 -0
- patchright/driver/package/lib/client/playwright.js +85 -0
- patchright/driver/package/lib/client/selectors.js +75 -0
- patchright/driver/package/lib/client/stream.js +39 -0
- patchright/driver/package/lib/client/timeoutSettings.js +75 -0
- patchright/driver/package/lib/client/tracing.js +114 -0
- patchright/driver/package/lib/client/types.js +28 -0
- patchright/driver/package/lib/client/video.js +59 -0
- patchright/driver/package/lib/client/waiter.js +142 -0
- patchright/driver/package/lib/client/webError.js +39 -0
- patchright/driver/package/lib/client/webSocket.js +111 -0
- patchright/driver/package/lib/client/worker.js +63 -0
- patchright/driver/package/lib/client/writableStream.js +39 -0
- patchright/driver/package/lib/generated/clockSource.js +28 -0
- patchright/driver/package/lib/generated/consoleApiSource.js +28 -0
- patchright/driver/package/lib/generated/injectedScriptSource.js +28 -0
- patchright/driver/package/lib/generated/pollingRecorderSource.js +28 -0
- patchright/driver/package/lib/generated/utilityScriptSource.js +28 -0
- patchright/driver/package/lib/generated/webSocketMockSource.js +374 -0
- patchright/driver/package/lib/inProcessFactory.js +59 -0
- patchright/driver/package/lib/inprocess.js +3 -0
- patchright/driver/package/lib/outofprocess.js +78 -0
- patchright/driver/package/lib/protocol/debug.js +211 -0
- patchright/driver/package/lib/protocol/serializers.js +192 -0
- patchright/driver/package/lib/protocol/validator.js +2832 -0
- patchright/driver/package/lib/protocol/validatorPrimitives.js +179 -0
- patchright/driver/package/lib/remote/playwrightConnection.js +266 -0
- patchright/driver/package/lib/remote/playwrightServer.js +139 -0
- patchright/driver/package/lib/server/accessibility.js +69 -0
- patchright/driver/package/lib/server/android/android.js +451 -0
- patchright/driver/package/lib/server/android/backendAdb.js +179 -0
- patchright/driver/package/lib/server/artifact.js +127 -0
- patchright/driver/package/lib/server/bidi/bidiBrowser.js +380 -0
- patchright/driver/package/lib/server/bidi/bidiChromium.js +152 -0
- patchright/driver/package/lib/server/bidi/bidiConnection.js +187 -0
- patchright/driver/package/lib/server/bidi/bidiExecutionContext.js +220 -0
- patchright/driver/package/lib/server/bidi/bidiFirefox.js +112 -0
- patchright/driver/package/lib/server/bidi/bidiInput.js +146 -0
- patchright/driver/package/lib/server/bidi/bidiNetworkManager.js +320 -0
- patchright/driver/package/lib/server/bidi/bidiOverCdp.js +102 -0
- patchright/driver/package/lib/server/bidi/bidiPage.js +530 -0
- patchright/driver/package/lib/server/bidi/bidiPdf.js +106 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiDeserializer.js +98 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiProtocol.js +152 -0
- patchright/driver/package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
- patchright/driver/package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
- patchright/driver/package/lib/server/browser.js +140 -0
- patchright/driver/package/lib/server/browserContext.js +646 -0
- patchright/driver/package/lib/server/browserType.js +326 -0
- patchright/driver/package/lib/server/callLog.js +82 -0
- patchright/driver/package/lib/server/chromium/appIcon.png +0 -0
- patchright/driver/package/lib/server/chromium/chromium.js +376 -0
- patchright/driver/package/lib/server/chromium/chromiumSwitches.js +89 -0
- patchright/driver/package/lib/server/chromium/crAccessibility.js +263 -0
- patchright/driver/package/lib/server/chromium/crBrowser.js +503 -0
- patchright/driver/package/lib/server/chromium/crConnection.js +203 -0
- patchright/driver/package/lib/server/chromium/crCoverage.js +232 -0
- patchright/driver/package/lib/server/chromium/crDevTools.js +112 -0
- patchright/driver/package/lib/server/chromium/crDragDrop.js +126 -0
- patchright/driver/package/lib/server/chromium/crExecutionContext.js +145 -0
- patchright/driver/package/lib/server/chromium/crInput.js +184 -0
- patchright/driver/package/lib/server/chromium/crNetworkManager.js +742 -0
- patchright/driver/package/lib/server/chromium/crPage.js +1134 -0
- patchright/driver/package/lib/server/chromium/crPdf.js +121 -0
- patchright/driver/package/lib/server/chromium/crProtocolHelper.js +145 -0
- patchright/driver/package/lib/server/chromium/crServiceWorker.js +126 -0
- patchright/driver/package/lib/server/chromium/defaultFontFamilies.js +162 -0
- patchright/driver/package/lib/server/chromium/protocol.d.js +16 -0
- patchright/driver/package/lib/server/chromium/videoRecorder.js +121 -0
- patchright/driver/package/lib/server/clock.js +145 -0
- patchright/driver/package/lib/server/codegen/csharp.js +329 -0
- patchright/driver/package/lib/server/codegen/java.js +270 -0
- patchright/driver/package/lib/server/codegen/javascript.js +268 -0
- patchright/driver/package/lib/server/codegen/jsonl.js +51 -0
- patchright/driver/package/lib/server/codegen/language.js +111 -0
- patchright/driver/package/lib/server/codegen/languages.js +68 -0
- patchright/driver/package/lib/server/codegen/python.js +277 -0
- patchright/driver/package/lib/server/codegen/types.js +16 -0
- patchright/driver/package/lib/server/console.js +53 -0
- patchright/driver/package/lib/server/cookieStore.js +204 -0
- patchright/driver/package/lib/server/debugController.js +185 -0
- patchright/driver/package/lib/server/debugger.js +136 -0
- patchright/driver/package/lib/server/deviceDescriptors.js +39 -0
- patchright/driver/package/lib/server/deviceDescriptorsSource.json +1669 -0
- patchright/driver/package/lib/server/dialog.js +72 -0
- patchright/driver/package/lib/server/dispatchers/androidDispatcher.js +293 -0
- patchright/driver/package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- patchright/driver/package/lib/server/dispatchers/browserContextDispatcher.js +328 -0
- patchright/driver/package/lib/server/dispatchers/browserDispatcher.js +151 -0
- patchright/driver/package/lib/server/dispatchers/browserTypeDispatcher.js +55 -0
- patchright/driver/package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
- patchright/driver/package/lib/server/dispatchers/debugControllerDispatcher.js +87 -0
- patchright/driver/package/lib/server/dispatchers/dialogDispatcher.js +47 -0
- patchright/driver/package/lib/server/dispatchers/dispatcher.js +346 -0
- patchright/driver/package/lib/server/dispatchers/electronDispatcher.js +90 -0
- patchright/driver/package/lib/server/dispatchers/elementHandlerDispatcher.js +191 -0
- patchright/driver/package/lib/server/dispatchers/frameDispatcher.js +230 -0
- patchright/driver/package/lib/server/dispatchers/jsHandleDispatcher.js +80 -0
- patchright/driver/package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
- patchright/driver/package/lib/server/dispatchers/localUtilsDispatcher.js +155 -0
- patchright/driver/package/lib/server/dispatchers/networkDispatchers.js +204 -0
- patchright/driver/package/lib/server/dispatchers/pageDispatcher.js +328 -0
- patchright/driver/package/lib/server/dispatchers/playwrightDispatcher.js +100 -0
- patchright/driver/package/lib/server/dispatchers/selectorsDispatcher.js +40 -0
- patchright/driver/package/lib/server/dispatchers/streamDispatcher.js +60 -0
- patchright/driver/package/lib/server/dispatchers/tracingDispatcher.js +59 -0
- patchright/driver/package/lib/server/dispatchers/webSocketRouteDispatcher.js +154 -0
- patchright/driver/package/lib/server/dispatchers/writableStreamDispatcher.js +73 -0
- patchright/driver/package/lib/server/dom.js +869 -0
- patchright/driver/package/lib/server/download.js +70 -0
- patchright/driver/package/lib/server/electron/electron.js +277 -0
- patchright/driver/package/lib/server/electron/loader.js +29 -0
- patchright/driver/package/lib/server/errors.js +69 -0
- patchright/driver/package/lib/server/fetch.js +640 -0
- patchright/driver/package/lib/server/fileChooser.js +43 -0
- patchright/driver/package/lib/server/fileUploadUtils.js +84 -0
- patchright/driver/package/lib/server/firefox/ffAccessibility.js +238 -0
- patchright/driver/package/lib/server/firefox/ffBrowser.js +404 -0
- patchright/driver/package/lib/server/firefox/ffConnection.js +147 -0
- patchright/driver/package/lib/server/firefox/ffExecutionContext.js +149 -0
- patchright/driver/package/lib/server/firefox/ffInput.js +159 -0
- patchright/driver/package/lib/server/firefox/ffNetworkManager.js +254 -0
- patchright/driver/package/lib/server/firefox/ffPage.js +501 -0
- patchright/driver/package/lib/server/firefox/firefox.js +106 -0
- patchright/driver/package/lib/server/firefox/protocol.d.js +16 -0
- patchright/driver/package/lib/server/formData.js +147 -0
- patchright/driver/package/lib/server/frameSelectors.js +274 -0
- patchright/driver/package/lib/server/frames.js +1834 -0
- patchright/driver/package/lib/server/har/harRecorder.js +147 -0
- patchright/driver/package/lib/server/har/harTracer.js +606 -0
- patchright/driver/package/lib/server/harBackend.js +157 -0
- patchright/driver/package/lib/server/helper.js +100 -0
- patchright/driver/package/lib/server/index.js +61 -0
- patchright/driver/package/lib/server/input.js +280 -0
- patchright/driver/package/lib/server/instrumentation.js +75 -0
- patchright/driver/package/lib/server/javascript.js +315 -0
- patchright/driver/package/lib/server/launchApp.js +110 -0
- patchright/driver/package/lib/server/localUtils.js +211 -0
- patchright/driver/package/lib/server/macEditingCommands.js +143 -0
- patchright/driver/package/lib/server/network.js +583 -0
- patchright/driver/package/lib/server/page.js +775 -0
- patchright/driver/package/lib/server/pageBinding.js +88 -0
- patchright/driver/package/lib/server/pipeTransport.js +89 -0
- patchright/driver/package/lib/server/playwright.js +81 -0
- patchright/driver/package/lib/server/progress.js +104 -0
- patchright/driver/package/lib/server/protocolError.js +52 -0
- patchright/driver/package/lib/server/recorder/chat.js +161 -0
- patchright/driver/package/lib/server/recorder/contextRecorder.js +286 -0
- patchright/driver/package/lib/server/recorder/recorderApp.js +184 -0
- patchright/driver/package/lib/server/recorder/recorderCollection.js +116 -0
- patchright/driver/package/lib/server/recorder/recorderFrontend.js +16 -0
- patchright/driver/package/lib/server/recorder/recorderRunner.js +135 -0
- patchright/driver/package/lib/server/recorder/recorderUtils.js +100 -0
- patchright/driver/package/lib/server/recorder/throttledFile.js +57 -0
- patchright/driver/package/lib/server/recorder.js +360 -0
- patchright/driver/package/lib/server/registry/browserFetcher.js +175 -0
- patchright/driver/package/lib/server/registry/dependencies.js +371 -0
- patchright/driver/package/lib/server/registry/index.js +1271 -0
- patchright/driver/package/lib/server/registry/nativeDeps.js +1105 -0
- patchright/driver/package/lib/server/registry/oopDownloadBrowserMain.js +120 -0
- patchright/driver/package/lib/server/screenshotter.js +332 -0
- patchright/driver/package/lib/server/selectors.js +112 -0
- patchright/driver/package/lib/server/socksClientCertificatesInterceptor.js +321 -0
- patchright/driver/package/lib/server/socksInterceptor.js +95 -0
- patchright/driver/package/lib/server/storageScript.js +154 -0
- patchright/driver/package/lib/server/timeoutSettings.js +89 -0
- patchright/driver/package/lib/server/trace/recorder/snapshotter.js +143 -0
- patchright/driver/package/lib/server/trace/recorder/snapshotterInjected.js +539 -0
- patchright/driver/package/lib/server/trace/recorder/tracing.js +593 -0
- patchright/driver/package/lib/server/trace/test/inMemorySnapshotter.js +87 -0
- patchright/driver/package/lib/server/trace/viewer/traceViewer.js +249 -0
- patchright/driver/package/lib/server/transport.js +183 -0
- patchright/driver/package/lib/server/types.js +28 -0
- patchright/driver/package/lib/server/usKeyboardLayout.js +145 -0
- patchright/driver/package/lib/server/utils/ascii.js +44 -0
- patchright/driver/package/lib/server/utils/comparators.js +161 -0
- patchright/driver/package/lib/server/utils/crypto.js +216 -0
- patchright/driver/package/lib/server/utils/debug.js +47 -0
- patchright/driver/package/lib/server/utils/debugLogger.js +114 -0
- patchright/driver/package/lib/server/utils/env.js +68 -0
- patchright/driver/package/lib/server/utils/eventsHelper.js +39 -0
- patchright/driver/package/lib/server/utils/expectUtils.js +38 -0
- patchright/driver/package/lib/server/utils/fileUtils.js +191 -0
- patchright/driver/package/lib/server/utils/happyEyeballs.js +207 -0
- patchright/driver/package/lib/server/utils/hostPlatform.js +109 -0
- patchright/driver/package/lib/server/utils/httpServer.js +218 -0
- patchright/driver/package/lib/server/utils/image_tools/colorUtils.js +89 -0
- patchright/driver/package/lib/server/utils/image_tools/compare.js +109 -0
- patchright/driver/package/lib/server/utils/image_tools/imageChannel.js +78 -0
- patchright/driver/package/lib/server/utils/image_tools/stats.js +102 -0
- patchright/driver/package/lib/server/utils/linuxUtils.js +71 -0
- patchright/driver/package/lib/server/utils/network.js +217 -0
- patchright/driver/package/lib/server/utils/nodePlatform.js +148 -0
- patchright/driver/package/lib/server/utils/pipeTransport.js +84 -0
- patchright/driver/package/lib/server/utils/processLauncher.js +238 -0
- patchright/driver/package/lib/server/utils/profiler.js +65 -0
- patchright/driver/package/lib/server/utils/socksProxy.js +511 -0
- patchright/driver/package/lib/server/utils/spawnAsync.js +41 -0
- patchright/driver/package/lib/server/utils/task.js +51 -0
- patchright/driver/package/lib/server/utils/userAgent.js +98 -0
- patchright/driver/package/lib/server/utils/wsServer.js +132 -0
- patchright/driver/package/lib/server/utils/zipFile.js +74 -0
- patchright/driver/package/lib/server/utils/zones.js +57 -0
- patchright/driver/package/lib/server/webkit/protocol.d.js +16 -0
- patchright/driver/package/lib/server/webkit/webkit.js +100 -0
- patchright/driver/package/lib/server/webkit/wkAccessibility.js +237 -0
- patchright/driver/package/lib/server/webkit/wkBrowser.js +312 -0
- patchright/driver/package/lib/server/webkit/wkConnection.js +149 -0
- patchright/driver/package/lib/server/webkit/wkExecutionContext.js +153 -0
- patchright/driver/package/lib/server/webkit/wkInput.js +181 -0
- patchright/driver/package/lib/server/webkit/wkInterceptableRequest.js +169 -0
- patchright/driver/package/lib/server/webkit/wkPage.js +1114 -0
- patchright/driver/package/lib/server/webkit/wkProvisionalPage.js +83 -0
- patchright/driver/package/lib/server/webkit/wkWorkers.js +104 -0
- patchright/driver/package/lib/third_party/pixelmatch.js +255 -0
- patchright/driver/package/lib/utils/isomorphic/ariaSnapshot.js +384 -0
- patchright/driver/package/lib/utils/isomorphic/assert.js +31 -0
- patchright/driver/package/lib/utils/isomorphic/builtins.js +86 -0
- patchright/driver/package/lib/utils/isomorphic/colors.js +72 -0
- patchright/driver/package/lib/utils/isomorphic/cssParser.js +246 -0
- patchright/driver/package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
- patchright/driver/package/lib/utils/isomorphic/headers.js +53 -0
- patchright/driver/package/lib/utils/isomorphic/locatorGenerators.js +655 -0
- patchright/driver/package/lib/utils/isomorphic/locatorParser.js +176 -0
- patchright/driver/package/lib/utils/isomorphic/locatorUtils.js +81 -0
- patchright/driver/package/lib/utils/isomorphic/manualPromise.js +115 -0
- patchright/driver/package/lib/utils/isomorphic/mimeType.js +460 -0
- patchright/driver/package/lib/utils/isomorphic/multimap.js +81 -0
- patchright/driver/package/lib/utils/isomorphic/rtti.js +43 -0
- patchright/driver/package/lib/utils/isomorphic/selectorParser.js +387 -0
- patchright/driver/package/lib/utils/isomorphic/semaphore.js +54 -0
- patchright/driver/package/lib/utils/isomorphic/stackTrace.js +158 -0
- patchright/driver/package/lib/utils/isomorphic/stringUtils.js +176 -0
- patchright/driver/package/lib/utils/isomorphic/time.js +44 -0
- patchright/driver/package/lib/utils/isomorphic/timeoutRunner.js +67 -0
- patchright/driver/package/lib/utils/isomorphic/traceUtils.js +59 -0
- patchright/driver/package/lib/utils/isomorphic/types.js +16 -0
- patchright/driver/package/lib/utils/isomorphic/urlMatch.js +167 -0
- patchright/driver/package/lib/utils/isomorphic/utilityScriptSerializers.js +248 -0
- patchright/driver/package/lib/utils.js +101 -0
- patchright/driver/package/lib/utilsBundle.js +106 -0
- patchright/driver/package/lib/utilsBundleImpl/index.js +208 -0
- patchright/driver/package/lib/utilsBundleImpl/xdg-open +1066 -0
- patchright/driver/package/lib/zipBundle.js +34 -0
- patchright/driver/package/lib/zipBundleImpl.js +5 -0
- patchright/driver/package/package.json +44 -0
- patchright/driver/package/protocol.yml +3313 -0
- patchright/py.typed +0 -0
- patchright/sync_api/__init__.py +179 -0
- patchright/sync_api/_context_manager.py +74 -0
- patchright/sync_api/_generated.py +20632 -0
- pure_patchright-1.52.5.dist-info/LICENSE +201 -0
- pure_patchright-1.52.5.dist-info/METADATA +96 -0
- pure_patchright-1.52.5.dist-info/RECORD +381 -0
- pure_patchright-1.52.5.dist-info/WHEEL +4 -0
- pure_patchright-1.52.5.dist-info/entry_points.txt +5 -0
- pure_patchright-1.52.5.dist-info/licenses/LICENSE +202 -0
- pure_patchright-1.52.5.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,775 @@
|
|
|
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.exposeBinding(binding);
|
|
236
|
+
}
|
|
237
|
+
async _removeExposedBindings() {
|
|
238
|
+
for (const key of this._pageBindings.keys()) {
|
|
239
|
+
if (!key.startsWith("__pw"))
|
|
240
|
+
this._pageBindings.delete(key);
|
|
241
|
+
}
|
|
242
|
+
await this._delegate.removeExposedBindings();
|
|
243
|
+
}
|
|
244
|
+
setExtraHTTPHeaders(headers) {
|
|
245
|
+
this._extraHTTPHeaders = headers;
|
|
246
|
+
return this._delegate.updateExtraHTTPHeaders();
|
|
247
|
+
}
|
|
248
|
+
extraHTTPHeaders() {
|
|
249
|
+
return this._extraHTTPHeaders;
|
|
250
|
+
}
|
|
251
|
+
async _onBindingCalled(payload, context) {
|
|
252
|
+
if (this._closedState === "closed")
|
|
253
|
+
return;
|
|
254
|
+
await PageBinding.dispatch(this, payload, context);
|
|
255
|
+
}
|
|
256
|
+
_addConsoleMessage(type, args, location, text) {
|
|
257
|
+
const message = new import_console.ConsoleMessage(this, type, text, args, location);
|
|
258
|
+
const intercepted = this._frameManager.interceptConsoleMessage(message);
|
|
259
|
+
if (intercepted) {
|
|
260
|
+
args.forEach((arg) => arg.dispose());
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
this.emitOnContextOnceInitialized(import_browserContext.BrowserContext.Events.Console, message);
|
|
264
|
+
}
|
|
265
|
+
async reload(metadata, options) {
|
|
266
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
267
|
+
return controller.run((progress) => this.mainFrame().raceNavigationAction(progress, options, async () => {
|
|
268
|
+
const [response] = await Promise.all([
|
|
269
|
+
// Reload must be a new document, and should not be confused with a stray pushState.
|
|
270
|
+
this.mainFrame()._waitForNavigation(progress, true, options),
|
|
271
|
+
this._delegate.reload()
|
|
272
|
+
]);
|
|
273
|
+
return response;
|
|
274
|
+
}), this._timeoutSettings.navigationTimeout(options));
|
|
275
|
+
}
|
|
276
|
+
async goBack(metadata, options) {
|
|
277
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
278
|
+
return controller.run((progress) => this.mainFrame().raceNavigationAction(progress, options, async () => {
|
|
279
|
+
let error;
|
|
280
|
+
const waitPromise = this.mainFrame()._waitForNavigation(progress, false, options).catch((e) => {
|
|
281
|
+
error = e;
|
|
282
|
+
return null;
|
|
283
|
+
});
|
|
284
|
+
const result = await this._delegate.goBack();
|
|
285
|
+
if (!result)
|
|
286
|
+
return null;
|
|
287
|
+
const response = await waitPromise;
|
|
288
|
+
if (error)
|
|
289
|
+
throw error;
|
|
290
|
+
return response;
|
|
291
|
+
}), this._timeoutSettings.navigationTimeout(options));
|
|
292
|
+
}
|
|
293
|
+
async goForward(metadata, options) {
|
|
294
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
295
|
+
return controller.run((progress) => this.mainFrame().raceNavigationAction(progress, options, async () => {
|
|
296
|
+
let error;
|
|
297
|
+
const waitPromise = this.mainFrame()._waitForNavigation(progress, false, options).catch((e) => {
|
|
298
|
+
error = e;
|
|
299
|
+
return null;
|
|
300
|
+
});
|
|
301
|
+
const result = await this._delegate.goForward();
|
|
302
|
+
if (!result)
|
|
303
|
+
return null;
|
|
304
|
+
const response = await waitPromise;
|
|
305
|
+
if (error)
|
|
306
|
+
throw error;
|
|
307
|
+
return response;
|
|
308
|
+
}), this._timeoutSettings.navigationTimeout(options));
|
|
309
|
+
}
|
|
310
|
+
requestGC() {
|
|
311
|
+
return this._delegate.requestGC();
|
|
312
|
+
}
|
|
313
|
+
registerLocatorHandler(selector, noWaitAfter) {
|
|
314
|
+
const uid = ++this._lastLocatorHandlerUid;
|
|
315
|
+
this._locatorHandlers.set(uid, { selector, noWaitAfter });
|
|
316
|
+
return uid;
|
|
317
|
+
}
|
|
318
|
+
resolveLocatorHandler(uid, remove) {
|
|
319
|
+
const handler = this._locatorHandlers.get(uid);
|
|
320
|
+
if (remove)
|
|
321
|
+
this._locatorHandlers.delete(uid);
|
|
322
|
+
if (handler) {
|
|
323
|
+
handler.resolved?.resolve();
|
|
324
|
+
handler.resolved = void 0;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
unregisterLocatorHandler(uid) {
|
|
328
|
+
this._locatorHandlers.delete(uid);
|
|
329
|
+
}
|
|
330
|
+
async performActionPreChecks(progress) {
|
|
331
|
+
await this._performWaitForNavigationCheck(progress);
|
|
332
|
+
progress.throwIfAborted();
|
|
333
|
+
await this._performLocatorHandlersCheckpoint(progress);
|
|
334
|
+
progress.throwIfAborted();
|
|
335
|
+
await this._performWaitForNavigationCheck(progress);
|
|
336
|
+
}
|
|
337
|
+
async _performWaitForNavigationCheck(progress) {
|
|
338
|
+
if (process.env.PLAYWRIGHT_SKIP_NAVIGATION_CHECK)
|
|
339
|
+
return;
|
|
340
|
+
const mainFrame = this._frameManager.mainFrame();
|
|
341
|
+
if (!mainFrame || !mainFrame.pendingDocument())
|
|
342
|
+
return;
|
|
343
|
+
const url = mainFrame.pendingDocument()?.request?.url();
|
|
344
|
+
const toUrl = url ? `" ${(0, import_utils.trimStringWithEllipsis)(url, 200)}"` : "";
|
|
345
|
+
progress.log(` waiting for${toUrl} navigation to finish...`);
|
|
346
|
+
await import_helper.helper.waitForEvent(progress, mainFrame, frames.Frame.Events.InternalNavigation, (e) => {
|
|
347
|
+
if (!e.isPublic)
|
|
348
|
+
return false;
|
|
349
|
+
if (!e.error)
|
|
350
|
+
progress.log(` navigated to "${(0, import_utils.trimStringWithEllipsis)(mainFrame.url(), 200)}"`);
|
|
351
|
+
return true;
|
|
352
|
+
}).promise;
|
|
353
|
+
}
|
|
354
|
+
async _performLocatorHandlersCheckpoint(progress) {
|
|
355
|
+
if (this._locatorHandlerRunningCounter)
|
|
356
|
+
return;
|
|
357
|
+
for (const [uid, handler] of this._locatorHandlers) {
|
|
358
|
+
if (!handler.resolved) {
|
|
359
|
+
if (await this.mainFrame().isVisibleInternal(handler.selector, { strict: true })) {
|
|
360
|
+
handler.resolved = new import_manualPromise.ManualPromise();
|
|
361
|
+
this.emit(Page.Events.LocatorHandlerTriggered, uid);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
if (handler.resolved) {
|
|
365
|
+
++this._locatorHandlerRunningCounter;
|
|
366
|
+
progress.log(` found ${(0, import_utils2.asLocator)(this.attribution.playwright.options.sdkLanguage, handler.selector)}, intercepting action to run the handler`);
|
|
367
|
+
const promise = handler.resolved.then(async () => {
|
|
368
|
+
progress.throwIfAborted();
|
|
369
|
+
if (!handler.noWaitAfter) {
|
|
370
|
+
progress.log(` locator handler has finished, waiting for ${(0, import_utils2.asLocator)(this.attribution.playwright.options.sdkLanguage, handler.selector)} to be hidden`);
|
|
371
|
+
await this.mainFrame().waitForSelectorInternal(progress, handler.selector, false, { state: "hidden" });
|
|
372
|
+
} else {
|
|
373
|
+
progress.log(` locator handler has finished`);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
await this.openScope.race(promise).finally(() => --this._locatorHandlerRunningCounter);
|
|
377
|
+
progress.throwIfAborted();
|
|
378
|
+
progress.log(` interception handler has finished, continuing`);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
async emulateMedia(options) {
|
|
383
|
+
if (options.media !== void 0)
|
|
384
|
+
this._emulatedMedia.media = options.media;
|
|
385
|
+
if (options.colorScheme !== void 0)
|
|
386
|
+
this._emulatedMedia.colorScheme = options.colorScheme;
|
|
387
|
+
if (options.reducedMotion !== void 0)
|
|
388
|
+
this._emulatedMedia.reducedMotion = options.reducedMotion;
|
|
389
|
+
if (options.forcedColors !== void 0)
|
|
390
|
+
this._emulatedMedia.forcedColors = options.forcedColors;
|
|
391
|
+
if (options.contrast !== void 0)
|
|
392
|
+
this._emulatedMedia.contrast = options.contrast;
|
|
393
|
+
await this._delegate.updateEmulateMedia();
|
|
394
|
+
}
|
|
395
|
+
emulatedMedia() {
|
|
396
|
+
const contextOptions = this._browserContext._options;
|
|
397
|
+
return {
|
|
398
|
+
media: this._emulatedMedia.media || "no-override",
|
|
399
|
+
colorScheme: this._emulatedMedia.colorScheme !== void 0 ? this._emulatedMedia.colorScheme : contextOptions.colorScheme ?? "light",
|
|
400
|
+
reducedMotion: this._emulatedMedia.reducedMotion !== void 0 ? this._emulatedMedia.reducedMotion : contextOptions.reducedMotion ?? "no-preference",
|
|
401
|
+
forcedColors: this._emulatedMedia.forcedColors !== void 0 ? this._emulatedMedia.forcedColors : contextOptions.forcedColors ?? "none",
|
|
402
|
+
contrast: this._emulatedMedia.contrast !== void 0 ? this._emulatedMedia.contrast : contextOptions.contrast ?? "no-preference"
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
async setViewportSize(viewportSize) {
|
|
406
|
+
this._emulatedSize = { viewport: { ...viewportSize }, screen: { ...viewportSize } };
|
|
407
|
+
await this._delegate.updateEmulatedViewportSize();
|
|
408
|
+
}
|
|
409
|
+
viewportSize() {
|
|
410
|
+
return this.emulatedSize()?.viewport || null;
|
|
411
|
+
}
|
|
412
|
+
emulatedSize() {
|
|
413
|
+
if (this._emulatedSize)
|
|
414
|
+
return this._emulatedSize;
|
|
415
|
+
const contextOptions = this._browserContext._options;
|
|
416
|
+
return contextOptions.viewport ? { viewport: contextOptions.viewport, screen: contextOptions.screen || contextOptions.viewport } : null;
|
|
417
|
+
}
|
|
418
|
+
async bringToFront() {
|
|
419
|
+
await this._delegate.bringToFront();
|
|
420
|
+
}
|
|
421
|
+
async addInitScript(source, name) {
|
|
422
|
+
const initScript = new InitScript(source, false, name);
|
|
423
|
+
this.initScripts.push(initScript);
|
|
424
|
+
await this._delegate.addInitScript(initScript);
|
|
425
|
+
}
|
|
426
|
+
async _removeInitScripts() {
|
|
427
|
+
this.initScripts.splice(0, this.initScripts.length);
|
|
428
|
+
await this._delegate.removeInitScripts();
|
|
429
|
+
}
|
|
430
|
+
needsRequestInterception() {
|
|
431
|
+
return !!this._clientRequestInterceptor || !!this._serverRequestInterceptor || !!this._browserContext._requestInterceptor;
|
|
432
|
+
}
|
|
433
|
+
async setClientRequestInterceptor(handler) {
|
|
434
|
+
this._clientRequestInterceptor = handler;
|
|
435
|
+
await this._delegate.updateRequestInterception();
|
|
436
|
+
}
|
|
437
|
+
async _setServerRequestInterceptor(handler) {
|
|
438
|
+
this._serverRequestInterceptor = handler;
|
|
439
|
+
await this._delegate.updateRequestInterception();
|
|
440
|
+
}
|
|
441
|
+
async expectScreenshot(metadata, options = {}) {
|
|
442
|
+
const locator = options.locator;
|
|
443
|
+
const rafrafScreenshot = locator ? async (progress, timeout) => {
|
|
444
|
+
return await locator.frame.rafrafTimeoutScreenshotElementWithProgress(progress, locator.selector, timeout, options || {});
|
|
445
|
+
} : async (progress, timeout) => {
|
|
446
|
+
await this.performActionPreChecks(progress);
|
|
447
|
+
await this.mainFrame().rafrafTimeout(timeout);
|
|
448
|
+
return await this._screenshotter.screenshotPage(progress, options || {});
|
|
449
|
+
};
|
|
450
|
+
const comparator = (0, import_comparators.getComparator)("image/png");
|
|
451
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
452
|
+
if (!options.expected && options.isNot)
|
|
453
|
+
return { errorMessage: '"not" matcher requires expected result' };
|
|
454
|
+
try {
|
|
455
|
+
const format = (0, import_screenshotter.validateScreenshotOptions)(options || {});
|
|
456
|
+
if (format !== "png")
|
|
457
|
+
throw new Error("Only PNG screenshots are supported");
|
|
458
|
+
} catch (error) {
|
|
459
|
+
return { errorMessage: error.message };
|
|
460
|
+
}
|
|
461
|
+
let intermediateResult = void 0;
|
|
462
|
+
const areEqualScreenshots = (actual, expected, previous) => {
|
|
463
|
+
const comparatorResult = actual && expected ? comparator(actual, expected, options) : void 0;
|
|
464
|
+
if (comparatorResult !== void 0 && !!comparatorResult === !!options.isNot)
|
|
465
|
+
return true;
|
|
466
|
+
if (comparatorResult)
|
|
467
|
+
intermediateResult = { errorMessage: comparatorResult.errorMessage, diff: comparatorResult.diff, actual, previous };
|
|
468
|
+
return false;
|
|
469
|
+
};
|
|
470
|
+
const callTimeout = this._timeoutSettings.timeout(options);
|
|
471
|
+
return controller.run(async (progress) => {
|
|
472
|
+
let actual;
|
|
473
|
+
let previous;
|
|
474
|
+
const pollIntervals = [0, 100, 250, 500];
|
|
475
|
+
progress.log(`${metadata.apiName}${callTimeout ? ` with timeout ${callTimeout}ms` : ""}`);
|
|
476
|
+
if (options.expected)
|
|
477
|
+
progress.log(` verifying given screenshot expectation`);
|
|
478
|
+
else
|
|
479
|
+
progress.log(` generating new stable screenshot expectation`);
|
|
480
|
+
let isFirstIteration = true;
|
|
481
|
+
while (true) {
|
|
482
|
+
progress.throwIfAborted();
|
|
483
|
+
if (this.isClosed())
|
|
484
|
+
throw new Error("The page has closed");
|
|
485
|
+
const screenshotTimeout = pollIntervals.shift() ?? 1e3;
|
|
486
|
+
if (screenshotTimeout)
|
|
487
|
+
progress.log(`waiting ${screenshotTimeout}ms before taking screenshot`);
|
|
488
|
+
previous = actual;
|
|
489
|
+
actual = await rafrafScreenshot(progress, screenshotTimeout).catch((e) => {
|
|
490
|
+
progress.log(`failed to take screenshot - ` + e.message);
|
|
491
|
+
return void 0;
|
|
492
|
+
});
|
|
493
|
+
if (!actual)
|
|
494
|
+
continue;
|
|
495
|
+
const expectation = options.expected && isFirstIteration ? options.expected : previous;
|
|
496
|
+
if (areEqualScreenshots(actual, expectation, previous))
|
|
497
|
+
break;
|
|
498
|
+
if (intermediateResult)
|
|
499
|
+
progress.log(intermediateResult.errorMessage);
|
|
500
|
+
isFirstIteration = false;
|
|
501
|
+
}
|
|
502
|
+
if (!isFirstIteration)
|
|
503
|
+
progress.log(`captured a stable screenshot`);
|
|
504
|
+
if (!options.expected)
|
|
505
|
+
return { actual };
|
|
506
|
+
if (isFirstIteration) {
|
|
507
|
+
progress.log(`screenshot matched expectation`);
|
|
508
|
+
return {};
|
|
509
|
+
}
|
|
510
|
+
if (areEqualScreenshots(actual, options.expected, void 0)) {
|
|
511
|
+
progress.log(`screenshot matched expectation`);
|
|
512
|
+
return {};
|
|
513
|
+
}
|
|
514
|
+
throw new Error(intermediateResult.errorMessage);
|
|
515
|
+
}, callTimeout).catch((e) => {
|
|
516
|
+
if (js.isJavaScriptErrorInEvaluate(e) || (0, import_selectorParser.isInvalidSelectorError)(e))
|
|
517
|
+
throw e;
|
|
518
|
+
let errorMessage = e.message;
|
|
519
|
+
if (e instanceof import_errors.TimeoutError && intermediateResult?.previous)
|
|
520
|
+
errorMessage = `Failed to take two consecutive stable screenshots.`;
|
|
521
|
+
return {
|
|
522
|
+
log: (0, import_callLog.compressCallLog)(e.message ? [...metadata.log, e.message] : metadata.log),
|
|
523
|
+
...intermediateResult,
|
|
524
|
+
errorMessage,
|
|
525
|
+
timedOut: e instanceof import_errors.TimeoutError
|
|
526
|
+
};
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
async screenshot(metadata, options = {}) {
|
|
530
|
+
const controller = new import_progress.ProgressController(metadata, this);
|
|
531
|
+
return controller.run(
|
|
532
|
+
(progress) => this._screenshotter.screenshotPage(progress, options),
|
|
533
|
+
this._timeoutSettings.timeout(options)
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
async close(metadata, options = {}) {
|
|
537
|
+
if (this._closedState === "closed")
|
|
538
|
+
return;
|
|
539
|
+
if (options.reason)
|
|
540
|
+
this._closeReason = options.reason;
|
|
541
|
+
const runBeforeUnload = !!options.runBeforeUnload;
|
|
542
|
+
if (this._closedState !== "closing") {
|
|
543
|
+
this._closedState = "closing";
|
|
544
|
+
await this._delegate.closePage(runBeforeUnload).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
545
|
+
}
|
|
546
|
+
if (!runBeforeUnload)
|
|
547
|
+
await this._closedPromise;
|
|
548
|
+
if (this._ownedContext)
|
|
549
|
+
await this._ownedContext.close(options);
|
|
550
|
+
}
|
|
551
|
+
isClosed() {
|
|
552
|
+
return this._closedState === "closed";
|
|
553
|
+
}
|
|
554
|
+
hasCrashed() {
|
|
555
|
+
return this._crashed;
|
|
556
|
+
}
|
|
557
|
+
isClosedOrClosingOrCrashed() {
|
|
558
|
+
return this._closedState !== "open" || this._crashed;
|
|
559
|
+
}
|
|
560
|
+
_addWorker(workerId, worker) {
|
|
561
|
+
this._workers.set(workerId, worker);
|
|
562
|
+
this.emit(Page.Events.Worker, worker);
|
|
563
|
+
}
|
|
564
|
+
_removeWorker(workerId) {
|
|
565
|
+
const worker = this._workers.get(workerId);
|
|
566
|
+
if (!worker)
|
|
567
|
+
return;
|
|
568
|
+
worker.didClose();
|
|
569
|
+
this._workers.delete(workerId);
|
|
570
|
+
}
|
|
571
|
+
_clearWorkers() {
|
|
572
|
+
for (const [workerId, worker] of this._workers) {
|
|
573
|
+
worker.didClose();
|
|
574
|
+
this._workers.delete(workerId);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
async setFileChooserIntercepted(enabled) {
|
|
578
|
+
this._interceptFileChooser = enabled;
|
|
579
|
+
await this._delegate.updateFileChooserInterception();
|
|
580
|
+
}
|
|
581
|
+
fileChooserIntercepted() {
|
|
582
|
+
return this._interceptFileChooser;
|
|
583
|
+
}
|
|
584
|
+
frameNavigatedToNewDocument(frame) {
|
|
585
|
+
this.emit(Page.Events.InternalFrameNavigatedToNewDocument, frame);
|
|
586
|
+
const origin = frame.origin();
|
|
587
|
+
if (origin)
|
|
588
|
+
this._browserContext.addVisitedOrigin(origin);
|
|
589
|
+
}
|
|
590
|
+
getBinding(name) {
|
|
591
|
+
return this._pageBindings.get(name) || this._browserContext._pageBindings.get(name);
|
|
592
|
+
}
|
|
593
|
+
setScreencastOptions(options) {
|
|
594
|
+
this._delegate.setScreencastOptions(options).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
595
|
+
this._frameThrottler.setThrottlingEnabled(!!options);
|
|
596
|
+
}
|
|
597
|
+
throttleScreencastFrameAck(ack) {
|
|
598
|
+
this._frameThrottler.ack(ack);
|
|
599
|
+
}
|
|
600
|
+
temporarilyDisableTracingScreencastThrottling() {
|
|
601
|
+
this._frameThrottler.recharge();
|
|
602
|
+
}
|
|
603
|
+
async safeNonStallingEvaluateInAllFrames(expression, world, options = {}) {
|
|
604
|
+
await Promise.all(this.frames().map(async (frame) => {
|
|
605
|
+
try {
|
|
606
|
+
await frame.nonStallingEvaluateInExistingContext(expression, world);
|
|
607
|
+
} catch (e) {
|
|
608
|
+
if (options.throwOnJSErrors && js.isJavaScriptErrorInEvaluate(e))
|
|
609
|
+
throw e;
|
|
610
|
+
}
|
|
611
|
+
}));
|
|
612
|
+
}
|
|
613
|
+
async hideHighlight() {
|
|
614
|
+
await Promise.all(this.frames().map((frame) => frame.hideHighlight().catch(() => {
|
|
615
|
+
})));
|
|
616
|
+
}
|
|
617
|
+
markAsServerSideOnly() {
|
|
618
|
+
this._isServerSideOnly = true;
|
|
619
|
+
}
|
|
620
|
+
allBindings() {
|
|
621
|
+
return [...this._browserContext._pageBindings.values(), ...this._pageBindings.values()];
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
class Worker extends import_instrumentation.SdkObject {
|
|
625
|
+
constructor(parent, url) {
|
|
626
|
+
super(parent, "worker");
|
|
627
|
+
this._existingExecutionContext = null;
|
|
628
|
+
this.openScope = new import_utils.LongStandingScope();
|
|
629
|
+
this._url = url;
|
|
630
|
+
this._executionContextCallback = () => {
|
|
631
|
+
};
|
|
632
|
+
this._executionContextPromise = new Promise((x) => this._executionContextCallback = x);
|
|
633
|
+
}
|
|
634
|
+
static {
|
|
635
|
+
this.Events = {
|
|
636
|
+
Close: "close"
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
_createExecutionContext(delegate) {
|
|
640
|
+
this._existingExecutionContext = new js.ExecutionContext(this, delegate, "worker");
|
|
641
|
+
this._executionContextCallback(this._existingExecutionContext);
|
|
642
|
+
return this._existingExecutionContext;
|
|
643
|
+
}
|
|
644
|
+
url() {
|
|
645
|
+
return this._url;
|
|
646
|
+
}
|
|
647
|
+
didClose() {
|
|
648
|
+
if (this._existingExecutionContext)
|
|
649
|
+
this._existingExecutionContext.contextDestroyed("Worker was closed");
|
|
650
|
+
this.emit(Worker.Events.Close, this);
|
|
651
|
+
this.openScope.close(new Error("Worker closed"));
|
|
652
|
+
}
|
|
653
|
+
async evaluateExpression(expression, isFunction, arg, isolatedContext) {
|
|
654
|
+
let context = await this._executionContextPromise;
|
|
655
|
+
if (context.constructor.name === "FrameExecutionContext") {
|
|
656
|
+
const frame = context.frame;
|
|
657
|
+
if (frame) {
|
|
658
|
+
if (isolatedContext) context = await frame._utilityContext();
|
|
659
|
+
else if (!isolatedContext) context = await frame._mainContext();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
return js.evaluateExpression(context, expression, { returnByValue: true, isFunction }, arg);
|
|
663
|
+
}
|
|
664
|
+
async evaluateExpressionHandle(expression, isFunction, arg, isolatedContext) {
|
|
665
|
+
let context = await this._executionContextPromise;
|
|
666
|
+
if (context.constructor.name === "FrameExecutionContext") {
|
|
667
|
+
const frame = this._context.frame;
|
|
668
|
+
if (frame) {
|
|
669
|
+
if (isolatedContext) context = await frame._utilityContext();
|
|
670
|
+
else if (!isolatedContext) context = await frame._mainContext();
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
return js.evaluateExpression(context, expression, { returnByValue: false, isFunction }, arg);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
class PageBinding {
|
|
677
|
+
constructor(name, playwrightFunction, needsHandle) {
|
|
678
|
+
this.name = name;
|
|
679
|
+
this.playwrightFunction = playwrightFunction;
|
|
680
|
+
this.source = (0, import_pageBinding.createPageBindingScript)(name, needsHandle);
|
|
681
|
+
this.needsHandle = needsHandle;
|
|
682
|
+
}
|
|
683
|
+
static async dispatch(page, payload, context) {
|
|
684
|
+
const { name, seq, serializedArgs } = JSON.parse(payload);
|
|
685
|
+
try {
|
|
686
|
+
(0, import_utils.assert)(context.world);
|
|
687
|
+
const binding = page.getBinding(name);
|
|
688
|
+
if (!binding)
|
|
689
|
+
throw new Error(`Function "${name}" is not exposed`);
|
|
690
|
+
let result;
|
|
691
|
+
if (binding.needsHandle) {
|
|
692
|
+
const handle = await context.evaluateHandle(import_pageBinding.takeBindingHandle, { name, seq }).catch((e) => null);
|
|
693
|
+
result = await binding.playwrightFunction({ frame: context.frame, page, context: page._browserContext }, handle);
|
|
694
|
+
} else {
|
|
695
|
+
if (!Array.isArray(serializedArgs))
|
|
696
|
+
throw new Error(`serializedArgs is not an array. This can happen when Array.prototype.toJSON is defined incorrectly`);
|
|
697
|
+
const args = serializedArgs.map((a) => js.parseEvaluationResultValue(a));
|
|
698
|
+
result = await binding.playwrightFunction({ frame: context.frame, page, context: page._browserContext }, ...args);
|
|
699
|
+
}
|
|
700
|
+
context.evaluate(import_pageBinding.deliverBindingResult, { name, seq, result }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
701
|
+
} catch (error) {
|
|
702
|
+
context.evaluate(import_pageBinding.deliverBindingResult, { name, seq, error }).catch((e) => import_debugLogger.debugLogger.log("error", e));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
class InitScript {
|
|
707
|
+
constructor(source, internal, name) {
|
|
708
|
+
const guid = (0, import_crypto.createGuid)();
|
|
709
|
+
this.source = `(() => { ${source} })();`;
|
|
710
|
+
this.internal = !!internal;
|
|
711
|
+
this.name = name;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const kBuiltinsScript = new InitScript(
|
|
715
|
+
`(${import_builtins.builtins})()`,
|
|
716
|
+
true
|
|
717
|
+
/* internal */
|
|
718
|
+
);
|
|
719
|
+
class FrameThrottler {
|
|
720
|
+
constructor(nonThrottledFrames, defaultInterval, throttlingInterval) {
|
|
721
|
+
this._acks = [];
|
|
722
|
+
this._throttlingEnabled = false;
|
|
723
|
+
this._nonThrottledFrames = nonThrottledFrames;
|
|
724
|
+
this._budget = nonThrottledFrames;
|
|
725
|
+
this._defaultInterval = defaultInterval;
|
|
726
|
+
this._throttlingInterval = throttlingInterval;
|
|
727
|
+
this._tick();
|
|
728
|
+
}
|
|
729
|
+
dispose() {
|
|
730
|
+
if (this._timeoutId) {
|
|
731
|
+
clearTimeout(this._timeoutId);
|
|
732
|
+
this._timeoutId = void 0;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
setThrottlingEnabled(enabled) {
|
|
736
|
+
this._throttlingEnabled = enabled;
|
|
737
|
+
}
|
|
738
|
+
recharge() {
|
|
739
|
+
for (const ack of this._acks)
|
|
740
|
+
ack();
|
|
741
|
+
this._acks = [];
|
|
742
|
+
this._budget = this._nonThrottledFrames;
|
|
743
|
+
if (this._timeoutId) {
|
|
744
|
+
clearTimeout(this._timeoutId);
|
|
745
|
+
this._tick();
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
ack(ack) {
|
|
749
|
+
if (!this._timeoutId) {
|
|
750
|
+
ack();
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
this._acks.push(ack);
|
|
754
|
+
}
|
|
755
|
+
_tick() {
|
|
756
|
+
const ack = this._acks.shift();
|
|
757
|
+
if (ack) {
|
|
758
|
+
--this._budget;
|
|
759
|
+
ack();
|
|
760
|
+
}
|
|
761
|
+
if (this._throttlingEnabled && this._budget <= 0) {
|
|
762
|
+
this._timeoutId = setTimeout(() => this._tick(), this._throttlingInterval);
|
|
763
|
+
} else {
|
|
764
|
+
this._timeoutId = setTimeout(() => this._tick(), this._defaultInterval);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
769
|
+
0 && (module.exports = {
|
|
770
|
+
InitScript,
|
|
771
|
+
Page,
|
|
772
|
+
PageBinding,
|
|
773
|
+
Worker,
|
|
774
|
+
kBuiltinsScript
|
|
775
|
+
});
|