patchright-core 1.57.0 → 1.58.2
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 +3223 -308
- package/browsers.json +21 -22
- package/lib/cli/program.js +4 -5
- package/lib/client/api.js +3 -0
- package/lib/client/browser.js +3 -5
- package/lib/client/browserContext.js +40 -4
- package/lib/client/browserType.js +4 -3
- package/lib/client/connection.js +4 -0
- package/lib/client/elementHandle.js +3 -0
- package/lib/client/events.js +3 -0
- package/lib/client/fetch.js +3 -4
- package/lib/client/frame.js +10 -1
- package/lib/client/locator.js +8 -0
- package/lib/client/network.js +5 -1
- package/lib/client/page.js +29 -1
- package/lib/client/pageAgent.js +64 -0
- package/lib/client/platform.js +3 -0
- package/lib/client/tracing.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/pollingRecorderSource.js +1 -1
- package/lib/mcpBundle.js +84 -0
- package/lib/mcpBundleImpl/index.js +147 -0
- package/lib/protocol/serializers.js +5 -0
- package/lib/protocol/validator.js +88 -4
- package/lib/remote/playwrightServer.js +1 -2
- package/lib/server/agent/actionRunner.js +335 -0
- package/lib/server/agent/actions.js +128 -0
- package/lib/server/agent/codegen.js +111 -0
- package/lib/server/agent/context.js +150 -0
- package/lib/server/agent/expectTools.js +156 -0
- package/lib/server/agent/pageAgent.js +204 -0
- package/lib/server/agent/performTools.js +262 -0
- package/lib/server/agent/tool.js +109 -0
- package/lib/server/artifact.js +1 -1
- package/lib/server/bidi/bidiBrowser.js +56 -12
- package/lib/server/bidi/bidiChromium.js +8 -12
- package/lib/server/bidi/bidiConnection.js +1 -0
- package/lib/server/bidi/bidiDeserializer.js +116 -0
- package/lib/server/bidi/bidiExecutionContext.js +75 -29
- package/lib/server/bidi/bidiFirefox.js +6 -8
- package/lib/server/bidi/bidiNetworkManager.js +1 -1
- package/lib/server/bidi/bidiPage.js +39 -28
- package/lib/server/bidi/third_party/bidiProtocolCore.js +1 -0
- package/lib/server/browserContext.js +34 -26
- package/lib/server/browserType.js +12 -4
- package/lib/server/chromium/chromium.js +14 -20
- package/lib/server/chromium/chromiumSwitches.js +2 -2
- package/lib/server/chromium/crBrowser.js +22 -12
- package/lib/server/chromium/crConnection.js +0 -5
- package/lib/server/chromium/crCoverage.js +13 -1
- package/lib/server/chromium/crDevTools.js +0 -2
- package/lib/server/chromium/crNetworkManager.js +92 -12
- package/lib/server/chromium/crPage.js +62 -116
- package/lib/server/codegen/javascript.js +6 -29
- package/lib/server/deviceDescriptorsSource.json +56 -56
- package/lib/server/dispatchers/browserContextDispatcher.js +3 -2
- package/lib/server/dispatchers/dispatcher.js +6 -13
- package/lib/server/dispatchers/frameDispatcher.js +1 -1
- package/lib/server/dispatchers/jsHandleDispatcher.js +2 -2
- package/lib/server/dispatchers/pageAgentDispatcher.js +96 -0
- package/lib/server/dispatchers/pageDispatcher.js +4 -0
- package/lib/server/dom.js +12 -3
- package/lib/server/electron/electron.js +5 -2
- package/lib/server/firefox/ffBrowser.js +10 -20
- package/lib/server/firefox/ffConnection.js +0 -5
- package/lib/server/firefox/ffNetworkManager.js +2 -2
- package/lib/server/firefox/ffPage.js +15 -18
- package/lib/server/firefox/firefox.js +6 -8
- package/lib/server/frameSelectors.js +16 -4
- package/lib/server/frames.js +251 -86
- package/lib/server/instrumentation.js +3 -0
- package/lib/server/javascript.js +8 -4
- package/lib/server/launchApp.js +2 -1
- package/lib/server/network.js +50 -12
- package/lib/server/page.js +61 -91
- package/lib/server/progress.js +26 -6
- package/lib/server/recorder/recorderApp.js +79 -100
- package/lib/server/registry/browserFetcher.js +6 -4
- package/lib/server/registry/index.js +172 -149
- package/lib/server/registry/oopDownloadBrowserMain.js +3 -0
- package/lib/server/screencast.js +190 -0
- package/lib/server/screenshotter.js +6 -0
- package/lib/server/trace/recorder/snapshotter.js +17 -8
- package/lib/server/trace/recorder/snapshotterInjected.js +30 -72
- package/lib/server/trace/recorder/tracing.js +29 -21
- package/lib/server/trace/viewer/traceParser.js +72 -0
- package/lib/server/trace/viewer/traceViewer.js +21 -17
- package/lib/server/utils/expectUtils.js +87 -2
- package/lib/server/utils/hostPlatform.js +15 -0
- package/lib/server/utils/httpServer.js +5 -20
- package/lib/server/utils/network.js +37 -28
- package/lib/server/utils/nodePlatform.js +6 -0
- package/lib/server/{chromium/videoRecorder.js → videoRecorder.js} +22 -13
- package/lib/server/webkit/webkit.js +4 -6
- package/lib/server/webkit/wkBrowser.js +2 -6
- package/lib/server/webkit/wkConnection.js +1 -6
- package/lib/server/webkit/wkInterceptableRequest.js +29 -1
- package/lib/server/webkit/wkPage.js +75 -46
- package/lib/utils/isomorphic/ariaSnapshot.js +60 -2
- package/lib/utils/isomorphic/lruCache.js +51 -0
- package/lib/utils/isomorphic/protocolMetainfo.js +9 -1
- package/lib/utils/isomorphic/stringUtils.js +49 -0
- package/lib/utils/isomorphic/trace/entries.js +16 -0
- package/lib/utils/isomorphic/trace/snapshotRenderer.js +499 -0
- package/lib/utils/isomorphic/trace/snapshotServer.js +120 -0
- package/lib/utils/isomorphic/trace/snapshotStorage.js +89 -0
- package/lib/utils/isomorphic/trace/traceLoader.js +131 -0
- package/lib/utils/isomorphic/trace/traceModel.js +365 -0
- package/lib/utils/isomorphic/trace/traceModernizer.js +400 -0
- package/lib/utils/isomorphic/trace/versions/traceV3.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV4.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV5.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV6.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV7.js +16 -0
- package/lib/utils/isomorphic/trace/versions/traceV8.js +16 -0
- package/lib/utils/isomorphic/yaml.js +84 -0
- package/lib/utils.js +2 -0
- package/lib/utilsBundle.js +2 -5
- package/lib/utilsBundleImpl/index.js +165 -165
- package/lib/vite/htmlReport/index.html +21 -21
- package/lib/vite/recorder/assets/codeMirrorModule-CFUTFUO7.js +32 -0
- package/lib/vite/{traceViewer/codeMirrorModule.C3UTv-Ge.css → recorder/assets/codeMirrorModule-DYBRYzYX.css} +1 -1
- package/lib/vite/recorder/assets/{index-Ri0uHF7I.css → index-BSjZa4pk.css} +1 -1
- package/lib/vite/recorder/assets/index-CVkBxsGf.js +193 -0
- package/lib/vite/recorder/index.html +2 -2
- package/lib/vite/traceViewer/assets/codeMirrorModule-BVA4h_ZY.js +32 -0
- package/lib/vite/traceViewer/assets/defaultSettingsView-CjfmcdOz.js +266 -0
- package/lib/vite/{recorder/assets/codeMirrorModule-C3UTv-Ge.css → traceViewer/codeMirrorModule.DYBRYzYX.css} +1 -1
- package/lib/vite/traceViewer/defaultSettingsView.7ch9cixO.css +1 -0
- package/lib/vite/traceViewer/index.BVu7tZDe.css +1 -0
- package/lib/vite/traceViewer/index.BtyWtaE-.js +2 -0
- package/lib/vite/traceViewer/index.html +4 -4
- package/lib/vite/traceViewer/sw.bundle.js +5 -3
- package/lib/vite/traceViewer/uiMode.fyrXARf2.js +5 -0
- package/lib/vite/traceViewer/uiMode.html +3 -3
- package/package.json +2 -1
- package/types/protocol.d.ts +738 -159
- package/types/types.d.ts +25 -38
- package/lib/server/bidi/third_party/bidiDeserializer.js +0 -98
- package/lib/server/trace/test/inMemorySnapshotter.js +0 -87
- package/lib/vite/recorder/assets/codeMirrorModule-CBbSe-ZI.js +0 -25
- package/lib/vite/recorder/assets/index-CpZVd2nA.js +0 -193
- package/lib/vite/traceViewer/assets/codeMirrorModule-DHz0wP2C.js +0 -25
- package/lib/vite/traceViewer/assets/defaultSettingsView-WsZP88O6.js +0 -266
- package/lib/vite/traceViewer/defaultSettingsView.ConWv5KN.css +0 -1
- package/lib/vite/traceViewer/index.C4Y3Aw8n.css +0 -1
- package/lib/vite/traceViewer/index.C8xAeo93.js +0 -2
- package/lib/vite/traceViewer/uiMode.BltraIJB.js +0 -5
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var traceModernizer_exports = {};
|
|
20
|
+
__export(traceModernizer_exports, {
|
|
21
|
+
TraceModernizer: () => TraceModernizer,
|
|
22
|
+
TraceVersionError: () => TraceVersionError
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(traceModernizer_exports);
|
|
25
|
+
class TraceVersionError extends Error {
|
|
26
|
+
constructor(message) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = "TraceVersionError";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const latestVersion = 8;
|
|
32
|
+
class TraceModernizer {
|
|
33
|
+
constructor(contextEntry, snapshotStorage) {
|
|
34
|
+
this._actionMap = /* @__PURE__ */ new Map();
|
|
35
|
+
this._pageEntries = /* @__PURE__ */ new Map();
|
|
36
|
+
this._jsHandles = /* @__PURE__ */ new Map();
|
|
37
|
+
this._consoleObjects = /* @__PURE__ */ new Map();
|
|
38
|
+
this._contextEntry = contextEntry;
|
|
39
|
+
this._snapshotStorage = snapshotStorage;
|
|
40
|
+
}
|
|
41
|
+
appendTrace(trace) {
|
|
42
|
+
for (const line of trace.split("\n"))
|
|
43
|
+
this._appendEvent(line);
|
|
44
|
+
}
|
|
45
|
+
actions() {
|
|
46
|
+
return [...this._actionMap.values()];
|
|
47
|
+
}
|
|
48
|
+
_pageEntry(pageId) {
|
|
49
|
+
let pageEntry = this._pageEntries.get(pageId);
|
|
50
|
+
if (!pageEntry) {
|
|
51
|
+
pageEntry = {
|
|
52
|
+
pageId,
|
|
53
|
+
screencastFrames: []
|
|
54
|
+
};
|
|
55
|
+
this._pageEntries.set(pageId, pageEntry);
|
|
56
|
+
this._contextEntry.pages.push(pageEntry);
|
|
57
|
+
}
|
|
58
|
+
return pageEntry;
|
|
59
|
+
}
|
|
60
|
+
_appendEvent(line) {
|
|
61
|
+
if (!line)
|
|
62
|
+
return;
|
|
63
|
+
const events = this._modernize(JSON.parse(line));
|
|
64
|
+
for (const event of events)
|
|
65
|
+
this._innerAppendEvent(event);
|
|
66
|
+
}
|
|
67
|
+
_innerAppendEvent(event) {
|
|
68
|
+
const contextEntry = this._contextEntry;
|
|
69
|
+
switch (event.type) {
|
|
70
|
+
case "context-options": {
|
|
71
|
+
if (event.version > latestVersion)
|
|
72
|
+
throw new TraceVersionError("The trace was created by a newer version of Playwright and is not supported by this version of the viewer. Please use latest Playwright to open the trace.");
|
|
73
|
+
this._version = event.version;
|
|
74
|
+
contextEntry.origin = event.origin;
|
|
75
|
+
contextEntry.browserName = event.browserName;
|
|
76
|
+
contextEntry.channel = event.channel;
|
|
77
|
+
contextEntry.title = event.title;
|
|
78
|
+
contextEntry.platform = event.platform;
|
|
79
|
+
contextEntry.playwrightVersion = event.playwrightVersion;
|
|
80
|
+
contextEntry.wallTime = event.wallTime;
|
|
81
|
+
contextEntry.startTime = event.monotonicTime;
|
|
82
|
+
contextEntry.sdkLanguage = event.sdkLanguage;
|
|
83
|
+
contextEntry.options = event.options;
|
|
84
|
+
contextEntry.testIdAttributeName = event.testIdAttributeName;
|
|
85
|
+
contextEntry.contextId = event.contextId ?? "";
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
case "screencast-frame": {
|
|
89
|
+
this._pageEntry(event.pageId).screencastFrames.push(event);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "before": {
|
|
93
|
+
this._actionMap.set(event.callId, { ...event, type: "action", endTime: 0, log: [] });
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case "input": {
|
|
97
|
+
const existing = this._actionMap.get(event.callId);
|
|
98
|
+
existing.inputSnapshot = event.inputSnapshot;
|
|
99
|
+
existing.point = event.point;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case "log": {
|
|
103
|
+
const existing = this._actionMap.get(event.callId);
|
|
104
|
+
if (!existing)
|
|
105
|
+
return;
|
|
106
|
+
existing.log.push({
|
|
107
|
+
time: event.time,
|
|
108
|
+
message: event.message
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
case "after": {
|
|
113
|
+
const existing = this._actionMap.get(event.callId);
|
|
114
|
+
existing.afterSnapshot = event.afterSnapshot;
|
|
115
|
+
existing.endTime = event.endTime;
|
|
116
|
+
existing.result = event.result;
|
|
117
|
+
existing.error = event.error;
|
|
118
|
+
existing.attachments = event.attachments;
|
|
119
|
+
existing.annotations = event.annotations;
|
|
120
|
+
if (event.point)
|
|
121
|
+
existing.point = event.point;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "action": {
|
|
125
|
+
this._actionMap.set(event.callId, { ...event, log: [] });
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case "event": {
|
|
129
|
+
contextEntry.events.push(event);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "stdout": {
|
|
133
|
+
contextEntry.stdio.push(event);
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
case "stderr": {
|
|
137
|
+
contextEntry.stdio.push(event);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case "error": {
|
|
141
|
+
contextEntry.errors.push(event);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
case "console": {
|
|
145
|
+
contextEntry.events.push(event);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case "resource-snapshot":
|
|
149
|
+
this._snapshotStorage.addResource(this._contextEntry.contextId, event.snapshot);
|
|
150
|
+
contextEntry.resources.push(event.snapshot);
|
|
151
|
+
break;
|
|
152
|
+
case "frame-snapshot":
|
|
153
|
+
this._snapshotStorage.addFrameSnapshot(this._contextEntry.contextId, event.snapshot, this._pageEntry(event.snapshot.pageId).screencastFrames);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
if ("pageId" in event && event.pageId)
|
|
157
|
+
this._pageEntry(event.pageId);
|
|
158
|
+
if (event.type === "action" || event.type === "before")
|
|
159
|
+
contextEntry.startTime = Math.min(contextEntry.startTime, event.startTime);
|
|
160
|
+
if (event.type === "action" || event.type === "after")
|
|
161
|
+
contextEntry.endTime = Math.max(contextEntry.endTime, event.endTime);
|
|
162
|
+
if (event.type === "event") {
|
|
163
|
+
contextEntry.startTime = Math.min(contextEntry.startTime, event.time);
|
|
164
|
+
contextEntry.endTime = Math.max(contextEntry.endTime, event.time);
|
|
165
|
+
}
|
|
166
|
+
if (event.type === "screencast-frame") {
|
|
167
|
+
contextEntry.startTime = Math.min(contextEntry.startTime, event.timestamp);
|
|
168
|
+
contextEntry.endTime = Math.max(contextEntry.endTime, event.timestamp);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
_processedContextCreatedEvent() {
|
|
172
|
+
return this._version !== void 0;
|
|
173
|
+
}
|
|
174
|
+
_modernize(event) {
|
|
175
|
+
let version = this._version ?? event.version ?? 6;
|
|
176
|
+
let events = [event];
|
|
177
|
+
for (; version < latestVersion; ++version)
|
|
178
|
+
events = this[`_modernize_${version}_to_${version + 1}`].call(this, events);
|
|
179
|
+
return events;
|
|
180
|
+
}
|
|
181
|
+
_modernize_0_to_1(events) {
|
|
182
|
+
for (const event of events) {
|
|
183
|
+
if (event.type !== "action")
|
|
184
|
+
continue;
|
|
185
|
+
if (typeof event.metadata.error === "string")
|
|
186
|
+
event.metadata.error = { error: { name: "Error", message: event.metadata.error } };
|
|
187
|
+
}
|
|
188
|
+
return events;
|
|
189
|
+
}
|
|
190
|
+
_modernize_1_to_2(events) {
|
|
191
|
+
for (const event of events) {
|
|
192
|
+
if (event.type !== "frame-snapshot" || !event.snapshot.isMainFrame)
|
|
193
|
+
continue;
|
|
194
|
+
event.snapshot.viewport = this._contextEntry.options?.viewport || { width: 1280, height: 720 };
|
|
195
|
+
}
|
|
196
|
+
return events;
|
|
197
|
+
}
|
|
198
|
+
_modernize_2_to_3(events) {
|
|
199
|
+
for (const event of events) {
|
|
200
|
+
if (event.type !== "resource-snapshot" || event.snapshot.request)
|
|
201
|
+
continue;
|
|
202
|
+
const resource = event.snapshot;
|
|
203
|
+
event.snapshot = {
|
|
204
|
+
_frameref: resource.frameId,
|
|
205
|
+
request: {
|
|
206
|
+
url: resource.url,
|
|
207
|
+
method: resource.method,
|
|
208
|
+
headers: resource.requestHeaders,
|
|
209
|
+
postData: resource.requestSha1 ? { _sha1: resource.requestSha1 } : void 0
|
|
210
|
+
},
|
|
211
|
+
response: {
|
|
212
|
+
status: resource.status,
|
|
213
|
+
headers: resource.responseHeaders,
|
|
214
|
+
content: {
|
|
215
|
+
mimeType: resource.contentType,
|
|
216
|
+
_sha1: resource.responseSha1
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
_monotonicTime: resource.timestamp
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return events;
|
|
223
|
+
}
|
|
224
|
+
_modernize_3_to_4(events) {
|
|
225
|
+
const result = [];
|
|
226
|
+
for (const event of events) {
|
|
227
|
+
const e = this._modernize_event_3_to_4(event);
|
|
228
|
+
if (e)
|
|
229
|
+
result.push(e);
|
|
230
|
+
}
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
_modernize_event_3_to_4(event) {
|
|
234
|
+
if (event.type !== "action" && event.type !== "event") {
|
|
235
|
+
return event;
|
|
236
|
+
}
|
|
237
|
+
const metadata = event.metadata;
|
|
238
|
+
if (metadata.internal || metadata.method.startsWith("tracing"))
|
|
239
|
+
return null;
|
|
240
|
+
if (event.type === "event") {
|
|
241
|
+
if (metadata.method === "__create__" && metadata.type === "ConsoleMessage") {
|
|
242
|
+
return {
|
|
243
|
+
type: "object",
|
|
244
|
+
class: metadata.type,
|
|
245
|
+
guid: metadata.params.guid,
|
|
246
|
+
initializer: metadata.params.initializer
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
type: "event",
|
|
251
|
+
time: metadata.startTime,
|
|
252
|
+
class: metadata.type,
|
|
253
|
+
method: metadata.method,
|
|
254
|
+
params: metadata.params,
|
|
255
|
+
pageId: metadata.pageId
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
type: "action",
|
|
260
|
+
callId: metadata.id,
|
|
261
|
+
startTime: metadata.startTime,
|
|
262
|
+
endTime: metadata.endTime,
|
|
263
|
+
apiName: metadata.apiName || metadata.type + "." + metadata.method,
|
|
264
|
+
class: metadata.type,
|
|
265
|
+
method: metadata.method,
|
|
266
|
+
params: metadata.params,
|
|
267
|
+
// eslint-disable-next-line no-restricted-globals
|
|
268
|
+
wallTime: metadata.wallTime || Date.now(),
|
|
269
|
+
log: metadata.log,
|
|
270
|
+
beforeSnapshot: metadata.snapshots.find((s) => s.title === "before")?.snapshotName,
|
|
271
|
+
inputSnapshot: metadata.snapshots.find((s) => s.title === "input")?.snapshotName,
|
|
272
|
+
afterSnapshot: metadata.snapshots.find((s) => s.title === "after")?.snapshotName,
|
|
273
|
+
error: metadata.error?.error,
|
|
274
|
+
result: metadata.result,
|
|
275
|
+
point: metadata.point,
|
|
276
|
+
pageId: metadata.pageId
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
_modernize_4_to_5(events) {
|
|
280
|
+
const result = [];
|
|
281
|
+
for (const event of events) {
|
|
282
|
+
const e = this._modernize_event_4_to_5(event);
|
|
283
|
+
if (e)
|
|
284
|
+
result.push(e);
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
_modernize_event_4_to_5(event) {
|
|
289
|
+
if (event.type === "event" && event.method === "__create__" && event.class === "JSHandle")
|
|
290
|
+
this._jsHandles.set(event.params.guid, event.params.initializer);
|
|
291
|
+
if (event.type === "object") {
|
|
292
|
+
if (event.class !== "ConsoleMessage")
|
|
293
|
+
return null;
|
|
294
|
+
const args = event.initializer.args?.map((arg) => {
|
|
295
|
+
if (arg.guid) {
|
|
296
|
+
const handle = this._jsHandles.get(arg.guid);
|
|
297
|
+
return { preview: handle?.preview || "", value: "" };
|
|
298
|
+
}
|
|
299
|
+
return { preview: arg.preview || "", value: arg.value || "" };
|
|
300
|
+
});
|
|
301
|
+
this._consoleObjects.set(event.guid, {
|
|
302
|
+
type: event.initializer.type,
|
|
303
|
+
text: event.initializer.text,
|
|
304
|
+
location: event.initializer.location,
|
|
305
|
+
args
|
|
306
|
+
});
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
if (event.type === "event" && event.method === "console") {
|
|
310
|
+
const consoleMessage = this._consoleObjects.get(event.params.message?.guid || "");
|
|
311
|
+
if (!consoleMessage)
|
|
312
|
+
return null;
|
|
313
|
+
return {
|
|
314
|
+
type: "console",
|
|
315
|
+
time: event.time,
|
|
316
|
+
pageId: event.pageId,
|
|
317
|
+
messageType: consoleMessage.type,
|
|
318
|
+
text: consoleMessage.text,
|
|
319
|
+
args: consoleMessage.args,
|
|
320
|
+
location: consoleMessage.location
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
return event;
|
|
324
|
+
}
|
|
325
|
+
_modernize_5_to_6(events) {
|
|
326
|
+
const result = [];
|
|
327
|
+
for (const event of events) {
|
|
328
|
+
result.push(event);
|
|
329
|
+
if (event.type !== "after" || !event.log.length)
|
|
330
|
+
continue;
|
|
331
|
+
for (const log of event.log) {
|
|
332
|
+
result.push({
|
|
333
|
+
type: "log",
|
|
334
|
+
callId: event.callId,
|
|
335
|
+
message: log,
|
|
336
|
+
time: -1
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return result;
|
|
341
|
+
}
|
|
342
|
+
_modernize_6_to_7(events) {
|
|
343
|
+
const result = [];
|
|
344
|
+
if (!this._processedContextCreatedEvent() && events[0].type !== "context-options") {
|
|
345
|
+
const event = {
|
|
346
|
+
type: "context-options",
|
|
347
|
+
origin: "testRunner",
|
|
348
|
+
version: 6,
|
|
349
|
+
browserName: "",
|
|
350
|
+
options: {},
|
|
351
|
+
platform: "unknown",
|
|
352
|
+
wallTime: 0,
|
|
353
|
+
monotonicTime: 0,
|
|
354
|
+
sdkLanguage: "javascript",
|
|
355
|
+
contextId: ""
|
|
356
|
+
};
|
|
357
|
+
result.push(event);
|
|
358
|
+
}
|
|
359
|
+
for (const event of events) {
|
|
360
|
+
if (event.type === "context-options") {
|
|
361
|
+
result.push({ ...event, monotonicTime: 0, origin: "library", contextId: "" });
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (event.type === "before" || event.type === "action") {
|
|
365
|
+
if (!this._contextEntry.wallTime)
|
|
366
|
+
this._contextEntry.wallTime = event.wallTime;
|
|
367
|
+
const eventAsV6 = event;
|
|
368
|
+
const eventAsV7 = event;
|
|
369
|
+
eventAsV7.stepId = `${eventAsV6.apiName}@${eventAsV6.wallTime}`;
|
|
370
|
+
result.push(eventAsV7);
|
|
371
|
+
} else {
|
|
372
|
+
result.push(event);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return result;
|
|
376
|
+
}
|
|
377
|
+
_modernize_7_to_8(events) {
|
|
378
|
+
const result = [];
|
|
379
|
+
for (const event of events) {
|
|
380
|
+
if (event.type === "before" || event.type === "action") {
|
|
381
|
+
const eventAsV7 = event;
|
|
382
|
+
const eventAsV8 = event;
|
|
383
|
+
if (eventAsV7.apiName) {
|
|
384
|
+
eventAsV8.title = eventAsV7.apiName;
|
|
385
|
+
delete eventAsV8.apiName;
|
|
386
|
+
}
|
|
387
|
+
eventAsV8.stepId = eventAsV7.stepId ?? eventAsV7.callId;
|
|
388
|
+
result.push(eventAsV8);
|
|
389
|
+
} else {
|
|
390
|
+
result.push(event);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
397
|
+
0 && (module.exports = {
|
|
398
|
+
TraceModernizer,
|
|
399
|
+
TraceVersionError
|
|
400
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var traceV3_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(traceV3_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var traceV4_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(traceV4_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var traceV5_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(traceV5_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var traceV6_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(traceV6_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var traceV7_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(traceV7_exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var traceV8_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(traceV8_exports);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var yaml_exports = {};
|
|
20
|
+
__export(yaml_exports, {
|
|
21
|
+
yamlEscapeKeyIfNeeded: () => yamlEscapeKeyIfNeeded,
|
|
22
|
+
yamlEscapeValueIfNeeded: () => yamlEscapeValueIfNeeded
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(yaml_exports);
|
|
25
|
+
function yamlEscapeKeyIfNeeded(str) {
|
|
26
|
+
if (!yamlStringNeedsQuotes(str))
|
|
27
|
+
return str;
|
|
28
|
+
return `'` + str.replace(/'/g, `''`) + `'`;
|
|
29
|
+
}
|
|
30
|
+
function yamlEscapeValueIfNeeded(str) {
|
|
31
|
+
if (!yamlStringNeedsQuotes(str))
|
|
32
|
+
return str;
|
|
33
|
+
return '"' + str.replace(/[\\"\x00-\x1f\x7f-\x9f]/g, (c) => {
|
|
34
|
+
switch (c) {
|
|
35
|
+
case "\\":
|
|
36
|
+
return "\\\\";
|
|
37
|
+
case '"':
|
|
38
|
+
return '\\"';
|
|
39
|
+
case "\b":
|
|
40
|
+
return "\\b";
|
|
41
|
+
case "\f":
|
|
42
|
+
return "\\f";
|
|
43
|
+
case "\n":
|
|
44
|
+
return "\\n";
|
|
45
|
+
case "\r":
|
|
46
|
+
return "\\r";
|
|
47
|
+
case " ":
|
|
48
|
+
return "\\t";
|
|
49
|
+
default:
|
|
50
|
+
const code = c.charCodeAt(0);
|
|
51
|
+
return "\\x" + code.toString(16).padStart(2, "0");
|
|
52
|
+
}
|
|
53
|
+
}) + '"';
|
|
54
|
+
}
|
|
55
|
+
function yamlStringNeedsQuotes(str) {
|
|
56
|
+
if (str.length === 0)
|
|
57
|
+
return true;
|
|
58
|
+
if (/^\s|\s$/.test(str))
|
|
59
|
+
return true;
|
|
60
|
+
if (/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/.test(str))
|
|
61
|
+
return true;
|
|
62
|
+
if (/^-/.test(str))
|
|
63
|
+
return true;
|
|
64
|
+
if (/[\n:](\s|$)/.test(str))
|
|
65
|
+
return true;
|
|
66
|
+
if (/\s#/.test(str))
|
|
67
|
+
return true;
|
|
68
|
+
if (/[\n\r]/.test(str))
|
|
69
|
+
return true;
|
|
70
|
+
if (/^[&*\],?!>|@"'#%]/.test(str))
|
|
71
|
+
return true;
|
|
72
|
+
if (/[{}`]/.test(str))
|
|
73
|
+
return true;
|
|
74
|
+
if (/^\[/.test(str))
|
|
75
|
+
return true;
|
|
76
|
+
if (!isNaN(Number(str)) || ["y", "n", "yes", "no", "true", "false", "on", "off", "null"].includes(str.toLowerCase()))
|
|
77
|
+
return true;
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
yamlEscapeKeyIfNeeded,
|
|
83
|
+
yamlEscapeValueIfNeeded
|
|
84
|
+
});
|
package/lib/utils.js
CHANGED
|
@@ -39,6 +39,7 @@ __reExport(utils_exports, require("./utils/isomorphic/stringUtils"), module.expo
|
|
|
39
39
|
__reExport(utils_exports, require("./utils/isomorphic/time"), module.exports);
|
|
40
40
|
__reExport(utils_exports, require("./utils/isomorphic/timeoutRunner"), module.exports);
|
|
41
41
|
__reExport(utils_exports, require("./utils/isomorphic/urlMatch"), module.exports);
|
|
42
|
+
__reExport(utils_exports, require("./utils/isomorphic/yaml"), module.exports);
|
|
42
43
|
__reExport(utils_exports, require("./server/utils/ascii"), module.exports);
|
|
43
44
|
__reExport(utils_exports, require("./server/utils/comparators"), module.exports);
|
|
44
45
|
__reExport(utils_exports, require("./server/utils/crypto"), module.exports);
|
|
@@ -83,6 +84,7 @@ var import_utilsBundle = require("./utilsBundle");
|
|
|
83
84
|
...require("./utils/isomorphic/time"),
|
|
84
85
|
...require("./utils/isomorphic/timeoutRunner"),
|
|
85
86
|
...require("./utils/isomorphic/urlMatch"),
|
|
87
|
+
...require("./utils/isomorphic/yaml"),
|
|
86
88
|
...require("./server/utils/ascii"),
|
|
87
89
|
...require("./server/utils/comparators"),
|
|
88
90
|
...require("./server/utils/crypto"),
|
package/lib/utilsBundle.js
CHANGED
|
@@ -39,8 +39,7 @@ __export(utilsBundle_exports, {
|
|
|
39
39
|
wsReceiver: () => wsReceiver,
|
|
40
40
|
wsSender: () => wsSender,
|
|
41
41
|
wsServer: () => wsServer,
|
|
42
|
-
yaml: () => yaml
|
|
43
|
-
zod: () => zod
|
|
42
|
+
yaml: () => yaml
|
|
44
43
|
});
|
|
45
44
|
module.exports = __toCommonJS(utilsBundle_exports);
|
|
46
45
|
const colors = require("./utilsBundleImpl").colors;
|
|
@@ -64,7 +63,6 @@ const wsServer = require("./utilsBundleImpl").wsServer;
|
|
|
64
63
|
const wsReceiver = require("./utilsBundleImpl").wsReceiver;
|
|
65
64
|
const wsSender = require("./utilsBundleImpl").wsSender;
|
|
66
65
|
const yaml = require("./utilsBundleImpl").yaml;
|
|
67
|
-
const zod = require("./utilsBundleImpl").zod;
|
|
68
66
|
function ms(ms2) {
|
|
69
67
|
if (!isFinite(ms2))
|
|
70
68
|
return "-";
|
|
@@ -107,6 +105,5 @@ function ms(ms2) {
|
|
|
107
105
|
wsReceiver,
|
|
108
106
|
wsSender,
|
|
109
107
|
wsServer,
|
|
110
|
-
yaml
|
|
111
|
-
zod
|
|
108
|
+
yaml
|
|
112
109
|
});
|