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