@stablyai/internal-playwright-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +3 -0
- package/ThirdPartyNotices.txt +1134 -0
- package/bin/install_media_pack.ps1 +5 -0
- package/bin/install_webkit_wsl.ps1 +35 -0
- package/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/browsers.json +80 -0
- package/cli.js +18 -0
- package/index.d.ts +17 -0
- package/index.js +32 -0
- package/index.mjs +28 -0
- package/lib/androidServerImpl.js +65 -0
- package/lib/browserServerImpl.js +120 -0
- package/lib/cli/cli.js +58 -0
- package/lib/cli/driver.js +97 -0
- package/lib/cli/program.js +634 -0
- package/lib/cli/programWithTestStub.js +74 -0
- package/lib/client/accessibility.js +49 -0
- package/lib/client/android.js +361 -0
- package/lib/client/api.js +137 -0
- package/lib/client/artifact.js +79 -0
- package/lib/client/browser.js +163 -0
- package/lib/client/browserContext.js +529 -0
- package/lib/client/browserType.js +184 -0
- package/lib/client/cdpSession.js +51 -0
- package/lib/client/channelOwner.js +194 -0
- package/lib/client/clientHelper.js +64 -0
- package/lib/client/clientInstrumentation.js +55 -0
- package/lib/client/clientStackTrace.js +69 -0
- package/lib/client/clock.js +68 -0
- package/lib/client/connection.js +314 -0
- package/lib/client/consoleMessage.js +54 -0
- package/lib/client/coverage.js +44 -0
- package/lib/client/dialog.js +56 -0
- package/lib/client/download.js +62 -0
- package/lib/client/electron.js +138 -0
- package/lib/client/elementHandle.js +281 -0
- package/lib/client/errors.js +77 -0
- package/lib/client/eventEmitter.js +314 -0
- package/lib/client/events.js +99 -0
- package/lib/client/fetch.js +369 -0
- package/lib/client/fileChooser.js +46 -0
- package/lib/client/fileUtils.js +34 -0
- package/lib/client/frame.js +408 -0
- package/lib/client/harRouter.js +87 -0
- package/lib/client/input.js +84 -0
- package/lib/client/jsHandle.js +109 -0
- package/lib/client/jsonPipe.js +39 -0
- package/lib/client/localUtils.js +60 -0
- package/lib/client/locator.js +368 -0
- package/lib/client/network.js +747 -0
- package/lib/client/page.js +721 -0
- package/lib/client/platform.js +74 -0
- package/lib/client/playwright.js +71 -0
- package/lib/client/selectors.js +55 -0
- package/lib/client/stream.js +39 -0
- package/lib/client/timeoutSettings.js +79 -0
- package/lib/client/tracing.js +117 -0
- package/lib/client/types.js +28 -0
- package/lib/client/video.js +59 -0
- package/lib/client/waiter.js +142 -0
- package/lib/client/webError.js +39 -0
- package/lib/client/webSocket.js +93 -0
- package/lib/client/worker.js +63 -0
- package/lib/client/writableStream.js +39 -0
- package/lib/common/debugLogger.js +90 -0
- package/lib/common/socksProxy.js +569 -0
- package/lib/common/timeoutSettings.js +73 -0
- package/lib/common/types.js +5 -0
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +28 -0
- package/lib/generated/consoleApiSource.js +28 -0
- package/lib/generated/injectedScriptSource.js +28 -0
- package/lib/generated/pollingRecorderSource.js +28 -0
- package/lib/generated/recorderSource.js +28 -0
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +28 -0
- package/lib/generated/webSocketMockSource.js +336 -0
- package/lib/image_tools/colorUtils.js +98 -0
- package/lib/image_tools/compare.js +108 -0
- package/lib/image_tools/imageChannel.js +70 -0
- package/lib/image_tools/stats.js +102 -0
- package/lib/inProcessFactory.js +60 -0
- package/lib/index.js +19 -0
- package/lib/inprocess.js +3 -0
- package/lib/outofprocess.js +76 -0
- package/lib/protocol/debug.js +27 -0
- package/lib/protocol/serializers.js +192 -0
- package/lib/protocol/transport.js +82 -0
- package/lib/protocol/validator.js +2919 -0
- package/lib/protocol/validatorPrimitives.js +193 -0
- package/lib/remote/playwrightConnection.js +129 -0
- package/lib/remote/playwrightServer.js +335 -0
- package/lib/server/accessibility.js +69 -0
- package/lib/server/android/android.js +465 -0
- package/lib/server/android/backendAdb.js +177 -0
- package/lib/server/artifact.js +127 -0
- package/lib/server/bidi/bidiBrowser.js +490 -0
- package/lib/server/bidi/bidiChromium.js +153 -0
- package/lib/server/bidi/bidiConnection.js +212 -0
- package/lib/server/bidi/bidiExecutionContext.js +221 -0
- package/lib/server/bidi/bidiFirefox.js +130 -0
- package/lib/server/bidi/bidiInput.js +146 -0
- package/lib/server/bidi/bidiNetworkManager.js +383 -0
- package/lib/server/bidi/bidiOverCdp.js +102 -0
- package/lib/server/bidi/bidiPage.js +552 -0
- package/lib/server/bidi/bidiPdf.js +106 -0
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +98 -0
- package/lib/server/bidi/third_party/bidiKeyboard.js +256 -0
- package/lib/server/bidi/third_party/bidiProtocol.js +24 -0
- package/lib/server/bidi/third_party/bidiProtocolCore.js +179 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +148 -0
- package/lib/server/bidi/third_party/firefoxPrefs.js +259 -0
- package/lib/server/browser.js +149 -0
- package/lib/server/browserContext.js +695 -0
- package/lib/server/browserType.js +328 -0
- package/lib/server/callLog.js +82 -0
- package/lib/server/chromium/appIcon.png +0 -0
- package/lib/server/chromium/chromium.js +402 -0
- package/lib/server/chromium/chromiumSwitches.js +95 -0
- package/lib/server/chromium/crAccessibility.js +263 -0
- package/lib/server/chromium/crBrowser.js +501 -0
- package/lib/server/chromium/crConnection.js +202 -0
- package/lib/server/chromium/crCoverage.js +235 -0
- package/lib/server/chromium/crDevTools.js +113 -0
- package/lib/server/chromium/crDragDrop.js +131 -0
- package/lib/server/chromium/crExecutionContext.js +146 -0
- package/lib/server/chromium/crInput.js +187 -0
- package/lib/server/chromium/crNetworkManager.js +666 -0
- package/lib/server/chromium/crPage.js +1069 -0
- package/lib/server/chromium/crPdf.js +121 -0
- package/lib/server/chromium/crProtocolHelper.js +145 -0
- package/lib/server/chromium/crServiceWorker.js +123 -0
- package/lib/server/chromium/defaultFontFamilies.js +162 -0
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +113 -0
- package/lib/server/clock.js +149 -0
- package/lib/server/codegen/csharp.js +327 -0
- package/lib/server/codegen/java.js +274 -0
- package/lib/server/codegen/javascript.js +270 -0
- package/lib/server/codegen/jsonl.js +52 -0
- package/lib/server/codegen/language.js +132 -0
- package/lib/server/codegen/languages.js +68 -0
- package/lib/server/codegen/python.js +279 -0
- package/lib/server/codegen/types.js +16 -0
- package/lib/server/console.js +53 -0
- package/lib/server/cookieStore.js +206 -0
- package/lib/server/debugController.js +191 -0
- package/lib/server/debugger.js +119 -0
- package/lib/server/deviceDescriptors.js +39 -0
- package/lib/server/deviceDescriptorsSource.json +1779 -0
- package/lib/server/dialog.js +116 -0
- package/lib/server/dispatchers/androidDispatcher.js +325 -0
- package/lib/server/dispatchers/artifactDispatcher.js +118 -0
- package/lib/server/dispatchers/browserContextDispatcher.js +364 -0
- package/lib/server/dispatchers/browserDispatcher.js +118 -0
- package/lib/server/dispatchers/browserTypeDispatcher.js +64 -0
- package/lib/server/dispatchers/cdpSessionDispatcher.js +44 -0
- package/lib/server/dispatchers/debugControllerDispatcher.js +78 -0
- package/lib/server/dispatchers/dialogDispatcher.js +47 -0
- package/lib/server/dispatchers/dispatcher.js +371 -0
- package/lib/server/dispatchers/electronDispatcher.js +89 -0
- package/lib/server/dispatchers/elementHandlerDispatcher.js +181 -0
- package/lib/server/dispatchers/frameDispatcher.js +227 -0
- package/lib/server/dispatchers/jsHandleDispatcher.js +85 -0
- package/lib/server/dispatchers/jsonPipeDispatcher.js +58 -0
- package/lib/server/dispatchers/localUtilsDispatcher.js +149 -0
- package/lib/server/dispatchers/networkDispatchers.js +213 -0
- package/lib/server/dispatchers/pageDispatcher.js +401 -0
- package/lib/server/dispatchers/playwrightDispatcher.js +108 -0
- package/lib/server/dispatchers/selectorsDispatcher.js +36 -0
- package/lib/server/dispatchers/streamDispatcher.js +67 -0
- package/lib/server/dispatchers/tracingDispatcher.js +68 -0
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +165 -0
- package/lib/server/dispatchers/writableStreamDispatcher.js +79 -0
- package/lib/server/dom.js +806 -0
- package/lib/server/download.js +70 -0
- package/lib/server/electron/electron.js +270 -0
- package/lib/server/electron/loader.js +29 -0
- package/lib/server/errors.js +69 -0
- package/lib/server/fetch.js +621 -0
- package/lib/server/fileChooser.js +43 -0
- package/lib/server/fileUploadUtils.js +84 -0
- package/lib/server/firefox/ffAccessibility.js +238 -0
- package/lib/server/firefox/ffBrowser.js +428 -0
- package/lib/server/firefox/ffConnection.js +147 -0
- package/lib/server/firefox/ffExecutionContext.js +150 -0
- package/lib/server/firefox/ffInput.js +159 -0
- package/lib/server/firefox/ffNetworkManager.js +256 -0
- package/lib/server/firefox/ffPage.js +503 -0
- package/lib/server/firefox/firefox.js +116 -0
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +147 -0
- package/lib/server/frameSelectors.js +156 -0
- package/lib/server/frames.js +1502 -0
- package/lib/server/har/harRecorder.js +147 -0
- package/lib/server/har/harTracer.js +607 -0
- package/lib/server/harBackend.js +157 -0
- package/lib/server/helper.js +96 -0
- package/lib/server/index.js +58 -0
- package/lib/server/input.js +273 -0
- package/lib/server/instrumentation.js +69 -0
- package/lib/server/isomorphic/utilityScriptSerializers.js +212 -0
- package/lib/server/javascript.js +291 -0
- package/lib/server/launchApp.js +128 -0
- package/lib/server/localUtils.js +218 -0
- package/lib/server/macEditingCommands.js +143 -0
- package/lib/server/network.js +629 -0
- package/lib/server/page.js +871 -0
- package/lib/server/pipeTransport.js +89 -0
- package/lib/server/playwright.js +69 -0
- package/lib/server/progress.js +112 -0
- package/lib/server/protocolError.js +52 -0
- package/lib/server/recorder/chat.js +161 -0
- package/lib/server/recorder/codeGenerator.js +153 -0
- package/lib/server/recorder/csharp.js +310 -0
- package/lib/server/recorder/java.js +248 -0
- package/lib/server/recorder/javascript.js +229 -0
- package/lib/server/recorder/jsonl.js +47 -0
- package/lib/server/recorder/language.js +44 -0
- package/lib/server/recorder/python.js +276 -0
- package/lib/server/recorder/recorderActions.js +5 -0
- package/lib/server/recorder/recorderApp.js +387 -0
- package/lib/server/recorder/recorderRunner.js +138 -0
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +157 -0
- package/lib/server/recorder/throttledFile.js +57 -0
- package/lib/server/recorder/utils.js +45 -0
- package/lib/server/recorder.js +499 -0
- package/lib/server/registry/browserFetcher.js +175 -0
- package/lib/server/registry/dependencies.js +371 -0
- package/lib/server/registry/index.js +1331 -0
- package/lib/server/registry/nativeDeps.js +1280 -0
- package/lib/server/registry/oopDownloadBrowserMain.js +120 -0
- package/lib/server/screenshotter.js +333 -0
- package/lib/server/selectors.js +112 -0
- package/lib/server/socksClientCertificatesInterceptor.js +383 -0
- package/lib/server/socksInterceptor.js +95 -0
- package/lib/server/stably/ai-tools/http-request.js +70 -0
- package/lib/server/stably/ai-tools/stablyApiCaller.js +137 -0
- package/lib/server/stably/autohealing/elementHandleFromCoordinates.js +64 -0
- package/lib/server/stably/autohealing/healingService.js +228 -0
- package/lib/server/stably/autohealing/screenshotFrame.js +41 -0
- package/lib/server/stably/constants.js +31 -0
- package/lib/server/trace/recorder/snapshotter.js +147 -0
- package/lib/server/trace/recorder/snapshotterInjected.js +541 -0
- package/lib/server/trace/recorder/tracing.js +602 -0
- package/lib/server/trace/test/inMemorySnapshotter.js +87 -0
- package/lib/server/trace/viewer/traceViewer.js +240 -0
- package/lib/server/transport.js +181 -0
- package/lib/server/types.js +28 -0
- package/lib/server/usKeyboardLayout.js +145 -0
- package/lib/server/utils/ascii.js +44 -0
- package/lib/server/utils/comparators.js +161 -0
- package/lib/server/utils/crypto.js +216 -0
- package/lib/server/utils/debug.js +42 -0
- package/lib/server/utils/debugLogger.js +122 -0
- package/lib/server/utils/env.js +73 -0
- package/lib/server/utils/eventsHelper.js +39 -0
- package/lib/server/utils/expectUtils.js +38 -0
- package/lib/server/utils/fileUtils.js +191 -0
- package/lib/server/utils/happyEyeballs.js +207 -0
- package/lib/server/utils/hostPlatform.js +111 -0
- package/lib/server/utils/httpServer.js +218 -0
- package/lib/server/utils/image_tools/colorUtils.js +89 -0
- package/lib/server/utils/image_tools/compare.js +109 -0
- package/lib/server/utils/image_tools/imageChannel.js +78 -0
- package/lib/server/utils/image_tools/stats.js +102 -0
- package/lib/server/utils/linuxUtils.js +71 -0
- package/lib/server/utils/network.js +233 -0
- package/lib/server/utils/nodePlatform.js +148 -0
- package/lib/server/utils/pipeTransport.js +84 -0
- package/lib/server/utils/processLauncher.js +241 -0
- package/lib/server/utils/profiler.js +65 -0
- package/lib/server/utils/socksProxy.js +511 -0
- package/lib/server/utils/spawnAsync.js +41 -0
- package/lib/server/utils/task.js +51 -0
- package/lib/server/utils/userAgent.js +98 -0
- package/lib/server/utils/wsServer.js +121 -0
- package/lib/server/utils/zipFile.js +74 -0
- package/lib/server/utils/zones.js +57 -0
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +119 -0
- package/lib/server/webkit/wkAccessibility.js +237 -0
- package/lib/server/webkit/wkBrowser.js +339 -0
- package/lib/server/webkit/wkConnection.js +149 -0
- package/lib/server/webkit/wkExecutionContext.js +154 -0
- package/lib/server/webkit/wkInput.js +181 -0
- package/lib/server/webkit/wkInterceptableRequest.js +169 -0
- package/lib/server/webkit/wkPage.js +1134 -0
- package/lib/server/webkit/wkProvisionalPage.js +83 -0
- package/lib/server/webkit/wkWorkers.js +104 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-client.js +74 -0
- package/lib/server/webkit/wsl/webkit-wsl-transport-server.js +113 -0
- package/lib/third_party/diff_match_patch.js +2222 -0
- package/lib/third_party/pixelmatch.js +255 -0
- package/lib/utils/ascii.js +31 -0
- package/lib/utils/comparators.js +171 -0
- package/lib/utils/crypto.js +33 -0
- package/lib/utils/debug.js +46 -0
- package/lib/utils/debugLogger.js +89 -0
- package/lib/utils/env.js +49 -0
- package/lib/utils/eventsHelper.js +38 -0
- package/lib/utils/fileUtils.js +205 -0
- package/lib/utils/glob.js +83 -0
- package/lib/utils/happy-eyeballs.js +160 -0
- package/lib/utils/headers.js +52 -0
- package/lib/utils/hostPlatform.js +128 -0
- package/lib/utils/httpServer.js +236 -0
- package/lib/utils/index.js +346 -0
- package/lib/utils/isomorphic/ariaSnapshot.js +392 -0
- package/lib/utils/isomorphic/assert.js +31 -0
- package/lib/utils/isomorphic/colors.js +72 -0
- package/lib/utils/isomorphic/cssParser.js +245 -0
- package/lib/utils/isomorphic/cssTokenizer.js +1051 -0
- package/lib/utils/isomorphic/headers.js +53 -0
- package/lib/utils/isomorphic/locatorGenerators.js +673 -0
- package/lib/utils/isomorphic/locatorParser.js +176 -0
- package/lib/utils/isomorphic/locatorUtils.js +81 -0
- package/lib/utils/isomorphic/manualPromise.js +114 -0
- package/lib/utils/isomorphic/mimeType.js +459 -0
- package/lib/utils/isomorphic/multimap.js +80 -0
- package/lib/utils/isomorphic/protocolFormatter.js +78 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/rtti.js +43 -0
- package/lib/utils/isomorphic/selectorParser.js +386 -0
- package/lib/utils/isomorphic/semaphore.js +54 -0
- package/lib/utils/isomorphic/stackTrace.js +158 -0
- package/lib/utils/isomorphic/stringUtils.js +155 -0
- package/lib/utils/isomorphic/time.js +49 -0
- package/lib/utils/isomorphic/timeoutRunner.js +66 -0
- package/lib/utils/isomorphic/traceUtils.js +58 -0
- package/lib/utils/isomorphic/types.js +16 -0
- package/lib/utils/isomorphic/urlMatch.js +176 -0
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils/linuxUtils.js +78 -0
- package/lib/utils/manualPromise.js +109 -0
- package/lib/utils/mimeType.js +29 -0
- package/lib/utils/multimap.js +75 -0
- package/lib/utils/network.js +188 -0
- package/lib/utils/processLauncher.js +248 -0
- package/lib/utils/profiler.js +53 -0
- package/lib/utils/rtti.js +44 -0
- package/lib/utils/semaphore.js +51 -0
- package/lib/utils/spawnAsync.js +45 -0
- package/lib/utils/stackTrace.js +121 -0
- package/lib/utils/task.js +58 -0
- package/lib/utils/time.js +37 -0
- package/lib/utils/timeoutRunner.js +66 -0
- package/lib/utils/traceUtils.js +44 -0
- package/lib/utils/userAgent.js +105 -0
- package/lib/utils/wsServer.js +127 -0
- package/lib/utils/zipFile.js +75 -0
- package/lib/utils/zones.js +62 -0
- package/lib/utils.js +107 -0
- package/lib/utilsBundle.js +109 -0
- package/lib/utilsBundleImpl/index.js +218 -0
- package/lib/utilsBundleImpl/xdg-open +1066 -0
- package/lib/vite/htmlReport/index.html +84 -0
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-RJCXzfmE.js +24 -0
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-Ri0uHF7I.css +1 -0
- package/lib/vite/recorder/assets/index-Y-X2TGJv.js +193 -0
- package/lib/vite/recorder/index.html +29 -0
- package/lib/vite/recorder/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/assets/codeMirrorModule-Bhnc5o2x.js +24 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-ClwvkA2N.js +265 -0
- package/lib/vite/traceViewer/assets/xtermModule-CsJ4vdCR.js +9 -0
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +1 -0
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.TQ8_7ybu.css +1 -0
- package/lib/vite/traceViewer/index.DFO9NNF5.js +2 -0
- package/lib/vite/traceViewer/index.I8N9v4jT.css +1 -0
- package/lib/vite/traceViewer/index.html +43 -0
- package/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/lib/vite/traceViewer/snapshot.html +21 -0
- package/lib/vite/traceViewer/sw.bundle.js +3 -0
- package/lib/vite/traceViewer/uiMode.Btcz36p_.css +1 -0
- package/lib/vite/traceViewer/uiMode.Shu3QS-1.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +17 -0
- package/lib/vite/traceViewer/xtermModule.DYP7pi_n.css +32 -0
- package/lib/zipBundle.js +34 -0
- package/lib/zipBundleImpl.js +5 -0
- package/package.json +43 -0
- package/types/protocol.d.ts +23130 -0
- package/types/structs.d.ts +45 -0
- package/types/types.d.ts +22857 -0
@@ -0,0 +1,806 @@
|
|
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 dom_exports = {};
|
30
|
+
__export(dom_exports, {
|
31
|
+
ElementHandle: () => ElementHandle,
|
32
|
+
FrameExecutionContext: () => FrameExecutionContext,
|
33
|
+
NonRecoverableDOMError: () => NonRecoverableDOMError,
|
34
|
+
assertDone: () => assertDone,
|
35
|
+
isNonRecoverableDOMError: () => isNonRecoverableDOMError,
|
36
|
+
kUnableToAdoptErrorMessage: () => kUnableToAdoptErrorMessage,
|
37
|
+
throwElementIsNotAttached: () => throwElementIsNotAttached,
|
38
|
+
throwRetargetableDOMError: () => throwRetargetableDOMError
|
39
|
+
});
|
40
|
+
module.exports = __toCommonJS(dom_exports);
|
41
|
+
var import_fs = __toESM(require("fs"));
|
42
|
+
var js = __toESM(require("./javascript"));
|
43
|
+
var import_utils = require("../utils");
|
44
|
+
var import_fileUploadUtils = require("./fileUploadUtils");
|
45
|
+
var rawInjectedScriptSource = __toESM(require("../generated/injectedScriptSource"));
|
46
|
+
class NonRecoverableDOMError extends Error {
|
47
|
+
}
|
48
|
+
function isNonRecoverableDOMError(error) {
|
49
|
+
return error instanceof NonRecoverableDOMError;
|
50
|
+
}
|
51
|
+
class FrameExecutionContext extends js.ExecutionContext {
|
52
|
+
constructor(delegate, frame, world) {
|
53
|
+
super(frame, delegate, world || "content-script");
|
54
|
+
this.frame = frame;
|
55
|
+
this.world = world;
|
56
|
+
}
|
57
|
+
adoptIfNeeded(handle) {
|
58
|
+
if (handle instanceof ElementHandle && handle._context !== this)
|
59
|
+
return this.frame._page.delegate.adoptElementHandle(handle, this);
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
async evaluate(pageFunction, arg) {
|
63
|
+
return js.evaluate(this, true, pageFunction, arg);
|
64
|
+
}
|
65
|
+
async evaluateHandle(pageFunction, arg) {
|
66
|
+
return js.evaluate(this, false, pageFunction, arg);
|
67
|
+
}
|
68
|
+
async evaluateExpression(expression, options, arg) {
|
69
|
+
return js.evaluateExpression(this, expression, { ...options, returnByValue: true }, arg);
|
70
|
+
}
|
71
|
+
async evaluateExpressionHandle(expression, options, arg) {
|
72
|
+
return js.evaluateExpression(this, expression, { ...options, returnByValue: false }, arg);
|
73
|
+
}
|
74
|
+
injectedScript() {
|
75
|
+
if (!this._injectedScriptPromise) {
|
76
|
+
const customEngines = [];
|
77
|
+
const selectorsRegistry = this.frame._page.browserContext.selectors();
|
78
|
+
for (const [name, { source: source2 }] of selectorsRegistry._engines)
|
79
|
+
customEngines.push({ name, source: `(${source2})` });
|
80
|
+
const sdkLanguage = this.frame._page.browserContext._browser.sdkLanguage();
|
81
|
+
const options = {
|
82
|
+
isUnderTest: (0, import_utils.isUnderTest)(),
|
83
|
+
sdkLanguage,
|
84
|
+
testIdAttributeName: selectorsRegistry.testIdAttributeName(),
|
85
|
+
stableRafCount: this.frame._page.delegate.rafCountForStablePosition(),
|
86
|
+
browserName: this.frame._page.browserContext._browser.options.name,
|
87
|
+
isUtilityWorld: this.world === "utility",
|
88
|
+
customEngines
|
89
|
+
};
|
90
|
+
const source = `
|
91
|
+
(() => {
|
92
|
+
const module = {};
|
93
|
+
${rawInjectedScriptSource.source}
|
94
|
+
return new (module.exports.InjectedScript())(globalThis, ${JSON.stringify(options)});
|
95
|
+
})();
|
96
|
+
`;
|
97
|
+
this._injectedScriptPromise = this.rawEvaluateHandle(source).then((handle) => {
|
98
|
+
handle._setPreview("InjectedScript");
|
99
|
+
return handle;
|
100
|
+
});
|
101
|
+
}
|
102
|
+
return this._injectedScriptPromise;
|
103
|
+
}
|
104
|
+
}
|
105
|
+
class ElementHandle extends js.JSHandle {
|
106
|
+
constructor(context, objectId) {
|
107
|
+
super(context, "node", void 0, objectId);
|
108
|
+
this.__elementhandle = true;
|
109
|
+
this._page = context.frame._page;
|
110
|
+
this._frame = context.frame;
|
111
|
+
this._initializePreview().catch((e) => {
|
112
|
+
});
|
113
|
+
}
|
114
|
+
async _initializePreview() {
|
115
|
+
const utility = await this._context.injectedScript();
|
116
|
+
this._setPreview(await utility.evaluate((injected, e) => "JSHandle@" + injected.previewNode(e), this));
|
117
|
+
}
|
118
|
+
asElement() {
|
119
|
+
return this;
|
120
|
+
}
|
121
|
+
async evaluateInUtility(pageFunction, arg) {
|
122
|
+
try {
|
123
|
+
const utility = await this._frame._utilityContext();
|
124
|
+
return await utility.evaluate(pageFunction, [await utility.injectedScript(), this, arg]);
|
125
|
+
} catch (e) {
|
126
|
+
if (this._frame.isNonRetriableError(e))
|
127
|
+
throw e;
|
128
|
+
return "error:notconnected";
|
129
|
+
}
|
130
|
+
}
|
131
|
+
async evaluateHandleInUtility(pageFunction, arg) {
|
132
|
+
try {
|
133
|
+
const utility = await this._frame._utilityContext();
|
134
|
+
return await utility.evaluateHandle(pageFunction, [await utility.injectedScript(), this, arg]);
|
135
|
+
} catch (e) {
|
136
|
+
if (this._frame.isNonRetriableError(e))
|
137
|
+
throw e;
|
138
|
+
return "error:notconnected";
|
139
|
+
}
|
140
|
+
}
|
141
|
+
async ownerFrame() {
|
142
|
+
const frameId = await this._page.delegate.getOwnerFrame(this);
|
143
|
+
if (!frameId)
|
144
|
+
return null;
|
145
|
+
const frame = this._page.frameManager.frame(frameId);
|
146
|
+
if (frame)
|
147
|
+
return frame;
|
148
|
+
for (const page of this._page.browserContext.pages()) {
|
149
|
+
const frame2 = page.frameManager.frame(frameId);
|
150
|
+
if (frame2)
|
151
|
+
return frame2;
|
152
|
+
}
|
153
|
+
return null;
|
154
|
+
}
|
155
|
+
async isIframeElement() {
|
156
|
+
return this.evaluateInUtility(([injected, node]) => node && (node.nodeName === "IFRAME" || node.nodeName === "FRAME"), {});
|
157
|
+
}
|
158
|
+
async contentFrame() {
|
159
|
+
const isFrameElement = throwRetargetableDOMError(await this.isIframeElement());
|
160
|
+
if (!isFrameElement)
|
161
|
+
return null;
|
162
|
+
return this._page.delegate.getContentFrame(this);
|
163
|
+
}
|
164
|
+
async getAttribute(progress, name) {
|
165
|
+
return this._frame.getAttribute(progress, ":scope", name, {}, this);
|
166
|
+
}
|
167
|
+
async inputValue(progress) {
|
168
|
+
return this._frame.inputValue(progress, ":scope", {}, this);
|
169
|
+
}
|
170
|
+
async textContent(progress) {
|
171
|
+
return this._frame.textContent(progress, ":scope", {}, this);
|
172
|
+
}
|
173
|
+
async innerText(progress) {
|
174
|
+
return this._frame.innerText(progress, ":scope", {}, this);
|
175
|
+
}
|
176
|
+
async innerHTML(progress) {
|
177
|
+
return this._frame.innerHTML(progress, ":scope", {}, this);
|
178
|
+
}
|
179
|
+
async dispatchEvent(progress, type, eventInit = {}) {
|
180
|
+
return this._frame.dispatchEvent(progress, ":scope", type, eventInit, {}, this);
|
181
|
+
}
|
182
|
+
async _scrollRectIntoViewIfNeeded(progress, rect) {
|
183
|
+
return await progress.race(this._page.delegate.scrollRectIntoViewIfNeeded(this, rect));
|
184
|
+
}
|
185
|
+
async _waitAndScrollIntoViewIfNeeded(progress, waitForVisible) {
|
186
|
+
const result = await this._retryAction(progress, "scroll into view", async () => {
|
187
|
+
progress.log(` waiting for element to be stable`);
|
188
|
+
const waitResult = await progress.race(this.evaluateInUtility(async ([injected, node, { waitForVisible: waitForVisible2 }]) => {
|
189
|
+
return await injected.checkElementStates(node, waitForVisible2 ? ["visible", "stable"] : ["stable"]);
|
190
|
+
}, { waitForVisible }));
|
191
|
+
if (waitResult)
|
192
|
+
return waitResult;
|
193
|
+
return await this._scrollRectIntoViewIfNeeded(progress);
|
194
|
+
}, {});
|
195
|
+
assertDone(throwRetargetableDOMError(result));
|
196
|
+
}
|
197
|
+
async scrollIntoViewIfNeeded(progress) {
|
198
|
+
await this._waitAndScrollIntoViewIfNeeded(
|
199
|
+
progress,
|
200
|
+
false
|
201
|
+
/* waitForVisible */
|
202
|
+
);
|
203
|
+
}
|
204
|
+
async _clickablePoint() {
|
205
|
+
const intersectQuadWithViewport = (quad) => {
|
206
|
+
return quad.map((point) => ({
|
207
|
+
x: Math.min(Math.max(point.x, 0), metrics.width),
|
208
|
+
y: Math.min(Math.max(point.y, 0), metrics.height)
|
209
|
+
}));
|
210
|
+
};
|
211
|
+
const computeQuadArea = (quad) => {
|
212
|
+
let area = 0;
|
213
|
+
for (let i = 0; i < quad.length; ++i) {
|
214
|
+
const p1 = quad[i];
|
215
|
+
const p2 = quad[(i + 1) % quad.length];
|
216
|
+
area += (p1.x * p2.y - p2.x * p1.y) / 2;
|
217
|
+
}
|
218
|
+
return Math.abs(area);
|
219
|
+
};
|
220
|
+
const [quads, metrics] = await Promise.all([
|
221
|
+
this._page.delegate.getContentQuads(this),
|
222
|
+
this._page.mainFrame()._utilityContext().then((utility) => utility.evaluate(() => ({ width: innerWidth, height: innerHeight })))
|
223
|
+
]);
|
224
|
+
if (quads === "error:notconnected")
|
225
|
+
return quads;
|
226
|
+
if (!quads || !quads.length)
|
227
|
+
return "error:notvisible";
|
228
|
+
const filtered = quads.map((quad) => intersectQuadWithViewport(quad)).filter((quad) => computeQuadArea(quad) > 0.99);
|
229
|
+
if (!filtered.length)
|
230
|
+
return "error:notinviewport";
|
231
|
+
if (this._page.browserContext._browser.options.name === "firefox") {
|
232
|
+
for (const quad of filtered) {
|
233
|
+
const integerPoint = findIntegerPointInsideQuad(quad);
|
234
|
+
if (integerPoint)
|
235
|
+
return integerPoint;
|
236
|
+
}
|
237
|
+
}
|
238
|
+
return quadMiddlePoint(filtered[0]);
|
239
|
+
}
|
240
|
+
async _offsetPoint(offset) {
|
241
|
+
const [box, border] = await Promise.all([
|
242
|
+
this.boundingBox(),
|
243
|
+
this.evaluateInUtility(([injected, node]) => injected.getElementBorderWidth(node), {}).catch((e) => {
|
244
|
+
})
|
245
|
+
]);
|
246
|
+
if (!box || !border)
|
247
|
+
return "error:notvisible";
|
248
|
+
if (border === "error:notconnected")
|
249
|
+
return border;
|
250
|
+
return {
|
251
|
+
x: box.x + border.left + offset.x,
|
252
|
+
y: box.y + border.top + offset.y
|
253
|
+
};
|
254
|
+
}
|
255
|
+
async _retryAction(progress, actionName, action, options) {
|
256
|
+
let retry = 0;
|
257
|
+
const waitTime = [0, 20, 100, 100, 500];
|
258
|
+
while (true) {
|
259
|
+
if (retry) {
|
260
|
+
progress.log(`retrying ${actionName} action${options.trial ? " (trial run)" : ""}`);
|
261
|
+
const timeout = waitTime[Math.min(retry - 1, waitTime.length - 1)];
|
262
|
+
if (timeout) {
|
263
|
+
progress.log(` waiting ${timeout}ms`);
|
264
|
+
const result2 = await progress.race(this.evaluateInUtility(([injected, node, timeout2]) => new Promise((f) => setTimeout(f, timeout2)), timeout));
|
265
|
+
if (result2 === "error:notconnected")
|
266
|
+
return result2;
|
267
|
+
}
|
268
|
+
} else {
|
269
|
+
progress.log(`attempting ${actionName} action${options.trial ? " (trial run)" : ""}`);
|
270
|
+
}
|
271
|
+
if (!options.skipActionPreChecks && !options.force)
|
272
|
+
await this._frame._page.performActionPreChecks(progress);
|
273
|
+
const result = await action(retry);
|
274
|
+
++retry;
|
275
|
+
if (result === "error:notvisible") {
|
276
|
+
if (options.force)
|
277
|
+
throw new NonRecoverableDOMError("Element is not visible");
|
278
|
+
progress.log(" element is not visible");
|
279
|
+
continue;
|
280
|
+
}
|
281
|
+
if (result === "error:notinviewport") {
|
282
|
+
if (options.force)
|
283
|
+
throw new NonRecoverableDOMError("Element is outside of the viewport");
|
284
|
+
progress.log(" element is outside of the viewport");
|
285
|
+
continue;
|
286
|
+
}
|
287
|
+
if (result === "error:optionsnotfound") {
|
288
|
+
progress.log(" did not find some options");
|
289
|
+
continue;
|
290
|
+
}
|
291
|
+
if (result === "error:optionnotenabled") {
|
292
|
+
progress.log(" option being selected is not enabled");
|
293
|
+
continue;
|
294
|
+
}
|
295
|
+
if (typeof result === "object" && "hitTargetDescription" in result) {
|
296
|
+
progress.log(` ${result.hitTargetDescription} intercepts pointer events`);
|
297
|
+
continue;
|
298
|
+
}
|
299
|
+
if (typeof result === "object" && "missingState" in result) {
|
300
|
+
progress.log(` element is not ${result.missingState}`);
|
301
|
+
continue;
|
302
|
+
}
|
303
|
+
return result;
|
304
|
+
}
|
305
|
+
}
|
306
|
+
async _retryPointerAction(progress, actionName, waitForEnabled, action, options) {
|
307
|
+
const skipActionPreChecks = actionName === "move and up";
|
308
|
+
return await this._retryAction(progress, actionName, async (retry) => {
|
309
|
+
const scrollOptions = [
|
310
|
+
void 0,
|
311
|
+
{ block: "end", inline: "end" },
|
312
|
+
{ block: "center", inline: "center" },
|
313
|
+
{ block: "start", inline: "start" }
|
314
|
+
];
|
315
|
+
const forceScrollOptions = scrollOptions[retry % scrollOptions.length];
|
316
|
+
return await this._performPointerAction(progress, actionName, waitForEnabled, action, forceScrollOptions, options);
|
317
|
+
}, { ...options, skipActionPreChecks });
|
318
|
+
}
|
319
|
+
async _performPointerAction(progress, actionName, waitForEnabled, action, forceScrollOptions, options) {
|
320
|
+
const { force = false, position } = options;
|
321
|
+
const doScrollIntoView = async () => {
|
322
|
+
if (forceScrollOptions) {
|
323
|
+
return await this.evaluateInUtility(([injected, node, options2]) => {
|
324
|
+
if (node.nodeType === 1)
|
325
|
+
node.scrollIntoView(options2);
|
326
|
+
return "done";
|
327
|
+
}, forceScrollOptions);
|
328
|
+
}
|
329
|
+
return await this._scrollRectIntoViewIfNeeded(progress, position ? { x: position.x, y: position.y, width: 0, height: 0 } : void 0);
|
330
|
+
};
|
331
|
+
if (this._frame.parentFrame()) {
|
332
|
+
await progress.race(doScrollIntoView().catch(() => {
|
333
|
+
}));
|
334
|
+
}
|
335
|
+
if (options.__testHookBeforeStable)
|
336
|
+
await progress.race(options.__testHookBeforeStable());
|
337
|
+
if (!force) {
|
338
|
+
const elementStates = waitForEnabled ? ["visible", "enabled", "stable"] : ["visible", "stable"];
|
339
|
+
progress.log(` waiting for element to be ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
|
340
|
+
const result = await progress.race(this.evaluateInUtility(async ([injected, node, { elementStates: elementStates2 }]) => {
|
341
|
+
return await injected.checkElementStates(node, elementStates2);
|
342
|
+
}, { elementStates }));
|
343
|
+
if (result)
|
344
|
+
return result;
|
345
|
+
progress.log(` element is ${waitForEnabled ? "visible, enabled and stable" : "visible and stable"}`);
|
346
|
+
}
|
347
|
+
if (options.__testHookAfterStable)
|
348
|
+
await progress.race(options.__testHookAfterStable());
|
349
|
+
progress.log(" scrolling into view if needed");
|
350
|
+
const scrolled = await progress.race(doScrollIntoView());
|
351
|
+
if (scrolled !== "done")
|
352
|
+
return scrolled;
|
353
|
+
progress.log(" done scrolling");
|
354
|
+
const maybePoint = position ? await progress.race(this._offsetPoint(position)) : await progress.race(this._clickablePoint());
|
355
|
+
if (typeof maybePoint === "string")
|
356
|
+
return maybePoint;
|
357
|
+
const point = roundPoint(maybePoint);
|
358
|
+
progress.metadata.point = point;
|
359
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
360
|
+
let hitTargetInterceptionHandle;
|
361
|
+
if (force) {
|
362
|
+
progress.log(` forcing action`);
|
363
|
+
} else {
|
364
|
+
if (options.__testHookBeforeHitTarget)
|
365
|
+
await progress.race(options.__testHookBeforeHitTarget());
|
366
|
+
const frameCheckResult = await progress.race(this._checkFrameIsHitTarget(point));
|
367
|
+
if (frameCheckResult === "error:notconnected" || "hitTargetDescription" in frameCheckResult)
|
368
|
+
return frameCheckResult;
|
369
|
+
const hitPoint = frameCheckResult.framePoint;
|
370
|
+
const actionType = actionName === "move and up" ? "drag" : actionName === "hover" || actionName === "tap" ? actionName : "mouse";
|
371
|
+
const handle = await progress.race(this.evaluateHandleInUtility(([injected, node, { actionType: actionType2, hitPoint: hitPoint2, trial }]) => injected.setupHitTargetInterceptor(node, actionType2, hitPoint2, trial), { actionType, hitPoint, trial: !!options.trial }));
|
372
|
+
if (handle === "error:notconnected")
|
373
|
+
return handle;
|
374
|
+
if (!handle._objectId) {
|
375
|
+
const error = handle.rawValue();
|
376
|
+
if (error === "error:notconnected")
|
377
|
+
return error;
|
378
|
+
return { hitTargetDescription: error };
|
379
|
+
}
|
380
|
+
hitTargetInterceptionHandle = handle;
|
381
|
+
}
|
382
|
+
const actionResult = await this._page.frameManager.waitForSignalsCreatedBy(progress, options.waitAfter === true, async () => {
|
383
|
+
if (options.__testHookBeforePointerAction)
|
384
|
+
await progress.race(options.__testHookBeforePointerAction());
|
385
|
+
let restoreModifiers;
|
386
|
+
if (options && options.modifiers)
|
387
|
+
restoreModifiers = await this._page.keyboard.ensureModifiers(progress, options.modifiers);
|
388
|
+
progress.log(` performing ${actionName} action`);
|
389
|
+
await action(point);
|
390
|
+
if (restoreModifiers)
|
391
|
+
await this._page.keyboard.ensureModifiers(progress, restoreModifiers);
|
392
|
+
if (hitTargetInterceptionHandle) {
|
393
|
+
const stopHitTargetInterception = this._frame.raceAgainstEvaluationStallingEvents(() => {
|
394
|
+
return hitTargetInterceptionHandle.evaluate((h) => h.stop());
|
395
|
+
}).catch((e) => "done").finally(() => {
|
396
|
+
hitTargetInterceptionHandle?.dispose();
|
397
|
+
});
|
398
|
+
if (options.waitAfter !== false) {
|
399
|
+
const hitTargetResult = await progress.race(stopHitTargetInterception);
|
400
|
+
if (hitTargetResult !== "done")
|
401
|
+
return hitTargetResult;
|
402
|
+
}
|
403
|
+
}
|
404
|
+
progress.log(` ${options.trial ? "trial " : ""}${actionName} action done`);
|
405
|
+
progress.log(" waiting for scheduled navigations to finish");
|
406
|
+
if (options.__testHookAfterPointerAction)
|
407
|
+
await progress.race(options.__testHookAfterPointerAction());
|
408
|
+
return "done";
|
409
|
+
}).finally(() => {
|
410
|
+
const stopPromise = hitTargetInterceptionHandle?.evaluate((h) => h.stop()).catch(() => {
|
411
|
+
});
|
412
|
+
stopPromise?.then(() => hitTargetInterceptionHandle?.dispose());
|
413
|
+
});
|
414
|
+
if (actionResult !== "done")
|
415
|
+
return actionResult;
|
416
|
+
progress.log(" navigations have finished");
|
417
|
+
return "done";
|
418
|
+
}
|
419
|
+
async _markAsTargetElement(progress) {
|
420
|
+
if (!progress.metadata.id)
|
421
|
+
return;
|
422
|
+
await progress.race(this.evaluateInUtility(([injected, node, callId]) => {
|
423
|
+
if (node.nodeType === 1)
|
424
|
+
injected.markTargetElements(/* @__PURE__ */ new Set([node]), callId);
|
425
|
+
}, progress.metadata.id));
|
426
|
+
}
|
427
|
+
async hover(progress, options) {
|
428
|
+
await this._markAsTargetElement(progress);
|
429
|
+
const result = await this._hover(progress, options);
|
430
|
+
return assertDone(throwRetargetableDOMError(result));
|
431
|
+
}
|
432
|
+
_hover(progress, options) {
|
433
|
+
return this._retryPointerAction(progress, "hover", false, (point) => this._page.mouse.move(progress, point.x, point.y), { ...options, waitAfter: "disabled" });
|
434
|
+
}
|
435
|
+
async click(progress, options) {
|
436
|
+
await this._markAsTargetElement(progress);
|
437
|
+
const result = await this._click(progress, { ...options, waitAfter: !options.noWaitAfter });
|
438
|
+
return assertDone(throwRetargetableDOMError(result));
|
439
|
+
}
|
440
|
+
_click(progress, options) {
|
441
|
+
return this._retryPointerAction(progress, "click", true, (point) => this._page.mouse.click(progress, point.x, point.y, options), options);
|
442
|
+
}
|
443
|
+
async dblclick(progress, options) {
|
444
|
+
await this._markAsTargetElement(progress);
|
445
|
+
const result = await this._dblclick(progress, options);
|
446
|
+
return assertDone(throwRetargetableDOMError(result));
|
447
|
+
}
|
448
|
+
_dblclick(progress, options) {
|
449
|
+
return this._retryPointerAction(progress, "dblclick", true, (point) => this._page.mouse.click(progress, point.x, point.y, { ...options, clickCount: 2 }), { ...options, waitAfter: "disabled" });
|
450
|
+
}
|
451
|
+
async tap(progress, options) {
|
452
|
+
await this._markAsTargetElement(progress);
|
453
|
+
const result = await this._tap(progress, options);
|
454
|
+
return assertDone(throwRetargetableDOMError(result));
|
455
|
+
}
|
456
|
+
_tap(progress, options) {
|
457
|
+
return this._retryPointerAction(progress, "tap", true, (point) => this._page.touchscreen.tap(progress, point.x, point.y), { ...options, waitAfter: "disabled" });
|
458
|
+
}
|
459
|
+
async selectOption(progress, elements, values, options) {
|
460
|
+
await this._markAsTargetElement(progress);
|
461
|
+
const result = await this._selectOption(progress, elements, values, options);
|
462
|
+
return throwRetargetableDOMError(result);
|
463
|
+
}
|
464
|
+
async _selectOption(progress, elements, values, options) {
|
465
|
+
let resultingOptions = [];
|
466
|
+
const result = await this._retryAction(progress, "select option", async () => {
|
467
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
468
|
+
if (!options.force)
|
469
|
+
progress.log(` waiting for element to be visible and enabled`);
|
470
|
+
const optionsToSelect = [...elements, ...values];
|
471
|
+
const result2 = await progress.race(this.evaluateInUtility(async ([injected, node, { optionsToSelect: optionsToSelect2, force }]) => {
|
472
|
+
if (!force) {
|
473
|
+
const checkResult = await injected.checkElementStates(node, ["visible", "enabled"]);
|
474
|
+
if (checkResult)
|
475
|
+
return checkResult;
|
476
|
+
}
|
477
|
+
return injected.selectOptions(node, optionsToSelect2);
|
478
|
+
}, { optionsToSelect, force: options.force }));
|
479
|
+
if (Array.isArray(result2)) {
|
480
|
+
progress.log(" selected specified option(s)");
|
481
|
+
resultingOptions = result2;
|
482
|
+
return "done";
|
483
|
+
}
|
484
|
+
return result2;
|
485
|
+
}, options);
|
486
|
+
if (result === "error:notconnected")
|
487
|
+
return result;
|
488
|
+
return resultingOptions;
|
489
|
+
}
|
490
|
+
async fill(progress, value, options) {
|
491
|
+
await this._markAsTargetElement(progress);
|
492
|
+
const result = await this._fill(progress, value, options);
|
493
|
+
assertDone(throwRetargetableDOMError(result));
|
494
|
+
}
|
495
|
+
async _fill(progress, value, options) {
|
496
|
+
progress.log(` fill("${value}")`);
|
497
|
+
return await this._retryAction(progress, "fill", async () => {
|
498
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
499
|
+
if (!options.force)
|
500
|
+
progress.log(" waiting for element to be visible, enabled and editable");
|
501
|
+
const result = await progress.race(this.evaluateInUtility(async ([injected, node, { value: value2, force }]) => {
|
502
|
+
if (!force) {
|
503
|
+
const checkResult = await injected.checkElementStates(node, ["visible", "enabled", "editable"]);
|
504
|
+
if (checkResult)
|
505
|
+
return checkResult;
|
506
|
+
}
|
507
|
+
return injected.fill(node, value2);
|
508
|
+
}, { value, force: options.force }));
|
509
|
+
if (result === "needsinput") {
|
510
|
+
if (value)
|
511
|
+
await this._page.keyboard.insertText(progress, value);
|
512
|
+
else
|
513
|
+
await this._page.keyboard.press(progress, "Delete");
|
514
|
+
return "done";
|
515
|
+
} else {
|
516
|
+
return result;
|
517
|
+
}
|
518
|
+
}, options);
|
519
|
+
}
|
520
|
+
async selectText(progress, options) {
|
521
|
+
const result = await this._retryAction(progress, "selectText", async () => {
|
522
|
+
if (!options.force)
|
523
|
+
progress.log(" waiting for element to be visible");
|
524
|
+
return await progress.race(this.evaluateInUtility(async ([injected, node, { force }]) => {
|
525
|
+
if (!force) {
|
526
|
+
const checkResult = await injected.checkElementStates(node, ["visible"]);
|
527
|
+
if (checkResult)
|
528
|
+
return checkResult;
|
529
|
+
}
|
530
|
+
return injected.selectText(node);
|
531
|
+
}, { force: options.force }));
|
532
|
+
}, options);
|
533
|
+
assertDone(throwRetargetableDOMError(result));
|
534
|
+
}
|
535
|
+
async setInputFiles(progress, params) {
|
536
|
+
const inputFileItems = await progress.race((0, import_fileUploadUtils.prepareFilesForUpload)(this._frame, params));
|
537
|
+
await this._markAsTargetElement(progress);
|
538
|
+
const result = await this._setInputFiles(progress, inputFileItems);
|
539
|
+
return assertDone(throwRetargetableDOMError(result));
|
540
|
+
}
|
541
|
+
async _setInputFiles(progress, items) {
|
542
|
+
const { filePayloads, localPaths, localDirectory } = items;
|
543
|
+
const multiple = filePayloads && filePayloads.length > 1 || localPaths && localPaths.length > 1;
|
544
|
+
const result = await progress.race(this.evaluateHandleInUtility(([injected, node, { multiple: multiple2, directoryUpload }]) => {
|
545
|
+
const element = injected.retarget(node, "follow-label");
|
546
|
+
if (!element)
|
547
|
+
return;
|
548
|
+
if (element.tagName !== "INPUT")
|
549
|
+
throw injected.createStacklessError("Node is not an HTMLInputElement");
|
550
|
+
const inputElement = element;
|
551
|
+
if (multiple2 && !inputElement.multiple && !inputElement.webkitdirectory)
|
552
|
+
throw injected.createStacklessError("Non-multiple file input can only accept single file");
|
553
|
+
if (directoryUpload && !inputElement.webkitdirectory)
|
554
|
+
throw injected.createStacklessError("File input does not support directories, pass individual files instead");
|
555
|
+
if (!directoryUpload && inputElement.webkitdirectory)
|
556
|
+
throw injected.createStacklessError("[webkitdirectory] input requires passing a path to a directory");
|
557
|
+
return inputElement;
|
558
|
+
}, { multiple, directoryUpload: !!localDirectory }));
|
559
|
+
if (result === "error:notconnected" || !result.asElement())
|
560
|
+
return "error:notconnected";
|
561
|
+
const retargeted = result.asElement();
|
562
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
563
|
+
if (localPaths || localDirectory) {
|
564
|
+
const localPathsOrDirectory = localDirectory ? [localDirectory] : localPaths;
|
565
|
+
await progress.race(Promise.all(localPathsOrDirectory.map((localPath) => import_fs.default.promises.access(localPath, import_fs.default.constants.F_OK))));
|
566
|
+
const waitForInputEvent = localDirectory ? this.evaluate((node) => new Promise((fulfill) => {
|
567
|
+
node.addEventListener("input", fulfill, { once: true });
|
568
|
+
})).catch(() => {
|
569
|
+
}) : Promise.resolve();
|
570
|
+
await progress.race(this._page.delegate.setInputFilePaths(retargeted, localPathsOrDirectory));
|
571
|
+
await progress.race(waitForInputEvent);
|
572
|
+
} else {
|
573
|
+
await progress.race(retargeted.evaluateInUtility(([injected, node, files]) => injected.setInputFiles(node, files), filePayloads));
|
574
|
+
}
|
575
|
+
return "done";
|
576
|
+
}
|
577
|
+
async focus(progress) {
|
578
|
+
await this._markAsTargetElement(progress);
|
579
|
+
const result = await this._focus(progress);
|
580
|
+
return assertDone(throwRetargetableDOMError(result));
|
581
|
+
}
|
582
|
+
async _focus(progress, resetSelectionIfNotFocused) {
|
583
|
+
return await progress.race(this.evaluateInUtility(([injected, node, resetSelectionIfNotFocused2]) => injected.focusNode(node, resetSelectionIfNotFocused2), resetSelectionIfNotFocused));
|
584
|
+
}
|
585
|
+
async _blur(progress) {
|
586
|
+
return await progress.race(this.evaluateInUtility(([injected, node]) => injected.blurNode(node), {}));
|
587
|
+
}
|
588
|
+
async type(progress, text, options) {
|
589
|
+
await this._markAsTargetElement(progress);
|
590
|
+
const result = await this._type(progress, text, options);
|
591
|
+
return assertDone(throwRetargetableDOMError(result));
|
592
|
+
}
|
593
|
+
async _type(progress, text, options) {
|
594
|
+
progress.log(`elementHandle.type("${text}")`);
|
595
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
596
|
+
const result = await this._focus(
|
597
|
+
progress,
|
598
|
+
true
|
599
|
+
/* resetSelectionIfNotFocused */
|
600
|
+
);
|
601
|
+
if (result !== "done")
|
602
|
+
return result;
|
603
|
+
await this._page.keyboard.type(progress, text, options);
|
604
|
+
return "done";
|
605
|
+
}
|
606
|
+
async press(progress, key, options) {
|
607
|
+
await this._markAsTargetElement(progress);
|
608
|
+
const result = await this._press(progress, key, options);
|
609
|
+
return assertDone(throwRetargetableDOMError(result));
|
610
|
+
}
|
611
|
+
async _press(progress, key, options) {
|
612
|
+
progress.log(`elementHandle.press("${key}")`);
|
613
|
+
await progress.race(this.instrumentation.onBeforeInputAction(this, progress.metadata));
|
614
|
+
return this._page.frameManager.waitForSignalsCreatedBy(progress, !options.noWaitAfter, async () => {
|
615
|
+
const result = await this._focus(
|
616
|
+
progress,
|
617
|
+
true
|
618
|
+
/* resetSelectionIfNotFocused */
|
619
|
+
);
|
620
|
+
if (result !== "done")
|
621
|
+
return result;
|
622
|
+
await this._page.keyboard.press(progress, key, options);
|
623
|
+
return "done";
|
624
|
+
});
|
625
|
+
}
|
626
|
+
async check(progress, options) {
|
627
|
+
const result = await this._setChecked(progress, true, options);
|
628
|
+
return assertDone(throwRetargetableDOMError(result));
|
629
|
+
}
|
630
|
+
async uncheck(progress, options) {
|
631
|
+
const result = await this._setChecked(progress, false, options);
|
632
|
+
return assertDone(throwRetargetableDOMError(result));
|
633
|
+
}
|
634
|
+
async _setChecked(progress, state, options) {
|
635
|
+
const isChecked = async () => {
|
636
|
+
const result2 = await progress.race(this.evaluateInUtility(([injected, node]) => injected.elementState(node, "checked"), {}));
|
637
|
+
if (result2 === "error:notconnected" || result2.received === "error:notconnected")
|
638
|
+
throwElementIsNotAttached();
|
639
|
+
return { matches: result2.matches, isRadio: result2.isRadio };
|
640
|
+
};
|
641
|
+
await this._markAsTargetElement(progress);
|
642
|
+
const checkedState = await isChecked();
|
643
|
+
if (checkedState.matches === state)
|
644
|
+
return "done";
|
645
|
+
if (!state && checkedState.isRadio)
|
646
|
+
throw new NonRecoverableDOMError("Cannot uncheck radio button. Radio buttons can only be unchecked by selecting another radio button in the same group.");
|
647
|
+
const result = await this._click(progress, { ...options, waitAfter: "disabled" });
|
648
|
+
if (result !== "done")
|
649
|
+
return result;
|
650
|
+
if (options.trial)
|
651
|
+
return "done";
|
652
|
+
const finalState = await isChecked();
|
653
|
+
if (finalState.matches !== state)
|
654
|
+
throw new NonRecoverableDOMError("Clicking the checkbox did not change its state");
|
655
|
+
return "done";
|
656
|
+
}
|
657
|
+
async boundingBox() {
|
658
|
+
return this._page.delegate.getBoundingBox(this);
|
659
|
+
}
|
660
|
+
async ariaSnapshot() {
|
661
|
+
return await this.evaluateInUtility(([injected, element]) => injected.ariaSnapshot(element, { mode: "expect" }), {});
|
662
|
+
}
|
663
|
+
async screenshot(progress, options) {
|
664
|
+
return await this._page.screenshotter.screenshotElement(progress, this, options);
|
665
|
+
}
|
666
|
+
async querySelector(selector, options) {
|
667
|
+
return this._frame.selectors.query(selector, options, this);
|
668
|
+
}
|
669
|
+
async querySelectorAll(selector) {
|
670
|
+
return this._frame.selectors.queryAll(selector, this);
|
671
|
+
}
|
672
|
+
async evalOnSelector(selector, strict, expression, isFunction, arg) {
|
673
|
+
return this._frame.evalOnSelector(selector, strict, expression, isFunction, arg, this);
|
674
|
+
}
|
675
|
+
async evalOnSelectorAll(selector, expression, isFunction, arg) {
|
676
|
+
return this._frame.evalOnSelectorAll(selector, expression, isFunction, arg, this);
|
677
|
+
}
|
678
|
+
async isVisible(progress) {
|
679
|
+
return this._frame.isVisible(progress, ":scope", {}, this);
|
680
|
+
}
|
681
|
+
async isHidden(progress) {
|
682
|
+
return this._frame.isHidden(progress, ":scope", {}, this);
|
683
|
+
}
|
684
|
+
async isEnabled(progress) {
|
685
|
+
return this._frame.isEnabled(progress, ":scope", {}, this);
|
686
|
+
}
|
687
|
+
async isDisabled(progress) {
|
688
|
+
return this._frame.isDisabled(progress, ":scope", {}, this);
|
689
|
+
}
|
690
|
+
async isEditable(progress) {
|
691
|
+
return this._frame.isEditable(progress, ":scope", {}, this);
|
692
|
+
}
|
693
|
+
async isChecked(progress) {
|
694
|
+
return this._frame.isChecked(progress, ":scope", {}, this);
|
695
|
+
}
|
696
|
+
async waitForElementState(progress, state) {
|
697
|
+
const actionName = `wait for ${state}`;
|
698
|
+
const result = await this._retryAction(progress, actionName, async () => {
|
699
|
+
return await progress.race(this.evaluateInUtility(async ([injected, node, state2]) => {
|
700
|
+
return await injected.checkElementStates(node, [state2]) || "done";
|
701
|
+
}, state));
|
702
|
+
}, {});
|
703
|
+
assertDone(throwRetargetableDOMError(result));
|
704
|
+
}
|
705
|
+
async waitForSelector(progress, selector, options) {
|
706
|
+
return await this._frame.waitForSelector(progress, selector, true, options, this);
|
707
|
+
}
|
708
|
+
async _adoptTo(context) {
|
709
|
+
if (this._context !== context) {
|
710
|
+
const adopted = await this._page.delegate.adoptElementHandle(this, context);
|
711
|
+
this.dispose();
|
712
|
+
return adopted;
|
713
|
+
}
|
714
|
+
return this;
|
715
|
+
}
|
716
|
+
async _checkFrameIsHitTarget(point) {
|
717
|
+
let frame = this._frame;
|
718
|
+
const data = [];
|
719
|
+
while (frame.parentFrame()) {
|
720
|
+
const frameElement = await frame.frameElement();
|
721
|
+
const box = await frameElement.boundingBox();
|
722
|
+
const style = await frameElement.evaluateInUtility(([injected, iframe]) => injected.describeIFrameStyle(iframe), {}).catch((e) => "error:notconnected");
|
723
|
+
if (!box || style === "error:notconnected")
|
724
|
+
return "error:notconnected";
|
725
|
+
if (style === "transformed") {
|
726
|
+
return { framePoint: void 0 };
|
727
|
+
}
|
728
|
+
const pointInFrame = { x: point.x - box.x - style.left, y: point.y - box.y - style.top };
|
729
|
+
data.push({ frame, frameElement, pointInFrame });
|
730
|
+
frame = frame.parentFrame();
|
731
|
+
}
|
732
|
+
data.push({ frame, frameElement: null, pointInFrame: point });
|
733
|
+
for (let i = data.length - 1; i > 0; i--) {
|
734
|
+
const element = data[i - 1].frameElement;
|
735
|
+
const point2 = data[i].pointInFrame;
|
736
|
+
const hitTargetResult = await element.evaluateInUtility(([injected, element2, hitPoint]) => {
|
737
|
+
return injected.expectHitTarget(hitPoint, element2);
|
738
|
+
}, point2);
|
739
|
+
if (hitTargetResult !== "done")
|
740
|
+
return hitTargetResult;
|
741
|
+
}
|
742
|
+
return { framePoint: data[0].pointInFrame };
|
743
|
+
}
|
744
|
+
}
|
745
|
+
function throwRetargetableDOMError(result) {
|
746
|
+
if (result === "error:notconnected")
|
747
|
+
throwElementIsNotAttached();
|
748
|
+
return result;
|
749
|
+
}
|
750
|
+
function throwElementIsNotAttached() {
|
751
|
+
throw new Error("Element is not attached to the DOM");
|
752
|
+
}
|
753
|
+
function assertDone(result) {
|
754
|
+
}
|
755
|
+
function roundPoint(point) {
|
756
|
+
return {
|
757
|
+
x: (point.x * 100 | 0) / 100,
|
758
|
+
y: (point.y * 100 | 0) / 100
|
759
|
+
};
|
760
|
+
}
|
761
|
+
function quadMiddlePoint(quad) {
|
762
|
+
const result = { x: 0, y: 0 };
|
763
|
+
for (const point of quad) {
|
764
|
+
result.x += point.x / 4;
|
765
|
+
result.y += point.y / 4;
|
766
|
+
}
|
767
|
+
return result;
|
768
|
+
}
|
769
|
+
function triangleArea(p1, p2, p3) {
|
770
|
+
return Math.abs(p1.x * (p2.y - p3.y) + p2.x * (p3.y - p1.y) + p3.x * (p1.y - p2.y)) / 2;
|
771
|
+
}
|
772
|
+
function isPointInsideQuad(point, quad) {
|
773
|
+
const area1 = triangleArea(point, quad[0], quad[1]) + triangleArea(point, quad[1], quad[2]) + triangleArea(point, quad[2], quad[3]) + triangleArea(point, quad[3], quad[0]);
|
774
|
+
const area2 = triangleArea(quad[0], quad[1], quad[2]) + triangleArea(quad[1], quad[2], quad[3]);
|
775
|
+
if (Math.abs(area1 - area2) > 0.1)
|
776
|
+
return false;
|
777
|
+
return point.x < Math.max(quad[0].x, quad[1].x, quad[2].x, quad[3].x) && point.y < Math.max(quad[0].y, quad[1].y, quad[2].y, quad[3].y);
|
778
|
+
}
|
779
|
+
function findIntegerPointInsideQuad(quad) {
|
780
|
+
const point = quadMiddlePoint(quad);
|
781
|
+
point.x = Math.floor(point.x);
|
782
|
+
point.y = Math.floor(point.y);
|
783
|
+
if (isPointInsideQuad(point, quad))
|
784
|
+
return point;
|
785
|
+
point.x += 1;
|
786
|
+
if (isPointInsideQuad(point, quad))
|
787
|
+
return point;
|
788
|
+
point.y += 1;
|
789
|
+
if (isPointInsideQuad(point, quad))
|
790
|
+
return point;
|
791
|
+
point.x -= 1;
|
792
|
+
if (isPointInsideQuad(point, quad))
|
793
|
+
return point;
|
794
|
+
}
|
795
|
+
const kUnableToAdoptErrorMessage = "Unable to adopt element handle from a different document";
|
796
|
+
// Annotate the CommonJS export names for ESM import in node:
|
797
|
+
0 && (module.exports = {
|
798
|
+
ElementHandle,
|
799
|
+
FrameExecutionContext,
|
800
|
+
NonRecoverableDOMError,
|
801
|
+
assertDone,
|
802
|
+
isNonRecoverableDOMError,
|
803
|
+
kUnableToAdoptErrorMessage,
|
804
|
+
throwElementIsNotAttached,
|
805
|
+
throwRetargetableDOMError
|
806
|
+
});
|