@checkly/playwright-core 1.51.17-beta.2 → 1.54.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ThirdPartyNotices.txt +65 -123
- package/browsers.json +16 -14
- package/index.js +1 -1
- package/lib/androidServerImpl.js +47 -50
- package/lib/browserServerImpl.js +89 -69
- package/lib/checkly/escapeRegExp.js +23 -27
- package/lib/checkly/fetch.js +64 -46
- package/lib/checkly/secretsFilter.js +49 -35
- package/lib/cli/driver.js +71 -69
- package/lib/cli/program.js +400 -359
- package/lib/cli/programWithTestStub.js +51 -45
- package/lib/client/accessibility.js +31 -32
- package/lib/client/android.js +151 -242
- package/lib/client/api.js +135 -283
- package/lib/client/artifact.js +39 -36
- package/lib/client/browser.js +96 -71
- package/lib/client/browserContext.js +314 -345
- package/lib/client/browserType.js +103 -127
- package/lib/client/cdpSession.js +29 -31
- package/lib/client/channelOwner.js +90 -113
- package/lib/client/clientHelper.js +48 -39
- package/lib/client/clientInstrumentation.js +40 -37
- package/lib/client/clientStackTrace.js +41 -37
- package/lib/client/clock.js +36 -36
- package/lib/client/connection.js +188 -214
- package/lib/client/consoleMessage.js +31 -28
- package/lib/client/coverage.js +25 -22
- package/lib/client/dialog.js +30 -31
- package/lib/client/download.js +25 -25
- package/lib/client/electron.js +80 -77
- package/lib/client/elementHandle.js +120 -159
- package/lib/client/errors.js +53 -53
- package/lib/client/eventEmitter.js +124 -121
- package/lib/client/events.js +72 -68
- package/lib/client/fetch.js +166 -190
- package/lib/client/fileChooser.js +25 -24
- package/lib/client/fileUtils.js +31 -28
- package/lib/client/frame.js +207 -306
- package/lib/client/harRouter.js +42 -52
- package/lib/client/input.js +42 -69
- package/lib/client/jsHandle.js +54 -69
- package/lib/client/jsonPipe.js +27 -23
- package/lib/client/localUtils.js +29 -29
- package/lib/client/locator.js +145 -237
- package/lib/client/network.js +282 -307
- package/lib/client/page.js +269 -318
- package/lib/client/platform.js +46 -43
- package/lib/client/playwright.js +51 -76
- package/lib/client/selectors.js +45 -63
- package/lib/client/stream.js +29 -25
- package/lib/client/timeoutSettings.js +55 -41
- package/lib/client/tracing.js +49 -96
- package/lib/client/types.js +26 -22
- package/lib/client/video.js +35 -27
- package/lib/client/waiter.js +69 -88
- package/lib/client/webError.js +25 -23
- package/lib/client/webSocket.js +43 -56
- package/lib/client/worker.js +48 -56
- package/lib/client/writableStream.js +27 -23
- package/lib/generated/bindingsControllerSource.js +28 -0
- package/lib/generated/clockSource.js +26 -6
- package/lib/generated/consoleApiSource.js +26 -6
- package/lib/generated/injectedScriptSource.js +26 -6
- package/lib/generated/pollingRecorderSource.js +26 -6
- package/lib/generated/storageScriptSource.js +28 -0
- package/lib/generated/utilityScriptSource.js +26 -6
- package/lib/generated/webSocketMockSource.js +333 -5
- package/lib/inProcessFactory.js +51 -53
- package/lib/inprocess.js +2 -19
- package/lib/outofprocess.js +51 -46
- package/lib/protocol/serializers.js +153 -134
- package/lib/protocol/validator.js +2807 -2739
- package/lib/protocol/validatorPrimitives.js +114 -73
- package/lib/remote/playwrightConnection.js +88 -242
- package/lib/remote/playwrightServer.js +305 -92
- package/lib/server/accessibility.js +44 -37
- package/lib/server/android/android.js +251 -241
- package/lib/server/android/backendAdb.js +87 -82
- package/lib/server/artifact.js +78 -55
- package/lib/server/bidi/bidiBrowser.js +297 -158
- package/lib/server/bidi/bidiChromium.js +119 -89
- package/lib/server/bidi/bidiConnection.js +66 -83
- package/lib/server/bidi/bidiExecutionContext.js +129 -113
- package/lib/server/bidi/bidiFirefox.js +86 -76
- package/lib/server/bidi/bidiInput.js +106 -117
- package/lib/server/bidi/bidiNetworkManager.js +142 -159
- package/lib/server/bidi/bidiOverCdp.js +57 -58
- package/lib/server/bidi/bidiPage.js +260 -260
- package/lib/server/bidi/bidiPdf.js +52 -86
- package/lib/server/bidi/third_party/bidiCommands.d.js +22 -0
- package/lib/server/bidi/third_party/bidiDeserializer.js +55 -50
- package/lib/server/bidi/third_party/bidiKeyboard.js +236 -220
- package/lib/server/bidi/third_party/bidiProtocol.js +22 -137
- package/lib/server/bidi/third_party/bidiProtocolCore.js +152 -0
- package/lib/server/bidi/third_party/bidiProtocolPermissions.js +42 -0
- package/lib/server/bidi/third_party/bidiSerializer.js +67 -63
- package/lib/server/bidi/third_party/firefoxPrefs.js +141 -119
- package/lib/server/browser.js +93 -95
- package/lib/server/browserContext.js +419 -429
- package/lib/server/browserType.js +186 -216
- package/lib/server/callLog.js +47 -44
- package/lib/server/chromium/chromium.js +235 -203
- package/lib/server/chromium/chromiumSwitches.js +100 -67
- package/lib/server/chromium/crAccessibility.js +157 -131
- package/lib/server/chromium/crBrowser.js +310 -292
- package/lib/server/chromium/crConnection.js +95 -121
- package/lib/server/chromium/crCoverage.js +121 -131
- package/lib/server/chromium/crDevTools.js +60 -51
- package/lib/server/chromium/crDragDrop.js +68 -84
- package/lib/server/chromium/crExecutionContext.js +89 -83
- package/lib/server/chromium/crInput.js +118 -113
- package/lib/server/chromium/crNetworkManager.js +274 -375
- package/lib/server/chromium/crPage.js +536 -593
- package/lib/server/chromium/crPdf.js +54 -86
- package/lib/server/chromium/crProtocolHelper.js +92 -80
- package/lib/server/chromium/crServiceWorker.js +84 -73
- package/lib/server/chromium/defaultFontFamilies.js +152 -135
- package/lib/server/chromium/protocol.d.js +16 -0
- package/lib/server/chromium/videoRecorder.js +66 -99
- package/lib/server/clock.js +107 -83
- package/lib/server/codegen/csharp.js +192 -162
- package/lib/server/codegen/java.js +156 -129
- package/lib/server/codegen/javascript.js +163 -148
- package/lib/server/codegen/jsonl.js +32 -28
- package/lib/server/codegen/language.js +75 -52
- package/lib/server/codegen/languages.js +65 -27
- package/lib/server/codegen/python.js +141 -126
- package/lib/server/codegen/types.js +15 -4
- package/lib/server/console.js +28 -32
- package/lib/server/cookieStore.js +108 -86
- package/lib/server/debugController.js +147 -151
- package/lib/server/debugger.js +86 -78
- package/lib/server/deviceDescriptors.js +37 -24
- package/lib/server/deviceDescriptorsSource.json +238 -128
- package/lib/server/dialog.js +84 -39
- package/lib/server/dispatchers/androidDispatcher.js +257 -148
- package/lib/server/dispatchers/artifactDispatcher.js +79 -79
- package/lib/server/dispatchers/browserContextDispatcher.js +289 -259
- package/lib/server/dispatchers/browserDispatcher.js +96 -148
- package/lib/server/dispatchers/browserTypeDispatcher.js +50 -41
- package/lib/server/dispatchers/cdpSessionDispatcher.js +35 -39
- package/lib/server/dispatchers/debugControllerDispatcher.js +65 -83
- package/lib/server/dispatchers/dialogDispatcher.js +34 -31
- package/lib/server/dispatchers/dispatcher.js +208 -248
- package/lib/server/dispatchers/electronDispatcher.js +66 -70
- package/lib/server/dispatchers/elementHandlerDispatcher.js +164 -216
- package/lib/server/dispatchers/frameDispatcher.js +211 -272
- package/lib/server/dispatchers/jsHandleDispatcher.js +63 -75
- package/lib/server/dispatchers/jsonPipeDispatcher.js +37 -38
- package/lib/server/dispatchers/localUtilsDispatcher.js +121 -119
- package/lib/server/dispatchers/networkDispatchers.js +117 -128
- package/lib/server/dispatchers/pageDispatcher.js +256 -248
- package/lib/server/dispatchers/playwrightDispatcher.js +92 -87
- package/lib/server/dispatchers/streamDispatcher.js +52 -48
- package/lib/server/dispatchers/tracingDispatcher.js +47 -52
- package/lib/server/dispatchers/webSocketRouteDispatcher.js +126 -150
- package/lib/server/dispatchers/writableStreamDispatcher.js +65 -43
- package/lib/server/dom.js +485 -582
- package/lib/server/download.js +47 -37
- package/lib/server/electron/electron.js +216 -243
- package/lib/server/electron/loader.js +9 -37
- package/lib/server/errors.js +47 -46
- package/lib/server/fetch.js +317 -360
- package/lib/server/fileChooser.js +25 -24
- package/lib/server/fileUploadUtils.js +66 -60
- package/lib/server/firefox/ffAccessibility.js +153 -131
- package/lib/server/firefox/ffBrowser.js +268 -305
- package/lib/server/firefox/ffConnection.js +63 -84
- package/lib/server/firefox/ffExecutionContext.js +92 -73
- package/lib/server/firefox/ffInput.js +82 -84
- package/lib/server/firefox/ffNetworkManager.js +137 -114
- package/lib/server/firefox/ffPage.js +261 -293
- package/lib/server/firefox/firefox.js +80 -72
- package/lib/server/firefox/protocol.d.js +16 -0
- package/lib/server/formData.js +107 -35
- package/lib/server/frameSelectors.js +98 -114
- package/lib/server/frames.js +845 -1055
- package/lib/server/har/harRecorder.js +85 -77
- package/lib/server/har/harTracer.js +290 -223
- package/lib/server/harBackend.js +80 -80
- package/lib/server/helper.js +55 -59
- package/lib/server/index.js +59 -99
- package/lib/server/input.js +151 -189
- package/lib/server/instrumentation.js +57 -44
- package/lib/server/javascript.js +133 -134
- package/lib/server/launchApp.js +113 -75
- package/lib/server/localUtils.js +150 -142
- package/lib/server/macEditingCommands.js +141 -137
- package/lib/server/network.js +299 -303
- package/lib/server/page.js +513 -544
- package/lib/server/pipeTransport.js +49 -45
- package/lib/server/playwright.js +58 -67
- package/lib/server/progress.js +137 -68
- package/lib/server/protocolError.js +34 -31
- package/lib/server/recorder/chat.js +70 -86
- package/lib/server/recorder/recorderApp.js +341 -176
- package/lib/server/recorder/recorderInTraceViewer.js +65 -94
- package/lib/server/recorder/recorderRunner.js +93 -116
- package/lib/server/recorder/recorderSignalProcessor.js +83 -0
- package/lib/server/recorder/recorderUtils.js +104 -47
- package/lib/server/recorder/throttledFile.js +42 -30
- package/lib/server/recorder.js +395 -275
- package/lib/server/registry/browserFetcher.js +106 -101
- package/lib/server/registry/dependencies.js +245 -196
- package/lib/server/registry/index.js +930 -803
- package/lib/server/registry/nativeDeps.js +1073 -464
- package/lib/server/registry/oopDownloadBrowserMain.js +57 -75
- package/lib/server/screenshotter.js +160 -191
- package/lib/server/selectors.js +90 -51
- package/lib/server/socksClientCertificatesInterceptor.js +171 -186
- package/lib/server/socksInterceptor.js +62 -70
- package/lib/server/trace/recorder/snapshotter.js +76 -102
- package/lib/server/trace/recorder/snapshotterInjected.js +238 -217
- package/lib/server/trace/recorder/tracing.js +354 -362
- package/lib/server/trace/test/inMemorySnapshotter.js +46 -52
- package/lib/server/trace/viewer/traceViewer.js +160 -147
- package/lib/server/transport.js +119 -134
- package/lib/server/types.js +26 -22
- package/lib/server/usKeyboardLayout.js +135 -545
- package/lib/server/utils/ascii.js +39 -26
- package/lib/server/utils/comparators.js +105 -103
- package/lib/server/utils/crypto.js +157 -112
- package/lib/server/utils/debug.js +36 -32
- package/lib/server/utils/debugLogger.js +77 -48
- package/lib/server/utils/env.js +52 -37
- package/lib/server/utils/eventsHelper.js +29 -28
- package/lib/server/utils/expectUtils.js +31 -26
- package/lib/server/utils/fileUtils.js +123 -136
- package/lib/server/utils/happyEyeballs.js +141 -126
- package/lib/server/utils/hostPlatform.js +84 -120
- package/lib/server/utils/httpServer.js +106 -121
- package/lib/server/utils/image_tools/colorUtils.js +42 -51
- package/lib/server/utils/image_tools/compare.js +44 -43
- package/lib/server/utils/image_tools/imageChannel.js +38 -30
- package/lib/server/utils/image_tools/stats.js +40 -40
- package/lib/server/utils/linuxUtils.js +50 -37
- package/lib/server/utils/network.js +152 -96
- package/lib/server/utils/nodePlatform.js +87 -79
- package/lib/server/utils/pipeTransport.js +44 -42
- package/lib/server/utils/processLauncher.js +111 -121
- package/lib/server/utils/profiler.js +52 -39
- package/lib/server/utils/socksProxy.js +280 -339
- package/lib/server/utils/spawnAsync.js +37 -41
- package/lib/server/utils/task.js +31 -38
- package/lib/server/utils/userAgent.js +73 -66
- package/lib/server/utils/wsServer.js +68 -75
- package/lib/server/utils/zipFile.js +36 -37
- package/lib/server/utils/zones.js +37 -34
- package/lib/server/webkit/protocol.d.js +16 -0
- package/lib/server/webkit/webkit.js +77 -61
- package/lib/server/webkit/wkAccessibility.js +161 -118
- package/lib/server/webkit/wkBrowser.js +193 -184
- package/lib/server/webkit/wkConnection.js +59 -83
- package/lib/server/webkit/wkExecutionContext.js +85 -70
- package/lib/server/webkit/wkInput.js +97 -95
- package/lib/server/webkit/wkInterceptableRequest.js +102 -95
- package/lib/server/webkit/wkPage.js +568 -667
- package/lib/server/webkit/wkProvisionalPage.js +45 -56
- package/lib/server/webkit/wkWorkers.js +79 -79
- package/lib/utils/expectUtils.js +31 -26
- package/lib/utils/isomorphic/ariaSnapshot.js +149 -152
- package/lib/utils/isomorphic/assert.js +28 -22
- package/lib/utils/isomorphic/colors.js +66 -59
- package/lib/utils/isomorphic/cssParser.js +120 -125
- package/lib/utils/isomorphic/cssTokenizer.js +436 -364
- package/lib/utils/isomorphic/headers.js +38 -37
- package/lib/utils/isomorphic/locatorGenerators.js +358 -357
- package/lib/utils/isomorphic/locatorParser.js +96 -105
- package/lib/utils/isomorphic/locatorUtils.js +63 -44
- package/lib/utils/isomorphic/manualPromise.js +46 -39
- package/lib/utils/isomorphic/mimeType.js +447 -25
- package/lib/utils/isomorphic/multimap.js +34 -27
- package/lib/utils/isomorphic/protocolFormatter.js +68 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +321 -0
- package/lib/utils/isomorphic/recorderUtils.js +140 -181
- package/lib/utils/isomorphic/rtti.js +35 -33
- package/lib/utils/isomorphic/selectorParser.js +182 -193
- package/lib/utils/isomorphic/semaphore.js +27 -24
- package/lib/utils/isomorphic/stackTrace.js +87 -98
- package/lib/utils/isomorphic/stringUtils.js +98 -112
- package/lib/utils/isomorphic/time.js +46 -22
- package/lib/utils/isomorphic/timeoutRunner.js +53 -53
- package/lib/utils/isomorphic/traceUtils.js +37 -41
- package/lib/utils/isomorphic/types.js +15 -4
- package/lib/utils/isomorphic/urlMatch.js +113 -67
- package/lib/utils/isomorphic/utilityScriptSerializers.js +251 -0
- package/lib/utils.js +101 -443
- package/lib/utilsBundle.js +101 -52
- package/lib/utilsBundleImpl/index.js +160 -150
- package/lib/zipBundle.js +32 -23
- package/lib/zipBundleImpl.js +4 -4
- package/package.json +1 -1
- package/types/protocol.d.ts +1267 -1057
- package/types/types.d.ts +131 -29
- package/lib/common/socksProxy.js +0 -569
- package/lib/common/timeoutSettings.js +0 -73
- package/lib/common/types.js +0 -5
- package/lib/image_tools/colorUtils.js +0 -98
- package/lib/image_tools/compare.js +0 -108
- package/lib/image_tools/imageChannel.js +0 -70
- package/lib/image_tools/stats.js +0 -102
- package/lib/protocol/debug.js +0 -27
- package/lib/protocol/transport.js +0 -82
- package/lib/server/dispatchers/selectorsDispatcher.js +0 -36
- package/lib/server/isomorphic/utilityScriptSerializers.js +0 -229
- package/lib/server/recorder/contextRecorder.js +0 -290
- package/lib/server/recorder/recorderCollection.js +0 -104
- package/lib/server/recorder/recorderFrontend.js +0 -5
- package/lib/server/storageScript.js +0 -160
- package/lib/server/timeoutSettings.js +0 -74
- package/lib/third_party/diff_match_patch.js +0 -2222
- package/lib/utils/ascii.js +0 -31
- package/lib/utils/comparators.js +0 -171
- package/lib/utils/crypto.js +0 -174
- package/lib/utils/debug.js +0 -46
- package/lib/utils/debugLogger.js +0 -91
- package/lib/utils/env.js +0 -49
- package/lib/utils/eventsHelper.js +0 -38
- package/lib/utils/fileUtils.js +0 -205
- package/lib/utils/happy-eyeballs.js +0 -210
- package/lib/utils/headers.js +0 -52
- package/lib/utils/hostPlatform.js +0 -133
- package/lib/utils/httpServer.js +0 -237
- package/lib/utils/index.js +0 -368
- package/lib/utils/linuxUtils.js +0 -78
- package/lib/utils/manualPromise.js +0 -109
- package/lib/utils/multimap.js +0 -75
- package/lib/utils/network.js +0 -160
- package/lib/utils/processLauncher.js +0 -248
- package/lib/utils/profiler.js +0 -53
- package/lib/utils/rtti.js +0 -44
- package/lib/utils/semaphore.js +0 -51
- package/lib/utils/spawnAsync.js +0 -45
- package/lib/utils/stackTrace.js +0 -121
- package/lib/utils/task.js +0 -58
- package/lib/utils/time.js +0 -37
- package/lib/utils/timeoutRunner.js +0 -66
- package/lib/utils/traceUtils.js +0 -44
- package/lib/utils/userAgent.js +0 -105
- package/lib/utils/wsServer.js +0 -127
- package/lib/utils/zipFile.js +0 -75
- package/lib/utils/zones.js +0 -62
- package/lib/vite/htmlReport/index.html +0 -69
- package/lib/vite/recorder/assets/codeMirrorModule-B9YMkrwa.js +0 -24
- package/lib/vite/recorder/assets/codeMirrorModule-C3UTv-Ge.css +0 -1
- package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/lib/vite/recorder/assets/index-ELPgmkwA.js +0 -184
- package/lib/vite/recorder/assets/index-eHBmevrY.css +0 -1
- package/lib/vite/recorder/index.html +0 -29
- package/lib/vite/recorder/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/assets/codeMirrorModule-gU1OOCQO.js +0 -24
- package/lib/vite/traceViewer/assets/defaultSettingsView-B5n_FjMx.js +0 -1
- package/lib/vite/traceViewer/assets/inspectorTab-6Tru8Mn_.js +0 -235
- package/lib/vite/traceViewer/assets/workbench-B_Nj4NA2.js +0 -25
- package/lib/vite/traceViewer/assets/xtermModule-BoAIEibi.js +0 -9
- package/lib/vite/traceViewer/codeMirrorModule.C3UTv-Ge.css +0 -1
- package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/lib/vite/traceViewer/defaultSettingsView.CO3FR0CX.css +0 -1
- package/lib/vite/traceViewer/embedded.DpNPH6mk.js +0 -2
- package/lib/vite/traceViewer/embedded.html +0 -18
- package/lib/vite/traceViewer/embedded.mLhjB5IF.css +0 -1
- package/lib/vite/traceViewer/index.CFOW-Ezb.css +0 -1
- package/lib/vite/traceViewer/index.CuE3SYGw.js +0 -2
- package/lib/vite/traceViewer/index.html +0 -47
- package/lib/vite/traceViewer/inspectorTab.CXDulcFG.css +0 -1
- package/lib/vite/traceViewer/playwright-logo.svg +0 -9
- package/lib/vite/traceViewer/recorder.BD-uZJs7.js +0 -2
- package/lib/vite/traceViewer/recorder.html +0 -17
- package/lib/vite/traceViewer/recorder.tn0RQdqM.css +0 -0
- package/lib/vite/traceViewer/snapshot.html +0 -21
- package/lib/vite/traceViewer/sw.bundle.js +0 -3
- package/lib/vite/traceViewer/uiMode.BatfzHMG.css +0 -1
- package/lib/vite/traceViewer/uiMode.DHrNgddz.js +0 -5
- package/lib/vite/traceViewer/uiMode.html +0 -21
- package/lib/vite/traceViewer/workbench.B9vIAzH9.css +0 -1
- package/lib/vite/traceViewer/xtermModule.Beg8tuEN.css +0 -32
package/lib/server/recorder.js
CHANGED
|
@@ -1,369 +1,489 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
/**
|
|
20
|
-
* Copyright (c) Microsoft Corporation.
|
|
21
|
-
*
|
|
22
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
-
* you may not use this file except in compliance with the License.
|
|
24
|
-
* You may obtain a copy of the License at
|
|
25
|
-
*
|
|
26
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
-
* See the License for the specific language governing permissions and
|
|
32
|
-
* limitations under the License.
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
const recorderSymbol = Symbol('recorderSymbol');
|
|
36
|
-
class Recorder {
|
|
37
|
-
static async showInspector(context, params, recorderAppFactory) {
|
|
38
|
-
if ((0, _utils.isUnderTest)()) params.language = process.env.TEST_INSPECTOR_LANGUAGE;
|
|
39
|
-
return await Recorder.show(context, recorderAppFactory, params);
|
|
40
|
-
}
|
|
41
|
-
static showInspectorNoReply(context, recorderAppFactory) {
|
|
42
|
-
Recorder.showInspector(context, {}, recorderAppFactory).catch(() => {});
|
|
43
|
-
}
|
|
44
|
-
static show(context, recorderAppFactory, params) {
|
|
45
|
-
let recorderPromise = context[recorderSymbol];
|
|
46
|
-
if (!recorderPromise) {
|
|
47
|
-
recorderPromise = Recorder._create(context, recorderAppFactory, params);
|
|
48
|
-
context[recorderSymbol] = recorderPromise;
|
|
49
|
-
}
|
|
50
|
-
return recorderPromise;
|
|
51
|
-
}
|
|
52
|
-
static async _create(context, recorderAppFactory, params = {}) {
|
|
53
|
-
const recorder = new Recorder(context, params);
|
|
54
|
-
const recorderApp = await recorderAppFactory(recorder);
|
|
55
|
-
await recorder._install(recorderApp);
|
|
56
|
-
return recorder;
|
|
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 });
|
|
57
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 recorder_exports = {};
|
|
30
|
+
__export(recorder_exports, {
|
|
31
|
+
Recorder: () => Recorder,
|
|
32
|
+
RecorderEvent: () => RecorderEvent
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(recorder_exports);
|
|
35
|
+
var import_events = __toESM(require("events"));
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_utils = require("../utils");
|
|
38
|
+
var import_browserContext = require("./browserContext");
|
|
39
|
+
var import_debugger = require("./debugger");
|
|
40
|
+
var import_recorderUtils = require("./recorder/recorderUtils");
|
|
41
|
+
var import_locatorParser = require("../utils/isomorphic/locatorParser");
|
|
42
|
+
var import_selectorParser = require("../utils/isomorphic/selectorParser");
|
|
43
|
+
var import_progress = require("./progress");
|
|
44
|
+
var import_instrumentation = require("./instrumentation");
|
|
45
|
+
var import_recorderSignalProcessor = require("./recorder/recorderSignalProcessor");
|
|
46
|
+
var rawRecorderSource = __toESM(require("./../generated/pollingRecorderSource"));
|
|
47
|
+
var import_utils2 = require("./../utils");
|
|
48
|
+
var import_frames = require("./frames");
|
|
49
|
+
var import_page = require("./page");
|
|
50
|
+
var import_recorderRunner = require("./recorder/recorderRunner");
|
|
51
|
+
const recorderSymbol = Symbol("recorderSymbol");
|
|
52
|
+
const RecorderEvent = {
|
|
53
|
+
PausedStateChanged: "pausedStateChanged",
|
|
54
|
+
ModeChanged: "modeChanged",
|
|
55
|
+
ElementPicked: "elementPicked",
|
|
56
|
+
CallLogsUpdated: "callLogsUpdated",
|
|
57
|
+
UserSourcesChanged: "userSourcesChanged",
|
|
58
|
+
ActionAdded: "actionAdded",
|
|
59
|
+
SignalAdded: "signalAdded",
|
|
60
|
+
PageNavigated: "pageNavigated",
|
|
61
|
+
ContextClosed: "contextClosed"
|
|
62
|
+
};
|
|
63
|
+
class Recorder extends import_events.default {
|
|
58
64
|
constructor(context, params) {
|
|
59
|
-
|
|
60
|
-
this._context = void 0;
|
|
61
|
-
this._mode = void 0;
|
|
65
|
+
super();
|
|
62
66
|
this._highlightedElement = {};
|
|
63
|
-
this._overlayState = {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this._recorderApp = null;
|
|
67
|
-
this._currentCallsMetadata = new Map();
|
|
68
|
-
this._recorderSources = [];
|
|
69
|
-
this._userSources = new Map();
|
|
70
|
-
this._debugger = void 0;
|
|
71
|
-
this._contextRecorder = void 0;
|
|
67
|
+
this._overlayState = { offsetX: 0 };
|
|
68
|
+
this._currentCallsMetadata = /* @__PURE__ */ new Map();
|
|
69
|
+
this._userSources = /* @__PURE__ */ new Map();
|
|
72
70
|
this._omitCallTracking = false;
|
|
73
|
-
this._currentLanguage =
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
71
|
+
this._currentLanguage = "javascript";
|
|
72
|
+
this._pageAliases = /* @__PURE__ */ new Map();
|
|
73
|
+
this._lastPopupOrdinal = 0;
|
|
74
|
+
this._lastDialogOrdinal = -1;
|
|
75
|
+
this._lastDownloadOrdinal = -1;
|
|
76
|
+
this._listeners = [];
|
|
77
|
+
this._enabled = false;
|
|
78
|
+
this._callLogs = [];
|
|
77
79
|
this._context = context;
|
|
80
|
+
this._params = params;
|
|
81
|
+
this._mode = params.mode || "none";
|
|
82
|
+
this._recorderMode = params.recorderMode ?? "default";
|
|
83
|
+
this.handleSIGINT = params.handleSIGINT;
|
|
84
|
+
this._signalProcessor = new import_recorderSignalProcessor.RecorderSignalProcessor({
|
|
85
|
+
addAction: (actionInContext) => {
|
|
86
|
+
if (this._enabled)
|
|
87
|
+
this.emit(RecorderEvent.ActionAdded, actionInContext);
|
|
88
|
+
},
|
|
89
|
+
addSignal: (signal) => {
|
|
90
|
+
if (this._enabled)
|
|
91
|
+
this.emit(RecorderEvent.SignalAdded, signal);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
context.on(import_browserContext.BrowserContext.Events.BeforeClose, () => {
|
|
95
|
+
this.emit(RecorderEvent.ContextClosed);
|
|
96
|
+
});
|
|
97
|
+
this._listeners.push(import_utils2.eventsHelper.addEventListener(process, "exit", () => {
|
|
98
|
+
this.emit(RecorderEvent.ContextClosed);
|
|
99
|
+
}));
|
|
100
|
+
this._setEnabled(params.mode === "recording");
|
|
78
101
|
this._omitCallTracking = !!params.omitCallTracking;
|
|
79
102
|
this._debugger = context.debugger();
|
|
80
103
|
context.instrumentation.addListener(this, context);
|
|
81
|
-
|
|
82
|
-
if ((0, _utils.isUnderTest)()) {
|
|
83
|
-
// Most of our tests put elements at the top left, so get out of the way.
|
|
104
|
+
if ((0, import_utils.isUnderTest)()) {
|
|
84
105
|
this._overlayState.offsetX = 200;
|
|
85
106
|
}
|
|
86
107
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this._currentLanguage = this._contextRecorder.languageName(data.params.file);
|
|
109
|
-
this._refreshOverlay();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (data.event === 'resume') {
|
|
113
|
-
this._debugger.resume(false);
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
if (data.event === 'pause') {
|
|
117
|
-
this._debugger.pauseOnNextStatement();
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (data.event === 'clear') {
|
|
121
|
-
this._contextRecorder.clearScript();
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (data.event === 'runTask') {
|
|
125
|
-
this._contextRecorder.runTask(data.params.task);
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
await Promise.all([recorderApp.setMode(this._mode), recorderApp.setPaused(this._debugger.isPaused()), this._pushAllSources()]);
|
|
130
|
-
this._context.once(_browserContext.BrowserContext.Events.Close, () => {
|
|
131
|
-
var _this$_recorderApp;
|
|
132
|
-
this._contextRecorder.dispose();
|
|
108
|
+
static forContext(context, params) {
|
|
109
|
+
let recorderPromise = context[recorderSymbol];
|
|
110
|
+
if (!recorderPromise) {
|
|
111
|
+
recorderPromise = Recorder._create(context, params);
|
|
112
|
+
context[recorderSymbol] = recorderPromise;
|
|
113
|
+
}
|
|
114
|
+
return recorderPromise;
|
|
115
|
+
}
|
|
116
|
+
static existingForContext(context) {
|
|
117
|
+
return context[recorderSymbol];
|
|
118
|
+
}
|
|
119
|
+
static async _create(context, params = {}) {
|
|
120
|
+
const recorder = new Recorder(context, params);
|
|
121
|
+
await recorder._install();
|
|
122
|
+
return recorder;
|
|
123
|
+
}
|
|
124
|
+
async _install() {
|
|
125
|
+
this.emit(RecorderEvent.ModeChanged, this._mode);
|
|
126
|
+
this.emit(RecorderEvent.PausedStateChanged, this._debugger.isPaused());
|
|
127
|
+
this._context.once(import_browserContext.BrowserContext.Events.Close, () => {
|
|
128
|
+
import_utils2.eventsHelper.removeEventListeners(this._listeners);
|
|
133
129
|
this._context.instrumentation.removeListener(this);
|
|
134
|
-
|
|
135
|
-
});
|
|
136
|
-
this._contextRecorder.on(_contextRecorder.ContextRecorder.Events.Change, data => {
|
|
137
|
-
this._recorderSources = data.sources;
|
|
138
|
-
recorderApp.setActions(data.actions, data.sources);
|
|
139
|
-
recorderApp.setRunningFile(undefined);
|
|
140
|
-
this._pushAllSources();
|
|
130
|
+
this.emit(RecorderEvent.ContextClosed);
|
|
141
131
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
132
|
+
const controller = new import_progress.ProgressController((0, import_instrumentation.serverSideCallMetadata)(), this._context);
|
|
133
|
+
await controller.run(async (progress) => {
|
|
134
|
+
await this._context.exposeBinding(progress, "__pw_recorderState", false, async (source) => {
|
|
135
|
+
let actionSelector;
|
|
136
|
+
let actionPoint;
|
|
137
|
+
const hasActiveScreenshotCommand = [...this._currentCallsMetadata.keys()].some(isScreenshotCommand);
|
|
138
|
+
if (!hasActiveScreenshotCommand) {
|
|
139
|
+
actionSelector = await this._scopeHighlightedSelectorToFrame(source.frame);
|
|
140
|
+
for (const [metadata, sdkObject] of this._currentCallsMetadata) {
|
|
141
|
+
if (source.page === sdkObject.attribution.page) {
|
|
142
|
+
actionPoint = metadata.point || actionPoint;
|
|
143
|
+
actionSelector = actionSelector || metadata.params.selector;
|
|
144
|
+
}
|
|
152
145
|
}
|
|
153
146
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
this.
|
|
147
|
+
const uiState = {
|
|
148
|
+
mode: this._mode,
|
|
149
|
+
actionPoint,
|
|
150
|
+
actionSelector,
|
|
151
|
+
ariaTemplate: this._highlightedElement.ariaTemplate,
|
|
152
|
+
language: this._currentLanguage,
|
|
153
|
+
testIdAttributeName: this._testIdAttributeName(),
|
|
154
|
+
overlay: this._overlayState
|
|
155
|
+
};
|
|
156
|
+
return uiState;
|
|
157
|
+
});
|
|
158
|
+
await this._context.exposeBinding(progress, "__pw_recorderElementPicked", false, async ({ frame }, elementInfo) => {
|
|
159
|
+
const selectorChain = await (0, import_recorderUtils.generateFrameSelector)(frame);
|
|
160
|
+
this.emit(RecorderEvent.ElementPicked, { selector: (0, import_recorderUtils.buildFullSelector)(selectorChain, elementInfo.selector), ariaSnapshot: elementInfo.ariaSnapshot }, true);
|
|
161
|
+
});
|
|
162
|
+
await this._context.exposeBinding(progress, "__pw_recorderSetMode", false, async ({ frame }, mode) => {
|
|
163
|
+
if (frame.parentFrame())
|
|
164
|
+
return;
|
|
165
|
+
this.setMode(mode);
|
|
166
|
+
});
|
|
167
|
+
await this._context.exposeBinding(progress, "__pw_recorderSetOverlayState", false, async ({ frame }, state) => {
|
|
168
|
+
if (frame.parentFrame())
|
|
169
|
+
return;
|
|
170
|
+
this._overlayState = state;
|
|
171
|
+
});
|
|
172
|
+
await this._context.exposeBinding(progress, "__pw_resume", false, () => {
|
|
173
|
+
this._debugger.resume(false);
|
|
174
|
+
});
|
|
175
|
+
this._context.on(import_browserContext.BrowserContext.Events.Page, (page) => this._onPage(page));
|
|
176
|
+
for (const page of this._context.pages())
|
|
177
|
+
this._onPage(page);
|
|
178
|
+
this._context.dialogManager.addDialogHandler((dialog) => {
|
|
179
|
+
this._onDialog(dialog.page());
|
|
180
|
+
return false;
|
|
181
|
+
});
|
|
182
|
+
await this._context.exposeBinding(
|
|
183
|
+
progress,
|
|
184
|
+
"__pw_recorderPerformAction",
|
|
185
|
+
false,
|
|
186
|
+
(source, action) => this._performAction(source.frame, action)
|
|
187
|
+
);
|
|
188
|
+
await this._context.exposeBinding(
|
|
189
|
+
progress,
|
|
190
|
+
"__pw_recorderRecordAction",
|
|
191
|
+
false,
|
|
192
|
+
(source, action) => this._recordAction(source.frame, action)
|
|
193
|
+
);
|
|
194
|
+
await this._context.extendInjectedScript(rawRecorderSource.source, { recorderMode: this._recorderMode });
|
|
190
195
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this._debugger.on(_debugger.Debugger.Events.PausedStateChanged, () => this._pausedStateChanged());
|
|
195
|
-
this._context.recorderAppForTest = this._recorderApp;
|
|
196
|
+
if (this._debugger.isPaused())
|
|
197
|
+
this._pausedStateChanged();
|
|
198
|
+
this._debugger.on(import_debugger.Debugger.Events.PausedStateChanged, () => this._pausedStateChanged());
|
|
196
199
|
}
|
|
197
200
|
_pausedStateChanged() {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
metadata,
|
|
202
|
-
sdkObject
|
|
203
|
-
} of this._debugger.pausedDetails()) {
|
|
204
|
-
if (!this._currentCallsMetadata.has(metadata)) this.onBeforeCall(sdkObject, metadata);
|
|
201
|
+
for (const { metadata, sdkObject } of this._debugger.pausedDetails()) {
|
|
202
|
+
if (!this._currentCallsMetadata.has(metadata))
|
|
203
|
+
this.onBeforeCall(sdkObject, metadata);
|
|
205
204
|
}
|
|
206
|
-
|
|
205
|
+
this.emit(RecorderEvent.PausedStateChanged, this._debugger.isPaused());
|
|
207
206
|
this._updateUserSources();
|
|
208
207
|
this.updateCallLog([...this._currentCallsMetadata.keys()]);
|
|
209
208
|
}
|
|
209
|
+
mode() {
|
|
210
|
+
return this._mode;
|
|
211
|
+
}
|
|
210
212
|
setMode(mode) {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
+
if (this._mode === mode)
|
|
214
|
+
return;
|
|
213
215
|
this._highlightedElement = {};
|
|
214
216
|
this._mode = mode;
|
|
215
|
-
|
|
216
|
-
this.
|
|
217
|
+
this.emit(RecorderEvent.ModeChanged, this._mode);
|
|
218
|
+
this._setEnabled(this._isRecording());
|
|
217
219
|
this._debugger.setMuted(this._isRecording());
|
|
218
|
-
if (this._mode !==
|
|
220
|
+
if (this._mode !== "none" && this._mode !== "standby" && this._context.pages().length === 1)
|
|
221
|
+
this._context.pages()[0].bringToFront().catch(() => {
|
|
222
|
+
});
|
|
219
223
|
this._refreshOverlay();
|
|
220
224
|
}
|
|
221
|
-
|
|
222
|
-
this.
|
|
223
|
-
|
|
224
|
-
mode() {
|
|
225
|
-
return this._mode;
|
|
225
|
+
url() {
|
|
226
|
+
const page = this._context.pages()[0];
|
|
227
|
+
return page?.mainFrame().url();
|
|
226
228
|
}
|
|
227
|
-
setHighlightedSelector(
|
|
228
|
-
this._highlightedElement = {
|
|
229
|
-
selector: (0, _locatorParser.locatorOrSelectorAsSelector)(language, selector, this._context.selectors().testIdAttributeName())
|
|
230
|
-
};
|
|
229
|
+
setHighlightedSelector(selector) {
|
|
230
|
+
this._highlightedElement = { selector: (0, import_locatorParser.locatorOrSelectorAsSelector)(this._currentLanguage, selector, this._context.selectors().testIdAttributeName()) };
|
|
231
231
|
this._refreshOverlay();
|
|
232
232
|
}
|
|
233
233
|
setHighlightedAriaTemplate(ariaTemplate) {
|
|
234
|
-
this._highlightedElement = {
|
|
235
|
-
|
|
236
|
-
|
|
234
|
+
this._highlightedElement = { ariaTemplate };
|
|
235
|
+
this._refreshOverlay();
|
|
236
|
+
}
|
|
237
|
+
step() {
|
|
238
|
+
this._debugger.resume(true);
|
|
239
|
+
}
|
|
240
|
+
setLanguage(language) {
|
|
241
|
+
this._currentLanguage = language;
|
|
237
242
|
this._refreshOverlay();
|
|
238
243
|
}
|
|
244
|
+
resume() {
|
|
245
|
+
this._debugger.resume(false);
|
|
246
|
+
}
|
|
247
|
+
pause() {
|
|
248
|
+
this._debugger.pauseOnNextStatement();
|
|
249
|
+
}
|
|
250
|
+
paused() {
|
|
251
|
+
return this._debugger.isPaused();
|
|
252
|
+
}
|
|
253
|
+
close() {
|
|
254
|
+
this._debugger.resume(false);
|
|
255
|
+
}
|
|
239
256
|
hideHighlightedSelector() {
|
|
240
257
|
this._highlightedElement = {};
|
|
241
258
|
this._refreshOverlay();
|
|
242
259
|
}
|
|
260
|
+
userSources() {
|
|
261
|
+
return [...this._userSources.values()];
|
|
262
|
+
}
|
|
263
|
+
callLog() {
|
|
264
|
+
return this._callLogs;
|
|
265
|
+
}
|
|
243
266
|
async _scopeHighlightedSelectorToFrame(frame) {
|
|
244
|
-
if (!this._highlightedElement.selector)
|
|
267
|
+
if (!this._highlightedElement.selector)
|
|
268
|
+
return;
|
|
245
269
|
try {
|
|
246
270
|
const mainFrame = frame._page.mainFrame();
|
|
247
271
|
const resolved = await mainFrame.selectors.resolveFrameForSelector(this._highlightedElement.selector);
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
if ((resolved === null || resolved === void 0 ? void 0 : resolved.frame) === frame) return (0, _selectorParser.stringifySelector)(resolved.info.parsed);
|
|
256
|
-
|
|
257
|
-
// selector points to a different frame, highlight nothing
|
|
258
|
-
return '';
|
|
272
|
+
if (!resolved)
|
|
273
|
+
return "";
|
|
274
|
+
if (resolved?.frame === mainFrame)
|
|
275
|
+
return (0, import_selectorParser.stringifySelector)(resolved.info.parsed);
|
|
276
|
+
if (resolved?.frame === frame)
|
|
277
|
+
return (0, import_selectorParser.stringifySelector)(resolved.info.parsed);
|
|
278
|
+
return "";
|
|
259
279
|
} catch {
|
|
260
|
-
return
|
|
280
|
+
return "";
|
|
261
281
|
}
|
|
262
282
|
}
|
|
263
|
-
setOutput(codegenId, outputFile) {
|
|
264
|
-
this._contextRecorder.setOutput(codegenId, outputFile);
|
|
265
|
-
}
|
|
266
283
|
_refreshOverlay() {
|
|
267
284
|
for (const page of this._context.pages()) {
|
|
268
|
-
for (const frame of page.frames())
|
|
285
|
+
for (const frame of page.frames())
|
|
286
|
+
frame.evaluateExpression("window.__pw_refreshOverlay()").catch(() => {
|
|
287
|
+
});
|
|
269
288
|
}
|
|
270
289
|
}
|
|
271
290
|
async onBeforeCall(sdkObject, metadata) {
|
|
272
|
-
if (this._omitCallTracking || this._isRecording())
|
|
291
|
+
if (this._omitCallTracking || this._isRecording())
|
|
292
|
+
return;
|
|
273
293
|
this._currentCallsMetadata.set(metadata, sdkObject);
|
|
274
294
|
this._updateUserSources();
|
|
275
295
|
this.updateCallLog([metadata]);
|
|
276
|
-
if (isScreenshotCommand(metadata))
|
|
277
|
-
|
|
278
|
-
|
|
296
|
+
if (isScreenshotCommand(metadata))
|
|
297
|
+
this.hideHighlightedSelector();
|
|
298
|
+
else if (metadata.params && metadata.params.selector)
|
|
299
|
+
this._highlightedElement = { selector: metadata.params.selector };
|
|
279
300
|
}
|
|
280
301
|
async onAfterCall(sdkObject, metadata) {
|
|
281
|
-
if (this._omitCallTracking || this._isRecording())
|
|
282
|
-
|
|
302
|
+
if (this._omitCallTracking || this._isRecording())
|
|
303
|
+
return;
|
|
304
|
+
if (!metadata.error)
|
|
305
|
+
this._currentCallsMetadata.delete(metadata);
|
|
283
306
|
this._updateUserSources();
|
|
284
307
|
this.updateCallLog([metadata]);
|
|
285
308
|
}
|
|
286
309
|
_updateUserSources() {
|
|
287
|
-
|
|
288
|
-
// Remove old decorations.
|
|
310
|
+
const timestamp = (0, import_utils2.monotonicTime)();
|
|
289
311
|
for (const source of this._userSources.values()) {
|
|
290
312
|
source.highlight = [];
|
|
291
|
-
source.revealLine =
|
|
313
|
+
source.revealLine = void 0;
|
|
292
314
|
}
|
|
293
|
-
|
|
294
|
-
// Apply new decorations.
|
|
295
|
-
let fileToSelect = undefined;
|
|
296
315
|
for (const metadata of this._currentCallsMetadata.keys()) {
|
|
297
|
-
if (!metadata.location)
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
line
|
|
301
|
-
} = metadata.location;
|
|
316
|
+
if (!metadata.location)
|
|
317
|
+
continue;
|
|
318
|
+
const { file, line } = metadata.location;
|
|
302
319
|
let source = this._userSources.get(file);
|
|
303
320
|
if (!source) {
|
|
304
|
-
source = {
|
|
305
|
-
isRecorded: false,
|
|
306
|
-
label: file,
|
|
307
|
-
id: file,
|
|
308
|
-
text: this._readSource(file),
|
|
309
|
-
highlight: [],
|
|
310
|
-
language: languageForFile(file)
|
|
311
|
-
};
|
|
321
|
+
source = { isPrimary: false, isRecorded: false, label: file, id: file, text: this._readSource(file), highlight: [], language: languageForFile(file), timestamp };
|
|
312
322
|
this._userSources.set(file, source);
|
|
313
323
|
}
|
|
314
324
|
if (line) {
|
|
315
325
|
const paused = this._debugger.isPaused(metadata);
|
|
316
|
-
source.highlight.push({
|
|
317
|
-
line,
|
|
318
|
-
type: metadata.error ? 'error' : paused ? 'paused' : 'running'
|
|
319
|
-
});
|
|
326
|
+
source.highlight.push({ line, type: metadata.error ? "error" : paused ? "paused" : "running" });
|
|
320
327
|
source.revealLine = line;
|
|
321
|
-
fileToSelect = source.id;
|
|
322
328
|
}
|
|
323
329
|
}
|
|
324
|
-
this.
|
|
325
|
-
if (fileToSelect) (_this$_recorderApp5 = this._recorderApp) === null || _this$_recorderApp5 === void 0 || _this$_recorderApp5.setRunningFile(fileToSelect);
|
|
330
|
+
this.emit(RecorderEvent.UserSourcesChanged, this.userSources());
|
|
326
331
|
}
|
|
327
|
-
|
|
328
|
-
var _this$_recorderApp6;
|
|
329
|
-
const primaryPage = this._context.pages()[0];
|
|
330
|
-
(_this$_recorderApp6 = this._recorderApp) === null || _this$_recorderApp6 === void 0 || _this$_recorderApp6.setSources([...this._recorderSources, ...this._userSources.values()], primaryPage === null || primaryPage === void 0 ? void 0 : primaryPage.mainFrame().url());
|
|
332
|
+
async onBeforeInputAction(sdkObject, metadata) {
|
|
331
333
|
}
|
|
332
|
-
async onBeforeInputAction(sdkObject, metadata) {}
|
|
333
334
|
async onCallLog(sdkObject, metadata, logName, message) {
|
|
334
335
|
this.updateCallLog([metadata]);
|
|
335
336
|
}
|
|
336
337
|
updateCallLog(metadatas) {
|
|
337
|
-
|
|
338
|
-
|
|
338
|
+
if (this._isRecording())
|
|
339
|
+
return;
|
|
339
340
|
const logs = [];
|
|
340
341
|
for (const metadata of metadatas) {
|
|
341
|
-
if (!metadata.method || metadata.internal)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
if (this.
|
|
345
|
-
|
|
342
|
+
if (!metadata.method || metadata.internal)
|
|
343
|
+
continue;
|
|
344
|
+
let status = "done";
|
|
345
|
+
if (this._currentCallsMetadata.has(metadata))
|
|
346
|
+
status = "in-progress";
|
|
347
|
+
if (this._debugger.isPaused(metadata))
|
|
348
|
+
status = "paused";
|
|
349
|
+
logs.push((0, import_recorderUtils.metadataToCallLog)(metadata, status));
|
|
346
350
|
}
|
|
347
|
-
|
|
351
|
+
this._callLogs = logs;
|
|
352
|
+
this.emit(RecorderEvent.CallLogsUpdated, logs);
|
|
348
353
|
}
|
|
349
354
|
_isRecording() {
|
|
350
|
-
return [
|
|
355
|
+
return ["recording", "assertingText", "assertingVisibility", "assertingValue", "assertingSnapshot"].includes(this._mode);
|
|
351
356
|
}
|
|
352
357
|
_readSource(fileName) {
|
|
353
358
|
try {
|
|
354
|
-
return
|
|
359
|
+
return import_fs.default.readFileSync(fileName, "utf-8");
|
|
355
360
|
} catch (e) {
|
|
356
|
-
return
|
|
361
|
+
return "// No source available";
|
|
357
362
|
}
|
|
358
363
|
}
|
|
364
|
+
_setEnabled(enabled) {
|
|
365
|
+
this._enabled = enabled;
|
|
366
|
+
}
|
|
367
|
+
async _onPage(page) {
|
|
368
|
+
const frame = page.mainFrame();
|
|
369
|
+
page.on(import_page.Page.Events.Close, () => {
|
|
370
|
+
this._signalProcessor.addAction({
|
|
371
|
+
frame: this._describeMainFrame(page),
|
|
372
|
+
action: {
|
|
373
|
+
name: "closePage",
|
|
374
|
+
signals: []
|
|
375
|
+
},
|
|
376
|
+
startTime: (0, import_utils2.monotonicTime)()
|
|
377
|
+
});
|
|
378
|
+
this._pageAliases.delete(page);
|
|
379
|
+
this._filePrimaryURLChanged();
|
|
380
|
+
});
|
|
381
|
+
frame.on(import_frames.Frame.Events.InternalNavigation, (event) => {
|
|
382
|
+
if (event.isPublic) {
|
|
383
|
+
this._onFrameNavigated(frame, page);
|
|
384
|
+
this._filePrimaryURLChanged();
|
|
385
|
+
}
|
|
386
|
+
});
|
|
387
|
+
page.on(import_page.Page.Events.Download, () => this._onDownload(page));
|
|
388
|
+
const suffix = this._pageAliases.size ? String(++this._lastPopupOrdinal) : "";
|
|
389
|
+
const pageAlias = "page" + suffix;
|
|
390
|
+
this._pageAliases.set(page, pageAlias);
|
|
391
|
+
if (page.opener()) {
|
|
392
|
+
this._onPopup(page.opener(), page);
|
|
393
|
+
} else {
|
|
394
|
+
this._signalProcessor.addAction({
|
|
395
|
+
frame: this._describeMainFrame(page),
|
|
396
|
+
action: {
|
|
397
|
+
name: "openPage",
|
|
398
|
+
url: page.mainFrame().url(),
|
|
399
|
+
signals: []
|
|
400
|
+
},
|
|
401
|
+
startTime: (0, import_utils2.monotonicTime)()
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
this._filePrimaryURLChanged();
|
|
405
|
+
}
|
|
406
|
+
_filePrimaryURLChanged() {
|
|
407
|
+
const page = this._context.pages()[0];
|
|
408
|
+
this.emit(RecorderEvent.PageNavigated, page?.mainFrame().url());
|
|
409
|
+
}
|
|
410
|
+
clear() {
|
|
411
|
+
if (this._params.mode === "recording") {
|
|
412
|
+
for (const page of this._context.pages())
|
|
413
|
+
this._onFrameNavigated(page.mainFrame(), page);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
_describeMainFrame(page) {
|
|
417
|
+
return {
|
|
418
|
+
pageGuid: page.guid,
|
|
419
|
+
pageAlias: this._pageAliases.get(page),
|
|
420
|
+
framePath: []
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
async _describeFrame(frame) {
|
|
424
|
+
return {
|
|
425
|
+
pageGuid: frame._page.guid,
|
|
426
|
+
pageAlias: this._pageAliases.get(frame._page),
|
|
427
|
+
framePath: await (0, import_recorderUtils.generateFrameSelector)(frame)
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
_testIdAttributeName() {
|
|
431
|
+
return this._params.testIdAttributeName || this._context.selectors().testIdAttributeName() || "data-testid";
|
|
432
|
+
}
|
|
433
|
+
async _createActionInContext(frame, action) {
|
|
434
|
+
const frameDescription = await this._describeFrame(frame);
|
|
435
|
+
const actionInContext = {
|
|
436
|
+
frame: frameDescription,
|
|
437
|
+
action,
|
|
438
|
+
description: void 0,
|
|
439
|
+
startTime: (0, import_utils2.monotonicTime)()
|
|
440
|
+
};
|
|
441
|
+
return actionInContext;
|
|
442
|
+
}
|
|
443
|
+
async _performAction(frame, action) {
|
|
444
|
+
const actionInContext = await this._createActionInContext(frame, action);
|
|
445
|
+
this._signalProcessor.addAction(actionInContext);
|
|
446
|
+
if (actionInContext.action.name !== "openPage" && actionInContext.action.name !== "closePage")
|
|
447
|
+
await (0, import_recorderRunner.performAction)(this._pageAliases, actionInContext);
|
|
448
|
+
actionInContext.endTime = (0, import_utils2.monotonicTime)();
|
|
449
|
+
}
|
|
450
|
+
async _recordAction(frame, action) {
|
|
451
|
+
this._signalProcessor.addAction(await this._createActionInContext(frame, action));
|
|
452
|
+
}
|
|
453
|
+
_onFrameNavigated(frame, page) {
|
|
454
|
+
const pageAlias = this._pageAliases.get(page);
|
|
455
|
+
this._signalProcessor.signal(pageAlias, frame, { name: "navigation", url: frame.url() });
|
|
456
|
+
}
|
|
457
|
+
_onPopup(page, popup) {
|
|
458
|
+
const pageAlias = this._pageAliases.get(page);
|
|
459
|
+
const popupAlias = this._pageAliases.get(popup);
|
|
460
|
+
this._signalProcessor.signal(pageAlias, page.mainFrame(), { name: "popup", popupAlias });
|
|
461
|
+
}
|
|
462
|
+
_onDownload(page) {
|
|
463
|
+
const pageAlias = this._pageAliases.get(page);
|
|
464
|
+
++this._lastDownloadOrdinal;
|
|
465
|
+
this._signalProcessor.signal(pageAlias, page.mainFrame(), { name: "download", downloadAlias: this._lastDownloadOrdinal ? String(this._lastDownloadOrdinal) : "" });
|
|
466
|
+
}
|
|
467
|
+
_onDialog(page) {
|
|
468
|
+
const pageAlias = this._pageAliases.get(page);
|
|
469
|
+
++this._lastDialogOrdinal;
|
|
470
|
+
this._signalProcessor.signal(pageAlias, page.mainFrame(), { name: "dialog", dialogAlias: this._lastDialogOrdinal ? String(this._lastDialogOrdinal) : "" });
|
|
471
|
+
}
|
|
359
472
|
}
|
|
360
|
-
exports.Recorder = Recorder;
|
|
361
473
|
function isScreenshotCommand(metadata) {
|
|
362
|
-
return metadata.method.toLowerCase().includes(
|
|
474
|
+
return metadata.method.toLowerCase().includes("screenshot");
|
|
363
475
|
}
|
|
364
476
|
function languageForFile(file) {
|
|
365
|
-
if (file.endsWith(
|
|
366
|
-
|
|
367
|
-
if (file.endsWith(
|
|
368
|
-
|
|
369
|
-
|
|
477
|
+
if (file.endsWith(".py"))
|
|
478
|
+
return "python";
|
|
479
|
+
if (file.endsWith(".java"))
|
|
480
|
+
return "java";
|
|
481
|
+
if (file.endsWith(".cs"))
|
|
482
|
+
return "csharp";
|
|
483
|
+
return "javascript";
|
|
484
|
+
}
|
|
485
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
486
|
+
0 && (module.exports = {
|
|
487
|
+
Recorder,
|
|
488
|
+
RecorderEvent
|
|
489
|
+
});
|