@piwitests/reporter 0.66.0 → 0.67.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/dist/global-setup-module.js +100 -14
- package/dist/index.d.ts +45 -21
- package/dist/index.js +2261 -1892
- package/dist/internal/capture/capture-fixtures.d.ts +14 -1
- package/dist/internal/capture/capture-fixtures.js +350 -211
- package/package.json +1 -1
|
@@ -55,13 +55,14 @@ __export(capture_fixtures_exports, {
|
|
|
55
55
|
readPageInteraction: () => readPageInteraction,
|
|
56
56
|
recordResourceCensus: () => recordResourceCensus,
|
|
57
57
|
resolveCodeReach: () => resolveCodeReach,
|
|
58
|
+
runningCall: () => runningCall,
|
|
58
59
|
startCodeReach: () => startCodeReach,
|
|
59
60
|
startResourceLedger: () => startResourceLedger,
|
|
60
61
|
stopCodeReach: () => stopCodeReach,
|
|
61
62
|
stopResourceLedger: () => stopResourceLedger
|
|
62
63
|
});
|
|
63
64
|
module.exports = __toCommonJS(capture_fixtures_exports);
|
|
64
|
-
var
|
|
65
|
+
var path19 = __toESM(require("path"));
|
|
65
66
|
var import_node_zlib2 = require("zlib");
|
|
66
67
|
|
|
67
68
|
// ../picker-dom/src/probe.ts
|
|
@@ -520,8 +521,8 @@ function installPickerOverlay(arg) {
|
|
|
520
521
|
return root && root !== doc && root.host ? root.host : null;
|
|
521
522
|
};
|
|
522
523
|
const targetOf = (e) => {
|
|
523
|
-
const
|
|
524
|
-
const first =
|
|
524
|
+
const path20 = typeof e.composedPath === "function" ? e.composedPath() : null;
|
|
525
|
+
const first = path20 && path20.length ? path20[0] : null;
|
|
525
526
|
return first && first.nodeType === 1 ? first : e.target;
|
|
526
527
|
};
|
|
527
528
|
const buildChain = (raw) => {
|
|
@@ -1223,8 +1224,8 @@ function showPauseBar(arg) {
|
|
|
1223
1224
|
g.__piwiPauseState = choice;
|
|
1224
1225
|
};
|
|
1225
1226
|
const pageTakesEscape = (e) => {
|
|
1226
|
-
const
|
|
1227
|
-
const el =
|
|
1227
|
+
const path20 = typeof e.composedPath === "function" ? e.composedPath() : [e.target];
|
|
1228
|
+
const el = path20.find((node) => node && node.nodeType === 1);
|
|
1228
1229
|
if (el && !bar.contains(el) && typeof el.closest === "function") {
|
|
1229
1230
|
if (el.closest('dialog[open],[role="dialog"],[role="alertdialog"],[role="listbox"],[role="menu"]')) return true;
|
|
1230
1231
|
const popup = '[aria-expanded="true"]:is([role="combobox"],[aria-haspopup]:not([aria-haspopup="false"]))';
|
|
@@ -2116,21 +2117,21 @@ var MAX_INDETERMINATE = 20;
|
|
|
2116
2117
|
var STEP = String.raw`[a-zA-Z][\w.-]*:[1-9]\d*`;
|
|
2117
2118
|
var LEVEL = `${STEP}(?:/${STEP})*`;
|
|
2118
2119
|
var ELEMENT_PATH_RE = new RegExp(`^${LEVEL}(?:\\|${LEVEL})*$`);
|
|
2119
|
-
function isElementPath(
|
|
2120
|
-
return typeof
|
|
2120
|
+
function isElementPath(path20) {
|
|
2121
|
+
return typeof path20 === "string" && path20.length <= ELEMENT_PATH_MAX_CHARS && ELEMENT_PATH_RE.test(path20);
|
|
2121
2122
|
}
|
|
2122
2123
|
var offsetOf = (v) => typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 1e7 ? v : null;
|
|
2123
2124
|
function elementRef(v) {
|
|
2124
2125
|
if (!v || typeof v !== "object") return null;
|
|
2125
|
-
const { path:
|
|
2126
|
-
if (!isElementPath(
|
|
2127
|
-
return { path:
|
|
2126
|
+
const { path: path20, label } = v;
|
|
2127
|
+
if (!isElementPath(path20)) return null;
|
|
2128
|
+
return { path: path20, label: typeof label === "string" ? label.slice(0, ELEMENT_LABEL_MAX_CHARS) : "" };
|
|
2128
2129
|
}
|
|
2129
2130
|
function textPoint(v) {
|
|
2130
2131
|
if (!v || typeof v !== "object") return null;
|
|
2131
|
-
const { path:
|
|
2132
|
+
const { path: path20, offset } = v;
|
|
2132
2133
|
const at = offsetOf(offset);
|
|
2133
|
-
return isElementPath(
|
|
2134
|
+
return isElementPath(path20) && at !== null ? { path: path20, offset: at } : null;
|
|
2134
2135
|
}
|
|
2135
2136
|
function sanitizePageInteraction(raw) {
|
|
2136
2137
|
if (!raw || typeof raw !== "object") return {};
|
|
@@ -2556,9 +2557,9 @@ var LOCATOR_SUGGESTION_ANNOTATION = ATTACHMENT_NAMES.locatorSuggestion;
|
|
|
2556
2557
|
var USER_PICK_ANNOTATION = ATTACHMENT_NAMES.userPick;
|
|
2557
2558
|
|
|
2558
2559
|
// src/internal/capture/failure-screenshot.ts
|
|
2559
|
-
function keepsFailureScreenshots(option,
|
|
2560
|
+
function keepsFailureScreenshots(option, retry2) {
|
|
2560
2561
|
const mode = typeof option === "string" ? option : option?.mode;
|
|
2561
|
-
return mode === "on" || mode === "only-on-failure" || mode === "on-first-failure" &&
|
|
2562
|
+
return mode === "on" || mode === "only-on-failure" || mode === "on-first-failure" && retry2 === 0;
|
|
2562
2563
|
}
|
|
2563
2564
|
async function readFailureScreenshot(page, option) {
|
|
2564
2565
|
const options = typeof option === "object" && option !== null ? option : null;
|
|
@@ -2907,6 +2908,7 @@ var PIWI_FLAKE_ENV = {
|
|
|
2907
2908
|
results: "PIWI_FLAKE_RESULTS"
|
|
2908
2909
|
};
|
|
2909
2910
|
var PIWI_RESOURCES_RESULTS_ENV = "PIWI_RESOURCES_RESULTS";
|
|
2911
|
+
var PIWI_RUN_LOG_ENV = "PIWI_RUN_LOG";
|
|
2910
2912
|
var ENV_FALLBACK_SPECS = [
|
|
2911
2913
|
{ option: "serverUrl", env: PIWI_ENV_KEYS.serverUrl, kind: "string" },
|
|
2912
2914
|
{ option: "projectName", env: PIWI_ENV_KEYS.projectName, kind: "string" },
|
|
@@ -3002,16 +3004,16 @@ function parseRouteKey(routeKey2) {
|
|
|
3002
3004
|
}
|
|
3003
3005
|
var ROUTE_PARAM = /:[A-Za-z0-9_]+/y;
|
|
3004
3006
|
function routePatternMatcher(pattern) {
|
|
3005
|
-
const
|
|
3007
|
+
const path20 = pattern.split("?")[0] ?? pattern;
|
|
3006
3008
|
const tokens = [];
|
|
3007
|
-
for (let i = 0; i <
|
|
3009
|
+
for (let i = 0; i < path20.length; i++) {
|
|
3008
3010
|
ROUTE_PARAM.lastIndex = i;
|
|
3009
|
-
const param = ROUTE_PARAM.exec(
|
|
3011
|
+
const param = ROUTE_PARAM.exec(path20);
|
|
3010
3012
|
if (param) {
|
|
3011
3013
|
tokens.push({ kind: "one", slash: false }, { kind: "run", slash: false });
|
|
3012
3014
|
i += param[0].length - 1;
|
|
3013
3015
|
} else {
|
|
3014
|
-
tokens.push({ kind: "char", char:
|
|
3016
|
+
tokens.push({ kind: "char", char: path20[i] });
|
|
3015
3017
|
}
|
|
3016
3018
|
}
|
|
3017
3019
|
return compileGlob(tokens);
|
|
@@ -3036,13 +3038,13 @@ function matchProbeItem(plan, test) {
|
|
|
3036
3038
|
function requestMatchesRoute(method, url, routeKey2) {
|
|
3037
3039
|
const { method: rm, pattern } = parseRouteKey(routeKey2);
|
|
3038
3040
|
if (rm && rm !== method.toUpperCase()) return false;
|
|
3039
|
-
let
|
|
3041
|
+
let path20;
|
|
3040
3042
|
try {
|
|
3041
|
-
|
|
3043
|
+
path20 = new URL(url).pathname;
|
|
3042
3044
|
} catch {
|
|
3043
|
-
|
|
3045
|
+
path20 = url.split("?")[0] ?? url;
|
|
3044
3046
|
}
|
|
3045
|
-
return routePatternMatcher(pattern)(
|
|
3047
|
+
return routePatternMatcher(pattern)(path20);
|
|
3046
3048
|
}
|
|
3047
3049
|
function createProbeState() {
|
|
3048
3050
|
return { navigated: false, matches: 0 };
|
|
@@ -3064,10 +3066,10 @@ function isProbeMode() {
|
|
|
3064
3066
|
function loadPlan() {
|
|
3065
3067
|
if (planCache !== void 0) return planCache;
|
|
3066
3068
|
planCache = null;
|
|
3067
|
-
const
|
|
3068
|
-
if (
|
|
3069
|
+
const path20 = process.env[PIWI_PROBE_ENV.plan];
|
|
3070
|
+
if (path20) {
|
|
3069
3071
|
try {
|
|
3070
|
-
planCache = JSON.parse(fs3.readFileSync(
|
|
3072
|
+
planCache = JSON.parse(fs3.readFileSync(path20, "utf8"));
|
|
3071
3073
|
} catch {
|
|
3072
3074
|
planCache = null;
|
|
3073
3075
|
}
|
|
@@ -3101,10 +3103,10 @@ function outcomeFromStatus(status, applied) {
|
|
|
3101
3103
|
return status === "passed" ? "not-noticed" : "inconclusive";
|
|
3102
3104
|
}
|
|
3103
3105
|
function recordProbeOutcome(line) {
|
|
3104
|
-
const
|
|
3105
|
-
if (!
|
|
3106
|
+
const path20 = process.env[PIWI_PROBE_ENV.results];
|
|
3107
|
+
if (!path20) return;
|
|
3106
3108
|
try {
|
|
3107
|
-
fs3.appendFileSync(
|
|
3109
|
+
fs3.appendFileSync(path20, `${JSON.stringify(line)}
|
|
3108
3110
|
`);
|
|
3109
3111
|
} catch {
|
|
3110
3112
|
}
|
|
@@ -4054,9 +4056,9 @@ function hideParams(params, count) {
|
|
|
4054
4056
|
return isSecretName(decodeSafe(name)) || isSecretValue(decoded) ? `${name}=${hide()}` : part;
|
|
4055
4057
|
}).join("");
|
|
4056
4058
|
}
|
|
4057
|
-
function hidePath(
|
|
4059
|
+
function hidePath(path20, count) {
|
|
4058
4060
|
const hide = hider(count);
|
|
4059
|
-
return
|
|
4061
|
+
return path20.split("/").map((segment) => {
|
|
4060
4062
|
const [own = "", ...params] = segment.split(";");
|
|
4061
4063
|
const decoded = decodeSafe(own);
|
|
4062
4064
|
const kept = decoded !== HIDDEN_VALUE && isSecretValue(decoded) ? hide() : own;
|
|
@@ -4066,14 +4068,14 @@ function hidePath(path19, count) {
|
|
|
4066
4068
|
function hideSecretsInUrl(url, count = { n: 0 }) {
|
|
4067
4069
|
const parts = URL_PARTS.exec(url);
|
|
4068
4070
|
if (!parts) return url;
|
|
4069
|
-
const [, scheme = "", authority,
|
|
4071
|
+
const [, scheme = "", authority, path20 = "", query = "", fragment = ""] = parts;
|
|
4070
4072
|
let out = "";
|
|
4071
4073
|
if (authority !== void 0) {
|
|
4072
4074
|
const at = authority.lastIndexOf("@");
|
|
4073
4075
|
const colon = at >= 0 ? authority.slice(0, at).indexOf(":") : -1;
|
|
4074
4076
|
out += colon >= 0 && colon < at - 1 ? `${scheme}//${authority.slice(0, colon + 1)}${hider(count)()}${authority.slice(at)}` : `${scheme}//${authority}`;
|
|
4075
4077
|
}
|
|
4076
|
-
out += hidePath(
|
|
4078
|
+
out += hidePath(path20, count);
|
|
4077
4079
|
if (query) out += `?${hideParams(query.slice(1), count)}`;
|
|
4078
4080
|
if (fragment) {
|
|
4079
4081
|
const body = fragment.slice(1);
|
|
@@ -4145,9 +4147,17 @@ function hideTypedText(title) {
|
|
|
4145
4147
|
const typing = TYPED_TITLE.exec(title);
|
|
4146
4148
|
if (!typing) return title;
|
|
4147
4149
|
const start = typing[0].length;
|
|
4148
|
-
const end = title.endsWith('"') ? title.length - 1 : title
|
|
4150
|
+
const end = title.endsWith('"') ? title.length - 1 : typedTextEnd(title, start);
|
|
4149
4151
|
return end >= start ? `${title.slice(0, start)}${HIDDEN_VALUE}${title.slice(end)}` : `${typing[0]}${HIDDEN_VALUE}"`;
|
|
4150
4152
|
}
|
|
4153
|
+
var MAX_TITLE_LOCATOR = 1e3;
|
|
4154
|
+
function typedTextEnd(title, start) {
|
|
4155
|
+
const from = Math.max(start, title.length - MAX_TITLE_LOCATOR - 2);
|
|
4156
|
+
for (let at = title.lastIndexOf('" '); at >= from; at = title.lastIndexOf('" ', at - 1)) {
|
|
4157
|
+
if (tryParseLocatorChain(title.slice(at + 2))) return at;
|
|
4158
|
+
}
|
|
4159
|
+
return title.lastIndexOf('" ');
|
|
4160
|
+
}
|
|
4151
4161
|
var SECRET_FIELD_WORDS = /* @__PURE__ */ new Set([
|
|
4152
4162
|
"passe",
|
|
4153
4163
|
"mdp",
|
|
@@ -4341,13 +4351,13 @@ function normalizeFunctionRanges(ranges) {
|
|
|
4341
4351
|
}
|
|
4342
4352
|
function normalizeCoveragePath(raw) {
|
|
4343
4353
|
if (typeof raw !== "string" || raw.length > MAX_PATH_LENGTH || raw.includes("\0")) return null;
|
|
4344
|
-
const
|
|
4345
|
-
if (!
|
|
4346
|
-
if (/(^|\/)node_modules\//.test(
|
|
4347
|
-
return
|
|
4354
|
+
const path20 = raw.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
4355
|
+
if (!path20 || path20.startsWith("../") || path20.startsWith("/") || /^[A-Za-z]:\//.test(path20)) return null;
|
|
4356
|
+
if (/(^|\/)node_modules\//.test(path20)) return null;
|
|
4357
|
+
return path20;
|
|
4348
4358
|
}
|
|
4349
|
-
function fileEntry(
|
|
4350
|
-
const file = { path:
|
|
4359
|
+
function fileEntry(path20, runtime, blob, functions = [], lines = []) {
|
|
4360
|
+
const file = { path: path20, runtime };
|
|
4351
4361
|
if (blob && (functions.length > 0 || lines.length > 0)) file.blob = blob;
|
|
4352
4362
|
if (functions.length > 0) file.functions = functions;
|
|
4353
4363
|
if (lines.length > 0) file.lines = lines;
|
|
@@ -4366,11 +4376,11 @@ function sanitizeCoverage(raw) {
|
|
|
4366
4376
|
const files = [];
|
|
4367
4377
|
for (const item of raw.files) {
|
|
4368
4378
|
if (!isRecord(item) || !isRuntime(item.runtime)) continue;
|
|
4369
|
-
const
|
|
4370
|
-
if (
|
|
4379
|
+
const path20 = normalizeCoveragePath(item.path);
|
|
4380
|
+
if (path20 === null) continue;
|
|
4371
4381
|
const blob = typeof item.blob === "string" && BLOB_ID.test(item.blob) ? item.blob : void 0;
|
|
4372
4382
|
files.push(
|
|
4373
|
-
fileEntry(
|
|
4383
|
+
fileEntry(path20, item.runtime, blob, normalizeFunctionRanges(item.functions), normalizeLineRanges(item.lines))
|
|
4374
4384
|
);
|
|
4375
4385
|
}
|
|
4376
4386
|
const merged = mergeCoverage(captureOf(files, raw.incomplete === true));
|
|
@@ -5688,17 +5698,18 @@ async function pauseHere(page, point, probe, onPick, onRecord, ended, intents, o
|
|
|
5688
5698
|
highlight = point.target.highlight();
|
|
5689
5699
|
await within(highlight.shown, HIGHLIGHT_MS);
|
|
5690
5700
|
}
|
|
5701
|
+
const call = hideSecretsInText(hideTypedText(point.call));
|
|
5691
5702
|
const arg = {
|
|
5692
5703
|
place: pausePlace(point.location),
|
|
5693
5704
|
attempt: point.attempt,
|
|
5694
|
-
action:
|
|
5705
|
+
action: call,
|
|
5695
5706
|
locator: null,
|
|
5696
5707
|
record: !!onRecord,
|
|
5697
5708
|
...point.failure ? { failure: true } : {},
|
|
5698
5709
|
...point.end ? { end: true } : {}
|
|
5699
5710
|
};
|
|
5700
5711
|
console.log(
|
|
5701
|
-
point.failure ? `[piwi] The test failed at ${callSiteLine(point.location)}: Resume, Pick a locator${onRecord ? " or Record here" : ""} in the browser (Esc resumes, and the test ends as it failed).` : `[piwi] Paused at ${callSiteLine(point.location)} before ${
|
|
5712
|
+
point.failure ? `[piwi] The test failed at ${callSiteLine(point.location)}: Resume, Pick a locator${onRecord ? " or Record here" : ""} in the browser (Esc resumes, and the test ends as it failed).` : `[piwi] Paused at ${callSiteLine(point.location)} before ${call}: Resume, Step, Pick a locator${onRecord ? ", Record here" : ""}, Finish${point.end ? " or End the test" : ""} in the browser (Esc resumes).`
|
|
5702
5713
|
);
|
|
5703
5714
|
let navigated = 0;
|
|
5704
5715
|
for (; ; ) {
|
|
@@ -6709,6 +6720,7 @@ async function maskedImage(page, options) {
|
|
|
6709
6720
|
() => page.screenshot({
|
|
6710
6721
|
type: "jpeg",
|
|
6711
6722
|
quality: options.quality,
|
|
6723
|
+
scale: "css",
|
|
6712
6724
|
timeout: options.timeout,
|
|
6713
6725
|
...options.style ? { style: options.style } : {}
|
|
6714
6726
|
})
|
|
@@ -6753,6 +6765,9 @@ function maskSecretFields(page, options) {
|
|
|
6753
6765
|
let data;
|
|
6754
6766
|
try {
|
|
6755
6767
|
data = paintBoxes(jpeg, frame, boxes, size, options.quality);
|
|
6768
|
+
if (data.length > options.maxBytes && options.lightQuality !== void 0) {
|
|
6769
|
+
data = paintBoxes(jpeg, frame, boxes, size, options.lightQuality);
|
|
6770
|
+
}
|
|
6756
6771
|
} catch {
|
|
6757
6772
|
return null;
|
|
6758
6773
|
}
|
|
@@ -6775,10 +6790,14 @@ function maskSecretFields(page, options) {
|
|
|
6775
6790
|
}
|
|
6776
6791
|
if (page.isClosed()) return null;
|
|
6777
6792
|
const at = Date.now();
|
|
6778
|
-
const
|
|
6793
|
+
const take2 = (quality) => internalCall(
|
|
6779
6794
|
page,
|
|
6780
|
-
() => page.screenshot({ type: "jpeg", quality
|
|
6795
|
+
() => page.screenshot({ type: "jpeg", quality, scale: "css", caret: "initial", timeout: 5e3 })
|
|
6781
6796
|
).catch(() => null);
|
|
6797
|
+
let shot = await take2(options.quality);
|
|
6798
|
+
if (shot && shot.length > options.maxBytes && options.lightQuality !== void 0) {
|
|
6799
|
+
shot = await take2(options.lightQuality);
|
|
6800
|
+
}
|
|
6782
6801
|
if (!shot) return null;
|
|
6783
6802
|
const again = await read();
|
|
6784
6803
|
if (typeof again === "string" || !again) return again;
|
|
@@ -7034,7 +7053,7 @@ async function bindBrowser(browser, name, workspaceDir, on) {
|
|
|
7034
7053
|
}
|
|
7035
7054
|
|
|
7036
7055
|
// src/internal/capture/run-events.ts
|
|
7037
|
-
var
|
|
7056
|
+
var path13 = __toESM(require("path"));
|
|
7038
7057
|
|
|
7039
7058
|
// src/internal/capture/run-channel.ts
|
|
7040
7059
|
var net = __toESM(require("net"));
|
|
@@ -7049,8 +7068,8 @@ function parseRecordChannel(value) {
|
|
|
7049
7068
|
const hash = text.lastIndexOf("#");
|
|
7050
7069
|
if (hash <= 0) return null;
|
|
7051
7070
|
const token = text.slice(hash + 1);
|
|
7052
|
-
const
|
|
7053
|
-
return /^[A-Za-z0-9_-]{16,}$/.test(token) && !
|
|
7071
|
+
const path20 = text.slice(0, hash);
|
|
7072
|
+
return /^[A-Za-z0-9_-]{16,}$/.test(token) && !path20.includes("\0") ? { path: path20, token } : null;
|
|
7054
7073
|
}
|
|
7055
7074
|
function isObject4(value) {
|
|
7056
7075
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -7103,6 +7122,11 @@ function startedByTestRunner(env) {
|
|
|
7103
7122
|
const reporter = env[TEST_RUNNER_REPORTER_ENV]?.trim();
|
|
7104
7123
|
return !!reporter && /[\\/]/.test(reporter);
|
|
7105
7124
|
}
|
|
7125
|
+
function runChannelRef(env) {
|
|
7126
|
+
if (!parseRecordChannel(env[RUN_CHANNEL_ENV])) return null;
|
|
7127
|
+
const ref = env[RUN_REF_ENV] ?? env[PIWI_ORIGIN_ENV.ref];
|
|
7128
|
+
return ref && /^[\w-]{1,64}$/.test(ref) ? ref : null;
|
|
7129
|
+
}
|
|
7106
7130
|
|
|
7107
7131
|
// src/internal/capture/kept-responses.ts
|
|
7108
7132
|
var keeping = null;
|
|
@@ -7220,14 +7244,16 @@ function liveRunPage(address) {
|
|
|
7220
7244
|
url.hash = "";
|
|
7221
7245
|
return url.toString();
|
|
7222
7246
|
}
|
|
7223
|
-
var MISSING = ["no-instance", "unregistered", "off", "local"];
|
|
7247
|
+
var MISSING = ["no-instance", "streaming-off", "unregistered", "setup-failed", "off", "local"];
|
|
7224
7248
|
function parseLiveViewMissing(value) {
|
|
7225
7249
|
const why = value?.startsWith("none:") ? value.slice(5) : null;
|
|
7226
7250
|
return why && MISSING.includes(why) ? why : null;
|
|
7227
7251
|
}
|
|
7228
7252
|
var LIVE_SHARE_MISSING = {
|
|
7229
7253
|
"no-instance": "This run cannot be shared live: it reports to no Piwi instance. Name your team's instance in PIWI_DASHBOARD_URL.",
|
|
7230
|
-
|
|
7254
|
+
"streaming-off": "This run cannot be shared live: it sends its results at its end alone (streaming: false), so it has no live run on the instance.",
|
|
7255
|
+
unregistered: "This run cannot be shared live: the reporter's global setup did not register it as it started (wrapConfig adds it, and it registers a run whose config lists Piwi's reporter).",
|
|
7256
|
+
"setup-failed": "This run cannot be shared live: the instance did not register it as it started (the reporter's global setup could not reach it, or was refused: its warning says why).",
|
|
7231
7257
|
off: "This run cannot be shared live: its project's live view is off on the instance. A Project admin turns it on in Project \u2192 Settings \u2192 Live view.",
|
|
7232
7258
|
local: "This run cannot be shared live: it reports to the Piwi desktop app on this machine, which no teammate reaches. Name your team's instance in PIWI_DASHBOARD_URL to share a run there."
|
|
7233
7259
|
};
|
|
@@ -7235,10 +7261,11 @@ var LIVE_SHARE_UNKNOWN = "This run cannot be shared live: the Piwi reporter gave
|
|
|
7235
7261
|
function liveShareRefusal(status) {
|
|
7236
7262
|
switch (status) {
|
|
7237
7263
|
case 404:
|
|
7238
|
-
return "Sharing stopped: the project's live view was turned off on the instance.";
|
|
7264
|
+
return "Sharing stopped: the project's live view was turned off on the instance. Share the run again once it is back on.";
|
|
7239
7265
|
case 401:
|
|
7266
|
+
return "Sharing stopped: the instance does not take this run's live view key now. Share the run again to try once more.";
|
|
7240
7267
|
case 403:
|
|
7241
|
-
return "Sharing stopped: the instance
|
|
7268
|
+
return "Sharing stopped: the instance refuses this run's live view key.";
|
|
7242
7269
|
case 410:
|
|
7243
7270
|
return "Sharing stopped: the run is no longer live on the instance.";
|
|
7244
7271
|
case 409:
|
|
@@ -7322,6 +7349,79 @@ function parseInstanceToWorker(data) {
|
|
|
7322
7349
|
return { type: "viewers", count: value.count };
|
|
7323
7350
|
}
|
|
7324
7351
|
|
|
7352
|
+
// src/internal/support/run-log.ts
|
|
7353
|
+
var import_node_crypto2 = require("crypto");
|
|
7354
|
+
var fs9 = __toESM(require("fs"));
|
|
7355
|
+
var path11 = __toESM(require("path"));
|
|
7356
|
+
|
|
7357
|
+
// src/internal/support/private-file.ts
|
|
7358
|
+
var crypto2 = __toESM(require("crypto"));
|
|
7359
|
+
var fs8 = __toESM(require("fs"));
|
|
7360
|
+
var os3 = __toESM(require("os"));
|
|
7361
|
+
var path10 = __toESM(require("path"));
|
|
7362
|
+
function privateTempDir() {
|
|
7363
|
+
if (process.platform !== "win32") return os3.tmpdir();
|
|
7364
|
+
const dir = path10.join(process.env.LOCALAPPDATA || path10.join(os3.homedir(), "AppData", "Local"), "piwi", "tmp");
|
|
7365
|
+
try {
|
|
7366
|
+
fs8.mkdirSync(dir, { recursive: true });
|
|
7367
|
+
} catch {
|
|
7368
|
+
}
|
|
7369
|
+
return dir;
|
|
7370
|
+
}
|
|
7371
|
+
var NO_FOLLOW = fs8.constants.O_NOFOLLOW ?? 0;
|
|
7372
|
+
var NO_WAIT = fs8.constants.O_NONBLOCK ?? 0;
|
|
7373
|
+
function untrustedReason(stat) {
|
|
7374
|
+
if (stat.isSymbolicLink()) return "it is a symbolic link";
|
|
7375
|
+
if (!stat.isFile()) return "it is not a regular file";
|
|
7376
|
+
if (typeof process.getuid === "function") {
|
|
7377
|
+
if (stat.uid !== process.getuid()) return "another user owns it";
|
|
7378
|
+
if (stat.mode & 18) return "other users may write to it";
|
|
7379
|
+
if (stat.nlink > 1) return "it has another name";
|
|
7380
|
+
}
|
|
7381
|
+
return null;
|
|
7382
|
+
}
|
|
7383
|
+
function appendPrivateFile(file, text) {
|
|
7384
|
+
const found = fs8.lstatSync(file, { throwIfNoEntry: false });
|
|
7385
|
+
const refused = found && untrustedReason(found);
|
|
7386
|
+
if (refused) throw new Error(`${file} is not written: ${refused}`);
|
|
7387
|
+
const fd = fs8.openSync(
|
|
7388
|
+
file,
|
|
7389
|
+
fs8.constants.O_WRONLY | fs8.constants.O_APPEND | fs8.constants.O_CREAT | NO_FOLLOW | NO_WAIT,
|
|
7390
|
+
384
|
|
7391
|
+
);
|
|
7392
|
+
try {
|
|
7393
|
+
const reason = untrustedReason(fs8.fstatSync(fd));
|
|
7394
|
+
if (reason) throw new Error(`${file} is not written: ${reason}`);
|
|
7395
|
+
fs8.appendFileSync(fd, text, "utf8");
|
|
7396
|
+
} finally {
|
|
7397
|
+
fs8.closeSync(fd);
|
|
7398
|
+
}
|
|
7399
|
+
}
|
|
7400
|
+
function readPrivateFile(file) {
|
|
7401
|
+
const found = fs8.lstatSync(file, { throwIfNoEntry: false });
|
|
7402
|
+
if (!found) return null;
|
|
7403
|
+
const reason = untrustedReason(found);
|
|
7404
|
+
if (reason) return { untrusted: reason };
|
|
7405
|
+
const fd = fs8.openSync(file, fs8.constants.O_RDONLY | NO_FOLLOW | NO_WAIT);
|
|
7406
|
+
try {
|
|
7407
|
+
const opened = untrustedReason(fs8.fstatSync(fd));
|
|
7408
|
+
if (opened) return { untrusted: opened };
|
|
7409
|
+
return { text: fs8.readFileSync(fd, "utf8") };
|
|
7410
|
+
} finally {
|
|
7411
|
+
fs8.closeSync(fd);
|
|
7412
|
+
}
|
|
7413
|
+
}
|
|
7414
|
+
|
|
7415
|
+
// src/internal/support/run-log.ts
|
|
7416
|
+
function printRunLine(file, line) {
|
|
7417
|
+
if (!file) return;
|
|
7418
|
+
try {
|
|
7419
|
+
appendPrivateFile(file, `${line.replace(/[\r\n]+/g, " ")}
|
|
7420
|
+
`);
|
|
7421
|
+
} catch {
|
|
7422
|
+
}
|
|
7423
|
+
}
|
|
7424
|
+
|
|
7325
7425
|
// src/internal/support/shard-info.ts
|
|
7326
7426
|
function parseShardSpec(raw) {
|
|
7327
7427
|
const match = raw?.trim().match(/^(\d+)\s*\/\s*(\d+)$/);
|
|
@@ -7337,7 +7437,7 @@ function resolveShardInfo(config, env = process.env) {
|
|
|
7337
7437
|
}
|
|
7338
7438
|
|
|
7339
7439
|
// src/internal/capture/live-call-log.ts
|
|
7340
|
-
var
|
|
7440
|
+
var path12 = __toESM(require("path"));
|
|
7341
7441
|
var TARGET_EVERY_MS = 1e3;
|
|
7342
7442
|
var KEPT_LINES = 1e3;
|
|
7343
7443
|
var MAX_LINE2 = 600;
|
|
@@ -7375,8 +7475,8 @@ function heardAs(id) {
|
|
|
7375
7475
|
}
|
|
7376
7476
|
function userFile(file) {
|
|
7377
7477
|
if (typeof file !== "string" || !file || /[\\/]node_modules[\\/]/.test(file)) return null;
|
|
7378
|
-
const relative7 =
|
|
7379
|
-
return relative7 && !relative7.startsWith("..") && !
|
|
7478
|
+
const relative7 = path12.relative(process.cwd(), file).split(path12.sep).join("/");
|
|
7479
|
+
return relative7 && !relative7.startsWith("..") && !path12.isAbsolute(relative7) ? relative7 : null;
|
|
7380
7480
|
}
|
|
7381
7481
|
var followed = /* @__PURE__ */ new WeakMap();
|
|
7382
7482
|
function take(state, update) {
|
|
@@ -7746,7 +7846,8 @@ async function openPageView(page, options) {
|
|
|
7746
7846
|
|
|
7747
7847
|
// src/internal/capture/live-view.ts
|
|
7748
7848
|
var RETRY_MS = [1e3, 2e3, 4e3, 8e3, 16e3];
|
|
7749
|
-
var
|
|
7849
|
+
var SLOW_RETRY_MS = 3e4;
|
|
7850
|
+
var SLOW_RETRY_JITTER_MS = 3e4;
|
|
7750
7851
|
var STEADY_MS = 3e4;
|
|
7751
7852
|
var STREAM_IDLE_MS = 45e3;
|
|
7752
7853
|
var POST_TIMEOUT_MS = 1e4;
|
|
@@ -7756,7 +7857,8 @@ var LIGHT_QUALITY = 30;
|
|
|
7756
7857
|
var SHOT_MS = 1e3;
|
|
7757
7858
|
var LOG_SPACING_MS = Math.ceil(1e3 / LIVE_CALL_LOGS_PER_SECOND);
|
|
7758
7859
|
var VIEW_END_MS = 1e3;
|
|
7759
|
-
var GIVE_UP = /* @__PURE__ */ new Set([
|
|
7860
|
+
var GIVE_UP = /* @__PURE__ */ new Set([403, 410]);
|
|
7861
|
+
var NOT_NOW = /* @__PURE__ */ new Set([401, 404]);
|
|
7760
7862
|
var TOO_HEAVY = `This page is too heavy for the live view: each image of it is over ${MAX_LIVE_FRAME / 1024} KB, a lighter one included.`;
|
|
7761
7863
|
var NO_PAGE = "This test has no page to show yet.";
|
|
7762
7864
|
var NO_TEST = "No test runs on this worker now: the next one shows once it opens its page.";
|
|
@@ -7825,25 +7927,33 @@ function openLiveView(worker, env = process.env, ci = detectCi(env)) {
|
|
|
7825
7927
|
const client = secure ? https : http;
|
|
7826
7928
|
link = {
|
|
7827
7929
|
address,
|
|
7828
|
-
id: {
|
|
7930
|
+
id: {
|
|
7931
|
+
shard: resolveShardInfo(worker.config, env)?.current ?? null,
|
|
7932
|
+
worker: worker.workerIndex,
|
|
7933
|
+
// The lane, which a worker Playwright starts again after a failure keeps, so a view follows it.
|
|
7934
|
+
...typeof worker.parallelIndex === "number" ? { slot: worker.parallelIndex } : {}
|
|
7935
|
+
},
|
|
7829
7936
|
client,
|
|
7830
7937
|
// The stream, and a frame, a call log and a stop or an end in flight at once: none waits behind another.
|
|
7831
7938
|
agent: new client.Agent({ keepAlive: true, maxSockets: 4 }),
|
|
7832
7939
|
stream: null,
|
|
7833
7940
|
timer: null,
|
|
7834
7941
|
retries: 0,
|
|
7835
|
-
reconnects: 0,
|
|
7836
7942
|
ended: false,
|
|
7837
7943
|
refused: null,
|
|
7838
7944
|
sharing: ci,
|
|
7839
7945
|
ci,
|
|
7840
7946
|
lost: null,
|
|
7947
|
+
runLog: ci ? env[PIWI_RUN_LOG_ENV] || null : null,
|
|
7948
|
+
dark: false,
|
|
7949
|
+
backTimer: null,
|
|
7841
7950
|
answered: null,
|
|
7842
7951
|
viewers: 0,
|
|
7843
7952
|
states: Promise.resolve(),
|
|
7844
7953
|
statesWaiting: 0,
|
|
7845
7954
|
stop: null,
|
|
7846
7955
|
posting: false,
|
|
7956
|
+
framePost: null,
|
|
7847
7957
|
log: null,
|
|
7848
7958
|
logPosting: false,
|
|
7849
7959
|
logSentAt: 0,
|
|
@@ -7865,6 +7975,7 @@ function closeLiveView() {
|
|
|
7865
7975
|
if (!own) return;
|
|
7866
7976
|
own.ended = true;
|
|
7867
7977
|
if (own.timer) clearTimeout(own.timer);
|
|
7978
|
+
stopBackTimer(own);
|
|
7868
7979
|
own.stream?.destroy();
|
|
7869
7980
|
own.agent.destroy();
|
|
7870
7981
|
}
|
|
@@ -7880,7 +7991,6 @@ function startSharing() {
|
|
|
7880
7991
|
own.lost = null;
|
|
7881
7992
|
own.answered = null;
|
|
7882
7993
|
own.retries = 0;
|
|
7883
|
-
own.reconnects = 0;
|
|
7884
7994
|
connect(own);
|
|
7885
7995
|
changed();
|
|
7886
7996
|
}
|
|
@@ -7908,12 +8018,16 @@ function liveViewPage(page) {
|
|
|
7908
8018
|
running.page = page;
|
|
7909
8019
|
if (link.viewers > 0 && active(link)) startView();
|
|
7910
8020
|
}
|
|
7911
|
-
async function liveViewTestEnded() {
|
|
8021
|
+
async function liveViewTestEnded(status) {
|
|
7912
8022
|
if (!running) return;
|
|
8023
|
+
const ended = running;
|
|
7913
8024
|
running = null;
|
|
8025
|
+
const outcome = status ? { test: ended.title, status, ms: Math.max(0, Date.now() - ended.began) } : null;
|
|
7914
8026
|
await stopView();
|
|
7915
8027
|
const own = link;
|
|
7916
|
-
if (own
|
|
8028
|
+
if (!own) return;
|
|
8029
|
+
await own.framePost;
|
|
8030
|
+
if (own.viewers > 0 && active(own)) void post(own, { type: "ended", ...own.id, outcome });
|
|
7917
8031
|
}
|
|
7918
8032
|
function liveViewStopped(stop) {
|
|
7919
8033
|
const own = link;
|
|
@@ -7941,6 +8055,7 @@ function connect(own) {
|
|
|
7941
8055
|
const url = new URL(own.address.url);
|
|
7942
8056
|
url.searchParams.set("worker", String(own.id.worker));
|
|
7943
8057
|
if (own.id.shard !== null) url.searchParams.set("shard", String(own.id.shard));
|
|
8058
|
+
if (own.id.slot !== void 0) url.searchParams.set("slot", String(own.id.slot));
|
|
7944
8059
|
let openedAt = null;
|
|
7945
8060
|
let dropped = false;
|
|
7946
8061
|
const drop = (status) => {
|
|
@@ -7948,19 +8063,13 @@ function connect(own) {
|
|
|
7948
8063
|
dropped = true;
|
|
7949
8064
|
if (own.stream !== request) return;
|
|
7950
8065
|
own.stream = null;
|
|
8066
|
+
stopBackTimer(own);
|
|
7951
8067
|
setViewers(own, 0);
|
|
7952
8068
|
if (!active(own)) return;
|
|
7953
8069
|
if (openedAt !== null && Date.now() - openedAt >= STEADY_MS) own.retries = 0;
|
|
7954
8070
|
if (status !== null) own.answered = status;
|
|
7955
8071
|
if (status !== null && GIVE_UP.has(status)) return void refuse(own, status);
|
|
7956
|
-
|
|
7957
|
-
const wait = RETRY_MS[own.retries++];
|
|
7958
|
-
own.reconnects++;
|
|
7959
|
-
own.timer = setTimeout(() => {
|
|
7960
|
-
own.timer = null;
|
|
7961
|
-
connect(own);
|
|
7962
|
-
}, wait);
|
|
7963
|
-
own.timer.unref?.();
|
|
8072
|
+
retry(own, status !== null && NOT_NOW.has(status));
|
|
7964
8073
|
};
|
|
7965
8074
|
const request = own.client.request(url, {
|
|
7966
8075
|
method: "GET",
|
|
@@ -7983,6 +8092,15 @@ function connect(own) {
|
|
|
7983
8092
|
}
|
|
7984
8093
|
openedAt = Date.now();
|
|
7985
8094
|
own.answered = null;
|
|
8095
|
+
if (own.dark) {
|
|
8096
|
+
own.backTimer = setTimeout(() => {
|
|
8097
|
+
own.backTimer = null;
|
|
8098
|
+
if (own.stream !== request || !own.dark) return;
|
|
8099
|
+
own.dark = false;
|
|
8100
|
+
printRunLine(own.runLog, `${workerName(own.id)}: live view back.`);
|
|
8101
|
+
}, STEADY_MS);
|
|
8102
|
+
own.backTimer.unref?.();
|
|
8103
|
+
}
|
|
7986
8104
|
if (own.stop) postState(own, { type: "stop", ...own.id, stop: own.stop });
|
|
7987
8105
|
response.setEncoding("utf8");
|
|
7988
8106
|
let text = "";
|
|
@@ -8004,9 +8122,55 @@ function connect(own) {
|
|
|
8004
8122
|
});
|
|
8005
8123
|
request.end();
|
|
8006
8124
|
}
|
|
8125
|
+
function retry(own, notNow) {
|
|
8126
|
+
if (!notNow && own.retries < RETRY_MS.length) return void later(own, RETRY_MS[own.retries++]);
|
|
8127
|
+
if (!own.ci) return void giveUp(own);
|
|
8128
|
+
goDark(own, "Trying again every 30 to 60 s while the run lasts.");
|
|
8129
|
+
later(own, SLOW_RETRY_MS + Math.random() * SLOW_RETRY_JITTER_MS);
|
|
8130
|
+
}
|
|
8131
|
+
function goDark(own, next) {
|
|
8132
|
+
if (own.dark) return;
|
|
8133
|
+
own.dark = true;
|
|
8134
|
+
printRunLine(own.runLog, `${workerName(own.id)}: live view lost: ${lostCause(own.answered)}. ${next}`);
|
|
8135
|
+
}
|
|
8136
|
+
function stopBackTimer(own) {
|
|
8137
|
+
if (own.backTimer) clearTimeout(own.backTimer);
|
|
8138
|
+
own.backTimer = null;
|
|
8139
|
+
}
|
|
8140
|
+
function later(own, wait) {
|
|
8141
|
+
own.timer = setTimeout(() => {
|
|
8142
|
+
own.timer = null;
|
|
8143
|
+
connect(own);
|
|
8144
|
+
}, wait);
|
|
8145
|
+
own.timer.unref?.();
|
|
8146
|
+
}
|
|
8147
|
+
function workerName(id) {
|
|
8148
|
+
const worker = `Worker ${id.slot === void 0 ? id.worker : id.slot + 1}`;
|
|
8149
|
+
return id.shard === null ? worker : `${worker} of shard ${id.shard}`;
|
|
8150
|
+
}
|
|
8151
|
+
function lostCause(status) {
|
|
8152
|
+
switch (status) {
|
|
8153
|
+
case null:
|
|
8154
|
+
return "the instance did not answer";
|
|
8155
|
+
case 401:
|
|
8156
|
+
return "the instance does not take the run's live view key now";
|
|
8157
|
+
case 404:
|
|
8158
|
+
return "the project's live view is off";
|
|
8159
|
+
case 403:
|
|
8160
|
+
return "the instance refuses the run's live view key";
|
|
8161
|
+
case 409:
|
|
8162
|
+
return "the instance holds the run as interrupted";
|
|
8163
|
+
case 410:
|
|
8164
|
+
return "the run is no longer live on the instance";
|
|
8165
|
+
default:
|
|
8166
|
+
return `the instance answered ${status}`;
|
|
8167
|
+
}
|
|
8168
|
+
}
|
|
8007
8169
|
function refuse(own, status) {
|
|
8008
8170
|
if (own.refused !== null) return;
|
|
8009
8171
|
own.refused = liveShareRefusal(status);
|
|
8172
|
+
own.answered = status;
|
|
8173
|
+
if (own.ci) goDark(own, "It stays off for this worker.");
|
|
8010
8174
|
own.viewers = 0;
|
|
8011
8175
|
own.stream?.destroy();
|
|
8012
8176
|
own.agent.destroy();
|
|
@@ -8061,6 +8225,7 @@ function startView() {
|
|
|
8061
8225
|
const mask = maskSecretFields(page, {
|
|
8062
8226
|
masks: () => own.masks,
|
|
8063
8227
|
quality: LIVE_FRAME_QUALITY,
|
|
8228
|
+
lightQuality: LIGHT_QUALITY,
|
|
8064
8229
|
maxBytes: MAX_LIVE_FRAME
|
|
8065
8230
|
});
|
|
8066
8231
|
const opened = openPageView(page, {
|
|
@@ -8114,14 +8279,16 @@ function postFrame(own, frame) {
|
|
|
8114
8279
|
own.posting = true;
|
|
8115
8280
|
const call = running?.call() ?? null;
|
|
8116
8281
|
const data = frame.data.toString("base64");
|
|
8117
|
-
|
|
8282
|
+
own.framePost = post(own, {
|
|
8118
8283
|
type: "frame",
|
|
8119
8284
|
...own.id,
|
|
8120
8285
|
data,
|
|
8121
8286
|
call: call && hideCallSecrets(call),
|
|
8122
|
-
test: running?.title ?? null
|
|
8287
|
+
test: running?.title ?? null,
|
|
8288
|
+
...Number.isFinite(frame.at) ? { at: Math.round(frame.at) } : {}
|
|
8123
8289
|
}).catch(() => void 0).finally(() => {
|
|
8124
8290
|
own.posting = false;
|
|
8291
|
+
own.framePost = null;
|
|
8125
8292
|
});
|
|
8126
8293
|
}
|
|
8127
8294
|
function postLog(own, log) {
|
|
@@ -8164,6 +8331,7 @@ function send(own, message) {
|
|
|
8164
8331
|
if (settled) return;
|
|
8165
8332
|
settled = true;
|
|
8166
8333
|
if (status !== null && GIVE_UP.has(status)) refuse(own, status);
|
|
8334
|
+
else if (status !== null && NOT_NOW.has(status)) own.stream?.destroy();
|
|
8167
8335
|
resolve6(status);
|
|
8168
8336
|
};
|
|
8169
8337
|
const request = own.client.request(own.address.url, {
|
|
@@ -8248,8 +8416,8 @@ function workerTakes(env = process.env, playwright) {
|
|
|
8248
8416
|
}
|
|
8249
8417
|
async function openRunChannel(worker, handlers, env = process.env) {
|
|
8250
8418
|
const channel = parseRecordChannel(env[RUN_CHANNEL_ENV]);
|
|
8251
|
-
const ref = env
|
|
8252
|
-
if (socket || !channel || !ref
|
|
8419
|
+
const ref = runChannelRef(env);
|
|
8420
|
+
if (socket || !channel || !ref) return false;
|
|
8253
8421
|
const opening = net.connect(channel.path);
|
|
8254
8422
|
opening.setEncoding("utf8");
|
|
8255
8423
|
const opened = await new Promise((resolve6) => {
|
|
@@ -8414,7 +8582,8 @@ function holdStop(stop, onAnswer) {
|
|
|
8414
8582
|
type: "stopped",
|
|
8415
8583
|
stop: id,
|
|
8416
8584
|
reason: stop.reason,
|
|
8417
|
-
|
|
8585
|
+
// The text the stopped call types stays in the worker, as on every surface.
|
|
8586
|
+
title: hideSecretsInText(hideTypedText(stop.title)),
|
|
8418
8587
|
place: stop.place,
|
|
8419
8588
|
locator: stop.locator,
|
|
8420
8589
|
bar: stop.bar,
|
|
@@ -8509,6 +8678,12 @@ function startView2(holding) {
|
|
|
8509
8678
|
return started;
|
|
8510
8679
|
}
|
|
8511
8680
|
async function openView(page, stop) {
|
|
8681
|
+
const mask = maskSecretFields(page, {
|
|
8682
|
+
masks: () => [],
|
|
8683
|
+
quality: VIEW_QUALITY,
|
|
8684
|
+
lightQuality: LIGHT_QUALITY2,
|
|
8685
|
+
maxBytes: MAX_VIEW_FRAME
|
|
8686
|
+
});
|
|
8512
8687
|
const opened = await openPageView(page, {
|
|
8513
8688
|
size: viewSize,
|
|
8514
8689
|
quality: VIEW_QUALITY,
|
|
@@ -8516,11 +8691,12 @@ async function openView(page, stop) {
|
|
|
8516
8691
|
maxFrameBytes: MAX_VIEW_FRAME,
|
|
8517
8692
|
lightQuality: LIGHT_QUALITY2,
|
|
8518
8693
|
shotMs: SHOT_MS2,
|
|
8519
|
-
busy: () => !!socket && socket.writableLength > MAX_FRAME_BACKLOG,
|
|
8694
|
+
busy: () => !!socket && socket.writableLength > MAX_FRAME_BACKLOG || mask.resting,
|
|
8520
8695
|
// Once its stop began to end, no frame of it goes.
|
|
8521
8696
|
live: () => held?.stop === stop,
|
|
8697
|
+
screen: (frame) => mask.screen(frame),
|
|
8522
8698
|
send: (frame) => tellHub({ type: "frame", stop, width: frame.width, height: frame.height, data: frame.data.toString("base64") }),
|
|
8523
|
-
refuse: () => tellHub({ type: "frame", stop, refused: TOO_HEAVY2 })
|
|
8699
|
+
refuse: (why) => tellHub({ type: "frame", stop, refused: why ?? TOO_HEAVY2 })
|
|
8524
8700
|
});
|
|
8525
8701
|
if (!opened) return null;
|
|
8526
8702
|
const onClose = () => {
|
|
@@ -8813,16 +8989,21 @@ async function bindAt(at, on) {
|
|
|
8813
8989
|
async function imageOf(page) {
|
|
8814
8990
|
if (!page || page.isClosed()) return null;
|
|
8815
8991
|
try {
|
|
8816
|
-
const shot = await
|
|
8817
|
-
|
|
8818
|
-
() => page.screenshot({ type: "jpeg", quality: 60, style: BAR_HIDDEN2, timeout: 5e3 })
|
|
8819
|
-
);
|
|
8992
|
+
const shot = await maskedImage(page, { quality: 60, style: BAR_HIDDEN2, timeout: 5e3 });
|
|
8993
|
+
if (!shot) return null;
|
|
8820
8994
|
const viewport = await viewportOf(page);
|
|
8995
|
+
const size = jpegSize(shot);
|
|
8996
|
+
if (viewport && (!size || !sameShape(size, viewport))) return null;
|
|
8821
8997
|
return { mime: "image/jpeg", data: shot.toString("base64"), ...viewport };
|
|
8822
8998
|
} catch {
|
|
8823
8999
|
return null;
|
|
8824
9000
|
}
|
|
8825
9001
|
}
|
|
9002
|
+
function sameShape(image, viewport) {
|
|
9003
|
+
if (image.height <= 0 || viewport.height <= 0) return false;
|
|
9004
|
+
const shape = viewport.width / viewport.height;
|
|
9005
|
+
return Math.abs(image.width / image.height - shape) <= shape * 0.02;
|
|
9006
|
+
}
|
|
8826
9007
|
|
|
8827
9008
|
// src/internal/capture/run-events.ts
|
|
8828
9009
|
var begun = /* @__PURE__ */ new WeakMap();
|
|
@@ -8831,7 +9012,7 @@ var watched = /* @__PURE__ */ new WeakSet();
|
|
|
8831
9012
|
function userFile2(file, cwd, windows) {
|
|
8832
9013
|
if (!file || /[\\/]node_modules[\\/]/.test(file)) return null;
|
|
8833
9014
|
const relative7 = callSitePath(file, cwd, windows);
|
|
8834
|
-
if (!relative7 || (windows ?
|
|
9015
|
+
if (!relative7 || (windows ? path13.win32 : path13.posix).isAbsolute(relative7) || relative7.startsWith("..")) return null;
|
|
8835
9016
|
return relative7;
|
|
8836
9017
|
}
|
|
8837
9018
|
function callPlace(frames, cwd = process.cwd(), windows = process.platform === "win32") {
|
|
@@ -8845,7 +9026,7 @@ function callPlace(frames, cwd = process.cwd(), windows = process.platform === "
|
|
|
8845
9026
|
function callTitle(zone, channel) {
|
|
8846
9027
|
const selector = typeof channel?.params?.selector === "string" ? ` ${channel.params.selector}` : "";
|
|
8847
9028
|
const title = zone.title || `${zone.apiName || "call"}${selector}`;
|
|
8848
|
-
return hideSecretsInText(title).slice(0, 300);
|
|
9029
|
+
return hideSecretsInText(hideTypedText(title)).slice(0, 300);
|
|
8849
9030
|
}
|
|
8850
9031
|
function errorText(error) {
|
|
8851
9032
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -8972,9 +9153,9 @@ function yamlScalar(text) {
|
|
|
8972
9153
|
}
|
|
8973
9154
|
|
|
8974
9155
|
// src/internal/capture/record-handoff.ts
|
|
8975
|
-
var
|
|
9156
|
+
var fs10 = __toESM(require("fs"));
|
|
8976
9157
|
var net2 = __toESM(require("net"));
|
|
8977
|
-
var
|
|
9158
|
+
var path14 = __toESM(require("path"));
|
|
8978
9159
|
var START_WAIT_MS = 6e4;
|
|
8979
9160
|
var NEW_TAB_NOTICE = "A new tab opened: what you do there is not recorded yet. Record in the first tab.";
|
|
8980
9161
|
var relays = /* @__PURE__ */ new WeakMap();
|
|
@@ -8994,7 +9175,7 @@ function canRecordFromHere(channel = process.env[RECORD_CHANNEL_ENV]) {
|
|
|
8994
9175
|
function handoffPlace(location, cwd = process.cwd()) {
|
|
8995
9176
|
const m = /^(.+):(\d+):\d+$/.exec(location);
|
|
8996
9177
|
if (!m) return null;
|
|
8997
|
-
return { file:
|
|
9178
|
+
return { file: path14.resolve(cwd, m[1]), line: Number(m[2]) };
|
|
8998
9179
|
}
|
|
8999
9180
|
async function recordFromHere(options) {
|
|
9000
9181
|
const channel = parseRecordChannel(options.channel ?? process.env[RECORD_CHANNEL_ENV]);
|
|
@@ -9097,7 +9278,7 @@ async function recordFromHere(options) {
|
|
|
9097
9278
|
if (typeof initScript?.dispose !== "function") relay.lingering = true;
|
|
9098
9279
|
}
|
|
9099
9280
|
if (settled) return release();
|
|
9100
|
-
await page.evaluate(
|
|
9281
|
+
await page.evaluate(fs10.readFileSync(bundle, "utf-8"));
|
|
9101
9282
|
if (settled) return release();
|
|
9102
9283
|
recording = true;
|
|
9103
9284
|
clearTimeout(startWait);
|
|
@@ -9155,6 +9336,15 @@ async function recordFromHere(options) {
|
|
|
9155
9336
|
});
|
|
9156
9337
|
}
|
|
9157
9338
|
|
|
9339
|
+
// ../core/src/step-analysis.ts
|
|
9340
|
+
function stepLabel(step) {
|
|
9341
|
+
const title = typeof step.title === "string" ? step.title : "";
|
|
9342
|
+
const subtitle = typeof step.subtitle === "string" ? step.subtitle.trim() : "";
|
|
9343
|
+
if (!subtitle) return title;
|
|
9344
|
+
if (!title) return subtitle;
|
|
9345
|
+
return title.includes(subtitle) ? title : `${title} ${subtitle}`;
|
|
9346
|
+
}
|
|
9347
|
+
|
|
9158
9348
|
// src/internal/collect/coverage-settings.ts
|
|
9159
9349
|
var SERVER_VALUES = /* @__PURE__ */ new Set(["files", "functions", "lines"]);
|
|
9160
9350
|
function isServerGranularity(value) {
|
|
@@ -9175,20 +9365,20 @@ function browserLinesInWorker() {
|
|
|
9175
9365
|
return process.env[PIWI_ENV_KEYS.coverageBrowser] === "lines";
|
|
9176
9366
|
}
|
|
9177
9367
|
function browserFunctionCoverage(files, lines) {
|
|
9178
|
-
const entries = [...files].map(([
|
|
9368
|
+
const entries = [...files].map(([path20, functions]) => ({ path: path20, functions: normalizeFunctionRanges(functions) }));
|
|
9179
9369
|
let budget = MAX_COVERAGE_RANGES - entries.reduce((n, entry) => n + entry.functions.length, 0);
|
|
9180
9370
|
let incomplete = false;
|
|
9181
9371
|
return sanitizeCoverage({
|
|
9182
9372
|
v: 1,
|
|
9183
|
-
files: entries.map(({ path:
|
|
9184
|
-
const ran = normalizeLineRanges(lines?.get(
|
|
9185
|
-
if (ran.length === 0) return { path:
|
|
9373
|
+
files: entries.map(({ path: path20, functions }) => {
|
|
9374
|
+
const ran = normalizeLineRanges(lines?.get(path20) ?? []);
|
|
9375
|
+
if (ran.length === 0) return { path: path20, runtime: "browser", functions };
|
|
9186
9376
|
if (ran.length > budget) {
|
|
9187
9377
|
incomplete = true;
|
|
9188
|
-
return { path:
|
|
9378
|
+
return { path: path20, runtime: "browser", functions };
|
|
9189
9379
|
}
|
|
9190
9380
|
budget -= ran.length;
|
|
9191
|
-
return { path:
|
|
9381
|
+
return { path: path20, runtime: "browser", functions, lines: ran };
|
|
9192
9382
|
}),
|
|
9193
9383
|
...incomplete ? { incomplete: true } : {}
|
|
9194
9384
|
});
|
|
@@ -9203,19 +9393,19 @@ function newRangeParts(known, sent2, normalize2) {
|
|
|
9203
9393
|
budget = MAX_COVERAGE_RANGES;
|
|
9204
9394
|
};
|
|
9205
9395
|
for (const [raw, ranges] of known) {
|
|
9206
|
-
const
|
|
9207
|
-
if (
|
|
9208
|
-
let named = sent2.get(
|
|
9396
|
+
const path20 = normalizeCoveragePath(raw);
|
|
9397
|
+
if (path20 === null) continue;
|
|
9398
|
+
let named = sent2.get(path20);
|
|
9209
9399
|
let fresh = normalize2(ranges).filter((range) => !named?.has(`${range[0]}:${range[1]}`));
|
|
9210
9400
|
if (fresh.length === 0) continue;
|
|
9211
|
-
if (!named) sent2.set(
|
|
9401
|
+
if (!named) sent2.set(path20, named = /* @__PURE__ */ new Set());
|
|
9212
9402
|
for (const range of fresh) named.add(`${range[0]}:${range[1]}`);
|
|
9213
9403
|
while (fresh.length > 0) {
|
|
9214
9404
|
if (budget === 0 || files.length >= MAX_COVERAGE_FILES) close();
|
|
9215
9405
|
const part = fresh.slice(0, budget);
|
|
9216
9406
|
fresh = fresh.slice(part.length);
|
|
9217
9407
|
budget -= part.length;
|
|
9218
|
-
files.push({ path:
|
|
9408
|
+
files.push({ path: path20, ranges: part });
|
|
9219
9409
|
}
|
|
9220
9410
|
}
|
|
9221
9411
|
close();
|
|
@@ -9224,18 +9414,18 @@ function newRangeParts(known, sent2, normalize2) {
|
|
|
9224
9414
|
function newKnownFunctions(known, sent2) {
|
|
9225
9415
|
return newRangeParts(known, sent2, normalizeFunctionRanges).map((files) => ({
|
|
9226
9416
|
v: 1,
|
|
9227
|
-
files: files.map(({ path:
|
|
9417
|
+
files: files.map(({ path: path20, ranges }) => ({ path: path20, allFunctions: ranges }))
|
|
9228
9418
|
}));
|
|
9229
9419
|
}
|
|
9230
9420
|
function newBrowserLines(executable, lines, sentExecutable, sentLines) {
|
|
9231
9421
|
return [
|
|
9232
9422
|
...newRangeParts(executable, sentExecutable, normalizeLineRanges).map((files) => ({
|
|
9233
9423
|
v: 1,
|
|
9234
|
-
files: files.map(({ path:
|
|
9424
|
+
files: files.map(({ path: path20, ranges }) => ({ path: path20, executable: ranges }))
|
|
9235
9425
|
})),
|
|
9236
9426
|
...newRangeParts(lines, sentLines, normalizeLineRanges).map((files) => ({
|
|
9237
9427
|
v: 1,
|
|
9238
|
-
files: files.map(({ path:
|
|
9428
|
+
files: files.map(({ path: path20, ranges }) => ({ path: path20, lines: ranges }))
|
|
9239
9429
|
}))
|
|
9240
9430
|
];
|
|
9241
9431
|
}
|
|
@@ -9244,72 +9434,14 @@ function serverCoverageInWorker() {
|
|
|
9244
9434
|
}
|
|
9245
9435
|
|
|
9246
9436
|
// src/internal/support/aria-sampling.ts
|
|
9247
|
-
var
|
|
9248
|
-
var
|
|
9437
|
+
var path15 = __toESM(require("path"));
|
|
9438
|
+
var fs11 = __toESM(require("fs"));
|
|
9249
9439
|
|
|
9250
9440
|
// src/internal/support/instance-id.ts
|
|
9251
|
-
var crypto2 = __toESM(require("crypto"));
|
|
9252
|
-
var os3 = __toESM(require("os"));
|
|
9253
|
-
function hashForProject(projectName) {
|
|
9254
|
-
return crypto2.createHash("sha1").update(projectName).digest("hex").slice(0, 16);
|
|
9255
|
-
}
|
|
9256
|
-
|
|
9257
|
-
// src/internal/support/private-file.ts
|
|
9258
9441
|
var crypto3 = __toESM(require("crypto"));
|
|
9259
|
-
var fs9 = __toESM(require("fs"));
|
|
9260
9442
|
var os4 = __toESM(require("os"));
|
|
9261
|
-
|
|
9262
|
-
|
|
9263
|
-
if (process.platform !== "win32") return os4.tmpdir();
|
|
9264
|
-
const dir = path13.join(process.env.LOCALAPPDATA || path13.join(os4.homedir(), "AppData", "Local"), "piwi", "tmp");
|
|
9265
|
-
try {
|
|
9266
|
-
fs9.mkdirSync(dir, { recursive: true });
|
|
9267
|
-
} catch {
|
|
9268
|
-
}
|
|
9269
|
-
return dir;
|
|
9270
|
-
}
|
|
9271
|
-
var NO_FOLLOW = fs9.constants.O_NOFOLLOW ?? 0;
|
|
9272
|
-
var NO_WAIT = fs9.constants.O_NONBLOCK ?? 0;
|
|
9273
|
-
function untrustedReason(stat) {
|
|
9274
|
-
if (stat.isSymbolicLink()) return "it is a symbolic link";
|
|
9275
|
-
if (!stat.isFile()) return "it is not a regular file";
|
|
9276
|
-
if (typeof process.getuid === "function") {
|
|
9277
|
-
if (stat.uid !== process.getuid()) return "another user owns it";
|
|
9278
|
-
if (stat.mode & 18) return "other users may write to it";
|
|
9279
|
-
if (stat.nlink > 1) return "it has another name";
|
|
9280
|
-
}
|
|
9281
|
-
return null;
|
|
9282
|
-
}
|
|
9283
|
-
function appendPrivateFile(file, text) {
|
|
9284
|
-
const found = fs9.lstatSync(file, { throwIfNoEntry: false });
|
|
9285
|
-
const refused = found && untrustedReason(found);
|
|
9286
|
-
if (refused) throw new Error(`${file} is not written: ${refused}`);
|
|
9287
|
-
const fd = fs9.openSync(
|
|
9288
|
-
file,
|
|
9289
|
-
fs9.constants.O_WRONLY | fs9.constants.O_APPEND | fs9.constants.O_CREAT | NO_FOLLOW | NO_WAIT,
|
|
9290
|
-
384
|
|
9291
|
-
);
|
|
9292
|
-
try {
|
|
9293
|
-
const reason = untrustedReason(fs9.fstatSync(fd));
|
|
9294
|
-
if (reason) throw new Error(`${file} is not written: ${reason}`);
|
|
9295
|
-
fs9.appendFileSync(fd, text, "utf8");
|
|
9296
|
-
} finally {
|
|
9297
|
-
fs9.closeSync(fd);
|
|
9298
|
-
}
|
|
9299
|
-
}
|
|
9300
|
-
function readPrivateFile(file) {
|
|
9301
|
-
const found = fs9.lstatSync(file, { throwIfNoEntry: false });
|
|
9302
|
-
if (!found) return null;
|
|
9303
|
-
const reason = untrustedReason(found);
|
|
9304
|
-
if (reason) return { untrusted: reason };
|
|
9305
|
-
const fd = fs9.openSync(file, fs9.constants.O_RDONLY | NO_FOLLOW | NO_WAIT);
|
|
9306
|
-
try {
|
|
9307
|
-
const opened = untrustedReason(fs9.fstatSync(fd));
|
|
9308
|
-
if (opened) return { untrusted: opened };
|
|
9309
|
-
return { text: fs9.readFileSync(fd, "utf8") };
|
|
9310
|
-
} finally {
|
|
9311
|
-
fs9.closeSync(fd);
|
|
9312
|
-
}
|
|
9443
|
+
function hashForProject(projectName) {
|
|
9444
|
+
return crypto3.createHash("sha1").update(projectName).digest("hex").slice(0, 16);
|
|
9313
9445
|
}
|
|
9314
9446
|
|
|
9315
9447
|
// src/internal/support/aria-sampling.ts
|
|
@@ -9317,7 +9449,7 @@ function ariaSampleIdentity(filePath2, title) {
|
|
|
9317
9449
|
return `${filePath2}\0${title}`;
|
|
9318
9450
|
}
|
|
9319
9451
|
function getAriaSampleFilePath(projectName) {
|
|
9320
|
-
return
|
|
9452
|
+
return path15.join(privateTempDir(), `piwi-dashboard-aria-sample-${hashForProject(projectName)}.json`);
|
|
9321
9453
|
}
|
|
9322
9454
|
var cachedSets = /* @__PURE__ */ new Map();
|
|
9323
9455
|
function loadAriaSampleSet(projectName) {
|
|
@@ -9347,8 +9479,8 @@ function isDueForAriaSample(testInfo) {
|
|
|
9347
9479
|
|
|
9348
9480
|
// src/internal/capture/code-reach.ts
|
|
9349
9481
|
var crypto4 = __toESM(require("crypto"));
|
|
9350
|
-
var
|
|
9351
|
-
var
|
|
9482
|
+
var fs12 = __toESM(require("fs"));
|
|
9483
|
+
var path16 = __toESM(require("path"));
|
|
9352
9484
|
var import_node_child_process = require("child_process");
|
|
9353
9485
|
var MAX_MAP_BYTES = 20 * 1024 * 1024;
|
|
9354
9486
|
var MAP_TIMEOUT_MS = 5e3;
|
|
@@ -9391,12 +9523,12 @@ function repositoryRoot(from) {
|
|
|
9391
9523
|
}).trim();
|
|
9392
9524
|
} catch {
|
|
9393
9525
|
}
|
|
9394
|
-
cachedRepoRoot = { from, root:
|
|
9526
|
+
cachedRepoRoot = { from, root: path16.resolve(root) };
|
|
9395
9527
|
return cachedRepoRoot.root;
|
|
9396
9528
|
}
|
|
9397
9529
|
function codeReachRoots(configDir, configured) {
|
|
9398
9530
|
const repoRoot = repositoryRoot(configDir);
|
|
9399
|
-
const resolve6 = (dirs) => (Array.isArray(dirs) ? dirs : dirs ? [dirs] : []).filter(Boolean).map((r) =>
|
|
9531
|
+
const resolve6 = (dirs) => (Array.isArray(dirs) ? dirs : dirs ? [dirs] : []).filter(Boolean).map((r) => path16.resolve(configDir, r));
|
|
9400
9532
|
const global = Array.isArray(configured) ? resolve6(configured) : resolve6(configured?.["*"]);
|
|
9401
9533
|
const byOrigin = /* @__PURE__ */ new Map();
|
|
9402
9534
|
if (configured && !Array.isArray(configured)) {
|
|
@@ -9425,7 +9557,7 @@ function scriptRoots(roots, scriptUrl, pageUrl) {
|
|
|
9425
9557
|
}
|
|
9426
9558
|
function isFile(file) {
|
|
9427
9559
|
try {
|
|
9428
|
-
return
|
|
9560
|
+
return fs12.statSync(file).isFile();
|
|
9429
9561
|
} catch {
|
|
9430
9562
|
return false;
|
|
9431
9563
|
}
|
|
@@ -9433,10 +9565,10 @@ function isFile(file) {
|
|
|
9433
9565
|
function resolveSourcePath(source, roots) {
|
|
9434
9566
|
const normalized = normalizeSourcePath(source);
|
|
9435
9567
|
if (!normalized || /(?:^|\/)node_modules\//.test(normalized)) return null;
|
|
9436
|
-
if (
|
|
9568
|
+
if (path16.isAbsolute(normalized) && isFile(normalized)) return path16.resolve(normalized);
|
|
9437
9569
|
const relative7 = normalized.replace(/^\/+/, "");
|
|
9438
9570
|
for (const root of roots) {
|
|
9439
|
-
const candidate =
|
|
9571
|
+
const candidate = path16.resolve(root, relative7);
|
|
9440
9572
|
if (isFile(candidate)) return candidate;
|
|
9441
9573
|
}
|
|
9442
9574
|
return null;
|
|
@@ -9468,7 +9600,7 @@ function fileForUrl(url, roots, bases) {
|
|
|
9468
9600
|
return file;
|
|
9469
9601
|
}
|
|
9470
9602
|
function relativeToRepo(file, repoRoot) {
|
|
9471
|
-
return
|
|
9603
|
+
return path16.relative(repoRoot, file).split(path16.sep).join("/");
|
|
9472
9604
|
}
|
|
9473
9605
|
var SERVED_AS_WRITTEN_PARAMS = /* @__PURE__ */ new Set(["t", "v", "import"]);
|
|
9474
9606
|
function servedAsWritten(url) {
|
|
@@ -9542,14 +9674,14 @@ async function resolveFunctions(entries, roots, fetchMap, pageUrl, withKnown, wi
|
|
|
9542
9674
|
const lines = /* @__PURE__ */ new Map();
|
|
9543
9675
|
const executable = /* @__PURE__ */ new Map();
|
|
9544
9676
|
const addLines = (into, file, ranges) => {
|
|
9545
|
-
const
|
|
9546
|
-
into.set(
|
|
9677
|
+
const path20 = relativeToRepo(file, roots.repoRoot);
|
|
9678
|
+
into.set(path20, normalizeLineRanges([...into.get(path20) ?? [], ...ranges]));
|
|
9547
9679
|
};
|
|
9548
9680
|
const addTo = (into, file, functions) => {
|
|
9549
|
-
const
|
|
9550
|
-
const listed = into.get(
|
|
9681
|
+
const path20 = relativeToRepo(file, roots.repoRoot);
|
|
9682
|
+
const listed = into.get(path20);
|
|
9551
9683
|
if (listed) listed.push(...functions);
|
|
9552
|
-
else into.set(
|
|
9684
|
+
else into.set(path20, [...functions]);
|
|
9553
9685
|
};
|
|
9554
9686
|
const add2 = (file, functions) => addTo(files, file, functions);
|
|
9555
9687
|
const bases = viteBases(entries);
|
|
@@ -9908,7 +10040,7 @@ async function stopPageCoverage(page) {
|
|
|
9908
10040
|
|
|
9909
10041
|
// src/internal/capture/css-coverage.ts
|
|
9910
10042
|
var crypto5 = __toESM(require("crypto"));
|
|
9911
|
-
var
|
|
10043
|
+
var fs13 = __toESM(require("fs"));
|
|
9912
10044
|
|
|
9913
10045
|
// ../core/src/css-rules.ts
|
|
9914
10046
|
var GROUPING = /* @__PURE__ */ new Set(["media", "supports", "layer", "container", "scope", "starting-style", "document"]);
|
|
@@ -10048,7 +10180,7 @@ function sourceFile(source, roots) {
|
|
|
10048
10180
|
function styleBlockLine(file, index) {
|
|
10049
10181
|
let text;
|
|
10050
10182
|
try {
|
|
10051
|
-
text =
|
|
10183
|
+
text = fs13.readFileSync(file, "utf-8");
|
|
10052
10184
|
} catch {
|
|
10053
10185
|
return 0;
|
|
10054
10186
|
}
|
|
@@ -10079,7 +10211,7 @@ async function sheetMap(sheet, text, fetchMap) {
|
|
|
10079
10211
|
function sameLines2(text, rules, file, lineOffset) {
|
|
10080
10212
|
let source;
|
|
10081
10213
|
try {
|
|
10082
|
-
source =
|
|
10214
|
+
source = fs13.readFileSync(file, "utf-8");
|
|
10083
10215
|
} catch {
|
|
10084
10216
|
return false;
|
|
10085
10217
|
}
|
|
@@ -10169,21 +10301,21 @@ async function resolveCssCoverage(sheets, roots, fetchMap) {
|
|
|
10169
10301
|
|
|
10170
10302
|
// src/internal/capture/resource-ledger.ts
|
|
10171
10303
|
var childProcess = __toESM(require("child_process"));
|
|
10172
|
-
var
|
|
10304
|
+
var fs15 = __toESM(require("fs"));
|
|
10173
10305
|
var net3 = __toESM(require("net"));
|
|
10174
|
-
var
|
|
10306
|
+
var path18 = __toESM(require("path"));
|
|
10175
10307
|
var import_node_module3 = require("module");
|
|
10176
10308
|
|
|
10177
10309
|
// src/internal/capture/worker-metrics.ts
|
|
10178
10310
|
var import_node_perf_hooks = require("perf_hooks");
|
|
10179
10311
|
|
|
10180
10312
|
// src/internal/support/system-readers.ts
|
|
10181
|
-
var
|
|
10182
|
-
var
|
|
10313
|
+
var fs14 = __toESM(require("fs"));
|
|
10314
|
+
var path17 = __toESM(require("path"));
|
|
10183
10315
|
var CLK_TCK = 100;
|
|
10184
10316
|
function readText(file) {
|
|
10185
10317
|
try {
|
|
10186
|
-
return
|
|
10318
|
+
return fs14.readFileSync(file, "utf8");
|
|
10187
10319
|
} catch {
|
|
10188
10320
|
return null;
|
|
10189
10321
|
}
|
|
@@ -10265,45 +10397,45 @@ var ProcFs = class {
|
|
|
10265
10397
|
}
|
|
10266
10398
|
/** Whether this looks like a Linux `/proc` at all. */
|
|
10267
10399
|
available() {
|
|
10268
|
-
return
|
|
10400
|
+
return fs14.existsSync(path17.join(this.root, "stat"));
|
|
10269
10401
|
}
|
|
10270
10402
|
/** Every process, keyed by pid. */
|
|
10271
10403
|
table() {
|
|
10272
10404
|
const out = /* @__PURE__ */ new Map();
|
|
10273
10405
|
let names;
|
|
10274
10406
|
try {
|
|
10275
|
-
names =
|
|
10407
|
+
names = fs14.readdirSync(this.root);
|
|
10276
10408
|
} catch {
|
|
10277
10409
|
return out;
|
|
10278
10410
|
}
|
|
10279
10411
|
for (const name of names) {
|
|
10280
10412
|
if (!/^\d+$/.test(name)) continue;
|
|
10281
|
-
const text = readText(
|
|
10413
|
+
const text = readText(path17.join(this.root, name, "stat"));
|
|
10282
10414
|
const stat = text ? parseProcStat(Number(name), text) : null;
|
|
10283
10415
|
if (stat) out.set(stat.pid, stat);
|
|
10284
10416
|
}
|
|
10285
10417
|
return out;
|
|
10286
10418
|
}
|
|
10287
10419
|
stat(pid) {
|
|
10288
|
-
const text = readText(
|
|
10420
|
+
const text = readText(path17.join(this.root, String(pid), "stat"));
|
|
10289
10421
|
return text ? parseProcStat(pid, text) : null;
|
|
10290
10422
|
}
|
|
10291
10423
|
runWaitMs(pid) {
|
|
10292
|
-
const text = readText(
|
|
10424
|
+
const text = readText(path17.join(this.root, String(pid), "schedstat"));
|
|
10293
10425
|
return text ? parseSchedstat(text) : null;
|
|
10294
10426
|
}
|
|
10295
10427
|
cmdline(pid) {
|
|
10296
|
-
return (readText(
|
|
10428
|
+
return (readText(path17.join(this.root, String(pid), "cmdline")) ?? "").split("\0").join(" ").trim();
|
|
10297
10429
|
}
|
|
10298
10430
|
/** A field of `/proc/<pid>/status`, in kB: `VmRSS`, `VmHWM`. */
|
|
10299
10431
|
statusKb(pid, key) {
|
|
10300
|
-
const text = readText(
|
|
10432
|
+
const text = readText(path17.join(this.root, String(pid), "status"));
|
|
10301
10433
|
return text ? parseKbField(text, key) : null;
|
|
10302
10434
|
}
|
|
10303
10435
|
/** Proportional set size: shared pages split between the processes sharing them, so a sum counts them once. */
|
|
10304
10436
|
async pssKb(pid) {
|
|
10305
10437
|
try {
|
|
10306
|
-
return parseKbField(await
|
|
10438
|
+
return parseKbField(await fs14.promises.readFile(path17.join(this.root, String(pid), "smaps_rollup"), "utf8"), "Pss");
|
|
10307
10439
|
} catch {
|
|
10308
10440
|
return null;
|
|
10309
10441
|
}
|
|
@@ -10311,29 +10443,29 @@ var ProcFs = class {
|
|
|
10311
10443
|
/** Reset a process's peak RSS (`VmHWM`) to its current RSS. */
|
|
10312
10444
|
resetPeakRss(pid) {
|
|
10313
10445
|
try {
|
|
10314
|
-
|
|
10446
|
+
fs14.writeFileSync(path17.join(this.root, String(pid), "clear_refs"), "5");
|
|
10315
10447
|
return true;
|
|
10316
10448
|
} catch {
|
|
10317
10449
|
return false;
|
|
10318
10450
|
}
|
|
10319
10451
|
}
|
|
10320
10452
|
cpuTicks() {
|
|
10321
|
-
const text = readText(
|
|
10453
|
+
const text = readText(path17.join(this.root, "stat"));
|
|
10322
10454
|
return text ? parseCpuTicks(text) : null;
|
|
10323
10455
|
}
|
|
10324
10456
|
/** Total stall time of a resource's pressure file, in µs. */
|
|
10325
10457
|
pressureUs(resource) {
|
|
10326
|
-
const text = readText(
|
|
10458
|
+
const text = readText(path17.join(this.root, "pressure", resource));
|
|
10327
10459
|
return text ? parsePsiTotal(text) : null;
|
|
10328
10460
|
}
|
|
10329
10461
|
memAvailableKb() {
|
|
10330
|
-
const text = readText(
|
|
10462
|
+
const text = readText(path17.join(this.root, "meminfo"));
|
|
10331
10463
|
return text ? parseKbField(text, "MemAvailable") : null;
|
|
10332
10464
|
}
|
|
10333
10465
|
/** Open file descriptors of a process. */
|
|
10334
10466
|
fdCount(pid) {
|
|
10335
10467
|
try {
|
|
10336
|
-
return
|
|
10468
|
+
return fs14.readdirSync(path17.join(this.root, String(pid), "fd")).length;
|
|
10337
10469
|
} catch {
|
|
10338
10470
|
return null;
|
|
10339
10471
|
}
|
|
@@ -10603,8 +10735,8 @@ var GLOBALS_FILES = [
|
|
|
10603
10735
|
function playwrightGlobalsFile() {
|
|
10604
10736
|
const packageJson = resolvePlaywrightPackageJson();
|
|
10605
10737
|
if (!packageJson) return null;
|
|
10606
|
-
const root =
|
|
10607
|
-
return GLOBALS_FILES.map((parts) =>
|
|
10738
|
+
const root = path18.dirname(packageJson);
|
|
10739
|
+
return GLOBALS_FILES.map((parts) => path18.join(root, ...parts)).find((file) => fs15.existsSync(file)) ?? null;
|
|
10608
10740
|
}
|
|
10609
10741
|
function playwrightTestInfoSource() {
|
|
10610
10742
|
try {
|
|
@@ -10653,7 +10785,7 @@ function deepUserSite() {
|
|
|
10653
10785
|
}
|
|
10654
10786
|
var SHELLS = /^(?:sh|bash|dash|zsh|cmd|cmd\.exe|powershell|powershell\.exe|pwsh)$/i;
|
|
10655
10787
|
function commandOf(spawnfile, spawnargs) {
|
|
10656
|
-
const name = (file) =>
|
|
10788
|
+
const name = (file) => path18.basename(file.replace(/\\/g, "/").replace(/^["']|["']$/g, ""));
|
|
10657
10789
|
const program = typeof spawnfile === "string" ? name(spawnfile) : "";
|
|
10658
10790
|
const args = Array.isArray(spawnargs) ? spawnargs.map(String) : [];
|
|
10659
10791
|
const script = args.findIndex((arg) => arg === "-c" || /^\/c$/i.test(arg));
|
|
@@ -11592,7 +11724,7 @@ function configuredCodeReachRoots() {
|
|
|
11592
11724
|
}
|
|
11593
11725
|
} catch {
|
|
11594
11726
|
}
|
|
11595
|
-
return raw.split(
|
|
11727
|
+
return raw.split(path19.delimiter).filter(Boolean);
|
|
11596
11728
|
}
|
|
11597
11729
|
async function stopSinkCodeReach(sink, closing) {
|
|
11598
11730
|
const stopping = [];
|
|
@@ -12241,7 +12373,7 @@ function endedWaiting(sink, call) {
|
|
|
12241
12373
|
return "finish";
|
|
12242
12374
|
}
|
|
12243
12375
|
function stopSite(sink, location) {
|
|
12244
|
-
if (
|
|
12376
|
+
if (path19.dirname(path19.resolve(location.file)) !== __dirname) return stopCallSite(location);
|
|
12245
12377
|
return inFlightCallSite([...sink.locatorCalls.values()].map((call) => call.location));
|
|
12246
12378
|
}
|
|
12247
12379
|
function stopBarPage(sink, context, of) {
|
|
@@ -12251,7 +12383,8 @@ function stopBarPage(sink, context, of) {
|
|
|
12251
12383
|
const open = openPages(context);
|
|
12252
12384
|
return open[open.length - 1] ?? null;
|
|
12253
12385
|
}
|
|
12254
|
-
async function showStop(sink, context,
|
|
12386
|
+
async function showStop(sink, context, calledAs, location, reason, call, of, failure = null) {
|
|
12387
|
+
const title = hideSecretsInText(hideTypedText(calledAs));
|
|
12255
12388
|
const testInfo = sink.testInfo;
|
|
12256
12389
|
const page = stopBarPage(sink, context, of);
|
|
12257
12390
|
const guessed = !("page" in of);
|
|
@@ -12586,8 +12719,8 @@ function errorPlace(error, windows = process.platform === "win32") {
|
|
|
12586
12719
|
for (const line of typeof stack === "string" ? stack.split("\n") : []) {
|
|
12587
12720
|
const frame = /^\s*at\s+(?:.*?\s+\()?(.+?):(\d+):(\d+)\)?$/.exec(line);
|
|
12588
12721
|
const file = frame ? framePath(frame[1], windows) : null;
|
|
12589
|
-
if (!frame || !file || !(windows ?
|
|
12590
|
-
if (/[\\/]node_modules[\\/]/.test(file) ||
|
|
12722
|
+
if (!frame || !file || !(windows ? path19.win32 : path19.posix).isAbsolute(file)) continue;
|
|
12723
|
+
if (/[\\/]node_modules[\\/]/.test(file) || path19.dirname(path19.resolve(file)) === __dirname) continue;
|
|
12591
12724
|
return { file, line: Number(frame[2]), column: Number(frame[3]) };
|
|
12592
12725
|
}
|
|
12593
12726
|
return null;
|
|
@@ -12602,7 +12735,7 @@ function callInProgress(testInfo) {
|
|
|
12602
12735
|
const called = step.category === "pw:api" || step.category === "expect" || step.category === "test.step";
|
|
12603
12736
|
if (called && typeof at?.file === "string" && typeof at.line === "number") {
|
|
12604
12737
|
found = {
|
|
12605
|
-
title: typeof step.title === "string" ? step
|
|
12738
|
+
title: typeof step.title === "string" ? stepLabel(step) : null,
|
|
12606
12739
|
place: { file: at.file, line: at.line, column: typeof at.column === "number" ? at.column : 0 }
|
|
12607
12740
|
};
|
|
12608
12741
|
}
|
|
@@ -12612,13 +12745,18 @@ function callInProgress(testInfo) {
|
|
|
12612
12745
|
visit(testInfo._steps);
|
|
12613
12746
|
return found;
|
|
12614
12747
|
}
|
|
12748
|
+
function liveOutcomeStatus(testInfo) {
|
|
12749
|
+
if (testInfo.expectedStatus !== "failed") return testInfo.status;
|
|
12750
|
+
if (testInfo.status === "failed") return "passed";
|
|
12751
|
+
return testInfo.status === "passed" ? "failed" : testInfo.status;
|
|
12752
|
+
}
|
|
12615
12753
|
function stepInProgress(testInfo) {
|
|
12616
12754
|
return callInProgress(testInfo)?.place ?? null;
|
|
12617
12755
|
}
|
|
12618
12756
|
function runningCall(testInfo) {
|
|
12619
12757
|
const call = callInProgress(testInfo);
|
|
12620
12758
|
if (!call?.title) return null;
|
|
12621
|
-
const file =
|
|
12759
|
+
const file = path19.relative(process.cwd(), call.place.file).split(path19.sep).join("/");
|
|
12622
12760
|
return { title: call.title, file, line: call.place.line };
|
|
12623
12761
|
}
|
|
12624
12762
|
function abortion(signal) {
|
|
@@ -13477,7 +13615,7 @@ var runControl = {
|
|
|
13477
13615
|
}
|
|
13478
13616
|
};
|
|
13479
13617
|
function runFile(file) {
|
|
13480
|
-
return
|
|
13618
|
+
return path19.relative(process.cwd(), file).split(path19.sep).join("/") || file;
|
|
13481
13619
|
}
|
|
13482
13620
|
function testBegin(testInfo, cannotPause) {
|
|
13483
13621
|
const title = testInfo.titlePath.slice(1);
|
|
@@ -13609,7 +13747,7 @@ var piwiFixtures = {
|
|
|
13609
13747
|
sink.ending = true;
|
|
13610
13748
|
await endShownStops(sink, "ended");
|
|
13611
13749
|
await awaitReleasedCalls(sink);
|
|
13612
|
-
await liveViewTestEnded();
|
|
13750
|
+
await liveViewTestEnded(liveOutcomeStatus(testInfo));
|
|
13613
13751
|
showRunChannel();
|
|
13614
13752
|
currentSink = null;
|
|
13615
13753
|
if (sink.pause?.pause) pauseNextTest = true;
|
|
@@ -13700,6 +13838,7 @@ function extendPiwiFixtures(test) {
|
|
|
13700
13838
|
readPageInteraction,
|
|
13701
13839
|
recordResourceCensus,
|
|
13702
13840
|
resolveCodeReach,
|
|
13841
|
+
runningCall,
|
|
13703
13842
|
startCodeReach,
|
|
13704
13843
|
startResourceLedger,
|
|
13705
13844
|
stopCodeReach,
|