@checkly/playwright-core 1.54.2-beta.1 → 1.54.2-beta.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/lib/checkly/index.js +22 -0
- package/lib/checkly/secretsFilter.js +51 -0
- package/lib/client/fetch.js +5 -0
- package/lib/generated/consoleApiSource.js +1 -1
- package/lib/generated/injectedScriptSource.js +1 -1
- package/lib/generated/webSocketMockSource.js +54 -12
- package/lib/server/dispatchers/localUtilsDispatcher.js +1 -1
- package/lib/server/har/harRecorder.js +3 -1
- package/lib/server/pageBinding.js +88 -0
- package/lib/server/trace/recorder/tracing.js +9 -19
- package/lib/server/utils/fileUtils.js +56 -0
- package/lib/server/webkit/wkExecutionContext.js +1 -2
- package/lib/utils/isomorphic/builtins.js +90 -0
- package/lib/utils/isomorphic/cssParser.js +2 -1
- package/lib/utils/isomorphic/manualPromise.js +2 -1
- package/lib/utils/isomorphic/mimeType.js +2 -1
- package/lib/utils/isomorphic/multimap.js +2 -1
- package/lib/utils/isomorphic/selectorParser.js +4 -3
- package/lib/utils/isomorphic/stringUtils.js +2 -1
- package/lib/utils/isomorphic/traceUtils.js +3 -2
- package/lib/utils/isomorphic/urlMatch.js +3 -2
- package/package.json +2 -1
- package/types/types.d.ts +6 -0
|
@@ -48,12 +48,54 @@ __export(webSocketMock_exports, {
|
|
|
48
48
|
inject: () => inject
|
|
49
49
|
});
|
|
50
50
|
module.exports = __toCommonJS(webSocketMock_exports);
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
|
|
52
|
+
// packages/playwright-core/src/utils/isomorphic/builtins.ts
|
|
53
|
+
function builtins(global) {
|
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
55
|
+
global = global != null ? global : globalThis;
|
|
56
|
+
if (!global["__playwright_builtins__"]) {
|
|
57
|
+
const builtins2 = {
|
|
58
|
+
setTimeout: (_a = global.setTimeout) == null ? void 0 : _a.bind(global),
|
|
59
|
+
clearTimeout: (_b = global.clearTimeout) == null ? void 0 : _b.bind(global),
|
|
60
|
+
setInterval: (_c = global.setInterval) == null ? void 0 : _c.bind(global),
|
|
61
|
+
clearInterval: (_d = global.clearInterval) == null ? void 0 : _d.bind(global),
|
|
62
|
+
requestAnimationFrame: (_e = global.requestAnimationFrame) == null ? void 0 : _e.bind(global),
|
|
63
|
+
cancelAnimationFrame: (_f = global.cancelAnimationFrame) == null ? void 0 : _f.bind(global),
|
|
64
|
+
requestIdleCallback: (_g = global.requestIdleCallback) == null ? void 0 : _g.bind(global),
|
|
65
|
+
cancelIdleCallback: (_h = global.cancelIdleCallback) == null ? void 0 : _h.bind(global),
|
|
66
|
+
performance: global.performance,
|
|
67
|
+
eval: (_i = global.eval) == null ? void 0 : _i.bind(global),
|
|
68
|
+
Intl: global.Intl,
|
|
69
|
+
Date: global.Date,
|
|
70
|
+
Map: global.Map,
|
|
71
|
+
Set: global.Set
|
|
72
|
+
};
|
|
73
|
+
Object.defineProperty(global, "__playwright_builtins__", { value: builtins2, configurable: false, enumerable: false, writable: false });
|
|
74
|
+
}
|
|
75
|
+
return global["__playwright_builtins__"];
|
|
76
|
+
}
|
|
77
|
+
var instance = builtins();
|
|
78
|
+
var setTimeout = instance.setTimeout;
|
|
79
|
+
var clearTimeout = instance.clearTimeout;
|
|
80
|
+
var setInterval = instance.setInterval;
|
|
81
|
+
var clearInterval = instance.clearInterval;
|
|
82
|
+
var requestAnimationFrame = instance.requestAnimationFrame;
|
|
83
|
+
var cancelAnimationFrame = instance.cancelAnimationFrame;
|
|
84
|
+
var requestIdleCallback = instance.requestIdleCallback;
|
|
85
|
+
var cancelIdleCallback = instance.cancelIdleCallback;
|
|
86
|
+
var performance = instance.performance;
|
|
87
|
+
var Intl = instance.Intl;
|
|
88
|
+
var Date = instance.Date;
|
|
89
|
+
var Map = instance.Map;
|
|
90
|
+
var Set = instance.Set;
|
|
91
|
+
|
|
92
|
+
// packages/injected/src/webSocketMock.ts
|
|
93
|
+
function inject(globalThis2) {
|
|
94
|
+
if (globalThis2.__pwWebSocketDispatch)
|
|
53
95
|
return;
|
|
54
96
|
function generateId() {
|
|
55
97
|
const bytes = new Uint8Array(32);
|
|
56
|
-
|
|
98
|
+
globalThis2.crypto.getRandomValues(bytes);
|
|
57
99
|
const hex = "0123456789abcdef";
|
|
58
100
|
return [...bytes].map((value) => {
|
|
59
101
|
const high = Math.floor(value / 16);
|
|
@@ -65,17 +107,17 @@ function inject(globalThis) {
|
|
|
65
107
|
let s = "";
|
|
66
108
|
for (let i = 0; i < b.length; i++)
|
|
67
109
|
s += String.fromCharCode(b[i]);
|
|
68
|
-
return { data:
|
|
110
|
+
return { data: globalThis2.btoa(s), isBase64: true };
|
|
69
111
|
}
|
|
70
112
|
function stringToBuffer(s) {
|
|
71
|
-
s =
|
|
113
|
+
s = globalThis2.atob(s);
|
|
72
114
|
const b = new Uint8Array(s.length);
|
|
73
115
|
for (let i = 0; i < s.length; i++)
|
|
74
116
|
b[i] = s.charCodeAt(i);
|
|
75
117
|
return b.buffer;
|
|
76
118
|
}
|
|
77
119
|
function messageToData(message, cb) {
|
|
78
|
-
if (message instanceof
|
|
120
|
+
if (message instanceof globalThis2.Blob)
|
|
79
121
|
return message.arrayBuffer().then((buffer) => cb(bufferToData(new Uint8Array(buffer))));
|
|
80
122
|
if (typeof message === "string")
|
|
81
123
|
return cb({ data: message, isBase64: false });
|
|
@@ -89,10 +131,10 @@ function inject(globalThis) {
|
|
|
89
131
|
const buffer = stringToBuffer(data.data);
|
|
90
132
|
return binaryType === "arraybuffer" ? buffer : new Blob([buffer]);
|
|
91
133
|
}
|
|
92
|
-
const binding =
|
|
93
|
-
const NativeWebSocket =
|
|
94
|
-
const idToWebSocket =
|
|
95
|
-
|
|
134
|
+
const binding = globalThis2.__pwWebSocketBinding;
|
|
135
|
+
const NativeWebSocket = globalThis2.WebSocket;
|
|
136
|
+
const idToWebSocket = new Map();
|
|
137
|
+
globalThis2.__pwWebSocketDispatch = (request) => {
|
|
96
138
|
const ws = idToWebSocket.get(request.id);
|
|
97
139
|
if (!ws)
|
|
98
140
|
return;
|
|
@@ -136,7 +178,7 @@ function inject(globalThis) {
|
|
|
136
178
|
this._passthrough = false;
|
|
137
179
|
this._wsBufferedMessages = [];
|
|
138
180
|
this._binaryType = "blob";
|
|
139
|
-
this.url = new URL(url,
|
|
181
|
+
this.url = new URL(url, globalThis2.window.document.baseURI).href.replace(/^http/, "ws");
|
|
140
182
|
this._origin = (_b = (_a = URL.parse(this.url)) == null ? void 0 : _a.origin) != null ? _b : "";
|
|
141
183
|
this._protocols = protocols;
|
|
142
184
|
this._id = generateId();
|
|
@@ -326,7 +368,7 @@ function inject(globalThis) {
|
|
|
326
368
|
// WebSocket.CLOSING
|
|
327
369
|
_WebSocketMock.CLOSED = 3;
|
|
328
370
|
let WebSocketMock = _WebSocketMock;
|
|
329
|
-
|
|
371
|
+
globalThis2.WebSocket = class WebSocket extends WebSocketMock {
|
|
330
372
|
};
|
|
331
373
|
}
|
|
332
374
|
`;
|
|
@@ -112,7 +112,7 @@ class LocalUtilsDispatcher extends import_dispatcher.Dispatcher {
|
|
|
112
112
|
pipe.on("close", () => transport.close());
|
|
113
113
|
return { pipe, headers: transport.headers };
|
|
114
114
|
}
|
|
115
|
-
async globToRegex(params,
|
|
115
|
+
async globToRegex(params, metadata) {
|
|
116
116
|
const regex = (0, import_urlMatch.resolveGlobToRegexPattern)(params.baseURL, params.glob, params.webSocketUrl);
|
|
117
117
|
return { regex };
|
|
118
118
|
}
|
|
@@ -38,6 +38,8 @@ var import_harTracer = require("./harTracer");
|
|
|
38
38
|
var import_crypto = require("../utils/crypto");
|
|
39
39
|
var import_manualPromise = require("../../utils/isomorphic/manualPromise");
|
|
40
40
|
var import_zipBundle = require("../../zipBundle");
|
|
41
|
+
var import_fileUtils = require("../utils/fileUtils");
|
|
42
|
+
var import_secretsFilter = require("../../checkly/secretsFilter");
|
|
41
43
|
class HarRecorder {
|
|
42
44
|
constructor(context, page, options) {
|
|
43
45
|
this._isFlushed = false;
|
|
@@ -56,7 +58,7 @@ class HarRecorder {
|
|
|
56
58
|
waitForContentOnStop: true,
|
|
57
59
|
urlFilter: urlFilterRe ?? options.urlGlob
|
|
58
60
|
});
|
|
59
|
-
this._zipFile = content === "attach" || expectsZip ? new import_zipBundle.yazl.ZipFile() : null;
|
|
61
|
+
this._zipFile = content === "attach" || expectsZip ? new (new import_fileUtils.SecretSerializedFS((0, import_secretsFilter.secretsFilter)()).createScrubbingZipFile(import_zipBundle.yazl.ZipFile))() : null;
|
|
60
62
|
this._tracer.start({ omitScripts: false });
|
|
61
63
|
}
|
|
62
64
|
onEntryStarted(entry) {
|
|
@@ -0,0 +1,88 @@
|
|
|
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 pageBinding_exports = {};
|
|
20
|
+
__export(pageBinding_exports, {
|
|
21
|
+
createPageBindingScript: () => createPageBindingScript,
|
|
22
|
+
deliverBindingResult: () => deliverBindingResult,
|
|
23
|
+
takeBindingHandle: () => takeBindingHandle
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(pageBinding_exports);
|
|
26
|
+
var import_builtins = require("../utils/isomorphic/builtins");
|
|
27
|
+
var import_utilityScriptSerializers = require("../utils/isomorphic/utilityScriptSerializers");
|
|
28
|
+
function addPageBinding(playwrightBinding, bindingName, needsHandle, utilityScriptSerializersFactory, builtins2) {
|
|
29
|
+
const { serializeAsCallArgument } = utilityScriptSerializersFactory(builtins2);
|
|
30
|
+
const binding = globalThis[playwrightBinding];
|
|
31
|
+
globalThis[bindingName] = (...args) => {
|
|
32
|
+
const me = globalThis[bindingName];
|
|
33
|
+
if (needsHandle && args.slice(1).some((arg) => arg !== void 0))
|
|
34
|
+
throw new Error(`exposeBindingHandle supports a single argument, ${args.length} received`);
|
|
35
|
+
let callbacks = me["callbacks"];
|
|
36
|
+
if (!callbacks) {
|
|
37
|
+
callbacks = new builtins2.Map();
|
|
38
|
+
me["callbacks"] = callbacks;
|
|
39
|
+
}
|
|
40
|
+
const seq = (me["lastSeq"] || 0) + 1;
|
|
41
|
+
me["lastSeq"] = seq;
|
|
42
|
+
let handles = me["handles"];
|
|
43
|
+
if (!handles) {
|
|
44
|
+
handles = new builtins2.Map();
|
|
45
|
+
me["handles"] = handles;
|
|
46
|
+
}
|
|
47
|
+
const promise = new Promise((resolve, reject) => callbacks.set(seq, { resolve, reject }));
|
|
48
|
+
let payload;
|
|
49
|
+
if (needsHandle) {
|
|
50
|
+
handles.set(seq, args[0]);
|
|
51
|
+
payload = { name: bindingName, seq };
|
|
52
|
+
} else {
|
|
53
|
+
const serializedArgs = [];
|
|
54
|
+
for (let i = 0; i < args.length; i++) {
|
|
55
|
+
serializedArgs[i] = serializeAsCallArgument(args[i], (v) => {
|
|
56
|
+
return { fallThrough: v };
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
payload = { name: bindingName, seq, serializedArgs };
|
|
60
|
+
}
|
|
61
|
+
binding(JSON.stringify(payload));
|
|
62
|
+
return promise;
|
|
63
|
+
};
|
|
64
|
+
globalThis[bindingName].__installed = true;
|
|
65
|
+
}
|
|
66
|
+
function takeBindingHandle(arg) {
|
|
67
|
+
const handles = globalThis[arg.name]["handles"];
|
|
68
|
+
const handle = handles.get(arg.seq);
|
|
69
|
+
handles.delete(arg.seq);
|
|
70
|
+
return handle;
|
|
71
|
+
}
|
|
72
|
+
function deliverBindingResult(arg) {
|
|
73
|
+
const callbacks = globalThis[arg.name]["callbacks"];
|
|
74
|
+
if ("error" in arg)
|
|
75
|
+
callbacks.get(arg.seq).reject(arg.error);
|
|
76
|
+
else
|
|
77
|
+
callbacks.get(arg.seq).resolve(arg.result);
|
|
78
|
+
callbacks.delete(arg.seq);
|
|
79
|
+
}
|
|
80
|
+
function createPageBindingScript(playwrightBinding, name, needsHandle) {
|
|
81
|
+
return `(${addPageBinding.toString()})(${JSON.stringify(playwrightBinding)}, ${JSON.stringify(name)}, ${needsHandle}, (${import_utilityScriptSerializers.source}), (${import_builtins.builtins})())`;
|
|
82
|
+
}
|
|
83
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
84
|
+
0 && (module.exports = {
|
|
85
|
+
createPageBindingScript,
|
|
86
|
+
deliverBindingResult,
|
|
87
|
+
takeBindingHandle
|
|
88
|
+
});
|
|
@@ -43,11 +43,11 @@ var import_eventsHelper = require("../../utils/eventsHelper");
|
|
|
43
43
|
var import_crypto = require("../../utils/crypto");
|
|
44
44
|
var import_artifact = require("../../artifact");
|
|
45
45
|
var import_browserContext = require("../../browserContext");
|
|
46
|
-
var import_dispatcher = require("../../dispatchers/dispatcher");
|
|
47
46
|
var import_errors = require("../../errors");
|
|
48
47
|
var import_fileUtils = require("../../utils/fileUtils");
|
|
49
48
|
var import_harTracer = require("../../har/harTracer");
|
|
50
49
|
var import_instrumentation = require("../../instrumentation");
|
|
50
|
+
var import_dispatcher = require("../../dispatchers/dispatcher");
|
|
51
51
|
var import_page = require("../../page");
|
|
52
52
|
var import_secretsFilter = require("../../../checkly/secretsFilter");
|
|
53
53
|
var import_progress = require("../../progress");
|
|
@@ -56,7 +56,6 @@ const kScreencastOptions = { width: 800, height: 600, quality: 90 };
|
|
|
56
56
|
class Tracing extends import_instrumentation.SdkObject {
|
|
57
57
|
constructor(context, tracesDir) {
|
|
58
58
|
super(context, "tracing");
|
|
59
|
-
this._fs = new import_fileUtils.SerializedFS();
|
|
60
59
|
this._screencastListeners = [];
|
|
61
60
|
this._eventListeners = [];
|
|
62
61
|
this._isStopping = false;
|
|
@@ -64,7 +63,7 @@ class Tracing extends import_instrumentation.SdkObject {
|
|
|
64
63
|
this._pendingHarEntries = /* @__PURE__ */ new Set();
|
|
65
64
|
this._context = context;
|
|
66
65
|
this._precreatedTracesDir = tracesDir;
|
|
67
|
-
this.
|
|
66
|
+
this._fs = new import_fileUtils.SecretSerializedFS((0, import_secretsFilter.secretsFilter)());
|
|
68
67
|
this._harTracer = new import_harTracer.HarTracer(context, null, this, {
|
|
69
68
|
content: "attach",
|
|
70
69
|
includeTraceInfo: true,
|
|
@@ -384,7 +383,7 @@ class Tracing extends import_instrumentation.SdkObject {
|
|
|
384
383
|
onEntryFinished(entry) {
|
|
385
384
|
this._pendingHarEntries.delete(entry);
|
|
386
385
|
const event = { type: "resource-snapshot", snapshot: entry };
|
|
387
|
-
const visited = visitTraceEvent(event, this._state.networkSha1s
|
|
386
|
+
const visited = visitTraceEvent(event, this._state.networkSha1s);
|
|
388
387
|
this._fs.appendFile(
|
|
389
388
|
this._state.networkFile,
|
|
390
389
|
JSON.stringify(visited) + "\n",
|
|
@@ -396,7 +395,7 @@ class Tracing extends import_instrumentation.SdkObject {
|
|
|
396
395
|
const harLines = [];
|
|
397
396
|
for (const entry of this._pendingHarEntries) {
|
|
398
397
|
const event = { type: "resource-snapshot", snapshot: entry };
|
|
399
|
-
const visited = visitTraceEvent(event, this._state.networkSha1s
|
|
398
|
+
const visited = visitTraceEvent(event, this._state.networkSha1s);
|
|
400
399
|
harLines.push(JSON.stringify(visited));
|
|
401
400
|
}
|
|
402
401
|
this._pendingHarEntries.clear();
|
|
@@ -502,7 +501,7 @@ class Tracing extends import_instrumentation.SdkObject {
|
|
|
502
501
|
);
|
|
503
502
|
}
|
|
504
503
|
_appendTraceEvent(event) {
|
|
505
|
-
const visited = visitTraceEvent(event, this._state.traceSha1s
|
|
504
|
+
const visited = visitTraceEvent(event, this._state.traceSha1s);
|
|
506
505
|
const flush = this._state.options.live || event.type !== "event" && event.type !== "console" && event.type !== "log";
|
|
507
506
|
this._fs.appendFile(this._state.traceFile, JSON.stringify(visited) + "\n", flush);
|
|
508
507
|
}
|
|
@@ -519,14 +518,9 @@ class Tracing extends import_instrumentation.SdkObject {
|
|
|
519
518
|
);
|
|
520
519
|
}
|
|
521
520
|
}
|
|
522
|
-
function visitTraceEvent(object, sha1s
|
|
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
|
-
}
|
|
521
|
+
function visitTraceEvent(object, sha1s) {
|
|
522
|
+
if (Array.isArray(object))
|
|
523
|
+
return object.map((o) => visitTraceEvent(o, sha1s));
|
|
530
524
|
if (object instanceof import_dispatcher.Dispatcher)
|
|
531
525
|
return `<${object._type}>`;
|
|
532
526
|
if (object instanceof Buffer)
|
|
@@ -541,11 +535,7 @@ function visitTraceEvent(object, sha1s, secretsFilter2) {
|
|
|
541
535
|
if (value)
|
|
542
536
|
sha1s.add(value);
|
|
543
537
|
}
|
|
544
|
-
|
|
545
|
-
result[key] = key.endsWith("Sha1") || ["pageref", "_sha1", "downloadsPath", "tracesDir", "pageId", "sha1"].includes(key) ? value : secretsFilter2(value);
|
|
546
|
-
} else {
|
|
547
|
-
result[key] = visitTraceEvent(value, sha1s, secretsFilter2);
|
|
548
|
-
}
|
|
538
|
+
result[key] = visitTraceEvent(value, sha1s);
|
|
549
539
|
}
|
|
550
540
|
return result;
|
|
551
541
|
}
|
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var fileUtils_exports = {};
|
|
30
30
|
__export(fileUtils_exports, {
|
|
31
|
+
SecretSerializedFS: () => SecretSerializedFS,
|
|
31
32
|
SerializedFS: () => SerializedFS,
|
|
32
33
|
canAccessFile: () => canAccessFile,
|
|
33
34
|
copyFileAndMakeWritable: () => copyFileAndMakeWritable,
|
|
@@ -178,8 +179,63 @@ class SerializedFS {
|
|
|
178
179
|
}
|
|
179
180
|
}
|
|
180
181
|
}
|
|
182
|
+
class SecretSerializedFS extends SerializedFS {
|
|
183
|
+
constructor(secretsFilter) {
|
|
184
|
+
super();
|
|
185
|
+
this._secretsFilter = secretsFilter;
|
|
186
|
+
}
|
|
187
|
+
writeFile(file, content, skipIfExists) {
|
|
188
|
+
const scrubbedContent = this._scrubContent(content);
|
|
189
|
+
super.writeFile(file, scrubbedContent, skipIfExists);
|
|
190
|
+
}
|
|
191
|
+
appendFile(file, text, flush) {
|
|
192
|
+
const scrubbedText = this._scrubContent(text);
|
|
193
|
+
super.appendFile(file, scrubbedText, flush);
|
|
194
|
+
}
|
|
195
|
+
// [Checkly] Create a scrubbing-enabled zip file wrapper
|
|
196
|
+
createScrubbingZipFile(ZipFileClass) {
|
|
197
|
+
const scrubContent = this._scrubContent.bind(this);
|
|
198
|
+
return class ScrubbingZipFile extends ZipFileClass {
|
|
199
|
+
addBuffer(buffer, metadataPath) {
|
|
200
|
+
const scrubbedBuffer = scrubContent(buffer);
|
|
201
|
+
super.addBuffer(scrubbedBuffer, metadataPath);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// [Checkly] Apply secret scrubbing to any content being written
|
|
206
|
+
_scrubContent(content) {
|
|
207
|
+
if (Buffer.isBuffer(content)) {
|
|
208
|
+
try {
|
|
209
|
+
const text = content.toString("utf8");
|
|
210
|
+
if (this._isLikelyTextContent(text)) {
|
|
211
|
+
const scrubbedText = this._secretsFilter(text);
|
|
212
|
+
return Buffer.from(scrubbedText, "utf8");
|
|
213
|
+
}
|
|
214
|
+
return content;
|
|
215
|
+
} catch {
|
|
216
|
+
return content;
|
|
217
|
+
}
|
|
218
|
+
} else {
|
|
219
|
+
return this._secretsFilter(content);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
// [Checkly] Check if content looks like text that could contain secrets
|
|
223
|
+
_isLikelyTextContent(text) {
|
|
224
|
+
if (text.length === 0)
|
|
225
|
+
return false;
|
|
226
|
+
const sampleSize = Math.min(1e3, text.length);
|
|
227
|
+
let printableCount = 0;
|
|
228
|
+
for (let i = 0; i < sampleSize; i++) {
|
|
229
|
+
const code = text.charCodeAt(i);
|
|
230
|
+
if (code >= 32 && code <= 126 || code === 9 || code === 10 || code === 13)
|
|
231
|
+
printableCount++;
|
|
232
|
+
}
|
|
233
|
+
return printableCount / sampleSize > 0.8;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
181
236
|
// Annotate the CommonJS export names for ESM import in node:
|
|
182
237
|
0 && (module.exports = {
|
|
238
|
+
SecretSerializedFS,
|
|
183
239
|
SerializedFS,
|
|
184
240
|
canAccessFile,
|
|
185
241
|
copyFileAndMakeWritable,
|
|
@@ -36,7 +36,6 @@ var js = __toESM(require("../javascript"));
|
|
|
36
36
|
var dom = __toESM(require("../dom"));
|
|
37
37
|
var import_protocolError = require("../protocolError");
|
|
38
38
|
var import_assert = require("../../utils/isomorphic/assert");
|
|
39
|
-
var import_utilityScriptSerializers = require("../../utils/isomorphic/utilityScriptSerializers");
|
|
40
39
|
class WKExecutionContext {
|
|
41
40
|
constructor(session, contextId) {
|
|
42
41
|
this._session = session;
|
|
@@ -87,7 +86,7 @@ class WKExecutionContext {
|
|
|
87
86
|
if (response.wasThrown)
|
|
88
87
|
throw new js.JavaScriptErrorInEvaluate(response.result.description);
|
|
89
88
|
if (returnByValue)
|
|
90
|
-
return
|
|
89
|
+
return js.parseEvaluationResultValue(response.result.value);
|
|
91
90
|
return createHandle(utilityScript._context, response.result);
|
|
92
91
|
} catch (error) {
|
|
93
92
|
throw rewriteError(error);
|
|
@@ -0,0 +1,90 @@
|
|
|
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 builtins_exports = {};
|
|
20
|
+
__export(builtins_exports, {
|
|
21
|
+
Date: () => Date,
|
|
22
|
+
Intl: () => Intl,
|
|
23
|
+
Map: () => Map,
|
|
24
|
+
Set: () => Set,
|
|
25
|
+
builtins: () => builtins,
|
|
26
|
+
cancelAnimationFrame: () => cancelAnimationFrame,
|
|
27
|
+
cancelIdleCallback: () => cancelIdleCallback,
|
|
28
|
+
clearInterval: () => clearInterval,
|
|
29
|
+
clearTimeout: () => clearTimeout,
|
|
30
|
+
performance: () => performance,
|
|
31
|
+
requestAnimationFrame: () => requestAnimationFrame,
|
|
32
|
+
requestIdleCallback: () => requestIdleCallback,
|
|
33
|
+
setInterval: () => setInterval,
|
|
34
|
+
setTimeout: () => setTimeout
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(builtins_exports);
|
|
37
|
+
function builtins(global) {
|
|
38
|
+
global = global ?? globalThis;
|
|
39
|
+
if (!global["__playwright_builtins__"]) {
|
|
40
|
+
const builtins2 = {
|
|
41
|
+
setTimeout: global.setTimeout?.bind(global),
|
|
42
|
+
clearTimeout: global.clearTimeout?.bind(global),
|
|
43
|
+
setInterval: global.setInterval?.bind(global),
|
|
44
|
+
clearInterval: global.clearInterval?.bind(global),
|
|
45
|
+
requestAnimationFrame: global.requestAnimationFrame?.bind(global),
|
|
46
|
+
cancelAnimationFrame: global.cancelAnimationFrame?.bind(global),
|
|
47
|
+
requestIdleCallback: global.requestIdleCallback?.bind(global),
|
|
48
|
+
cancelIdleCallback: global.cancelIdleCallback?.bind(global),
|
|
49
|
+
performance: global.performance,
|
|
50
|
+
eval: global.eval?.bind(global),
|
|
51
|
+
Intl: global.Intl,
|
|
52
|
+
Date: global.Date,
|
|
53
|
+
Map: global.Map,
|
|
54
|
+
Set: global.Set
|
|
55
|
+
};
|
|
56
|
+
Object.defineProperty(global, "__playwright_builtins__", { value: builtins2, configurable: false, enumerable: false, writable: false });
|
|
57
|
+
}
|
|
58
|
+
return global["__playwright_builtins__"];
|
|
59
|
+
}
|
|
60
|
+
const instance = builtins();
|
|
61
|
+
const setTimeout = instance.setTimeout;
|
|
62
|
+
const clearTimeout = instance.clearTimeout;
|
|
63
|
+
const setInterval = instance.setInterval;
|
|
64
|
+
const clearInterval = instance.clearInterval;
|
|
65
|
+
const requestAnimationFrame = instance.requestAnimationFrame;
|
|
66
|
+
const cancelAnimationFrame = instance.cancelAnimationFrame;
|
|
67
|
+
const requestIdleCallback = instance.requestIdleCallback;
|
|
68
|
+
const cancelIdleCallback = instance.cancelIdleCallback;
|
|
69
|
+
const performance = instance.performance;
|
|
70
|
+
const Intl = instance.Intl;
|
|
71
|
+
const Date = instance.Date;
|
|
72
|
+
const Map = instance.Map;
|
|
73
|
+
const Set = instance.Set;
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
Date,
|
|
77
|
+
Intl,
|
|
78
|
+
Map,
|
|
79
|
+
Set,
|
|
80
|
+
builtins,
|
|
81
|
+
cancelAnimationFrame,
|
|
82
|
+
cancelIdleCallback,
|
|
83
|
+
clearInterval,
|
|
84
|
+
clearTimeout,
|
|
85
|
+
performance,
|
|
86
|
+
requestAnimationFrame,
|
|
87
|
+
requestIdleCallback,
|
|
88
|
+
setInterval,
|
|
89
|
+
setTimeout
|
|
90
|
+
});
|
|
@@ -34,6 +34,7 @@ __export(cssParser_exports, {
|
|
|
34
34
|
serializeSelector: () => serializeSelector
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(cssParser_exports);
|
|
37
|
+
var import_builtins = require("./builtins");
|
|
37
38
|
var css = __toESM(require("./cssTokenizer"));
|
|
38
39
|
class InvalidSelectorError extends Error {
|
|
39
40
|
}
|
|
@@ -64,7 +65,7 @@ function parseCSS(selector, customNames) {
|
|
|
64
65
|
if (unsupportedToken)
|
|
65
66
|
throw new InvalidSelectorError(`Unsupported token "${unsupportedToken.toSource()}" while parsing css selector "${selector}". Did you mean to CSS.escape it?`);
|
|
66
67
|
let pos = 0;
|
|
67
|
-
const names =
|
|
68
|
+
const names = new import_builtins.Set();
|
|
68
69
|
function unexpected() {
|
|
69
70
|
return new InvalidSelectorError(`Unexpected token "${tokens[pos].toSource()}" while parsing css selector "${selector}". Did you mean to CSS.escape it?`);
|
|
70
71
|
}
|
|
@@ -22,6 +22,7 @@ __export(manualPromise_exports, {
|
|
|
22
22
|
ManualPromise: () => ManualPromise
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(manualPromise_exports);
|
|
25
|
+
var import_builtins = require("./builtins");
|
|
25
26
|
var import_stackTrace = require("./stackTrace");
|
|
26
27
|
class ManualPromise extends Promise {
|
|
27
28
|
constructor() {
|
|
@@ -55,7 +56,7 @@ class ManualPromise extends Promise {
|
|
|
55
56
|
}
|
|
56
57
|
class LongStandingScope {
|
|
57
58
|
constructor() {
|
|
58
|
-
this._terminatePromises =
|
|
59
|
+
this._terminatePromises = new import_builtins.Map();
|
|
59
60
|
this._isClosed = false;
|
|
60
61
|
}
|
|
61
62
|
reject(error) {
|
|
@@ -23,6 +23,7 @@ __export(mimeType_exports, {
|
|
|
23
23
|
isTextualMimeType: () => isTextualMimeType
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(mimeType_exports);
|
|
26
|
+
var import_builtins = require("./builtins");
|
|
26
27
|
function isJsonMimeType(mimeType) {
|
|
27
28
|
return !!mimeType.match(/^(application\/json|application\/.*?\+json|text\/(x-)?json)(;\s*charset=.*)?$/);
|
|
28
29
|
}
|
|
@@ -36,7 +37,7 @@ function getMimeTypeForPath(path) {
|
|
|
36
37
|
const extension = path.substring(dotIndex + 1);
|
|
37
38
|
return types.get(extension) || null;
|
|
38
39
|
}
|
|
39
|
-
const types =
|
|
40
|
+
const types = new import_builtins.Map([
|
|
40
41
|
["ez", "application/andrew-inset"],
|
|
41
42
|
["aw", "application/applixware"],
|
|
42
43
|
["atom", "application/atom+xml"],
|
|
@@ -21,9 +21,10 @@ __export(multimap_exports, {
|
|
|
21
21
|
MultiMap: () => MultiMap
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(multimap_exports);
|
|
24
|
+
var import_builtins = require("./builtins");
|
|
24
25
|
class MultiMap {
|
|
25
26
|
constructor() {
|
|
26
|
-
this._map =
|
|
27
|
+
this._map = new import_builtins.Map();
|
|
27
28
|
}
|
|
28
29
|
set(key, value) {
|
|
29
30
|
let values = this._map.get(key);
|
|
@@ -28,11 +28,12 @@ __export(selectorParser_exports, {
|
|
|
28
28
|
visitAllSelectorParts: () => visitAllSelectorParts
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(selectorParser_exports);
|
|
31
|
+
var import_builtins = require("./builtins");
|
|
31
32
|
var import_cssParser = require("./cssParser");
|
|
32
33
|
var import_cssParser2 = require("./cssParser");
|
|
33
|
-
const kNestedSelectorNames =
|
|
34
|
-
const kNestedSelectorNamesWithDistance =
|
|
35
|
-
const customCSSNames =
|
|
34
|
+
const kNestedSelectorNames = new import_builtins.Set(["internal:has", "internal:has-not", "internal:and", "internal:or", "internal:chain", "left-of", "right-of", "above", "below", "near"]);
|
|
35
|
+
const kNestedSelectorNamesWithDistance = new import_builtins.Set(["left-of", "right-of", "above", "below", "near"]);
|
|
36
|
+
const customCSSNames = new import_builtins.Set(["not", "is", "where", "has", "scope", "light", "visible", "text", "text-matches", "text-is", "has-text", "above", "below", "right-of", "left-of", "near", "nth-match"]);
|
|
36
37
|
function parseSelector(selector) {
|
|
37
38
|
const parsedStrings = parseSelectorString(selector);
|
|
38
39
|
const parts = [];
|
|
@@ -37,6 +37,7 @@ __export(stringUtils_exports, {
|
|
|
37
37
|
trimStringWithEllipsis: () => trimStringWithEllipsis
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(stringUtils_exports);
|
|
40
|
+
var import_builtins = require("./builtins");
|
|
40
41
|
function escapeWithQuotes(text, char = "'") {
|
|
41
42
|
const stringified = JSON.stringify(text);
|
|
42
43
|
const escapedText = stringified.substring(1, stringified.length - 1).replace(/\\"/g, '"');
|
|
@@ -65,7 +66,7 @@ function quoteCSSAttributeValue(text) {
|
|
|
65
66
|
}
|
|
66
67
|
let normalizedWhitespaceCache;
|
|
67
68
|
function cacheNormalizedWhitespaces() {
|
|
68
|
-
normalizedWhitespaceCache =
|
|
69
|
+
normalizedWhitespaceCache = new import_builtins.Map();
|
|
69
70
|
}
|
|
70
71
|
function normalizeWhiteSpace(text) {
|
|
71
72
|
let result = normalizedWhitespaceCache?.get(text);
|
|
@@ -22,8 +22,9 @@ __export(traceUtils_exports, {
|
|
|
22
22
|
serializeClientSideCallMetadata: () => serializeClientSideCallMetadata
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(traceUtils_exports);
|
|
25
|
+
var import_builtins = require("./builtins");
|
|
25
26
|
function parseClientSideCallMetadata(data) {
|
|
26
|
-
const result =
|
|
27
|
+
const result = new import_builtins.Map();
|
|
27
28
|
const { files, stacks } = data;
|
|
28
29
|
for (const s of stacks) {
|
|
29
30
|
const [id, ff] = s;
|
|
@@ -32,7 +33,7 @@ function parseClientSideCallMetadata(data) {
|
|
|
32
33
|
return result;
|
|
33
34
|
}
|
|
34
35
|
function serializeClientSideCallMetadata(metadatas) {
|
|
35
|
-
const fileNames =
|
|
36
|
+
const fileNames = new import_builtins.Map();
|
|
36
37
|
const stacks = [];
|
|
37
38
|
for (const m of metadatas) {
|
|
38
39
|
if (!m.stack || !m.stack.length)
|
|
@@ -25,8 +25,9 @@ __export(urlMatch_exports, {
|
|
|
25
25
|
urlMatchesEqual: () => urlMatchesEqual
|
|
26
26
|
});
|
|
27
27
|
module.exports = __toCommonJS(urlMatch_exports);
|
|
28
|
+
var import_builtins = require("./builtins");
|
|
28
29
|
var import_stringUtils = require("./stringUtils");
|
|
29
|
-
const escapedChars =
|
|
30
|
+
const escapedChars = new import_builtins.Set(["$", "^", "+", ".", "*", "(", ")", "|", "\\", "?", "{", "}", "[", "]"]);
|
|
30
31
|
function globToRegexPattern(glob) {
|
|
31
32
|
const tokens = ["^"];
|
|
32
33
|
let inGroup = false;
|
|
@@ -121,7 +122,7 @@ function resolveGlobBase(baseURL, match) {
|
|
|
121
122
|
return replacement;
|
|
122
123
|
};
|
|
123
124
|
var mapToken = mapToken2;
|
|
124
|
-
const tokenMap =
|
|
125
|
+
const tokenMap = new import_builtins.Map();
|
|
125
126
|
match = match.replaceAll(/\\\\\?/g, "?");
|
|
126
127
|
if (match.startsWith("about:") || match.startsWith("data:") || match.startsWith("chrome:") || match.startsWith("edge:") || match.startsWith("file:"))
|
|
127
128
|
return match;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checkly/playwright-core",
|
|
3
|
-
"version": "1.54.2-beta.
|
|
3
|
+
"version": "1.54.2-beta.2",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"./lib/server/registry/index": "./lib/server/registry/index.js",
|
|
34
34
|
"./lib/utils": "./lib/utils.js",
|
|
35
35
|
"./lib/utilsBundle": "./lib/utilsBundle.js",
|
|
36
|
+
"./lib/checkly": "./lib/checkly/index.js",
|
|
36
37
|
"./lib/zipBundle": "./lib/zipBundle.js",
|
|
37
38
|
"./types/protocol": "./types/protocol.d.ts",
|
|
38
39
|
"./types/structs": "./types/structs.d.ts"
|