rebrowser-playwright-core 1.52.0 → 1.64.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +7 -1554
- package/bin/install_webkit_wsl.ps1 +33 -0
- package/bin/reinstall_chrome_beta_linux.sh +1 -1
- package/bin/reinstall_chrome_beta_mac.sh +1 -1
- package/bin/reinstall_chrome_stable_linux.sh +1 -1
- package/bin/reinstall_chrome_stable_mac.sh +1 -1
- package/bin/reinstall_msedge_beta_linux.sh +1 -1
- package/bin/reinstall_msedge_beta_mac.sh +1 -1
- package/bin/reinstall_msedge_dev_linux.sh +1 -1
- package/bin/reinstall_msedge_dev_mac.sh +1 -1
- package/bin/reinstall_msedge_stable_linux.sh +1 -1
- package/bin/reinstall_msedge_stable_mac.sh +1 -1
- package/browsers.json +16 -44
- package/cli.js +5 -1
- package/index.js +2 -17
- package/lib/bootstrap.js +149 -0
- package/lib/coreBundle.js +78218 -0
- package/lib/entry/cliDaemon.js +5 -0
- package/lib/entry/dashboardApp.js +3 -0
- package/lib/entry/mcp.js +10 -0
- package/lib/entry/oopBrowserDownload.js +3 -0
- package/lib/{server/deviceDescriptors.js → package.js} +18 -7
- package/lib/server/electron/loader.js +108 -14
- package/lib/serverRegistry.js +1939 -0
- package/lib/serverRegistry.js.LICENSE +65 -0
- package/lib/tools/cli-client/channelSessions.js +141 -0
- package/lib/tools/cli-client/cli.js +7 -0
- package/lib/tools/cli-client/help.json +808 -0
- package/lib/tools/cli-client/minimist.js +128 -0
- package/lib/tools/cli-client/output.js +352 -0
- package/lib/tools/cli-client/program.js +422 -0
- package/lib/tools/cli-client/registry.js +180 -0
- package/lib/tools/cli-client/session.js +261 -0
- package/lib/tools/dashboard/appIcon.png +0 -0
- package/lib/tools/skills/playwright-cli/SKILL.md +493 -0
- package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- package/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
- package/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
- package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- package/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
- package/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
- package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- package/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
- package/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
- package/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
- package/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
- package/lib/tools/skills/playwright-trace/SKILL.md +174 -0
- package/lib/tools/utils/extension.js +112 -0
- package/lib/tools/utils/socketConnection.js +108 -0
- package/lib/utilsBundle.js +86038 -66
- package/lib/utilsBundle.js.LICENSE +1890 -0
- package/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
- package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- package/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
- package/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
- package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- package/lib/vite/dashboard/index.html +29 -0
- package/lib/vite/dashboard/playwright-logo.svg +24 -0
- package/lib/vite/htmlReport/index.html +2 -61
- package/lib/vite/htmlReport/report.css +2 -0
- package/lib/vite/htmlReport/report.js +32 -0
- package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
- package/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
- package/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
- package/lib/vite/recorder/index.html +3 -3
- package/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
- package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- package/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
- package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- package/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
- package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- package/lib/vite/traceViewer/index.html +9 -8
- package/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
- package/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- package/lib/vite/traceViewer/snapshot.html +4 -15
- package/lib/vite/traceViewer/sw.bundle.js +4 -3
- package/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
- package/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
- package/lib/vite/traceViewer/uiMode.html +6 -5
- package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- package/lib/webp_codec.LICENSE +173 -0
- package/lib/webp_codec.wasm +0 -0
- package/lib/{utilsBundleImpl/xdg-open → xdg-open} +338 -137
- package/package.json +6 -16
- package/types/protocol.d.ts +10495 -8030
- package/types/structs.d.ts +8 -1
- package/types/types.d.ts +9256 -4825
- package/lib/androidServerImpl.js +0 -63
- package/lib/browserServerImpl.js +0 -88
- package/lib/cli/driver.js +0 -97
- package/lib/cli/program.js +0 -567
- package/lib/cli/programWithTestStub.js +0 -74
- package/lib/client/accessibility.js +0 -49
- package/lib/client/android.js +0 -365
- package/lib/client/api.js +0 -137
- package/lib/client/artifact.js +0 -79
- package/lib/client/browser.js +0 -136
- package/lib/client/browserContext.js +0 -539
- package/lib/client/browserType.js +0 -193
- package/lib/client/cdpSession.js +0 -51
- package/lib/client/channelOwner.js +0 -205
- package/lib/client/clientHelper.js +0 -64
- package/lib/client/clientInstrumentation.js +0 -55
- package/lib/client/clientStackTrace.js +0 -69
- package/lib/client/clock.js +0 -68
- package/lib/client/connection.js +0 -318
- package/lib/client/consoleMessage.js +0 -55
- package/lib/client/coverage.js +0 -44
- package/lib/client/dialog.js +0 -56
- package/lib/client/download.js +0 -62
- package/lib/client/electron.js +0 -133
- package/lib/client/elementHandle.js +0 -284
- package/lib/client/errors.js +0 -77
- package/lib/client/eventEmitter.js +0 -314
- package/lib/client/events.js +0 -98
- package/lib/client/fetch.js +0 -367
- package/lib/client/fileChooser.js +0 -46
- package/lib/client/fileUtils.js +0 -34
- package/lib/client/frame.js +0 -386
- package/lib/client/harRouter.js +0 -87
- package/lib/client/input.js +0 -82
- package/lib/client/jsHandle.js +0 -105
- package/lib/client/jsonPipe.js +0 -39
- package/lib/client/localUtils.js +0 -61
- package/lib/client/locator.js +0 -362
- package/lib/client/network.js +0 -751
- package/lib/client/page.js +0 -709
- package/lib/client/platform.js +0 -74
- package/lib/client/playwright.js +0 -85
- package/lib/client/selectors.js +0 -75
- package/lib/client/stream.js +0 -39
- package/lib/client/timeoutSettings.js +0 -75
- package/lib/client/tracing.js +0 -114
- package/lib/client/types.js +0 -28
- package/lib/client/video.js +0 -59
- package/lib/client/waiter.js +0 -142
- package/lib/client/webError.js +0 -39
- package/lib/client/webSocket.js +0 -111
- package/lib/client/worker.js +0 -63
- package/lib/client/writableStream.js +0 -39
- package/lib/generated/clockSource.js +0 -28
- package/lib/generated/consoleApiSource.js +0 -28
- package/lib/generated/injectedScriptSource.js +0 -28
- package/lib/generated/pollingRecorderSource.js +0 -28
- package/lib/generated/utilityScriptSource.js +0 -28
- package/lib/generated/webSocketMockSource.js +0 -378
- package/lib/inProcessFactory.js +0 -59
- package/lib/inprocess.js +0 -3
- package/lib/outofprocess.js +0 -78
- package/lib/protocol/debug.js +0 -211
- package/lib/protocol/serializers.js +0 -192
- package/lib/protocol/validator.js +0 -2825
- package/lib/protocol/validatorPrimitives.js +0 -179
- package/lib/remote/playwrightConnection.js +0 -266
- package/lib/remote/playwrightServer.js +0 -139
- package/lib/server/accessibility.js +0 -69
- package/lib/server/android/android.js +0 -451
- package/lib/server/android/backendAdb.js +0 -179
- package/lib/server/artifact.js +0 -127
- package/lib/server/bidi/bidiBrowser.js +0 -380
- package/lib/server/bidi/bidiChromium.js +0 -152
- package/lib/server/bidi/bidiConnection.js +0 -187
- package/lib/server/bidi/bidiExecutionContext.js +0 -220
- package/lib/server/bidi/bidiFirefox.js +0 -112
- package/lib/server/bidi/bidiInput.js +0 -146
- package/lib/server/bidi/bidiNetworkManager.js +0 -320
- package/lib/server/bidi/bidiOverCdp.js +0 -102
- package/lib/server/bidi/bidiPage.js +0 -530
- package/lib/server/bidi/bidiPdf.js +0 -106
- package/lib/server/bidi/third_party/bidiCommands.d.js +0 -22
- package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
- package/lib/server/bidi/third_party/bidiKeyboard.js +0 -256
- package/lib/server/bidi/third_party/bidiProtocol.js +0 -152
- package/lib/server/bidi/third_party/bidiSerializer.js +0 -148
- package/lib/server/bidi/third_party/firefoxPrefs.js +0 -259
- package/lib/server/browser.js +0 -140
- package/lib/server/browserContext.js +0 -650
- package/lib/server/browserType.js +0 -326
- package/lib/server/callLog.js +0 -82
- package/lib/server/chromium/chromium.js +0 -376
- package/lib/server/chromium/chromiumSwitches.js +0 -101
- package/lib/server/chromium/crAccessibility.js +0 -263
- package/lib/server/chromium/crBrowser.js +0 -498
- package/lib/server/chromium/crConnection.js +0 -324
- package/lib/server/chromium/crCoverage.js +0 -232
- package/lib/server/chromium/crDevTools.js +0 -117
- package/lib/server/chromium/crDragDrop.js +0 -126
- package/lib/server/chromium/crExecutionContext.js +0 -145
- package/lib/server/chromium/crInput.js +0 -184
- package/lib/server/chromium/crNetworkManager.js +0 -666
- package/lib/server/chromium/crPage.js +0 -1055
- package/lib/server/chromium/crPdf.js +0 -121
- package/lib/server/chromium/crProtocolHelper.js +0 -145
- package/lib/server/chromium/crServiceWorker.js +0 -130
- package/lib/server/chromium/defaultFontFamilies.js +0 -162
- package/lib/server/chromium/protocol.d.js +0 -16
- package/lib/server/chromium/videoRecorder.js +0 -121
- package/lib/server/clock.js +0 -137
- package/lib/server/codegen/csharp.js +0 -329
- package/lib/server/codegen/java.js +0 -270
- package/lib/server/codegen/javascript.js +0 -268
- package/lib/server/codegen/jsonl.js +0 -51
- package/lib/server/codegen/language.js +0 -111
- package/lib/server/codegen/languages.js +0 -68
- package/lib/server/codegen/python.js +0 -277
- package/lib/server/codegen/types.js +0 -16
- package/lib/server/console.js +0 -53
- package/lib/server/cookieStore.js +0 -204
- package/lib/server/debugController.js +0 -185
- package/lib/server/debugger.js +0 -136
- package/lib/server/deviceDescriptorsSource.json +0 -1669
- package/lib/server/dialog.js +0 -72
- package/lib/server/dispatchers/androidDispatcher.js +0 -293
- package/lib/server/dispatchers/artifactDispatcher.js +0 -118
- package/lib/server/dispatchers/browserContextDispatcher.js +0 -328
- package/lib/server/dispatchers/browserDispatcher.js +0 -151
- package/lib/server/dispatchers/browserTypeDispatcher.js +0 -55
- package/lib/server/dispatchers/cdpSessionDispatcher.js +0 -44
- package/lib/server/dispatchers/debugControllerDispatcher.js +0 -87
- package/lib/server/dispatchers/dialogDispatcher.js +0 -47
- package/lib/server/dispatchers/dispatcher.js +0 -346
- package/lib/server/dispatchers/electronDispatcher.js +0 -90
- package/lib/server/dispatchers/elementHandlerDispatcher.js +0 -191
- package/lib/server/dispatchers/frameDispatcher.js +0 -224
- package/lib/server/dispatchers/jsHandleDispatcher.js +0 -80
- package/lib/server/dispatchers/jsonPipeDispatcher.js +0 -58
- package/lib/server/dispatchers/localUtilsDispatcher.js +0 -155
- package/lib/server/dispatchers/networkDispatchers.js +0 -204
- package/lib/server/dispatchers/pageDispatcher.js +0 -328
- package/lib/server/dispatchers/playwrightDispatcher.js +0 -100
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -40
- package/lib/server/dispatchers/streamDispatcher.js +0 -60
- package/lib/server/dispatchers/tracingDispatcher.js +0 -59
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +0 -154
- package/lib/server/dispatchers/writableStreamDispatcher.js +0 -73
- package/lib/server/dom.js +0 -869
- package/lib/server/download.js +0 -70
- package/lib/server/electron/electron.js +0 -277
- package/lib/server/errors.js +0 -69
- package/lib/server/fetch.js +0 -640
- package/lib/server/fileChooser.js +0 -43
- package/lib/server/fileUploadUtils.js +0 -84
- package/lib/server/firefox/ffAccessibility.js +0 -238
- package/lib/server/firefox/ffBrowser.js +0 -404
- package/lib/server/firefox/ffConnection.js +0 -147
- package/lib/server/firefox/ffExecutionContext.js +0 -149
- package/lib/server/firefox/ffInput.js +0 -159
- package/lib/server/firefox/ffNetworkManager.js +0 -254
- package/lib/server/firefox/ffPage.js +0 -501
- package/lib/server/firefox/firefox.js +0 -106
- package/lib/server/firefox/protocol.d.js +0 -16
- package/lib/server/formData.js +0 -147
- package/lib/server/frameSelectors.js +0 -137
- package/lib/server/frames.js +0 -1555
- package/lib/server/har/harRecorder.js +0 -147
- package/lib/server/har/harTracer.js +0 -606
- package/lib/server/harBackend.js +0 -157
- package/lib/server/helper.js +0 -100
- package/lib/server/index.js +0 -61
- package/lib/server/input.js +0 -280
- package/lib/server/instrumentation.js +0 -75
- package/lib/server/javascript.js +0 -299
- package/lib/server/launchApp.js +0 -110
- package/lib/server/localUtils.js +0 -211
- package/lib/server/macEditingCommands.js +0 -143
- package/lib/server/network.js +0 -583
- package/lib/server/page.js +0 -790
- package/lib/server/pageBinding.js +0 -88
- package/lib/server/pipeTransport.js +0 -89
- package/lib/server/playwright.js +0 -81
- package/lib/server/progress.js +0 -104
- package/lib/server/protocolError.js +0 -52
- package/lib/server/recorder/chat.js +0 -161
- package/lib/server/recorder/contextRecorder.js +0 -286
- package/lib/server/recorder/recorderApp.js +0 -184
- package/lib/server/recorder/recorderCollection.js +0 -116
- package/lib/server/recorder/recorderFrontend.js +0 -16
- package/lib/server/recorder/recorderRunner.js +0 -135
- package/lib/server/recorder/recorderUtils.js +0 -100
- package/lib/server/recorder/throttledFile.js +0 -57
- package/lib/server/recorder.js +0 -360
- package/lib/server/registry/browserFetcher.js +0 -175
- package/lib/server/registry/dependencies.js +0 -371
- package/lib/server/registry/index.js +0 -1271
- package/lib/server/registry/nativeDeps.js +0 -1105
- package/lib/server/registry/oopDownloadBrowserMain.js +0 -120
- package/lib/server/screenshotter.js +0 -332
- package/lib/server/selectors.js +0 -112
- package/lib/server/socksClientCertificatesInterceptor.js +0 -321
- package/lib/server/socksInterceptor.js +0 -95
- package/lib/server/storageScript.js +0 -154
- package/lib/server/timeoutSettings.js +0 -89
- package/lib/server/trace/recorder/snapshotter.js +0 -143
- package/lib/server/trace/recorder/snapshotterInjected.js +0 -539
- package/lib/server/trace/recorder/tracing.js +0 -593
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
- package/lib/server/trace/viewer/traceViewer.js +0 -249
- package/lib/server/transport.js +0 -183
- package/lib/server/types.js +0 -28
- package/lib/server/usKeyboardLayout.js +0 -145
- package/lib/server/utils/ascii.js +0 -44
- package/lib/server/utils/comparators.js +0 -161
- package/lib/server/utils/crypto.js +0 -216
- package/lib/server/utils/debug.js +0 -47
- package/lib/server/utils/debugLogger.js +0 -114
- package/lib/server/utils/env.js +0 -68
- package/lib/server/utils/eventsHelper.js +0 -39
- package/lib/server/utils/expectUtils.js +0 -38
- package/lib/server/utils/fileUtils.js +0 -191
- package/lib/server/utils/happyEyeballs.js +0 -207
- package/lib/server/utils/hostPlatform.js +0 -109
- package/lib/server/utils/httpServer.js +0 -218
- package/lib/server/utils/image_tools/colorUtils.js +0 -89
- package/lib/server/utils/image_tools/compare.js +0 -109
- package/lib/server/utils/image_tools/imageChannel.js +0 -78
- package/lib/server/utils/image_tools/stats.js +0 -102
- package/lib/server/utils/linuxUtils.js +0 -71
- package/lib/server/utils/network.js +0 -217
- package/lib/server/utils/nodePlatform.js +0 -148
- package/lib/server/utils/pipeTransport.js +0 -84
- package/lib/server/utils/processLauncher.js +0 -238
- package/lib/server/utils/profiler.js +0 -65
- package/lib/server/utils/socksProxy.js +0 -511
- package/lib/server/utils/spawnAsync.js +0 -41
- package/lib/server/utils/task.js +0 -51
- package/lib/server/utils/userAgent.js +0 -98
- package/lib/server/utils/wsServer.js +0 -132
- package/lib/server/utils/zipFile.js +0 -74
- package/lib/server/utils/zones.js +0 -57
- package/lib/server/webkit/protocol.d.js +0 -16
- package/lib/server/webkit/webkit.js +0 -100
- package/lib/server/webkit/wkAccessibility.js +0 -237
- package/lib/server/webkit/wkBrowser.js +0 -312
- package/lib/server/webkit/wkConnection.js +0 -149
- package/lib/server/webkit/wkExecutionContext.js +0 -153
- package/lib/server/webkit/wkInput.js +0 -181
- package/lib/server/webkit/wkInterceptableRequest.js +0 -169
- package/lib/server/webkit/wkPage.js +0 -1114
- package/lib/server/webkit/wkProvisionalPage.js +0 -83
- package/lib/server/webkit/wkWorkers.js +0 -104
- package/lib/third_party/pixelmatch.js +0 -255
- package/lib/utils/isomorphic/ariaSnapshot.js +0 -384
- package/lib/utils/isomorphic/assert.js +0 -31
- package/lib/utils/isomorphic/builtins.js +0 -90
- package/lib/utils/isomorphic/colors.js +0 -72
- package/lib/utils/isomorphic/cssParser.js +0 -246
- package/lib/utils/isomorphic/cssTokenizer.js +0 -1051
- package/lib/utils/isomorphic/headers.js +0 -53
- package/lib/utils/isomorphic/locatorGenerators.js +0 -655
- package/lib/utils/isomorphic/locatorParser.js +0 -176
- package/lib/utils/isomorphic/locatorUtils.js +0 -81
- package/lib/utils/isomorphic/manualPromise.js +0 -115
- package/lib/utils/isomorphic/mimeType.js +0 -460
- package/lib/utils/isomorphic/multimap.js +0 -81
- package/lib/utils/isomorphic/rtti.js +0 -43
- package/lib/utils/isomorphic/selectorParser.js +0 -387
- package/lib/utils/isomorphic/semaphore.js +0 -54
- package/lib/utils/isomorphic/stackTrace.js +0 -158
- package/lib/utils/isomorphic/stringUtils.js +0 -176
- package/lib/utils/isomorphic/time.js +0 -44
- package/lib/utils/isomorphic/timeoutRunner.js +0 -67
- package/lib/utils/isomorphic/traceUtils.js +0 -59
- package/lib/utils/isomorphic/types.js +0 -16
- package/lib/utils/isomorphic/urlMatch.js +0 -167
- package/lib/utils/isomorphic/utilityScriptSerializers.js +0 -248
- package/lib/utils.js +0 -101
- package/lib/utilsBundleImpl/index.js +0 -208
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codeMirrorModule-DVQi6prl.js +0 -24
- package/lib/vite/recorder/assets/index-97EUAAbk.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/traceViewer/assets/codeMirrorModule-DwAiTpyC.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-DkkRvn5X.js +0 -265
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/defaultSettingsView.QdHITyLI.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.DvtSwn6E.js +0 -2
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.Sdytl9wc.js +0 -5
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
- package/lib/zipBundle.js +0 -34
- package/lib/zipBundleImpl.js +0 -5
package/lib/server/clock.js
DELETED
|
@@ -1,137 +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 clock_exports = {};
|
|
30
|
-
__export(clock_exports, {
|
|
31
|
-
Clock: () => Clock
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(clock_exports);
|
|
34
|
-
var clockSource = __toESM(require("../generated/clockSource"));
|
|
35
|
-
class Clock {
|
|
36
|
-
constructor(browserContext) {
|
|
37
|
-
this._scriptInstalled = false;
|
|
38
|
-
this._browserContext = browserContext;
|
|
39
|
-
}
|
|
40
|
-
markAsUninstalled() {
|
|
41
|
-
this._scriptInstalled = false;
|
|
42
|
-
}
|
|
43
|
-
async fastForward(ticks) {
|
|
44
|
-
await this._installIfNeeded();
|
|
45
|
-
const ticksMillis = parseTicks(ticks);
|
|
46
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('fastForward', ${Date.now()}, ${ticksMillis})`);
|
|
47
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.fastForward(${ticksMillis})`);
|
|
48
|
-
}
|
|
49
|
-
async install(time) {
|
|
50
|
-
await this._installIfNeeded();
|
|
51
|
-
const timeMillis = time !== void 0 ? parseTime(time) : Date.now();
|
|
52
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('install', ${Date.now()}, ${timeMillis})`);
|
|
53
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.install(${timeMillis})`);
|
|
54
|
-
}
|
|
55
|
-
async pauseAt(ticks) {
|
|
56
|
-
await this._installIfNeeded();
|
|
57
|
-
const timeMillis = parseTime(ticks);
|
|
58
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('pauseAt', ${Date.now()}, ${timeMillis})`);
|
|
59
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.pauseAt(${timeMillis})`);
|
|
60
|
-
}
|
|
61
|
-
async resume() {
|
|
62
|
-
await this._installIfNeeded();
|
|
63
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('resume', ${Date.now()})`);
|
|
64
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.resume()`);
|
|
65
|
-
}
|
|
66
|
-
async setFixedTime(time) {
|
|
67
|
-
await this._installIfNeeded();
|
|
68
|
-
const timeMillis = parseTime(time);
|
|
69
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('setFixedTime', ${Date.now()}, ${timeMillis})`);
|
|
70
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.setFixedTime(${timeMillis})`);
|
|
71
|
-
}
|
|
72
|
-
async setSystemTime(time) {
|
|
73
|
-
await this._installIfNeeded();
|
|
74
|
-
const timeMillis = parseTime(time);
|
|
75
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('setSystemTime', ${Date.now()}, ${timeMillis})`);
|
|
76
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.setSystemTime(${timeMillis})`);
|
|
77
|
-
}
|
|
78
|
-
async runFor(ticks) {
|
|
79
|
-
await this._installIfNeeded();
|
|
80
|
-
const ticksMillis = parseTicks(ticks);
|
|
81
|
-
await this._browserContext.addInitScript(`globalThis.__pwClock.controller.log('runFor', ${Date.now()}, ${ticksMillis})`);
|
|
82
|
-
await this._evaluateInFrames(`globalThis.__pwClock.controller.runFor(${ticksMillis})`);
|
|
83
|
-
}
|
|
84
|
-
async _installIfNeeded() {
|
|
85
|
-
if (this._scriptInstalled)
|
|
86
|
-
return;
|
|
87
|
-
this._scriptInstalled = true;
|
|
88
|
-
const script = `(() => {
|
|
89
|
-
const module = {};
|
|
90
|
-
${clockSource.source}
|
|
91
|
-
globalThis.__pwClock = (module.exports.inject())(globalThis);
|
|
92
|
-
})();`;
|
|
93
|
-
await this._browserContext.addInitScript(script);
|
|
94
|
-
await this._evaluateInFrames(script);
|
|
95
|
-
}
|
|
96
|
-
async _evaluateInFrames(script) {
|
|
97
|
-
await this._browserContext.safeNonStallingEvaluateInAllFrames(script, "main", { throwOnJSErrors: true });
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
function parseTicks(value) {
|
|
101
|
-
if (typeof value === "number")
|
|
102
|
-
return value;
|
|
103
|
-
if (!value)
|
|
104
|
-
return 0;
|
|
105
|
-
const str = value;
|
|
106
|
-
const strings = str.split(":");
|
|
107
|
-
const l = strings.length;
|
|
108
|
-
let i = l;
|
|
109
|
-
let ms = 0;
|
|
110
|
-
let parsed;
|
|
111
|
-
if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
`Clock only understands numbers, 'mm:ss' and 'hh:mm:ss'`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
while (i--) {
|
|
117
|
-
parsed = parseInt(strings[i], 10);
|
|
118
|
-
if (parsed >= 60)
|
|
119
|
-
throw new Error(`Invalid time ${str}`);
|
|
120
|
-
ms += parsed * Math.pow(60, l - i - 1);
|
|
121
|
-
}
|
|
122
|
-
return ms * 1e3;
|
|
123
|
-
}
|
|
124
|
-
function parseTime(epoch) {
|
|
125
|
-
if (!epoch)
|
|
126
|
-
return 0;
|
|
127
|
-
if (typeof epoch === "number")
|
|
128
|
-
return epoch;
|
|
129
|
-
const parsed = new Date(epoch);
|
|
130
|
-
if (!isFinite(parsed.getTime()))
|
|
131
|
-
throw new Error(`Invalid date: ${epoch}`);
|
|
132
|
-
return parsed.getTime();
|
|
133
|
-
}
|
|
134
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
-
0 && (module.exports = {
|
|
136
|
-
Clock
|
|
137
|
-
});
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var csharp_exports = {};
|
|
20
|
-
__export(csharp_exports, {
|
|
21
|
-
CSharpLanguageGenerator: () => CSharpLanguageGenerator
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(csharp_exports);
|
|
24
|
-
var import_language = require("./language");
|
|
25
|
-
var import_utils = require("../../utils");
|
|
26
|
-
var import_deviceDescriptors = require("../deviceDescriptors");
|
|
27
|
-
class CSharpLanguageGenerator {
|
|
28
|
-
constructor(mode) {
|
|
29
|
-
this.groupName = ".NET C#";
|
|
30
|
-
this.highlighter = "csharp";
|
|
31
|
-
if (mode === "library") {
|
|
32
|
-
this.name = "Library";
|
|
33
|
-
this.id = "csharp";
|
|
34
|
-
} else if (mode === "mstest") {
|
|
35
|
-
this.name = "MSTest";
|
|
36
|
-
this.id = "csharp-mstest";
|
|
37
|
-
} else if (mode === "nunit") {
|
|
38
|
-
this.name = "NUnit";
|
|
39
|
-
this.id = "csharp-nunit";
|
|
40
|
-
} else {
|
|
41
|
-
throw new Error(`Unknown C# language mode: ${mode}`);
|
|
42
|
-
}
|
|
43
|
-
this._mode = mode;
|
|
44
|
-
}
|
|
45
|
-
generateAction(actionInContext) {
|
|
46
|
-
const action = this._generateActionInner(actionInContext);
|
|
47
|
-
if (action)
|
|
48
|
-
return action;
|
|
49
|
-
return "";
|
|
50
|
-
}
|
|
51
|
-
_generateActionInner(actionInContext) {
|
|
52
|
-
const action = actionInContext.action;
|
|
53
|
-
if (this._mode !== "library" && (action.name === "openPage" || action.name === "closePage"))
|
|
54
|
-
return "";
|
|
55
|
-
let pageAlias = actionInContext.frame.pageAlias;
|
|
56
|
-
if (this._mode !== "library")
|
|
57
|
-
pageAlias = pageAlias.replace("page", "Page");
|
|
58
|
-
const formatter = new CSharpFormatter(this._mode === "library" ? 0 : 8);
|
|
59
|
-
if (action.name === "openPage") {
|
|
60
|
-
formatter.add(`var ${pageAlias} = await context.NewPageAsync();`);
|
|
61
|
-
if (action.url && action.url !== "about:blank" && action.url !== "chrome://newtab/")
|
|
62
|
-
formatter.add(`await ${pageAlias}.GotoAsync(${quote(action.url)});`);
|
|
63
|
-
return formatter.format();
|
|
64
|
-
}
|
|
65
|
-
const locators = actionInContext.frame.framePath.map((selector) => `.${this._asLocator(selector)}.ContentFrame`);
|
|
66
|
-
const subject = `${pageAlias}${locators.join("")}`;
|
|
67
|
-
const signals = (0, import_language.toSignalMap)(action);
|
|
68
|
-
if (signals.dialog) {
|
|
69
|
-
formatter.add(` void ${pageAlias}_Dialog${signals.dialog.dialogAlias}_EventHandler(object sender, IDialog dialog)
|
|
70
|
-
{
|
|
71
|
-
Console.WriteLine($"Dialog message: {dialog.Message}");
|
|
72
|
-
dialog.DismissAsync();
|
|
73
|
-
${pageAlias}.Dialog -= ${pageAlias}_Dialog${signals.dialog.dialogAlias}_EventHandler;
|
|
74
|
-
}
|
|
75
|
-
${pageAlias}.Dialog += ${pageAlias}_Dialog${signals.dialog.dialogAlias}_EventHandler;`);
|
|
76
|
-
}
|
|
77
|
-
const lines = [];
|
|
78
|
-
lines.push(this._generateActionCall(subject, actionInContext));
|
|
79
|
-
if (signals.download) {
|
|
80
|
-
lines.unshift(`var download${signals.download.downloadAlias} = await ${pageAlias}.RunAndWaitForDownloadAsync(async () =>
|
|
81
|
-
{`);
|
|
82
|
-
lines.push(`});`);
|
|
83
|
-
}
|
|
84
|
-
if (signals.popup) {
|
|
85
|
-
lines.unshift(`var ${signals.popup.popupAlias} = await ${pageAlias}.RunAndWaitForPopupAsync(async () =>
|
|
86
|
-
{`);
|
|
87
|
-
lines.push(`});`);
|
|
88
|
-
}
|
|
89
|
-
for (const line of lines)
|
|
90
|
-
formatter.add(line);
|
|
91
|
-
return formatter.format();
|
|
92
|
-
}
|
|
93
|
-
_generateActionCall(subject, actionInContext) {
|
|
94
|
-
const action = actionInContext.action;
|
|
95
|
-
switch (action.name) {
|
|
96
|
-
case "openPage":
|
|
97
|
-
throw Error("Not reached");
|
|
98
|
-
case "closePage":
|
|
99
|
-
return `await ${subject}.CloseAsync();`;
|
|
100
|
-
case "click": {
|
|
101
|
-
let method = "Click";
|
|
102
|
-
if (action.clickCount === 2)
|
|
103
|
-
method = "DblClick";
|
|
104
|
-
const options = (0, import_language.toClickOptionsForSourceCode)(action);
|
|
105
|
-
if (!Object.entries(options).length)
|
|
106
|
-
return `await ${subject}.${this._asLocator(action.selector)}.${method}Async();`;
|
|
107
|
-
const optionsString = formatObject(options, " ", "Locator" + method + "Options");
|
|
108
|
-
return `await ${subject}.${this._asLocator(action.selector)}.${method}Async(${optionsString});`;
|
|
109
|
-
}
|
|
110
|
-
case "check":
|
|
111
|
-
return `await ${subject}.${this._asLocator(action.selector)}.CheckAsync();`;
|
|
112
|
-
case "uncheck":
|
|
113
|
-
return `await ${subject}.${this._asLocator(action.selector)}.UncheckAsync();`;
|
|
114
|
-
case "fill":
|
|
115
|
-
return `await ${subject}.${this._asLocator(action.selector)}.FillAsync(${quote(action.text)});`;
|
|
116
|
-
case "setInputFiles":
|
|
117
|
-
return `await ${subject}.${this._asLocator(action.selector)}.SetInputFilesAsync(${formatObject(action.files)});`;
|
|
118
|
-
case "press": {
|
|
119
|
-
const modifiers = (0, import_language.toKeyboardModifiers)(action.modifiers);
|
|
120
|
-
const shortcut = [...modifiers, action.key].join("+");
|
|
121
|
-
return `await ${subject}.${this._asLocator(action.selector)}.PressAsync(${quote(shortcut)});`;
|
|
122
|
-
}
|
|
123
|
-
case "navigate":
|
|
124
|
-
return `await ${subject}.GotoAsync(${quote(action.url)});`;
|
|
125
|
-
case "select":
|
|
126
|
-
return `await ${subject}.${this._asLocator(action.selector)}.SelectOptionAsync(${formatObject(action.options)});`;
|
|
127
|
-
case "assertText":
|
|
128
|
-
return `await Expect(${subject}.${this._asLocator(action.selector)}).${action.substring ? "ToContainTextAsync" : "ToHaveTextAsync"}(${quote(action.text)});`;
|
|
129
|
-
case "assertChecked":
|
|
130
|
-
return `await Expect(${subject}.${this._asLocator(action.selector)})${action.checked ? "" : ".Not"}.ToBeCheckedAsync();`;
|
|
131
|
-
case "assertVisible":
|
|
132
|
-
return `await Expect(${subject}.${this._asLocator(action.selector)}).ToBeVisibleAsync();`;
|
|
133
|
-
case "assertValue": {
|
|
134
|
-
const assertion = action.value ? `ToHaveValueAsync(${quote(action.value)})` : `ToBeEmptyAsync()`;
|
|
135
|
-
return `await Expect(${subject}.${this._asLocator(action.selector)}).${assertion};`;
|
|
136
|
-
}
|
|
137
|
-
case "assertSnapshot":
|
|
138
|
-
return `await Expect(${subject}.${this._asLocator(action.selector)}).ToMatchAriaSnapshotAsync(${quote(action.snapshot)});`;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
_asLocator(selector) {
|
|
142
|
-
return (0, import_utils.asLocator)("csharp", selector);
|
|
143
|
-
}
|
|
144
|
-
generateHeader(options) {
|
|
145
|
-
if (this._mode === "library")
|
|
146
|
-
return this.generateStandaloneHeader(options);
|
|
147
|
-
return this.generateTestRunnerHeader(options);
|
|
148
|
-
}
|
|
149
|
-
generateStandaloneHeader(options) {
|
|
150
|
-
const formatter = new CSharpFormatter(0);
|
|
151
|
-
formatter.add(`
|
|
152
|
-
using Microsoft.Playwright;
|
|
153
|
-
using System;
|
|
154
|
-
using System.Threading.Tasks;
|
|
155
|
-
|
|
156
|
-
using var playwright = await Playwright.CreateAsync();
|
|
157
|
-
await using var browser = await playwright.${toPascal(options.browserName)}.LaunchAsync(${formatObject(options.launchOptions, " ", "BrowserTypeLaunchOptions")});
|
|
158
|
-
var context = await browser.NewContextAsync(${formatContextOptions(options.contextOptions, options.deviceName)});`);
|
|
159
|
-
if (options.contextOptions.recordHar) {
|
|
160
|
-
const url = options.contextOptions.recordHar.urlFilter;
|
|
161
|
-
formatter.add(` await context.RouteFromHARAsync(${quote(options.contextOptions.recordHar.path)}${url ? `, ${formatObject({ url }, " ", "BrowserContextRouteFromHAROptions")}` : ""});`);
|
|
162
|
-
}
|
|
163
|
-
formatter.newLine();
|
|
164
|
-
return formatter.format();
|
|
165
|
-
}
|
|
166
|
-
generateTestRunnerHeader(options) {
|
|
167
|
-
const formatter = new CSharpFormatter(0);
|
|
168
|
-
formatter.add(`
|
|
169
|
-
using Microsoft.Playwright.${this._mode === "nunit" ? "NUnit" : "MSTest"};
|
|
170
|
-
using Microsoft.Playwright;
|
|
171
|
-
|
|
172
|
-
${this._mode === "nunit" ? `[Parallelizable(ParallelScope.Self)]
|
|
173
|
-
[TestFixture]` : "[TestClass]"}
|
|
174
|
-
public class Tests : PageTest
|
|
175
|
-
{`);
|
|
176
|
-
const formattedContextOptions = formatContextOptions(options.contextOptions, options.deviceName);
|
|
177
|
-
if (formattedContextOptions) {
|
|
178
|
-
formatter.add(`public override BrowserNewContextOptions ContextOptions()
|
|
179
|
-
{
|
|
180
|
-
return ${formattedContextOptions};
|
|
181
|
-
}`);
|
|
182
|
-
formatter.newLine();
|
|
183
|
-
}
|
|
184
|
-
formatter.add(` [${this._mode === "nunit" ? "Test" : "TestMethod"}]
|
|
185
|
-
public async Task MyTest()
|
|
186
|
-
{`);
|
|
187
|
-
if (options.contextOptions.recordHar) {
|
|
188
|
-
const url = options.contextOptions.recordHar.urlFilter;
|
|
189
|
-
formatter.add(` await Context.RouteFromHARAsync(${quote(options.contextOptions.recordHar.path)}${url ? `, ${formatObject({ url }, " ", "BrowserContextRouteFromHAROptions")}` : ""});`);
|
|
190
|
-
}
|
|
191
|
-
return formatter.format();
|
|
192
|
-
}
|
|
193
|
-
generateFooter(saveStorage) {
|
|
194
|
-
const offset = this._mode === "library" ? "" : " ";
|
|
195
|
-
let storageStateLine = saveStorage ? `
|
|
196
|
-
${offset}await context.StorageStateAsync(new BrowserContextStorageStateOptions
|
|
197
|
-
${offset}{
|
|
198
|
-
${offset} Path = ${quote(saveStorage)}
|
|
199
|
-
${offset}});
|
|
200
|
-
` : "";
|
|
201
|
-
if (this._mode !== "library")
|
|
202
|
-
storageStateLine += ` }
|
|
203
|
-
}
|
|
204
|
-
`;
|
|
205
|
-
return storageStateLine;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
function formatObject(value, indent = " ", name = "") {
|
|
209
|
-
if (typeof value === "string") {
|
|
210
|
-
if (["permissions", "colorScheme", "modifiers", "button", "recordHarContent", "recordHarMode", "serviceWorkers"].includes(name))
|
|
211
|
-
return `${getClassName(name)}.${toPascal(value)}`;
|
|
212
|
-
return quote(value);
|
|
213
|
-
}
|
|
214
|
-
if (Array.isArray(value))
|
|
215
|
-
return `new[] { ${value.map((o) => formatObject(o, indent, name)).join(", ")} }`;
|
|
216
|
-
if (typeof value === "object") {
|
|
217
|
-
const keys = Object.keys(value).filter((key) => value[key] !== void 0).sort();
|
|
218
|
-
if (!keys.length)
|
|
219
|
-
return name ? `new ${getClassName(name)}` : "";
|
|
220
|
-
const tokens = [];
|
|
221
|
-
for (const key of keys) {
|
|
222
|
-
const property = getPropertyName(key);
|
|
223
|
-
tokens.push(`${property} = ${formatObject(value[key], indent, key)},`);
|
|
224
|
-
}
|
|
225
|
-
if (name)
|
|
226
|
-
return `new ${getClassName(name)}
|
|
227
|
-
{
|
|
228
|
-
${indent}${tokens.join(`
|
|
229
|
-
${indent}`)}
|
|
230
|
-
${indent}}`;
|
|
231
|
-
return `{
|
|
232
|
-
${indent}${tokens.join(`
|
|
233
|
-
${indent}`)}
|
|
234
|
-
${indent}}`;
|
|
235
|
-
}
|
|
236
|
-
if (name === "latitude" || name === "longitude")
|
|
237
|
-
return String(value) + "m";
|
|
238
|
-
return String(value);
|
|
239
|
-
}
|
|
240
|
-
function getClassName(value) {
|
|
241
|
-
switch (value) {
|
|
242
|
-
case "viewport":
|
|
243
|
-
return "ViewportSize";
|
|
244
|
-
case "proxy":
|
|
245
|
-
return "ProxySettings";
|
|
246
|
-
case "permissions":
|
|
247
|
-
return "ContextPermission";
|
|
248
|
-
case "modifiers":
|
|
249
|
-
return "KeyboardModifier";
|
|
250
|
-
case "button":
|
|
251
|
-
return "MouseButton";
|
|
252
|
-
case "recordHarMode":
|
|
253
|
-
return "HarMode";
|
|
254
|
-
case "recordHarContent":
|
|
255
|
-
return "HarContentPolicy";
|
|
256
|
-
case "serviceWorkers":
|
|
257
|
-
return "ServiceWorkerPolicy";
|
|
258
|
-
default:
|
|
259
|
-
return toPascal(value);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function getPropertyName(key) {
|
|
263
|
-
switch (key) {
|
|
264
|
-
case "storageState":
|
|
265
|
-
return "StorageStatePath";
|
|
266
|
-
case "viewport":
|
|
267
|
-
return "ViewportSize";
|
|
268
|
-
default:
|
|
269
|
-
return toPascal(key);
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
function toPascal(value) {
|
|
273
|
-
return value[0].toUpperCase() + value.slice(1);
|
|
274
|
-
}
|
|
275
|
-
function formatContextOptions(contextOptions, deviceName) {
|
|
276
|
-
let options = { ...contextOptions };
|
|
277
|
-
delete options.recordHar;
|
|
278
|
-
const device = deviceName && import_deviceDescriptors.deviceDescriptors[deviceName];
|
|
279
|
-
if (!device) {
|
|
280
|
-
if (!Object.entries(options).length)
|
|
281
|
-
return "";
|
|
282
|
-
return formatObject(options, " ", "BrowserNewContextOptions");
|
|
283
|
-
}
|
|
284
|
-
options = (0, import_language.sanitizeDeviceOptions)(device, options);
|
|
285
|
-
if (!Object.entries(options).length)
|
|
286
|
-
return `playwright.Devices[${quote(deviceName)}]`;
|
|
287
|
-
return formatObject(options, " ", `BrowserNewContextOptions(playwright.Devices[${quote(deviceName)}])`);
|
|
288
|
-
}
|
|
289
|
-
class CSharpFormatter {
|
|
290
|
-
constructor(offset = 0) {
|
|
291
|
-
this._lines = [];
|
|
292
|
-
this._baseIndent = " ".repeat(4);
|
|
293
|
-
this._baseOffset = " ".repeat(offset);
|
|
294
|
-
}
|
|
295
|
-
prepend(text) {
|
|
296
|
-
this._lines = text.trim().split("\n").map((line) => line.trim()).concat(this._lines);
|
|
297
|
-
}
|
|
298
|
-
add(text) {
|
|
299
|
-
this._lines.push(...text.trim().split("\n").map((line) => line.trim()));
|
|
300
|
-
}
|
|
301
|
-
newLine() {
|
|
302
|
-
this._lines.push("");
|
|
303
|
-
}
|
|
304
|
-
format() {
|
|
305
|
-
let spaces = "";
|
|
306
|
-
let previousLine = "";
|
|
307
|
-
return this._lines.map((line) => {
|
|
308
|
-
if (line === "")
|
|
309
|
-
return line;
|
|
310
|
-
if (line.startsWith("}") || line.startsWith("]") || line.includes("});") || line === ");")
|
|
311
|
-
spaces = spaces.substring(this._baseIndent.length);
|
|
312
|
-
const extraSpaces = /^(for|while|if).*\(.*\)$/.test(previousLine) ? this._baseIndent : "";
|
|
313
|
-
previousLine = line;
|
|
314
|
-
line = spaces + extraSpaces + line;
|
|
315
|
-
if (line.endsWith("{") || line.endsWith("[") || line.endsWith("("))
|
|
316
|
-
spaces += this._baseIndent;
|
|
317
|
-
if (line.endsWith("));"))
|
|
318
|
-
spaces = spaces.substring(this._baseIndent.length);
|
|
319
|
-
return this._baseOffset + line;
|
|
320
|
-
}).join("\n");
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function quote(text) {
|
|
324
|
-
return (0, import_utils.escapeWithQuotes)(text, '"');
|
|
325
|
-
}
|
|
326
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
327
|
-
0 && (module.exports = {
|
|
328
|
-
CSharpLanguageGenerator
|
|
329
|
-
});
|