@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
|
@@ -1,265 +1,270 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _dispatcher = require("../../dispatchers/dispatcher");
|
|
20
|
-
var _errors = require("../../errors");
|
|
21
|
-
var _fileUtils = require("../../utils/fileUtils");
|
|
22
|
-
var _harTracer = require("../../har/harTracer");
|
|
23
|
-
var _instrumentation = require("../../instrumentation");
|
|
24
|
-
var _page = require("../../page");
|
|
25
|
-
var _secretsFilter = require("../../../checkly/secretsFilter");
|
|
26
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
|
-
/**
|
|
28
|
-
* Copyright (c) Microsoft Corporation.
|
|
29
|
-
*
|
|
30
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
31
|
-
* you may not use this file except in compliance with the License.
|
|
32
|
-
* You may obtain a copy of the License at
|
|
33
|
-
*
|
|
34
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
35
|
-
*
|
|
36
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
37
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
38
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
39
|
-
* See the License for the specific language governing permissions and
|
|
40
|
-
* limitations under the License.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
const version = 7;
|
|
44
|
-
const kScreencastOptions = {
|
|
45
|
-
width: 800,
|
|
46
|
-
height: 600,
|
|
47
|
-
quality: 90
|
|
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;
|
|
48
19
|
};
|
|
49
|
-
|
|
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 tracing_exports = {};
|
|
30
|
+
__export(tracing_exports, {
|
|
31
|
+
Tracing: () => Tracing,
|
|
32
|
+
shouldCaptureSnapshot: () => shouldCaptureSnapshot
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(tracing_exports);
|
|
35
|
+
var import_fs = __toESM(require("fs"));
|
|
36
|
+
var import_os = __toESM(require("os"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_snapshotter = require("./snapshotter");
|
|
39
|
+
var import_protocolMetainfo = require("../../../utils/isomorphic/protocolMetainfo");
|
|
40
|
+
var import_assert = require("../../../utils/isomorphic/assert");
|
|
41
|
+
var import_time = require("../../../utils/isomorphic/time");
|
|
42
|
+
var import_eventsHelper = require("../../utils/eventsHelper");
|
|
43
|
+
var import_crypto = require("../../utils/crypto");
|
|
44
|
+
var import_artifact = require("../../artifact");
|
|
45
|
+
var import_browserContext = require("../../browserContext");
|
|
46
|
+
var import_dispatcher = require("../../dispatchers/dispatcher");
|
|
47
|
+
var import_errors = require("../../errors");
|
|
48
|
+
var import_fileUtils = require("../../utils/fileUtils");
|
|
49
|
+
var import_harTracer = require("../../har/harTracer");
|
|
50
|
+
var import_instrumentation = require("../../instrumentation");
|
|
51
|
+
var import_page = require("../../page");
|
|
52
|
+
var import_secretsFilter = require("../../../checkly/secretsFilter");
|
|
53
|
+
var import_progress = require("../../progress");
|
|
54
|
+
const version = 8;
|
|
55
|
+
const kScreencastOptions = { width: 800, height: 600, quality: 90 };
|
|
56
|
+
class Tracing extends import_instrumentation.SdkObject {
|
|
50
57
|
constructor(context, tracesDir) {
|
|
51
|
-
super(context,
|
|
52
|
-
this._fs = new
|
|
53
|
-
this._snapshotter = void 0;
|
|
54
|
-
this._harTracer = void 0;
|
|
58
|
+
super(context, "tracing");
|
|
59
|
+
this._fs = new import_fileUtils.SerializedFS();
|
|
55
60
|
this._screencastListeners = [];
|
|
56
61
|
this._eventListeners = [];
|
|
57
|
-
this._context = void 0;
|
|
58
|
-
// Note: state should only be touched inside API methods, but not inside trace operations.
|
|
59
|
-
this._state = void 0;
|
|
60
62
|
this._isStopping = false;
|
|
61
|
-
this.
|
|
62
|
-
this.
|
|
63
|
-
this._allResources = new Set();
|
|
64
|
-
this._contextCreatedEvent = void 0;
|
|
65
|
-
this._pendingHarEntries = new Set();
|
|
66
|
-
this._secretsFilter = void 0;
|
|
63
|
+
this._allResources = /* @__PURE__ */ new Set();
|
|
64
|
+
this._pendingHarEntries = /* @__PURE__ */ new Set();
|
|
67
65
|
this._context = context;
|
|
68
66
|
this._precreatedTracesDir = tracesDir;
|
|
69
|
-
this._secretsFilter = (0,
|
|
70
|
-
this._harTracer = new
|
|
71
|
-
content:
|
|
67
|
+
this._secretsFilter = (0, import_secretsFilter.secretsFilter)();
|
|
68
|
+
this._harTracer = new import_harTracer.HarTracer(context, null, this, {
|
|
69
|
+
content: "attach",
|
|
72
70
|
includeTraceInfo: true,
|
|
73
71
|
recordRequestOverrides: false,
|
|
74
72
|
waitForContentOnStop: false
|
|
75
73
|
});
|
|
76
|
-
const testIdAttributeName =
|
|
74
|
+
const testIdAttributeName = "selectors" in context ? context.selectors().testIdAttributeName() : void 0;
|
|
77
75
|
this._contextCreatedEvent = {
|
|
78
76
|
version,
|
|
79
|
-
type:
|
|
80
|
-
origin:
|
|
81
|
-
browserName:
|
|
77
|
+
type: "context-options",
|
|
78
|
+
origin: "library",
|
|
79
|
+
browserName: "",
|
|
82
80
|
options: {},
|
|
83
81
|
platform: process.platform,
|
|
84
82
|
wallTime: 0,
|
|
85
83
|
monotonicTime: 0,
|
|
86
|
-
sdkLanguage:
|
|
84
|
+
sdkLanguage: this._sdkLanguage(),
|
|
87
85
|
testIdAttributeName,
|
|
88
86
|
contextId: context.guid
|
|
89
87
|
};
|
|
90
|
-
if (context instanceof
|
|
91
|
-
this._snapshotter = new
|
|
92
|
-
(0,
|
|
88
|
+
if (context instanceof import_browserContext.BrowserContext) {
|
|
89
|
+
this._snapshotter = new import_snapshotter.Snapshotter(context, this);
|
|
90
|
+
(0, import_assert.assert)(tracesDir, "tracesDir must be specified for BrowserContext");
|
|
93
91
|
this._contextCreatedEvent.browserName = context._browser.options.name;
|
|
94
92
|
this._contextCreatedEvent.channel = context._browser.options.channel;
|
|
95
93
|
this._contextCreatedEvent.options = context._options;
|
|
96
94
|
}
|
|
97
95
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
})
|
|
104
|
-
await this.stop();
|
|
105
|
-
(
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (this.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
// and conflict.
|
|
116
|
-
const traceName = options.name || (0, _crypto.createGuid)();
|
|
96
|
+
_sdkLanguage() {
|
|
97
|
+
return this._context instanceof import_browserContext.BrowserContext ? this._context._browser.sdkLanguage() : this._context.attribution.playwright.options.sdkLanguage;
|
|
98
|
+
}
|
|
99
|
+
async resetForReuse(progress) {
|
|
100
|
+
await this.stopChunk(progress, { mode: "discard" }).catch(() => {
|
|
101
|
+
});
|
|
102
|
+
await this.stop(progress);
|
|
103
|
+
if (this._snapshotter)
|
|
104
|
+
await progress.race(this._snapshotter.resetForReuse());
|
|
105
|
+
}
|
|
106
|
+
start(options) {
|
|
107
|
+
if (this._isStopping)
|
|
108
|
+
throw new Error("Cannot start tracing while stopping");
|
|
109
|
+
if (this._state)
|
|
110
|
+
throw new Error("Tracing has been already started");
|
|
111
|
+
this._contextCreatedEvent.sdkLanguage = this._sdkLanguage();
|
|
112
|
+
const traceName = options.name || (0, import_crypto.createGuid)();
|
|
117
113
|
const tracesDir = this._createTracesDirIfNeeded();
|
|
118
|
-
|
|
119
|
-
// Init the state synchronously.
|
|
120
114
|
this._state = {
|
|
121
115
|
options,
|
|
122
116
|
traceName,
|
|
123
117
|
tracesDir,
|
|
124
|
-
traceFile:
|
|
125
|
-
networkFile:
|
|
126
|
-
resourcesDir:
|
|
118
|
+
traceFile: import_path.default.join(tracesDir, traceName + ".trace"),
|
|
119
|
+
networkFile: import_path.default.join(tracesDir, traceName + ".network"),
|
|
120
|
+
resourcesDir: import_path.default.join(tracesDir, "resources"),
|
|
127
121
|
chunkOrdinal: 0,
|
|
128
|
-
traceSha1s: new Set(),
|
|
129
|
-
networkSha1s: new Set(),
|
|
122
|
+
traceSha1s: /* @__PURE__ */ new Set(),
|
|
123
|
+
networkSha1s: /* @__PURE__ */ new Set(),
|
|
130
124
|
recording: false,
|
|
131
|
-
callIds: new Set(),
|
|
125
|
+
callIds: /* @__PURE__ */ new Set(),
|
|
132
126
|
groupStack: []
|
|
133
127
|
};
|
|
134
128
|
this._fs.mkdir(this._state.resourcesDir);
|
|
135
|
-
this._fs.writeFile(this._state.networkFile,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
if (!this._state) throw new Error('Must start tracing before starting a new chunk');
|
|
147
|
-
if (this._isStopping) throw new Error('Cannot start a trace chunk while stopping');
|
|
129
|
+
this._fs.writeFile(this._state.networkFile, "");
|
|
130
|
+
if (options.snapshots)
|
|
131
|
+
this._harTracer.start({ omitScripts: !options.live });
|
|
132
|
+
}
|
|
133
|
+
async startChunk(progress, options = {}) {
|
|
134
|
+
if (this._state && this._state.recording)
|
|
135
|
+
await this.stopChunk(progress, { mode: "discard" });
|
|
136
|
+
if (!this._state)
|
|
137
|
+
throw new Error("Must start tracing before starting a new chunk");
|
|
138
|
+
if (this._isStopping)
|
|
139
|
+
throw new Error("Cannot start a trace chunk while stopping");
|
|
148
140
|
this._state.recording = true;
|
|
149
141
|
this._state.callIds.clear();
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
|
|
157
|
-
this._fs.mkdir(
|
|
142
|
+
const preserveNetworkResources = this._context instanceof import_browserContext.BrowserContext;
|
|
143
|
+
if (options.name && options.name !== this._state.traceName)
|
|
144
|
+
this._changeTraceName(this._state, options.name, preserveNetworkResources);
|
|
145
|
+
else
|
|
146
|
+
this._allocateNewTraceFile(this._state);
|
|
147
|
+
if (!preserveNetworkResources)
|
|
148
|
+
this._fs.writeFile(this._state.networkFile, "");
|
|
149
|
+
this._fs.mkdir(import_path.default.dirname(this._state.traceFile));
|
|
158
150
|
const event = {
|
|
159
151
|
...this._contextCreatedEvent,
|
|
160
152
|
title: options.title,
|
|
161
153
|
wallTime: Date.now(),
|
|
162
|
-
monotonicTime: (0,
|
|
154
|
+
monotonicTime: (0, import_time.monotonicTime)()
|
|
163
155
|
};
|
|
164
156
|
this._appendTraceEvent(event);
|
|
165
157
|
this._context.instrumentation.addListener(this, this._context);
|
|
166
|
-
this._eventListeners.push(
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
158
|
+
this._eventListeners.push(
|
|
159
|
+
import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.Console, this._onConsoleMessage.bind(this)),
|
|
160
|
+
import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.PageError, this._onPageError.bind(this))
|
|
161
|
+
);
|
|
162
|
+
if (this._state.options.screenshots)
|
|
163
|
+
this._startScreencast();
|
|
164
|
+
if (this._state.options.snapshots)
|
|
165
|
+
await this._snapshotter?.start();
|
|
166
|
+
return { traceName: this._state.traceName };
|
|
172
167
|
}
|
|
173
168
|
_currentGroupId() {
|
|
174
|
-
|
|
175
|
-
return (_this$_state = this._state) !== null && _this$_state !== void 0 && _this$_state.groupStack.length ? this._state.groupStack[this._state.groupStack.length - 1] : undefined;
|
|
169
|
+
return this._state?.groupStack.length ? this._state.groupStack[this._state.groupStack.length - 1] : void 0;
|
|
176
170
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
171
|
+
group(name, location, metadata) {
|
|
172
|
+
if (!this._state)
|
|
173
|
+
return;
|
|
180
174
|
const stackFrames = [];
|
|
181
|
-
const {
|
|
182
|
-
file,
|
|
183
|
-
line,
|
|
184
|
-
column
|
|
185
|
-
} = (_ref = location !== null && location !== void 0 ? location : metadata.location) !== null && _ref !== void 0 ? _ref : {};
|
|
175
|
+
const { file, line, column } = location ?? metadata.location ?? {};
|
|
186
176
|
if (file) {
|
|
187
177
|
stackFrames.push({
|
|
188
178
|
file,
|
|
189
|
-
line: line
|
|
190
|
-
column: column
|
|
179
|
+
line: line ?? 0,
|
|
180
|
+
column: column ?? 0
|
|
191
181
|
});
|
|
192
182
|
}
|
|
193
183
|
const event = {
|
|
194
|
-
type:
|
|
184
|
+
type: "before",
|
|
195
185
|
callId: metadata.id,
|
|
196
186
|
startTime: metadata.startTime,
|
|
197
|
-
|
|
198
|
-
class:
|
|
199
|
-
method:
|
|
187
|
+
title: name,
|
|
188
|
+
class: "Tracing",
|
|
189
|
+
method: "tracingGroup",
|
|
200
190
|
params: {},
|
|
201
191
|
stepId: metadata.stepId,
|
|
202
192
|
stack: stackFrames
|
|
203
193
|
};
|
|
204
|
-
if (this._currentGroupId())
|
|
194
|
+
if (this._currentGroupId())
|
|
195
|
+
event.parentId = this._currentGroupId();
|
|
205
196
|
this._state.groupStack.push(event.callId);
|
|
206
197
|
this._appendTraceEvent(event);
|
|
207
198
|
}
|
|
208
199
|
groupEnd() {
|
|
209
|
-
if (!this._state)
|
|
200
|
+
if (!this._state)
|
|
201
|
+
return;
|
|
210
202
|
const callId = this._state.groupStack.pop();
|
|
211
|
-
if (!callId)
|
|
203
|
+
if (!callId)
|
|
204
|
+
return;
|
|
212
205
|
const event = {
|
|
213
|
-
type:
|
|
206
|
+
type: "after",
|
|
214
207
|
callId,
|
|
215
|
-
endTime: (0,
|
|
208
|
+
endTime: (0, import_time.monotonicTime)()
|
|
216
209
|
};
|
|
217
210
|
this._appendTraceEvent(event);
|
|
218
211
|
}
|
|
219
212
|
_startScreencast() {
|
|
220
|
-
if (!(this._context instanceof
|
|
221
|
-
|
|
222
|
-
|
|
213
|
+
if (!(this._context instanceof import_browserContext.BrowserContext))
|
|
214
|
+
return;
|
|
215
|
+
for (const page of this._context.pages())
|
|
216
|
+
this._startScreencastInPage(page);
|
|
217
|
+
this._screencastListeners.push(
|
|
218
|
+
import_eventsHelper.eventsHelper.addEventListener(this._context, import_browserContext.BrowserContext.Events.Page, this._startScreencastInPage.bind(this))
|
|
219
|
+
);
|
|
223
220
|
}
|
|
224
221
|
_stopScreencast() {
|
|
225
|
-
|
|
226
|
-
if (!(this._context instanceof
|
|
227
|
-
|
|
222
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._screencastListeners);
|
|
223
|
+
if (!(this._context instanceof import_browserContext.BrowserContext))
|
|
224
|
+
return;
|
|
225
|
+
for (const page of this._context.pages())
|
|
226
|
+
page.setScreencastOptions(null);
|
|
228
227
|
}
|
|
229
228
|
_allocateNewTraceFile(state) {
|
|
230
229
|
const suffix = state.chunkOrdinal ? `-chunk${state.chunkOrdinal}` : ``;
|
|
231
230
|
state.chunkOrdinal++;
|
|
232
|
-
state.traceFile =
|
|
231
|
+
state.traceFile = import_path.default.join(state.tracesDir, `${state.traceName}${suffix}.trace`);
|
|
233
232
|
}
|
|
234
233
|
_changeTraceName(state, name, preserveNetworkResources) {
|
|
235
234
|
state.traceName = name;
|
|
236
|
-
state.chunkOrdinal = 0;
|
|
235
|
+
state.chunkOrdinal = 0;
|
|
237
236
|
this._allocateNewTraceFile(state);
|
|
238
|
-
const newNetworkFile =
|
|
239
|
-
if (preserveNetworkResources)
|
|
237
|
+
const newNetworkFile = import_path.default.join(state.tracesDir, name + ".network");
|
|
238
|
+
if (preserveNetworkResources)
|
|
239
|
+
this._fs.copyFile(state.networkFile, newNetworkFile);
|
|
240
240
|
state.networkFile = newNetworkFile;
|
|
241
241
|
}
|
|
242
|
-
async stop() {
|
|
243
|
-
if (!this._state)
|
|
244
|
-
|
|
245
|
-
if (this.
|
|
242
|
+
async stop(progress) {
|
|
243
|
+
if (!this._state)
|
|
244
|
+
return;
|
|
245
|
+
if (this._isStopping)
|
|
246
|
+
throw new Error(`Tracing is already stopping`);
|
|
247
|
+
if (this._state.recording)
|
|
248
|
+
throw new Error(`Must stop trace file before stopping tracing`);
|
|
246
249
|
this._closeAllGroups();
|
|
247
250
|
this._harTracer.stop();
|
|
248
251
|
this.flushHarEntries();
|
|
249
|
-
await this._fs.syncAndGetError()
|
|
250
|
-
|
|
252
|
+
await progress.race(this._fs.syncAndGetError()).finally(() => {
|
|
253
|
+
this._state = void 0;
|
|
254
|
+
});
|
|
251
255
|
}
|
|
252
256
|
async deleteTmpTracesDir() {
|
|
253
|
-
if (this._tracesTmpDir)
|
|
257
|
+
if (this._tracesTmpDir)
|
|
258
|
+
await (0, import_fileUtils.removeFolders)([this._tracesTmpDir]);
|
|
254
259
|
}
|
|
255
260
|
_createTracesDirIfNeeded() {
|
|
256
|
-
if (this._precreatedTracesDir)
|
|
257
|
-
|
|
261
|
+
if (this._precreatedTracesDir)
|
|
262
|
+
return this._precreatedTracesDir;
|
|
263
|
+
this._tracesTmpDir = import_fs.default.mkdtempSync(import_path.default.join(import_os.default.tmpdir(), "playwright-tracing-"));
|
|
258
264
|
return this._tracesTmpDir;
|
|
259
265
|
}
|
|
260
266
|
abort() {
|
|
261
|
-
|
|
262
|
-
(_this$_snapshotter3 = this._snapshotter) === null || _this$_snapshotter3 === void 0 || _this$_snapshotter3.dispose();
|
|
267
|
+
this._snapshotter?.dispose();
|
|
263
268
|
this._harTracer.stop();
|
|
264
269
|
}
|
|
265
270
|
async flush() {
|
|
@@ -267,120 +272,108 @@ class Tracing extends _instrumentation.SdkObject {
|
|
|
267
272
|
await this._fs.syncAndGetError();
|
|
268
273
|
}
|
|
269
274
|
_closeAllGroups() {
|
|
270
|
-
while (this._currentGroupId())
|
|
275
|
+
while (this._currentGroupId())
|
|
276
|
+
this.groupEnd();
|
|
271
277
|
}
|
|
272
|
-
async stopChunk(params) {
|
|
273
|
-
|
|
274
|
-
|
|
278
|
+
async stopChunk(progress, params) {
|
|
279
|
+
if (this._isStopping)
|
|
280
|
+
throw new Error(`Tracing is already stopping`);
|
|
275
281
|
this._isStopping = true;
|
|
276
282
|
if (!this._state || !this._state.recording) {
|
|
277
283
|
this._isStopping = false;
|
|
278
|
-
if (params.mode !==
|
|
284
|
+
if (params.mode !== "discard")
|
|
285
|
+
throw new Error(`Must start tracing before stopping`);
|
|
279
286
|
return {};
|
|
280
287
|
}
|
|
281
288
|
this._closeAllGroups();
|
|
282
289
|
this._context.instrumentation.removeListener(this);
|
|
283
|
-
|
|
284
|
-
if (this._state.options.screenshots)
|
|
285
|
-
|
|
290
|
+
import_eventsHelper.eventsHelper.removeEventListeners(this._eventListeners);
|
|
291
|
+
if (this._state.options.screenshots)
|
|
292
|
+
this._stopScreencast();
|
|
293
|
+
if (this._state.options.snapshots)
|
|
294
|
+
this._snapshotter?.stop();
|
|
286
295
|
this.flushHarEntries();
|
|
287
|
-
|
|
288
|
-
// Network file survives across chunks, make a snapshot before returning the resulting entries.
|
|
289
|
-
// We should pick a name starting with "traceName" and ending with .network.
|
|
290
|
-
// Something like <traceName>someSuffixHere.network.
|
|
291
|
-
// However, this name must not clash with any other "traceName".network in the same tracesDir.
|
|
292
|
-
// We can use <traceName>-<guid>.network, but "-pwnetcopy-0" suffix is more readable
|
|
293
|
-
// and makes it easier to debug future issues.
|
|
294
|
-
const newNetworkFile = _path.default.join(this._state.tracesDir, this._state.traceName + `-pwnetcopy-${this._state.chunkOrdinal}.network`);
|
|
296
|
+
const newNetworkFile = import_path.default.join(this._state.tracesDir, this._state.traceName + `-pwnetcopy-${this._state.chunkOrdinal}.network`);
|
|
295
297
|
const entries = [];
|
|
296
|
-
entries.push({
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
value: newNetworkFile
|
|
303
|
-
});
|
|
304
|
-
for (const sha1 of new Set([...this._state.traceSha1s, ...this._state.networkSha1s])) entries.push({
|
|
305
|
-
name: _path.default.join('resources', sha1),
|
|
306
|
-
value: _path.default.join(this._state.resourcesDir, sha1)
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
// Only reset trace sha1s, network resources are preserved between chunks.
|
|
310
|
-
this._state.traceSha1s = new Set();
|
|
311
|
-
if (params.mode === 'discard') {
|
|
298
|
+
entries.push({ name: "trace.trace", value: this._state.traceFile });
|
|
299
|
+
entries.push({ name: "trace.network", value: newNetworkFile });
|
|
300
|
+
for (const sha1 of /* @__PURE__ */ new Set([...this._state.traceSha1s, ...this._state.networkSha1s]))
|
|
301
|
+
entries.push({ name: import_path.default.join("resources", sha1), value: import_path.default.join(this._state.resourcesDir, sha1) });
|
|
302
|
+
this._state.traceSha1s = /* @__PURE__ */ new Set();
|
|
303
|
+
if (params.mode === "discard") {
|
|
312
304
|
this._isStopping = false;
|
|
313
305
|
this._state.recording = false;
|
|
314
306
|
return {};
|
|
315
307
|
}
|
|
316
308
|
this._fs.copyFile(this._state.networkFile, newNetworkFile);
|
|
317
|
-
const zipFileName = this._state.traceFile +
|
|
318
|
-
if (params.mode ===
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const error = await this._fs.syncAndGetError();
|
|
309
|
+
const zipFileName = this._state.traceFile + ".zip";
|
|
310
|
+
if (params.mode === "archive")
|
|
311
|
+
this._fs.zip(entries, zipFileName);
|
|
312
|
+
const error = await progress.race(this._fs.syncAndGetError()).catch((e) => e);
|
|
322
313
|
this._isStopping = false;
|
|
323
|
-
if (this._state)
|
|
324
|
-
|
|
325
|
-
// IMPORTANT: no awaits after this point, to make sure recording state is correct.
|
|
326
|
-
|
|
314
|
+
if (this._state)
|
|
315
|
+
this._state.recording = false;
|
|
327
316
|
if (error) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
if (this._context instanceof _browserContext.BrowserContext && !this._context._browser.isConnected()) return {};
|
|
317
|
+
if (!(0, import_progress.isAbortError)(error) && this._context instanceof import_browserContext.BrowserContext && !this._context._browser.isConnected())
|
|
318
|
+
return {};
|
|
331
319
|
throw error;
|
|
332
320
|
}
|
|
333
|
-
if (params.mode ===
|
|
334
|
-
entries
|
|
335
|
-
|
|
336
|
-
const artifact = new _artifact.Artifact(this._context, zipFileName);
|
|
321
|
+
if (params.mode === "entries")
|
|
322
|
+
return { entries };
|
|
323
|
+
const artifact = new import_artifact.Artifact(this._context, zipFileName);
|
|
337
324
|
artifact.reportFinished();
|
|
338
|
-
return {
|
|
339
|
-
artifact
|
|
340
|
-
};
|
|
325
|
+
return { artifact };
|
|
341
326
|
}
|
|
342
327
|
async _captureSnapshot(snapshotName, sdkObject, metadata) {
|
|
343
|
-
if (!this._snapshotter)
|
|
344
|
-
|
|
345
|
-
if (!
|
|
346
|
-
|
|
347
|
-
|
|
328
|
+
if (!this._snapshotter)
|
|
329
|
+
return;
|
|
330
|
+
if (!sdkObject.attribution.page)
|
|
331
|
+
return;
|
|
332
|
+
if (!this._snapshotter.started())
|
|
333
|
+
return;
|
|
334
|
+
if (!shouldCaptureSnapshot(metadata))
|
|
335
|
+
return;
|
|
336
|
+
await this._snapshotter.captureSnapshot(sdkObject.attribution.page, metadata.id, snapshotName).catch(() => {
|
|
337
|
+
});
|
|
348
338
|
}
|
|
349
339
|
onBeforeCall(sdkObject, metadata) {
|
|
350
|
-
var _sdkObject$attributio, _this$_state2;
|
|
351
|
-
// IMPORTANT: no awaits before this._appendTraceEvent in this method.
|
|
352
340
|
const event = createBeforeActionTraceEvent(metadata, this._currentGroupId());
|
|
353
|
-
if (!event)
|
|
354
|
-
|
|
341
|
+
if (!event)
|
|
342
|
+
return Promise.resolve();
|
|
343
|
+
sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();
|
|
355
344
|
event.beforeSnapshot = `before@${metadata.id}`;
|
|
356
|
-
|
|
345
|
+
this._state?.callIds.add(metadata.id);
|
|
357
346
|
this._appendTraceEvent(event);
|
|
358
347
|
return this._captureSnapshot(event.beforeSnapshot, sdkObject, metadata);
|
|
359
348
|
}
|
|
360
349
|
onBeforeInputAction(sdkObject, metadata) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
// IMPORTANT: no awaits before this._appendTraceEvent in this method.
|
|
350
|
+
if (!this._state?.callIds.has(metadata.id))
|
|
351
|
+
return Promise.resolve();
|
|
364
352
|
const event = createInputActionTraceEvent(metadata);
|
|
365
|
-
if (!event)
|
|
366
|
-
|
|
353
|
+
if (!event)
|
|
354
|
+
return Promise.resolve();
|
|
355
|
+
sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();
|
|
367
356
|
event.inputSnapshot = `input@${metadata.id}`;
|
|
368
357
|
this._appendTraceEvent(event);
|
|
369
358
|
return this._captureSnapshot(event.inputSnapshot, sdkObject, metadata);
|
|
370
359
|
}
|
|
371
360
|
onCallLog(sdkObject, metadata, logName, message) {
|
|
372
|
-
if (metadata.isServerSide || metadata.internal)
|
|
373
|
-
|
|
361
|
+
if (metadata.isServerSide || metadata.internal)
|
|
362
|
+
return;
|
|
363
|
+
if (logName !== "api")
|
|
364
|
+
return;
|
|
374
365
|
const event = createActionLogTraceEvent(metadata, message);
|
|
375
|
-
if (event)
|
|
366
|
+
if (event)
|
|
367
|
+
this._appendTraceEvent(event);
|
|
376
368
|
}
|
|
377
369
|
async onAfterCall(sdkObject, metadata) {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
370
|
+
if (!this._state?.callIds.has(metadata.id))
|
|
371
|
+
return;
|
|
372
|
+
this._state?.callIds.delete(metadata.id);
|
|
381
373
|
const event = createAfterActionTraceEvent(metadata);
|
|
382
|
-
if (!event)
|
|
383
|
-
|
|
374
|
+
if (!event)
|
|
375
|
+
return;
|
|
376
|
+
sdkObject.attribution.page?.temporarilyDisableTracingScreencastThrottling();
|
|
384
377
|
event.afterSnapshot = `after@${metadata.id}`;
|
|
385
378
|
this._appendTraceEvent(event);
|
|
386
379
|
return this._captureSnapshot(event.afterSnapshot, sdkObject, metadata);
|
|
@@ -390,25 +383,30 @@ class Tracing extends _instrumentation.SdkObject {
|
|
|
390
383
|
}
|
|
391
384
|
onEntryFinished(entry) {
|
|
392
385
|
this._pendingHarEntries.delete(entry);
|
|
393
|
-
const event = {
|
|
394
|
-
type: 'resource-snapshot',
|
|
395
|
-
snapshot: entry
|
|
396
|
-
};
|
|
386
|
+
const event = { type: "resource-snapshot", snapshot: entry };
|
|
397
387
|
const visited = visitTraceEvent(event, this._state.networkSha1s, this._secretsFilter);
|
|
398
|
-
this._fs.appendFile(
|
|
388
|
+
this._fs.appendFile(
|
|
389
|
+
this._state.networkFile,
|
|
390
|
+
JSON.stringify(visited) + "\n",
|
|
391
|
+
true
|
|
392
|
+
/* flush */
|
|
393
|
+
);
|
|
399
394
|
}
|
|
400
395
|
flushHarEntries() {
|
|
401
396
|
const harLines = [];
|
|
402
397
|
for (const entry of this._pendingHarEntries) {
|
|
403
|
-
const event = {
|
|
404
|
-
type: 'resource-snapshot',
|
|
405
|
-
snapshot: entry
|
|
406
|
-
};
|
|
398
|
+
const event = { type: "resource-snapshot", snapshot: entry };
|
|
407
399
|
const visited = visitTraceEvent(event, this._state.networkSha1s, this._secretsFilter);
|
|
408
400
|
harLines.push(JSON.stringify(visited));
|
|
409
401
|
}
|
|
410
402
|
this._pendingHarEntries.clear();
|
|
411
|
-
if (harLines.length)
|
|
403
|
+
if (harLines.length)
|
|
404
|
+
this._fs.appendFile(
|
|
405
|
+
this._state.networkFile,
|
|
406
|
+
harLines.join("\n") + "\n",
|
|
407
|
+
true
|
|
408
|
+
/* flush */
|
|
409
|
+
);
|
|
412
410
|
}
|
|
413
411
|
onContentBlob(sha1, buffer) {
|
|
414
412
|
this._appendResource(sha1, buffer);
|
|
@@ -417,91 +415,67 @@ class Tracing extends _instrumentation.SdkObject {
|
|
|
417
415
|
this._appendResource(blob.sha1, blob.buffer);
|
|
418
416
|
}
|
|
419
417
|
onFrameSnapshot(snapshot) {
|
|
420
|
-
this._appendTraceEvent({
|
|
421
|
-
type: 'frame-snapshot',
|
|
422
|
-
snapshot
|
|
423
|
-
});
|
|
418
|
+
this._appendTraceEvent({ type: "frame-snapshot", snapshot });
|
|
424
419
|
}
|
|
425
420
|
_onConsoleMessage(message) {
|
|
426
|
-
var _message$page;
|
|
427
421
|
const event = {
|
|
428
|
-
type:
|
|
422
|
+
type: "console",
|
|
429
423
|
messageType: message.type(),
|
|
430
424
|
text: message.text(),
|
|
431
|
-
args: message.args().map(a => ({
|
|
432
|
-
preview: a.toString(),
|
|
433
|
-
value: a.rawValue()
|
|
434
|
-
})),
|
|
425
|
+
args: message.args().map((a) => ({ preview: a.toString(), value: a.rawValue() })),
|
|
435
426
|
location: message.location(),
|
|
436
|
-
time: (0,
|
|
437
|
-
pageId:
|
|
427
|
+
time: (0, import_time.monotonicTime)(),
|
|
428
|
+
pageId: message.page()?.guid
|
|
438
429
|
};
|
|
439
430
|
this._appendTraceEvent(event);
|
|
440
431
|
}
|
|
441
432
|
onDialog(dialog) {
|
|
442
433
|
const event = {
|
|
443
|
-
type:
|
|
444
|
-
time: (0,
|
|
445
|
-
class:
|
|
446
|
-
method:
|
|
447
|
-
params: {
|
|
448
|
-
pageId: dialog.page().guid,
|
|
449
|
-
type: dialog.type(),
|
|
450
|
-
message: dialog.message(),
|
|
451
|
-
defaultValue: dialog.defaultValue()
|
|
452
|
-
}
|
|
434
|
+
type: "event",
|
|
435
|
+
time: (0, import_time.monotonicTime)(),
|
|
436
|
+
class: "BrowserContext",
|
|
437
|
+
method: "dialog",
|
|
438
|
+
params: { pageId: dialog.page().guid, type: dialog.type(), message: dialog.message(), defaultValue: dialog.defaultValue() }
|
|
453
439
|
};
|
|
454
440
|
this._appendTraceEvent(event);
|
|
455
441
|
}
|
|
456
442
|
onDownload(page, download) {
|
|
457
443
|
const event = {
|
|
458
|
-
type:
|
|
459
|
-
time: (0,
|
|
460
|
-
class:
|
|
461
|
-
method:
|
|
462
|
-
params: {
|
|
463
|
-
pageId: page.guid,
|
|
464
|
-
url: download.url,
|
|
465
|
-
suggestedFilename: download.suggestedFilename()
|
|
466
|
-
}
|
|
444
|
+
type: "event",
|
|
445
|
+
time: (0, import_time.monotonicTime)(),
|
|
446
|
+
class: "BrowserContext",
|
|
447
|
+
method: "download",
|
|
448
|
+
params: { pageId: page.guid, url: download.url, suggestedFilename: download.suggestedFilename() }
|
|
467
449
|
};
|
|
468
450
|
this._appendTraceEvent(event);
|
|
469
451
|
}
|
|
470
452
|
onPageOpen(page) {
|
|
471
|
-
var _page$opener;
|
|
472
453
|
const event = {
|
|
473
|
-
type:
|
|
474
|
-
time: (0,
|
|
475
|
-
class:
|
|
476
|
-
method:
|
|
477
|
-
params: {
|
|
478
|
-
pageId: page.guid,
|
|
479
|
-
openerPageId: (_page$opener = page.opener()) === null || _page$opener === void 0 ? void 0 : _page$opener.guid
|
|
480
|
-
}
|
|
454
|
+
type: "event",
|
|
455
|
+
time: (0, import_time.monotonicTime)(),
|
|
456
|
+
class: "BrowserContext",
|
|
457
|
+
method: "page",
|
|
458
|
+
params: { pageId: page.guid, openerPageId: page.opener()?.guid }
|
|
481
459
|
};
|
|
482
460
|
this._appendTraceEvent(event);
|
|
483
461
|
}
|
|
484
462
|
onPageClose(page) {
|
|
485
463
|
const event = {
|
|
486
|
-
type:
|
|
487
|
-
time: (0,
|
|
488
|
-
class:
|
|
489
|
-
method:
|
|
490
|
-
params: {
|
|
491
|
-
pageId: page.guid
|
|
492
|
-
}
|
|
464
|
+
type: "event",
|
|
465
|
+
time: (0, import_time.monotonicTime)(),
|
|
466
|
+
class: "BrowserContext",
|
|
467
|
+
method: "pageClosed",
|
|
468
|
+
params: { pageId: page.guid }
|
|
493
469
|
};
|
|
494
470
|
this._appendTraceEvent(event);
|
|
495
471
|
}
|
|
496
472
|
_onPageError(error, page) {
|
|
497
473
|
const event = {
|
|
498
|
-
type:
|
|
499
|
-
time: (0,
|
|
500
|
-
class:
|
|
501
|
-
method:
|
|
502
|
-
params: {
|
|
503
|
-
error: (0, _errors.serializeError)(error)
|
|
504
|
-
},
|
|
474
|
+
type: "event",
|
|
475
|
+
time: (0, import_time.monotonicTime)(),
|
|
476
|
+
class: "BrowserContext",
|
|
477
|
+
method: "pageError",
|
|
478
|
+
params: { error: (0, import_errors.serializeError)(error) },
|
|
505
479
|
pageId: page.guid
|
|
506
480
|
};
|
|
507
481
|
this._appendTraceEvent(event);
|
|
@@ -509,60 +483,68 @@ class Tracing extends _instrumentation.SdkObject {
|
|
|
509
483
|
_startScreencastInPage(page) {
|
|
510
484
|
page.setScreencastOptions(kScreencastOptions);
|
|
511
485
|
const prefix = page.guid;
|
|
512
|
-
this._screencastListeners.push(
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
486
|
+
this._screencastListeners.push(
|
|
487
|
+
import_eventsHelper.eventsHelper.addEventListener(page, import_page.Page.Events.ScreencastFrame, (params) => {
|
|
488
|
+
const suffix = params.timestamp || Date.now();
|
|
489
|
+
const sha1 = `${prefix}-${suffix}.jpeg`;
|
|
490
|
+
const event = {
|
|
491
|
+
type: "screencast-frame",
|
|
492
|
+
pageId: page.guid,
|
|
493
|
+
sha1,
|
|
494
|
+
width: params.width,
|
|
495
|
+
height: params.height,
|
|
496
|
+
timestamp: (0, import_time.monotonicTime)(),
|
|
497
|
+
frameSwapWallTime: params.frameSwapWallTime
|
|
498
|
+
};
|
|
499
|
+
this._appendResource(sha1, params.buffer);
|
|
500
|
+
this._appendTraceEvent(event);
|
|
501
|
+
})
|
|
502
|
+
);
|
|
528
503
|
}
|
|
529
504
|
_appendTraceEvent(event) {
|
|
530
505
|
const visited = visitTraceEvent(event, this._state.traceSha1s, this._secretsFilter);
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
this._fs.appendFile(this._state.traceFile, JSON.stringify(visited) + '\n', flush);
|
|
506
|
+
const flush = this._state.options.live || event.type !== "event" && event.type !== "console" && event.type !== "log";
|
|
507
|
+
this._fs.appendFile(this._state.traceFile, JSON.stringify(visited) + "\n", flush);
|
|
534
508
|
}
|
|
535
509
|
_appendResource(sha1, buffer) {
|
|
536
|
-
if (this._allResources.has(sha1))
|
|
510
|
+
if (this._allResources.has(sha1))
|
|
511
|
+
return;
|
|
537
512
|
this._allResources.add(sha1);
|
|
538
|
-
const resourcePath =
|
|
539
|
-
this._fs.writeFile(
|
|
513
|
+
const resourcePath = import_path.default.join(this._state.resourcesDir, sha1);
|
|
514
|
+
this._fs.writeFile(
|
|
515
|
+
resourcePath,
|
|
516
|
+
buffer,
|
|
517
|
+
true
|
|
518
|
+
/* skipIfExists */
|
|
519
|
+
);
|
|
540
520
|
}
|
|
541
521
|
}
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
}
|
|
550
|
-
if (object instanceof
|
|
551
|
-
|
|
552
|
-
if (object instanceof
|
|
553
|
-
|
|
522
|
+
function visitTraceEvent(object, sha1s, secretsFilter2) {
|
|
523
|
+
if (Array.isArray(object)) {
|
|
524
|
+
return object.map((o) => {
|
|
525
|
+
if (typeof o === "string" && new Date(o).toString() === "Invalid Date")
|
|
526
|
+
return secretsFilter2(o);
|
|
527
|
+
return visitTraceEvent(o, sha1s, secretsFilter2);
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
if (object instanceof import_dispatcher.Dispatcher)
|
|
531
|
+
return `<${object._type}>`;
|
|
532
|
+
if (object instanceof Buffer)
|
|
533
|
+
return `<Buffer>`;
|
|
534
|
+
if (object instanceof Date)
|
|
535
|
+
return object;
|
|
536
|
+
if (typeof object === "object") {
|
|
554
537
|
const result = {};
|
|
555
538
|
for (const key in object) {
|
|
556
539
|
const value = object[key];
|
|
557
|
-
if (key ===
|
|
558
|
-
if (value)
|
|
540
|
+
if (key === "sha1" || key === "_sha1" || key.endsWith("Sha1")) {
|
|
541
|
+
if (value)
|
|
542
|
+
sha1s.add(value);
|
|
559
543
|
}
|
|
560
|
-
if (typeof value ===
|
|
561
|
-
|
|
562
|
-
// Otherwise parts of the trace will be unreadable.
|
|
563
|
-
result[key] = key.endsWith('Sha1') || ['pageref', '_sha1', 'downloadsPath', 'tracesDir', 'pageId', 'sha1'].includes(key) ? value : secretsFilter(value);
|
|
544
|
+
if (typeof value === "string") {
|
|
545
|
+
result[key] = key.endsWith("Sha1") || ["pageref", "_sha1", "downloadsPath", "tracesDir", "pageId", "sha1"].includes(key) ? value : secretsFilter2(value);
|
|
564
546
|
} else {
|
|
565
|
-
result[key] = visitTraceEvent(value, sha1s,
|
|
547
|
+
result[key] = visitTraceEvent(value, sha1s, secretsFilter2);
|
|
566
548
|
}
|
|
567
549
|
}
|
|
568
550
|
return result;
|
|
@@ -570,50 +552,60 @@ function visitTraceEvent(object, sha1s, secretsFilter) {
|
|
|
570
552
|
return object;
|
|
571
553
|
}
|
|
572
554
|
function shouldCaptureSnapshot(metadata) {
|
|
573
|
-
|
|
555
|
+
const metainfo = import_protocolMetainfo.methodMetainfo.get(metadata.type + "." + metadata.method);
|
|
556
|
+
return !!metainfo?.snapshot;
|
|
574
557
|
}
|
|
575
558
|
function createBeforeActionTraceEvent(metadata, parentId) {
|
|
576
|
-
if (metadata.internal || metadata.method.startsWith(
|
|
559
|
+
if (metadata.internal || metadata.method.startsWith("tracing"))
|
|
560
|
+
return null;
|
|
577
561
|
const event = {
|
|
578
|
-
type:
|
|
562
|
+
type: "before",
|
|
579
563
|
callId: metadata.id,
|
|
580
564
|
startTime: metadata.startTime,
|
|
581
|
-
|
|
565
|
+
title: metadata.title,
|
|
582
566
|
class: metadata.type,
|
|
583
567
|
method: metadata.method,
|
|
584
568
|
params: metadata.params,
|
|
585
569
|
stepId: metadata.stepId,
|
|
586
570
|
pageId: metadata.pageId
|
|
587
571
|
};
|
|
588
|
-
if (parentId)
|
|
572
|
+
if (parentId)
|
|
573
|
+
event.parentId = parentId;
|
|
589
574
|
return event;
|
|
590
575
|
}
|
|
591
576
|
function createInputActionTraceEvent(metadata) {
|
|
592
|
-
if (metadata.internal || metadata.method.startsWith(
|
|
577
|
+
if (metadata.internal || metadata.method.startsWith("tracing"))
|
|
578
|
+
return null;
|
|
593
579
|
return {
|
|
594
|
-
type:
|
|
580
|
+
type: "input",
|
|
595
581
|
callId: metadata.id,
|
|
596
582
|
point: metadata.point
|
|
597
583
|
};
|
|
598
584
|
}
|
|
599
585
|
function createActionLogTraceEvent(metadata, message) {
|
|
600
|
-
if (metadata.internal || metadata.method.startsWith(
|
|
586
|
+
if (metadata.internal || metadata.method.startsWith("tracing"))
|
|
587
|
+
return null;
|
|
601
588
|
return {
|
|
602
|
-
type:
|
|
589
|
+
type: "log",
|
|
603
590
|
callId: metadata.id,
|
|
604
|
-
time: (0,
|
|
591
|
+
time: (0, import_time.monotonicTime)(),
|
|
605
592
|
message
|
|
606
593
|
};
|
|
607
594
|
}
|
|
608
595
|
function createAfterActionTraceEvent(metadata) {
|
|
609
|
-
|
|
610
|
-
|
|
596
|
+
if (metadata.internal || metadata.method.startsWith("tracing"))
|
|
597
|
+
return null;
|
|
611
598
|
return {
|
|
612
|
-
type:
|
|
599
|
+
type: "after",
|
|
613
600
|
callId: metadata.id,
|
|
614
601
|
endTime: metadata.endTime,
|
|
615
|
-
error:
|
|
602
|
+
error: metadata.error?.error,
|
|
616
603
|
result: metadata.result,
|
|
617
604
|
point: metadata.point
|
|
618
605
|
};
|
|
619
|
-
}
|
|
606
|
+
}
|
|
607
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
608
|
+
0 && (module.exports = {
|
|
609
|
+
Tracing,
|
|
610
|
+
shouldCaptureSnapshot
|
|
611
|
+
});
|