@piwitests/reporter 0.73.0 → 0.75.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/cli/index.js +1 -1
- package/dist/index.js +544 -164
- package/dist/internal/capture/capture-fixtures.d.ts +10 -4
- package/dist/internal/capture/capture-fixtures.js +541 -157
- package/package.json +2 -2
|
@@ -41,6 +41,7 @@ __export(capture_fixtures_exports, {
|
|
|
41
41
|
codeReachRoots: () => codeReachRoots,
|
|
42
42
|
computeCoreVitals: () => computeCoreVitals,
|
|
43
43
|
configuredCodeReachRoots: () => configuredCodeReachRoots,
|
|
44
|
+
endedFromPiwiError: () => endedFromPiwiError,
|
|
44
45
|
errorPlace: () => errorPlace,
|
|
45
46
|
extendPiwiFixtures: () => extendPiwiFixtures,
|
|
46
47
|
failureError: () => failureError,
|
|
@@ -4596,8 +4597,8 @@ function escapedInQuotes(value) {
|
|
|
4596
4597
|
let out = "";
|
|
4597
4598
|
for (const c of value) {
|
|
4598
4599
|
const code = c.charCodeAt(0);
|
|
4599
|
-
const
|
|
4600
|
-
out += ARIA_ESCAPES[c] ?? (
|
|
4600
|
+
const control3 = code < 32 || code >= 127 && code <= 159;
|
|
4601
|
+
out += ARIA_ESCAPES[c] ?? (control3 ? `\\x${code.toString(16).padStart(2, "0")}` : c);
|
|
4601
4602
|
}
|
|
4602
4603
|
return out;
|
|
4603
4604
|
}
|
|
@@ -4613,13 +4614,60 @@ function withoutFieldSecrets(snapshot, secrets) {
|
|
|
4613
4614
|
}).join("\n");
|
|
4614
4615
|
return hideKnownValues(out, values);
|
|
4615
4616
|
}
|
|
4617
|
+
var CUT_MARK = "\u2026";
|
|
4618
|
+
var MIN_CUT_START = 4;
|
|
4619
|
+
function cutText(text, max) {
|
|
4620
|
+
return text.length <= max ? text : `${text.slice(0, Math.max(0, max - 1))}${CUT_MARK}`;
|
|
4621
|
+
}
|
|
4616
4622
|
function hideKnownValues(text, values) {
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4623
|
+
return knownValuesHider(values)(text);
|
|
4624
|
+
}
|
|
4625
|
+
function knownValuesHider(values) {
|
|
4626
|
+
const known = values.filter((v) => v.trim());
|
|
4627
|
+
const wholes = new Set(known.map((v) => v.trim()));
|
|
4628
|
+
const forms = [...new Set(known.filter((v) => v.length >= 8).flatMap((v) => [v, escapedInQuotes(v)]))];
|
|
4629
|
+
return (text) => hideForms(text, wholes, forms);
|
|
4630
|
+
}
|
|
4631
|
+
function hideForms(text, wholes, forms) {
|
|
4632
|
+
const whole = text.trim();
|
|
4633
|
+
if (whole && wholes.has(whole)) return HIDDEN_VALUE;
|
|
4634
|
+
if (!forms.length) return text;
|
|
4635
|
+
const places = [];
|
|
4636
|
+
for (const form of forms) {
|
|
4637
|
+
for (let at = text.indexOf(form); at !== -1; at = text.indexOf(form, at + 1)) places.push([at, at + form.length]);
|
|
4638
|
+
}
|
|
4639
|
+
for (let mark = text.indexOf(CUT_MARK); mark !== -1; mark = text.indexOf(CUT_MARK, mark + 1)) {
|
|
4640
|
+
const start = longestStartBefore(text, mark, forms);
|
|
4641
|
+
if (start) places.push([Math.max(0, mark - Math.max(start, HIDDEN_VALUE.length)), mark]);
|
|
4642
|
+
}
|
|
4643
|
+
if (!places.length) return text;
|
|
4644
|
+
places.sort((a, b) => a[0] - b[0]);
|
|
4645
|
+
let out = "";
|
|
4646
|
+
let kept = 0;
|
|
4647
|
+
let open4 = places[0];
|
|
4648
|
+
for (const place of places.slice(1)) {
|
|
4649
|
+
if (place[0] < open4[1]) {
|
|
4650
|
+
open4 = [open4[0], Math.max(open4[1], place[1])];
|
|
4651
|
+
continue;
|
|
4652
|
+
}
|
|
4653
|
+
out += `${text.slice(kept, open4[0])}${HIDDEN_VALUE}`;
|
|
4654
|
+
kept = open4[1];
|
|
4655
|
+
open4 = place;
|
|
4621
4656
|
}
|
|
4622
|
-
return out
|
|
4657
|
+
return `${out}${text.slice(kept, open4[0])}${HIDDEN_VALUE}${text.slice(open4[1])}`;
|
|
4658
|
+
}
|
|
4659
|
+
function longestStartBefore(text, mark, forms) {
|
|
4660
|
+
const last = text.charCodeAt(mark - 1);
|
|
4661
|
+
let longest = 0;
|
|
4662
|
+
for (const form of forms) {
|
|
4663
|
+
for (let length = Math.min(form.length - 1, mark); length >= Math.max(longest + 1, MIN_CUT_START); length--) {
|
|
4664
|
+
if (form.charCodeAt(length - 1) === last && text.startsWith(form.slice(0, length), mark - length)) {
|
|
4665
|
+
longest = length;
|
|
4666
|
+
break;
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
return longest;
|
|
4623
4671
|
}
|
|
4624
4672
|
var FIELD_ROLES = /* @__PURE__ */ new Set(["textbox", "searchbox", "combobox", "spinbutton"]);
|
|
4625
4673
|
var CARD_WORDS = /* @__PURE__ */ new Set(["card", "cc", "credit", "debit", "kreditkarte", "carte", "tarjeta"]);
|
|
@@ -6071,11 +6119,11 @@ var FrameAcks = class {
|
|
|
6071
6119
|
this.release();
|
|
6072
6120
|
}
|
|
6073
6121
|
release() {
|
|
6074
|
-
const
|
|
6122
|
+
const waiting3 = this.waiting;
|
|
6075
6123
|
this.waiting = null;
|
|
6076
|
-
if (!
|
|
6077
|
-
clearTimeout(
|
|
6078
|
-
|
|
6124
|
+
if (!waiting3) return;
|
|
6125
|
+
clearTimeout(waiting3.timer);
|
|
6126
|
+
waiting3.resolve();
|
|
6079
6127
|
}
|
|
6080
6128
|
};
|
|
6081
6129
|
|
|
@@ -6581,7 +6629,8 @@ function maskSecretFields(page, options) {
|
|
|
6581
6629
|
const before = [...reads].reverse().find((r) => r.ended <= frame.at && r.ended >= frame.at - FRESH_MS) ?? null;
|
|
6582
6630
|
const after = await read();
|
|
6583
6631
|
if (typeof after === "string" || !after) return after;
|
|
6584
|
-
const
|
|
6632
|
+
const own = jpegSize(frame.data) ?? frame;
|
|
6633
|
+
const size = frame.fit ? fitViewSize(own, frame.fit.width, frame.fit.height) : own;
|
|
6585
6634
|
if (before && sameBoxes(before.boxes, after.boxes) && showsViewportOf(frame, before) && showsViewportOf(frame, after)) {
|
|
6586
6635
|
return shown2(frame, after.boxes, await also?.(frame) ?? [], size);
|
|
6587
6636
|
}
|
|
@@ -6617,6 +6666,8 @@ function maskSecretFields(page, options) {
|
|
|
6617
6666
|
var SCREENCAST_LAG_MS = 100;
|
|
6618
6667
|
var BAR_READ_MS = 1e3;
|
|
6619
6668
|
var UNDATED_MS = 1e3;
|
|
6669
|
+
var FIRST_FRAME_MS = 500;
|
|
6670
|
+
var STILL_SHOTS = 3;
|
|
6620
6671
|
var HOLDERS = /* @__PURE__ */ new WeakMap();
|
|
6621
6672
|
var TEST_SCREENCASTS = /* @__PURE__ */ new WeakSet();
|
|
6622
6673
|
var OWN_SCREENCASTS = /* @__PURE__ */ new WeakMap();
|
|
@@ -6742,6 +6793,14 @@ async function openPageView(page, options) {
|
|
|
6742
6793
|
if (!viewport) return null;
|
|
6743
6794
|
let closed = false;
|
|
6744
6795
|
let last = null;
|
|
6796
|
+
let again = false;
|
|
6797
|
+
let given = 0;
|
|
6798
|
+
let paintedLast = null;
|
|
6799
|
+
let imaged = false;
|
|
6800
|
+
let stills = 0;
|
|
6801
|
+
let stillTimer = null;
|
|
6802
|
+
let stillShot = null;
|
|
6803
|
+
let refreshing = null;
|
|
6745
6804
|
let sent2 = null;
|
|
6746
6805
|
let refused = false;
|
|
6747
6806
|
let screening = false;
|
|
@@ -6769,8 +6828,12 @@ async function openPageView(page, options) {
|
|
|
6769
6828
|
return bar;
|
|
6770
6829
|
});
|
|
6771
6830
|
paintMs = bar.length && painting && jpegCodec() ? Date.now() - painting : 0;
|
|
6772
|
-
if (typeof shown2
|
|
6773
|
-
|
|
6831
|
+
if (shown2 && typeof shown2 !== "string") {
|
|
6832
|
+
if (frame.data === paintedLast) stills = 0;
|
|
6833
|
+
return deliver(shown2);
|
|
6834
|
+
}
|
|
6835
|
+
if (shown2) refuse2(shown2);
|
|
6836
|
+
dropped(frame);
|
|
6774
6837
|
};
|
|
6775
6838
|
const pacer = new LatestPacer({
|
|
6776
6839
|
intervalMs: interval,
|
|
@@ -6779,56 +6842,110 @@ async function openPageView(page, options) {
|
|
|
6779
6842
|
send: (frame) => {
|
|
6780
6843
|
if (!options.live()) return;
|
|
6781
6844
|
screening = true;
|
|
6782
|
-
screened = show(frame).catch(() =>
|
|
6845
|
+
screened = show(frame).catch(() => dropped(frame)).finally(() => {
|
|
6783
6846
|
screening = false;
|
|
6784
6847
|
screened = null;
|
|
6785
6848
|
});
|
|
6786
6849
|
}
|
|
6787
6850
|
});
|
|
6788
6851
|
const shownSize = (shot) => page.viewportSize() ?? jpegSize(shot) ?? viewport;
|
|
6852
|
+
const takeImage = async (quality) => {
|
|
6853
|
+
if (closed) return null;
|
|
6854
|
+
const shot = await internalCall(
|
|
6855
|
+
page,
|
|
6856
|
+
() => page.screenshot({ type: "jpeg", quality, scale: "css", caret: "initial", timeout: 5e3 })
|
|
6857
|
+
).catch(() => null);
|
|
6858
|
+
if (!shot) return null;
|
|
6859
|
+
const size = shownSize(shot);
|
|
6860
|
+
const asked2 = options.size(size);
|
|
6861
|
+
const own = jpegSize(shot);
|
|
6862
|
+
const larger = !!own && (own.width > asked2.width || own.height > asked2.height);
|
|
6863
|
+
return { data: shot, ...size, ...larger ? { fit: asked2 } : {} };
|
|
6864
|
+
};
|
|
6789
6865
|
let lighter = null;
|
|
6866
|
+
const standsFor = /* @__PURE__ */ new WeakMap();
|
|
6790
6867
|
let lighterAt = -Infinity;
|
|
6791
6868
|
const lighten = () => {
|
|
6792
6869
|
const now = Date.now();
|
|
6793
6870
|
if (lighter || now - lighterAt < options.shotMs) return;
|
|
6794
6871
|
lighterAt = now;
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
(shot)
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
() => void 0
|
|
6805
|
-
).finally(() => {
|
|
6872
|
+
const heavy = last;
|
|
6873
|
+
lighter = takeImage(options.lightQuality).then((shot) => {
|
|
6874
|
+
if (!shot || closed) return;
|
|
6875
|
+
const quality = options.lightQuality;
|
|
6876
|
+
const data = shot.fit ? thumbnailOf(shot.data, { ...shot.fit, quality, maxBytes: Number.POSITIVE_INFINITY })?.data ?? shot.data : shot.data;
|
|
6877
|
+
if (data.length > options.maxFrameBytes) return refuse2();
|
|
6878
|
+
if (heavy) standsFor.set(data, heavy);
|
|
6879
|
+
pacer.offer({ data, width: shot.width, height: shot.height, at: now });
|
|
6880
|
+
}).finally(() => {
|
|
6806
6881
|
lighter = null;
|
|
6807
6882
|
});
|
|
6808
6883
|
};
|
|
6809
|
-
const
|
|
6810
|
-
if (
|
|
6884
|
+
const goingLength = (data, width, height, fit) => {
|
|
6885
|
+
if (!fit) return data.length;
|
|
6886
|
+
const own = jpegSize(data) ?? { width, height };
|
|
6887
|
+
return Math.round(data.length * Math.min(1, fit.width * fit.height / (own.width * own.height)));
|
|
6888
|
+
};
|
|
6889
|
+
const onFrame = (data, width, height, at, painted = false, fit) => {
|
|
6890
|
+
if (closed || last?.equals(data) && !again) return;
|
|
6891
|
+
if (painted) {
|
|
6892
|
+
if (imaged && paintedLast?.equals(data)) return;
|
|
6893
|
+
imaged = false;
|
|
6894
|
+
paintedLast = data;
|
|
6895
|
+
}
|
|
6896
|
+
again = false;
|
|
6811
6897
|
last = data;
|
|
6812
|
-
|
|
6898
|
+
given++;
|
|
6899
|
+
if (goingLength(data, width, height, fit) > options.maxFrameBytes) return lighten();
|
|
6813
6900
|
const named = isViewSize(width, height);
|
|
6814
|
-
|
|
6901
|
+
const shown2 = { width: named ? width : viewport.width, height: named ? height : viewport.height };
|
|
6902
|
+
pacer.offer({ data, ...shown2, at, ...fit ? { fit } : {} });
|
|
6903
|
+
};
|
|
6904
|
+
const imageNow = async () => {
|
|
6905
|
+
const at = Date.now();
|
|
6906
|
+
const before = given;
|
|
6907
|
+
const shot = await takeImage(options.quality);
|
|
6908
|
+
if (given !== before) return true;
|
|
6909
|
+
if (!shot) return false;
|
|
6910
|
+
imaged = true;
|
|
6911
|
+
onFrame(shot.data, shot.width, shot.height, at, false, shot.fit);
|
|
6912
|
+
return true;
|
|
6913
|
+
};
|
|
6914
|
+
const stillLater = (ms) => {
|
|
6915
|
+
if (closed || stills >= STILL_SHOTS) return;
|
|
6916
|
+
if (stillTimer) clearTimeout(stillTimer);
|
|
6917
|
+
const before = given;
|
|
6918
|
+
stillTimer = setTimeout(() => {
|
|
6919
|
+
stillTimer = null;
|
|
6920
|
+
if (closed || shooting || stillShot || given !== before || !options.live()) return;
|
|
6921
|
+
stills++;
|
|
6922
|
+
const taking = imageNow().then((taken) => {
|
|
6923
|
+
if (stillShot === taking) stillShot = null;
|
|
6924
|
+
if (!taken) stillLater(options.shotMs);
|
|
6925
|
+
});
|
|
6926
|
+
stillShot = taking;
|
|
6927
|
+
}, ms);
|
|
6928
|
+
stillTimer.unref?.();
|
|
6929
|
+
};
|
|
6930
|
+
const dropped = (frame) => {
|
|
6931
|
+
if (closed || (standsFor.get(frame.data) ?? frame.data) !== last || stills >= STILL_SHOTS) return;
|
|
6932
|
+
again = true;
|
|
6933
|
+
if (shooting) stills++;
|
|
6934
|
+
else stillLater(options.shotMs);
|
|
6815
6935
|
};
|
|
6816
6936
|
const screencast = screencastOf(page);
|
|
6817
6937
|
let end = null;
|
|
6818
6938
|
let shots = null;
|
|
6819
6939
|
let shooting = false;
|
|
6940
|
+
let timed = null;
|
|
6820
6941
|
const shoot = async () => {
|
|
6821
6942
|
shots = null;
|
|
6822
6943
|
if (closed || page.isClosed()) return;
|
|
6823
6944
|
const at = Date.now();
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
if (shot) {
|
|
6829
|
-
const size = shownSize(shot);
|
|
6830
|
-
onFrame(shot, size.width, size.height, at);
|
|
6831
|
-
}
|
|
6945
|
+
timed = takeImage(options.quality);
|
|
6946
|
+
const shot = await timed;
|
|
6947
|
+
timed = null;
|
|
6948
|
+
if (shot) onFrame(shot.data, shot.width, shot.height, at, true, shot.fit);
|
|
6832
6949
|
if (!closed) {
|
|
6833
6950
|
shots = setTimeout(() => void shoot(), options.shotMs);
|
|
6834
6951
|
shots.unref?.();
|
|
@@ -6855,6 +6972,7 @@ async function openPageView(page, options) {
|
|
|
6855
6972
|
};
|
|
6856
6973
|
if (typeof screencast?.start === "function" && !TEST_SCREENCASTS.has(page)) {
|
|
6857
6974
|
holders.add(holder);
|
|
6975
|
+
stillLater(FIRST_FRAME_MS);
|
|
6858
6976
|
starting = internalCall(
|
|
6859
6977
|
page,
|
|
6860
6978
|
() => screencast.start({
|
|
@@ -6863,7 +6981,7 @@ async function openPageView(page, options) {
|
|
|
6863
6981
|
onFrame: (frame) => {
|
|
6864
6982
|
const now = Date.now();
|
|
6865
6983
|
const at = typeof frame.timestamp === "number" && Number.isFinite(frame.timestamp) ? Math.min(frame.timestamp, now) - SCREENCAST_LAG_MS : Number.NEGATIVE_INFINITY;
|
|
6866
|
-
onFrame(frame.data, frame.viewportWidth, frame.viewportHeight, at);
|
|
6984
|
+
onFrame(frame.data, frame.viewportWidth, frame.viewportHeight, at, true);
|
|
6867
6985
|
return acks.next();
|
|
6868
6986
|
}
|
|
6869
6987
|
})
|
|
@@ -6901,17 +7019,12 @@ async function openPageView(page, options) {
|
|
|
6901
7019
|
if (closed) return;
|
|
6902
7020
|
sent2 = null;
|
|
6903
7021
|
last = null;
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
|
|
6907
|
-
()
|
|
6908
|
-
)
|
|
6909
|
-
|
|
6910
|
-
const size = shownSize(shot);
|
|
6911
|
-
onFrame(shot, size.width, size.height, at);
|
|
6912
|
-
},
|
|
6913
|
-
() => void 0
|
|
6914
|
-
);
|
|
7022
|
+
stills = 0;
|
|
7023
|
+
const taking = imageNow().then((taken) => {
|
|
7024
|
+
if (refreshing === taking) refreshing = null;
|
|
7025
|
+
if (!taken) stillLater(options.shotMs);
|
|
7026
|
+
});
|
|
7027
|
+
refreshing = taking;
|
|
6915
7028
|
},
|
|
6916
7029
|
close: async () => {
|
|
6917
7030
|
closed = true;
|
|
@@ -6919,8 +7032,9 @@ async function openPageView(page, options) {
|
|
|
6919
7032
|
acks.close();
|
|
6920
7033
|
pacer.close();
|
|
6921
7034
|
if (shots) clearTimeout(shots);
|
|
7035
|
+
if (stillTimer) clearTimeout(stillTimer);
|
|
6922
7036
|
holders.delete(holder);
|
|
6923
|
-
await Promise.all([lighter, screened]);
|
|
7037
|
+
await Promise.all([lighter, timed, stillShot, refreshing, screened]);
|
|
6924
7038
|
const stop2 = end;
|
|
6925
7039
|
end = null;
|
|
6926
7040
|
if (stop2 && !page.isClosed()) await stop2().catch(() => void 0);
|
|
@@ -7945,20 +8059,12 @@ function hideSrcset(value) {
|
|
|
7945
8059
|
);
|
|
7946
8060
|
}
|
|
7947
8061
|
function stringHider(secrets) {
|
|
7948
|
-
const
|
|
7949
|
-
const exact = new Set(values.map((value) => value.trim()));
|
|
7950
|
-
const long = values.filter((value) => value.length >= 8);
|
|
7951
|
-
const own = (value) => {
|
|
7952
|
-
const trimmed = value.trim();
|
|
7953
|
-
if (!trimmed) return null;
|
|
7954
|
-
if (exact.has(trimmed) || looksLikeCardNumber(trimmed)) return HIDDEN_VALUE;
|
|
7955
|
-
let out = value;
|
|
7956
|
-
for (const secret of long) if (out.includes(secret)) out = out.split(secret).join(HIDDEN_VALUE);
|
|
7957
|
-
return out;
|
|
7958
|
-
};
|
|
8062
|
+
const hideKnown = knownValuesHider(secrets);
|
|
7959
8063
|
const by = (hide) => (value) => {
|
|
7960
|
-
|
|
7961
|
-
|
|
8064
|
+
if (!value.trim()) return value;
|
|
8065
|
+
if (looksLikeCardNumber(value.trim())) return HIDDEN_VALUE;
|
|
8066
|
+
const out = hideKnown(value);
|
|
8067
|
+
return out === HIDDEN_VALUE ? out : hide(out);
|
|
7962
8068
|
};
|
|
7963
8069
|
return {
|
|
7964
8070
|
text: by((value) => besideKeptData(value, (text) => hideSecretsInText(hideCssUrls(text)))),
|
|
@@ -8353,6 +8459,10 @@ function liveShareRefusal(status) {
|
|
|
8353
8459
|
return "Sharing stopped: the instance did not answer. Share the run again to try once more.";
|
|
8354
8460
|
}
|
|
8355
8461
|
}
|
|
8462
|
+
var LIVE_VIEW_FEATURES_PARAM = "features";
|
|
8463
|
+
var LIVE_HOLD_FEATURE = "hold";
|
|
8464
|
+
var LIVE_PAUSE_FEATURE = "pause";
|
|
8465
|
+
var MAX_LIVE_HOLD_MINUTES = 15;
|
|
8356
8466
|
var MAX_LIVE_MASKS = 20;
|
|
8357
8467
|
var MAX_LIVE_MASK_LENGTH = 200;
|
|
8358
8468
|
var FRAME_CALLS = /* @__PURE__ */ new Set(["frameLocator", "contentFrame", "owner"]);
|
|
@@ -8443,10 +8553,22 @@ function parseInstanceToWorker(data) {
|
|
|
8443
8553
|
const full = typeof value.full === "boolean" ? value.full : true;
|
|
8444
8554
|
const layers = (readLaneLayers(value.layers) ?? []).filter((layer) => layer !== "calls");
|
|
8445
8555
|
const inspect = value.inspect === true;
|
|
8446
|
-
|
|
8556
|
+
const view3 = { type: "view", ...size, fps: Math.min(LIVE_FRAME_FPS, value.fps), full, layers, inspect };
|
|
8557
|
+
return value.controller === true && full ? { ...view3, controller: true } : view3;
|
|
8447
8558
|
}
|
|
8448
8559
|
if (value.type === "resend") return { type: "resend" };
|
|
8449
8560
|
if (value.type === "text") return { type: "text" };
|
|
8561
|
+
if (value.type === "let-go") return { type: "let-go" };
|
|
8562
|
+
if (value.type === "pause") return { type: "pause" };
|
|
8563
|
+
if (value.type === "resume") return { type: "resume" };
|
|
8564
|
+
if (value.type === "end-test") {
|
|
8565
|
+
const by = typeof value.by === "string" ? plainLiveText(value.by, MAX_ASK_BY) : "";
|
|
8566
|
+
return by ? { type: "end-test", by } : { type: "end-test" };
|
|
8567
|
+
}
|
|
8568
|
+
if (value.type === "hold") {
|
|
8569
|
+
const ms = isInt(value.ms, 1, MAX_LIVE_HOLD_MINUTES * 6e4) ? value.ms : null;
|
|
8570
|
+
return ms !== null && value.pause === true ? { type: "hold", ms, pause: true } : { type: "hold", ms };
|
|
8571
|
+
}
|
|
8450
8572
|
if (value.type !== "viewers" || !isInt(value.count, 0, 1e6)) return null;
|
|
8451
8573
|
return { type: "viewers", count: value.count };
|
|
8452
8574
|
}
|
|
@@ -8488,7 +8610,12 @@ function liveResourceHeader(id, resource) {
|
|
|
8488
8610
|
return { type: "resource", ...id, sha1: resource.sha1, contentType: resource.contentType };
|
|
8489
8611
|
}
|
|
8490
8612
|
var ASK_TO_WATCH_MS = 5 * 6e4;
|
|
8613
|
+
var MAX_ASK_BY = 100;
|
|
8491
8614
|
var LIVE_VIEW_AFTER_PARAM = "after";
|
|
8615
|
+
function plainLiveText(value, max) {
|
|
8616
|
+
const plain = value.replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, " ").replace(/[[\]()<>`]/g, " ").replace(/\s+/g, " ").trim();
|
|
8617
|
+
return Array.from(plain).slice(0, max).join("").trim();
|
|
8618
|
+
}
|
|
8492
8619
|
|
|
8493
8620
|
// ../core/src/run-channel.ts
|
|
8494
8621
|
var RUN_CHANNEL_ENV = "PIWI_RUN_CHANNEL";
|
|
@@ -8747,11 +8874,11 @@ async function readSnapshot(page, depth, image) {
|
|
|
8747
8874
|
var heldIn = (el, args) => {
|
|
8748
8875
|
const field = el;
|
|
8749
8876
|
const tag = (field.tagName ?? "").toLowerCase();
|
|
8750
|
-
const
|
|
8877
|
+
const control3 = tag === "input" || tag === "textarea" || tag === "select";
|
|
8751
8878
|
const type = typeof field.type === "string" ? field.type.toLowerCase() : null;
|
|
8752
8879
|
const secret = typeof field.matches === "function" && field.matches(args.secretFields);
|
|
8753
8880
|
const words = typeof field.textContent === "string" ? field.textContent.replace(/\u200b/g, "").replace(/\s+/g, " ").trim() : "";
|
|
8754
|
-
const value =
|
|
8881
|
+
const value = control3 && !secret && typeof field.value === "string" ? field.value : null;
|
|
8755
8882
|
return {
|
|
8756
8883
|
secret,
|
|
8757
8884
|
text: words ? { read: words.slice(0, args.read), length: words.length } : null,
|
|
@@ -9013,20 +9140,23 @@ function hearLine(call, line) {
|
|
|
9013
9140
|
if (call.secretField !== true && namesSecretField(dropped)) call.secretField = true;
|
|
9014
9141
|
}
|
|
9015
9142
|
function settle(call, titleOf) {
|
|
9016
|
-
call.title ??= hideSecretsInText(hideTypedText(titleOf(call.id) ?? call.named))
|
|
9143
|
+
call.title ??= cutText(hideSecretsInText(hideTypedText(titleOf(call.id) ?? call.named)), MAX_TITLE);
|
|
9017
9144
|
call.secretField ??= call.selector ? isSecretLocator(call.selector) : false;
|
|
9018
9145
|
for (const line of call.heardLines) {
|
|
9019
9146
|
call.secretField ||= namesSecretField(line);
|
|
9020
|
-
call.lines.push(hideSecretsInText(hideSecretsInLog(line, call.secretField))
|
|
9147
|
+
call.lines.push(cutText(hideSecretsInText(hideSecretsInLog(line, call.secretField)), MAX_LINE2));
|
|
9021
9148
|
}
|
|
9022
9149
|
call.heardLines = [];
|
|
9023
9150
|
if (call.lines.length > KEPT_LINES) call.lines.splice(0, call.lines.length - KEPT_LINES);
|
|
9024
9151
|
if (call.heardError !== null) {
|
|
9025
|
-
call.error = hideSecretsInText(hideSecretsInLog(call.heardError, call.secretField))
|
|
9152
|
+
call.error = cutText(hideSecretsInText(hideSecretsInLog(call.heardError, call.secretField)), MAX_LINE2);
|
|
9026
9153
|
call.heardError = null;
|
|
9027
9154
|
}
|
|
9028
9155
|
}
|
|
9029
9156
|
var followed = /* @__PURE__ */ new WeakMap();
|
|
9157
|
+
function followsCallStream(context) {
|
|
9158
|
+
return followed.has(context);
|
|
9159
|
+
}
|
|
9030
9160
|
var listened = /* @__PURE__ */ new WeakMap();
|
|
9031
9161
|
function take(state, update) {
|
|
9032
9162
|
if (typeof update?.id !== "string" || typeof update.title !== "string") return;
|
|
@@ -9268,8 +9398,7 @@ async function followCallLog(page, since, onLog, options = {}) {
|
|
|
9268
9398
|
if (stopped || !shown2) return;
|
|
9269
9399
|
settle(shown2, calls.titleOf);
|
|
9270
9400
|
const here = onThisPage();
|
|
9271
|
-
const
|
|
9272
|
-
const hidden2 = (text) => hideKnownValues(text, known);
|
|
9401
|
+
const hidden2 = knownValuesHider(secrets());
|
|
9273
9402
|
onLog({
|
|
9274
9403
|
id: shown2.id,
|
|
9275
9404
|
call: { title: hidden2(shown2.title), file: shown2.file, line: shown2.line },
|
|
@@ -9354,9 +9483,20 @@ function layersTestEnded() {
|
|
|
9354
9483
|
function layersTest() {
|
|
9355
9484
|
return current;
|
|
9356
9485
|
}
|
|
9486
|
+
var MAX_TITLE2 = 300;
|
|
9487
|
+
function keptTitle(title, max) {
|
|
9488
|
+
const hidden2 = hideSecretsInText(hideTypedText(title));
|
|
9489
|
+
return max === void 0 ? hidden2 : cutText(hidden2, max);
|
|
9490
|
+
}
|
|
9491
|
+
function shownTitle(title, options = {}) {
|
|
9492
|
+
return hideKnownValues(keptTitle(title, options.max), options.secrets ?? knownSecrets());
|
|
9493
|
+
}
|
|
9357
9494
|
function layersTitleOf(id) {
|
|
9358
9495
|
const title = current?.titleOf(id) ?? null;
|
|
9359
|
-
return title === null ? null :
|
|
9496
|
+
return title === null ? null : keptTitle(title, MAX_TITLE2);
|
|
9497
|
+
}
|
|
9498
|
+
function shownThumb(thumb) {
|
|
9499
|
+
return { ...thumb, title: shownTitle(thumb.title, { max: MAX_TITLE2 }) };
|
|
9360
9500
|
}
|
|
9361
9501
|
var eventSubscribers = /* @__PURE__ */ new Set();
|
|
9362
9502
|
function subscribePageEvents(send2) {
|
|
@@ -10660,12 +10800,12 @@ var LiveInspect = class {
|
|
|
10660
10800
|
* for the page's main frame. The frame's snapshots waiting stay (`kept`: they come before it), go up to a full one,
|
|
10661
10801
|
* which starts its chain again (`until-full`: they come after it), or all go (`none`).
|
|
10662
10802
|
*/
|
|
10663
|
-
stopChain(frame, main, why,
|
|
10803
|
+
stopChain(frame, main, why, waiting3) {
|
|
10664
10804
|
let restarts = false;
|
|
10665
|
-
if (
|
|
10805
|
+
if (waiting3 !== "kept") {
|
|
10666
10806
|
const kept = [];
|
|
10667
10807
|
for (const one of this.queue) {
|
|
10668
|
-
if (one.fields.frame === frame && one.fields.full &&
|
|
10808
|
+
if (one.fields.frame === frame && one.fields.full && waiting3 === "until-full") restarts = true;
|
|
10669
10809
|
if (one.fields.frame === frame && !restarts) this.queued -= one.bytes;
|
|
10670
10810
|
else kept.push(one);
|
|
10671
10811
|
}
|
|
@@ -10756,8 +10896,8 @@ var LiveInspect = class {
|
|
|
10756
10896
|
* Post a snapshot, what the page's secrets show and its credentials removed, after the resources it names that did not
|
|
10757
10897
|
* go yet; its frame's chain stops when it does not go.
|
|
10758
10898
|
*/
|
|
10759
|
-
async send(
|
|
10760
|
-
const { fields, snapshot } =
|
|
10899
|
+
async send(waiting3) {
|
|
10900
|
+
const { fields, snapshot } = waiting3;
|
|
10761
10901
|
const secrets = await this.readSecrets();
|
|
10762
10902
|
if (this.closed) return;
|
|
10763
10903
|
if (!secrets) return this.stopChain(fields.frame, fields.main, UNREAD_SECRETS2, "until-full");
|
|
@@ -10777,17 +10917,22 @@ var LiveInspect = class {
|
|
|
10777
10917
|
const shownUrl = this.link.sent.has(sha1) ? hideResourceUrl(url, secrets) : null;
|
|
10778
10918
|
if (shownUrl) named.push({ url: shownUrl, sha1 });
|
|
10779
10919
|
}
|
|
10780
|
-
const live = {
|
|
10920
|
+
const live = {
|
|
10921
|
+
...fields,
|
|
10922
|
+
title: this.titleOf(fields.call, snapshot.callId, secrets),
|
|
10923
|
+
resources: named
|
|
10924
|
+
};
|
|
10781
10925
|
const body = encodeLiveMessage(liveSnapshotHeader(this.link.id, live, this.link.test()), data);
|
|
10782
10926
|
this.link.budget.spend(body.length);
|
|
10783
10927
|
await this.link.post(body);
|
|
10784
10928
|
}
|
|
10785
|
-
/**
|
|
10786
|
-
|
|
10787
|
-
|
|
10788
|
-
|
|
10929
|
+
/**
|
|
10930
|
+
* The call's title: the runner's, else the trace's own, shown as `shownTitle` shows it with the attempt's `secrets`,
|
|
10931
|
+
* 300 characters at most.
|
|
10932
|
+
*/
|
|
10933
|
+
titleOf(step, callId, secrets) {
|
|
10789
10934
|
const own = typeof callId === "string" ? this.calls.get(callId)?.title : void 0;
|
|
10790
|
-
return
|
|
10935
|
+
return shownTitle(layersTitleOf(step) || (own ?? "Call"), { max: 300, secrets });
|
|
10791
10936
|
}
|
|
10792
10937
|
/**
|
|
10793
10938
|
* Post a resource from the trace folder's `resources/`, its bytes of the kind its content type says, once per run,
|
|
@@ -10872,9 +11017,24 @@ var VIEW_END_MS = 1e3;
|
|
|
10872
11017
|
var MAX_EVENT_POSTS = 8;
|
|
10873
11018
|
var GIVE_UP = /* @__PURE__ */ new Set([403, 410]);
|
|
10874
11019
|
var NOT_NOW = /* @__PURE__ */ new Set([401, 404]);
|
|
11020
|
+
var GONE_NOW = /* @__PURE__ */ new Set([404, 409]);
|
|
10875
11021
|
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.`;
|
|
10876
11022
|
var NO_PAGE = "This test has no page to show yet.";
|
|
10877
11023
|
var NO_TEST = "No test runs on this worker now: the next one shows once it opens its page.";
|
|
11024
|
+
var PAUSE_DROPPED = {
|
|
11025
|
+
noTest: "No test runs on this worker now.",
|
|
11026
|
+
stopped: "This worker's test stands at a stop.",
|
|
11027
|
+
left: "Nobody who may control the run watches this worker in full now.",
|
|
11028
|
+
off: "The project's setting is off.",
|
|
11029
|
+
resumed: "Resume came before the test paused.",
|
|
11030
|
+
ended: "The test ended before its next call.",
|
|
11031
|
+
functionEnded: "The test's function ended before its next call."
|
|
11032
|
+
};
|
|
11033
|
+
var waiting = null;
|
|
11034
|
+
var pauseHandlers = null;
|
|
11035
|
+
function onLiveViewPause(handlers) {
|
|
11036
|
+
pauseHandlers = handlers;
|
|
11037
|
+
}
|
|
10878
11038
|
var layerRuns = { events: null, text: null, texts: null, thumbs: null, inspect: null };
|
|
10879
11039
|
var budget = new LiveByteBudget();
|
|
10880
11040
|
var inspectSent = /* @__PURE__ */ new Set();
|
|
@@ -10924,7 +11084,7 @@ function liveViewOpen() {
|
|
|
10924
11084
|
return link !== null;
|
|
10925
11085
|
}
|
|
10926
11086
|
function liveViewMayPause() {
|
|
10927
|
-
return link !== null && !link.ci;
|
|
11087
|
+
return link !== null && (!link.ci || link.hold !== null && link.pause);
|
|
10928
11088
|
}
|
|
10929
11089
|
function active(own) {
|
|
10930
11090
|
return !own.ended && own.refused === null && own.sharing;
|
|
@@ -10995,7 +11155,10 @@ function openLiveView(worker, env = process.env, ci = detectCi(env)) {
|
|
|
10995
11155
|
logTimer: null,
|
|
10996
11156
|
logRefused: false,
|
|
10997
11157
|
masks: [],
|
|
10998
|
-
asked: null
|
|
11158
|
+
asked: null,
|
|
11159
|
+
hold: null,
|
|
11160
|
+
pause: false,
|
|
11161
|
+
pauseAsked: false
|
|
10999
11162
|
};
|
|
11000
11163
|
if (link.sharing) connect(link);
|
|
11001
11164
|
unhearLane = onLanePage(lanePageChanged);
|
|
@@ -11010,6 +11173,7 @@ function openLiveView(worker, env = process.env, ci = detectCi(env)) {
|
|
|
11010
11173
|
return true;
|
|
11011
11174
|
}
|
|
11012
11175
|
function closeLiveView() {
|
|
11176
|
+
letWaitGo(PAUSE_DROPPED.noTest);
|
|
11013
11177
|
const own = link;
|
|
11014
11178
|
link = null;
|
|
11015
11179
|
running = null;
|
|
@@ -11084,6 +11248,7 @@ async function liveViewTestEnded(status) {
|
|
|
11084
11248
|
if (!running) return;
|
|
11085
11249
|
const ended = running;
|
|
11086
11250
|
running = null;
|
|
11251
|
+
if (link) dropPause(link, PAUSE_DROPPED.ended);
|
|
11087
11252
|
const outcome = status ? { test: ended.title, status, ms: Math.max(0, Date.now() - ended.began) } : null;
|
|
11088
11253
|
await stopView();
|
|
11089
11254
|
const own = link;
|
|
@@ -11094,16 +11259,18 @@ async function liveViewTestEnded(status) {
|
|
|
11094
11259
|
function liveViewStopped(stop2) {
|
|
11095
11260
|
const own = link;
|
|
11096
11261
|
if (!own || own.ended) return () => void 0;
|
|
11097
|
-
|
|
11098
|
-
own.stop
|
|
11099
|
-
postState(own, { type: "stop", ...own.id, stop: shown2 });
|
|
11262
|
+
own.stop = stop2;
|
|
11263
|
+
postState(own, { type: "stop", ...own.id, stop: shownStop(stop2) });
|
|
11100
11264
|
return () => {
|
|
11101
|
-
if (own.stop ===
|
|
11265
|
+
if (own.stop === stop2) own.stop = null;
|
|
11102
11266
|
postState(own, { type: "stop", ...own.id, stop: null });
|
|
11103
11267
|
};
|
|
11104
11268
|
}
|
|
11105
11269
|
function hideCallSecrets(call) {
|
|
11106
|
-
return { ...call, title:
|
|
11270
|
+
return { ...call, title: shownTitle(call.title) };
|
|
11271
|
+
}
|
|
11272
|
+
function shownStop(stop2) {
|
|
11273
|
+
return { ...stop2, call: hideCallSecrets(stop2.call) };
|
|
11107
11274
|
}
|
|
11108
11275
|
function postState(own, message) {
|
|
11109
11276
|
if (!active(own) || own.statesWaiting >= MAX_STATES_WAITING) return;
|
|
@@ -11119,6 +11286,7 @@ function connect(own) {
|
|
|
11119
11286
|
if (own.id.shard !== null) url.searchParams.set("shard", String(own.id.shard));
|
|
11120
11287
|
if (own.id.slot !== void 0) url.searchParams.set("slot", String(own.id.slot));
|
|
11121
11288
|
if (own.after !== null) url.searchParams.set(LIVE_VIEW_AFTER_PARAM, String(own.after));
|
|
11289
|
+
if (own.ci) url.searchParams.set(LIVE_VIEW_FEATURES_PARAM, `${LIVE_HOLD_FEATURE},${LIVE_PAUSE_FEATURE}`);
|
|
11122
11290
|
let openedAt = null;
|
|
11123
11291
|
let dropped = false;
|
|
11124
11292
|
const drop = (status) => {
|
|
@@ -11132,6 +11300,7 @@ function connect(own) {
|
|
|
11132
11300
|
if (openedAt !== null && Date.now() - openedAt >= STEADY_MS) own.retries = 0;
|
|
11133
11301
|
if (status !== null) own.answered = status;
|
|
11134
11302
|
if (status !== null && GIVE_UP.has(status)) return void refuse(own, status);
|
|
11303
|
+
if (status !== null && GONE_NOW.has(status) && own === link) letWaitGo(PAUSE_DROPPED.left);
|
|
11135
11304
|
retry(own, status !== null && NOT_NOW.has(status));
|
|
11136
11305
|
};
|
|
11137
11306
|
const request = own.client.request(url, {
|
|
@@ -11166,7 +11335,7 @@ function connect(own) {
|
|
|
11166
11335
|
}, STEADY_MS);
|
|
11167
11336
|
own.backTimer.unref?.();
|
|
11168
11337
|
}
|
|
11169
|
-
if (own.stop) postState(own, { type: "stop", ...own.id, stop: own.stop });
|
|
11338
|
+
if (own.stop) postState(own, { type: "stop", ...own.id, stop: shownStop(own.stop) });
|
|
11170
11339
|
response.setEncoding("utf8");
|
|
11171
11340
|
let text = "";
|
|
11172
11341
|
response.on("data", (chunk) => {
|
|
@@ -11182,7 +11351,12 @@ function connect(own) {
|
|
|
11182
11351
|
else if (message?.type === "view") setAsked(own, message);
|
|
11183
11352
|
else if (message?.type === "resend") resendView(own);
|
|
11184
11353
|
else if (message?.type === "text") sendText(own);
|
|
11354
|
+
else if (message?.type === "hold") setHold(own, message.ms, message.pause === true);
|
|
11355
|
+
else if (message?.type === "let-go" || message?.type === "pause") control(own, request, message.type);
|
|
11356
|
+
else if (message?.type === "resume") control(own, request, "resume");
|
|
11357
|
+
else if (message?.type === "end-test") control(own, request, "end-test", message.by ?? null);
|
|
11185
11358
|
else if (message) setViewers(own, message.count);
|
|
11359
|
+
if (message?.type === "view" || message?.type === "viewers") keepHold(own, message);
|
|
11186
11360
|
}
|
|
11187
11361
|
});
|
|
11188
11362
|
response.on("error", () => drop(null));
|
|
@@ -11236,6 +11410,7 @@ function lostCause(status) {
|
|
|
11236
11410
|
}
|
|
11237
11411
|
function refuse(own, status) {
|
|
11238
11412
|
if (own.refused !== null) return;
|
|
11413
|
+
if (own === link) letWaitGo(PAUSE_DROPPED.left);
|
|
11239
11414
|
own.refused = liveShareRefusal(status);
|
|
11240
11415
|
own.answered = status;
|
|
11241
11416
|
if (own.ci) goDark(own, "It stays off for this worker.");
|
|
@@ -11246,6 +11421,7 @@ function refuse(own, status) {
|
|
|
11246
11421
|
changed();
|
|
11247
11422
|
}
|
|
11248
11423
|
function giveUp(own) {
|
|
11424
|
+
if (own === link) letWaitGo(PAUSE_DROPPED.left);
|
|
11249
11425
|
own.sharing = false;
|
|
11250
11426
|
own.lost = liveShareRefusal(own.answered);
|
|
11251
11427
|
own.viewers = 0;
|
|
@@ -11273,6 +11449,118 @@ function resendView(own) {
|
|
|
11273
11449
|
if (own.log && shownInFull(own)) postLog(own, own.log);
|
|
11274
11450
|
if (layerAsked(own, "filmstrip")) queueStrip(own);
|
|
11275
11451
|
}
|
|
11452
|
+
function setHold(own, ms, pause) {
|
|
11453
|
+
own.hold = ms;
|
|
11454
|
+
own.pause = ms !== null && pause;
|
|
11455
|
+
if (own !== link) return;
|
|
11456
|
+
if (!own.pause) dropPause(own, PAUSE_DROPPED.off);
|
|
11457
|
+
const wait = waiting;
|
|
11458
|
+
if (!wait) return;
|
|
11459
|
+
if (ms === null || wait.kind === "pause" && !own.pause) return endWait();
|
|
11460
|
+
const until = wait.began + ms;
|
|
11461
|
+
if (until <= Date.now()) return endWait();
|
|
11462
|
+
clearTimeout(wait.timer);
|
|
11463
|
+
wait.until = until;
|
|
11464
|
+
wait.timer = setTimeout(() => endWait(), until - Date.now());
|
|
11465
|
+
if (own.stop?.reason === wait.kind) {
|
|
11466
|
+
own.stop.until = until;
|
|
11467
|
+
postState(own, { type: "stop", ...own.id, stop: shownStop(own.stop) });
|
|
11468
|
+
}
|
|
11469
|
+
}
|
|
11470
|
+
function control(own, request, command, by = null) {
|
|
11471
|
+
if (own !== link || !own.ci || own.stream !== request || own.hold === null) return;
|
|
11472
|
+
if (command === "let-go") {
|
|
11473
|
+
if (waiting?.kind === "held") endWait();
|
|
11474
|
+
return;
|
|
11475
|
+
}
|
|
11476
|
+
if (!own.pause) return;
|
|
11477
|
+
if (command === "pause") {
|
|
11478
|
+
if (own.pauseAsked) return;
|
|
11479
|
+
const why = waiting ? PAUSE_DROPPED.stopped : !running || !active(own) ? PAUSE_DROPPED.noTest : !controllerWatches(own) ? PAUSE_DROPPED.left : pauseHandlers ? pauseHandlers.pause() : PAUSE_DROPPED.noTest;
|
|
11480
|
+
if (why) return void postState(own, { type: "pause-asked", ...own.id, waiting: false, why });
|
|
11481
|
+
own.pauseAsked = true;
|
|
11482
|
+
postState(own, { type: "pause-asked", ...own.id, waiting: true });
|
|
11483
|
+
} else if (waiting?.kind === "pause") {
|
|
11484
|
+
endWait(command === "end-test" ? "end" : "resume", by);
|
|
11485
|
+
} else if (command === "resume") {
|
|
11486
|
+
dropPause(own, PAUSE_DROPPED.resumed);
|
|
11487
|
+
}
|
|
11488
|
+
}
|
|
11489
|
+
function dropPause(own, why) {
|
|
11490
|
+
if (!own.pauseAsked) return;
|
|
11491
|
+
own.pauseAsked = false;
|
|
11492
|
+
pauseHandlers?.drop();
|
|
11493
|
+
postState(own, { type: "pause-asked", ...own.id, waiting: false, why });
|
|
11494
|
+
}
|
|
11495
|
+
function liveViewTestFunctionEnded() {
|
|
11496
|
+
if (link) dropPause(link, PAUSE_DROPPED.functionEnded);
|
|
11497
|
+
}
|
|
11498
|
+
function controllerWatches(own) {
|
|
11499
|
+
return own.viewers > 0 && !!own.asked?.full && own.asked.controller === true;
|
|
11500
|
+
}
|
|
11501
|
+
function keepHold(own, message) {
|
|
11502
|
+
const left = message.type === "view" ? !message.full || message.controller !== true : message.count === 0;
|
|
11503
|
+
if (own === link && left) letWaitGo(PAUSE_DROPPED.left);
|
|
11504
|
+
}
|
|
11505
|
+
function endWait(how = "resume", by = null) {
|
|
11506
|
+
waiting?.end(how, by);
|
|
11507
|
+
}
|
|
11508
|
+
function letWaitGo(why) {
|
|
11509
|
+
endWait();
|
|
11510
|
+
if (link) dropPause(link, why);
|
|
11511
|
+
}
|
|
11512
|
+
function liveViewMayHold() {
|
|
11513
|
+
const own = link;
|
|
11514
|
+
return !!own && own.ci && !waiting && !!running && active(own) && own.hold !== null && controllerWatches(own);
|
|
11515
|
+
}
|
|
11516
|
+
function startWait(kind, ms) {
|
|
11517
|
+
let resolve7;
|
|
11518
|
+
const ended = new Promise((settle2) => resolve7 = settle2);
|
|
11519
|
+
const began = Date.now();
|
|
11520
|
+
const wait = {
|
|
11521
|
+
kind,
|
|
11522
|
+
began,
|
|
11523
|
+
until: began + ms,
|
|
11524
|
+
timer: setTimeout(() => endWait(), ms),
|
|
11525
|
+
ended,
|
|
11526
|
+
by: null,
|
|
11527
|
+
over: false,
|
|
11528
|
+
end: (how = "resume", by = null) => {
|
|
11529
|
+
if (wait.over) return;
|
|
11530
|
+
wait.over = true;
|
|
11531
|
+
clearTimeout(wait.timer);
|
|
11532
|
+
if (waiting === wait) waiting = null;
|
|
11533
|
+
wait.by = by;
|
|
11534
|
+
resolve7(how);
|
|
11535
|
+
}
|
|
11536
|
+
};
|
|
11537
|
+
waiting = wait;
|
|
11538
|
+
return {
|
|
11539
|
+
get until() {
|
|
11540
|
+
return wait.until;
|
|
11541
|
+
},
|
|
11542
|
+
get by() {
|
|
11543
|
+
return wait.by;
|
|
11544
|
+
},
|
|
11545
|
+
ended,
|
|
11546
|
+
end: () => wait.end()
|
|
11547
|
+
};
|
|
11548
|
+
}
|
|
11549
|
+
function liveViewHold() {
|
|
11550
|
+
const own = link;
|
|
11551
|
+
if (!own || own.hold === null || !liveViewMayHold()) return null;
|
|
11552
|
+
return startWait("held", own.hold);
|
|
11553
|
+
}
|
|
11554
|
+
function liveViewPause() {
|
|
11555
|
+
const own = link;
|
|
11556
|
+
if (!own?.pauseAsked) return null;
|
|
11557
|
+
if (!own.pause || own.hold === null || !liveViewMayHold()) {
|
|
11558
|
+
dropPause(own, controllerWatches(own) ? PAUSE_DROPPED.noTest : PAUSE_DROPPED.left);
|
|
11559
|
+
return null;
|
|
11560
|
+
}
|
|
11561
|
+
own.pauseAsked = false;
|
|
11562
|
+
return startWait("pause", own.hold);
|
|
11563
|
+
}
|
|
11276
11564
|
function setMasks(own, locators) {
|
|
11277
11565
|
if (JSON.stringify(locators) === JSON.stringify(own.masks)) return;
|
|
11278
11566
|
own.masks = locators;
|
|
@@ -11395,7 +11683,11 @@ function startThumbPosts(own) {
|
|
|
11395
11683
|
if (thumbPosts.posting || !thumbPosts.queue.length || !own.asked || !layerAsked(own, "filmstrip")) return;
|
|
11396
11684
|
const next = thumbPosts.queue.shift();
|
|
11397
11685
|
thumbPosts.posting = true;
|
|
11398
|
-
void postBody(
|
|
11686
|
+
void postBody(
|
|
11687
|
+
own,
|
|
11688
|
+
encodeLiveMessage(liveThumbHeader(own.id, shownThumb(next.thumb), next.test), next.data),
|
|
11689
|
+
LIVE_FRAME_TYPE
|
|
11690
|
+
).catch(() => void 0).finally(() => {
|
|
11399
11691
|
thumbPosts.posting = false;
|
|
11400
11692
|
});
|
|
11401
11693
|
}, 1e3 / LANE_THUMBS_PER_SECOND);
|
|
@@ -11463,7 +11755,7 @@ function followCalls(own) {
|
|
|
11463
11755
|
const wanted = !!running && !own.logRefused && shownInFull(own);
|
|
11464
11756
|
if (wanted && !shown2.following) {
|
|
11465
11757
|
const { page } = shown2;
|
|
11466
|
-
const source2 = own
|
|
11758
|
+
const source2 = callSource(own);
|
|
11467
11759
|
shown2.following = followCallLog(
|
|
11468
11760
|
page,
|
|
11469
11761
|
running.began,
|
|
@@ -11478,6 +11770,9 @@ function followCalls(own) {
|
|
|
11478
11770
|
forgetLog(own);
|
|
11479
11771
|
}
|
|
11480
11772
|
}
|
|
11773
|
+
function callSource(own) {
|
|
11774
|
+
return own.ci && !running?.mayPause && !liveViewMayPause() ? "stream" : "listener";
|
|
11775
|
+
}
|
|
11481
11776
|
function forgetLog(own) {
|
|
11482
11777
|
own.log = null;
|
|
11483
11778
|
if (own.logTimer) clearTimeout(own.logTimer);
|
|
@@ -11610,7 +11905,7 @@ var VIEW_FRAMES = {
|
|
|
11610
11905
|
};
|
|
11611
11906
|
var NO_PAGE2 = "This stop has no page to show: its call does not name one among its context's pages. Use the pause bar in the test's window.";
|
|
11612
11907
|
var socket = null;
|
|
11613
|
-
var
|
|
11908
|
+
var control2 = null;
|
|
11614
11909
|
var shown = /* @__PURE__ */ new Set();
|
|
11615
11910
|
var host = null;
|
|
11616
11911
|
var stops = 0;
|
|
@@ -11687,7 +11982,7 @@ async function openRunChannel(worker, handlers, env = process.env) {
|
|
|
11687
11982
|
return false;
|
|
11688
11983
|
}
|
|
11689
11984
|
socket = opening;
|
|
11690
|
-
|
|
11985
|
+
control2 = handlers;
|
|
11691
11986
|
shown = /* @__PURE__ */ new Set();
|
|
11692
11987
|
runName = `piwi-${ref}-w${worker.workerIndex}`;
|
|
11693
11988
|
eventsOn = false;
|
|
@@ -11784,7 +12079,7 @@ function editorSendAddress(env = process.env) {
|
|
|
11784
12079
|
function closeRunChannel() {
|
|
11785
12080
|
socket?.end();
|
|
11786
12081
|
socket = null;
|
|
11787
|
-
|
|
12082
|
+
control2 = null;
|
|
11788
12083
|
filmstrip2?.close();
|
|
11789
12084
|
filmstrip2 = null;
|
|
11790
12085
|
}
|
|
@@ -11830,7 +12125,7 @@ function sendPendingPosition() {
|
|
|
11830
12125
|
pendingPosition = null;
|
|
11831
12126
|
if (!position || !positionsWanted()) return;
|
|
11832
12127
|
positionToldAt = performance.now();
|
|
11833
|
-
tellHub({ type: "position", testId: runningTestId, title: position.title, place: position.place });
|
|
12128
|
+
tellHub({ type: "position", testId: runningTestId, title: shownTitle(position.title), place: position.place });
|
|
11834
12129
|
}
|
|
11835
12130
|
function dropPendingPosition() {
|
|
11836
12131
|
pendingPosition = null;
|
|
@@ -11885,16 +12180,17 @@ function holdStop(stop2, onAnswer) {
|
|
|
11885
12180
|
browser: stop2.browser ?? null
|
|
11886
12181
|
};
|
|
11887
12182
|
held = holding;
|
|
12183
|
+
const known = knownSecrets();
|
|
11888
12184
|
tellHub({
|
|
11889
12185
|
type: "stopped",
|
|
11890
12186
|
stop: id,
|
|
11891
12187
|
reason: stop2.reason,
|
|
11892
|
-
// The text the stopped call types
|
|
11893
|
-
title:
|
|
12188
|
+
// The text the stopped call types, and each value the attempt knows, stay in the worker, as on every surface.
|
|
12189
|
+
title: shownTitle(stop2.title),
|
|
11894
12190
|
place: stop2.place,
|
|
11895
|
-
locator: stop2.locator,
|
|
12191
|
+
locator: stop2.locator === null ? null : hideKnownValues(stop2.locator, known),
|
|
11896
12192
|
bar: stop2.bar,
|
|
11897
|
-
...stop2.error ? { error: stop2.error } : {}
|
|
12193
|
+
...stop2.error ? { error: hideKnownValues(stop2.error, known) } : {}
|
|
11898
12194
|
});
|
|
11899
12195
|
laneStopped(id, stop2.page);
|
|
11900
12196
|
if (!runChannelOpen() && !stop2.bar) holding.answer("resume");
|
|
@@ -12116,7 +12412,7 @@ function startLaneStrip() {
|
|
|
12116
12412
|
const next = strip.queue.shift();
|
|
12117
12413
|
const now = laneAt().test;
|
|
12118
12414
|
if (next && (now === null || next.test === now)) {
|
|
12119
|
-
tellLayer({ layer: "filmstrip", thumb: next.thumb, data: next.data.toString("base64") }, next.test);
|
|
12415
|
+
tellLayer({ layer: "filmstrip", thumb: shownThumb(next.thumb), data: next.data.toString("base64") }, next.test);
|
|
12120
12416
|
}
|
|
12121
12417
|
}, 1e3 / LANE_THUMBS_PER_SECOND);
|
|
12122
12418
|
send2.unref?.();
|
|
@@ -12371,13 +12667,13 @@ function onMessage(message) {
|
|
|
12371
12667
|
void shareLiveView(message.on, message.after ?? null).then(tellLive);
|
|
12372
12668
|
return;
|
|
12373
12669
|
case "breakpoints":
|
|
12374
|
-
|
|
12670
|
+
control2?.breakpoints(message.places);
|
|
12375
12671
|
return;
|
|
12376
12672
|
case "control":
|
|
12377
12673
|
if (message.action === "pause") {
|
|
12378
|
-
if (!held)
|
|
12674
|
+
if (!held) control2?.pause();
|
|
12379
12675
|
} else if (message.action === "give-up") {
|
|
12380
|
-
if (!held)
|
|
12676
|
+
if (!held) control2?.giveUp(message.testId);
|
|
12381
12677
|
else
|
|
12382
12678
|
tellHub({
|
|
12383
12679
|
type: "notice",
|
|
@@ -12387,7 +12683,7 @@ function onMessage(message) {
|
|
|
12387
12683
|
return;
|
|
12388
12684
|
case "run-to":
|
|
12389
12685
|
if (held?.stop !== message.stop) return;
|
|
12390
|
-
|
|
12686
|
+
control2?.runTo(message.place);
|
|
12391
12687
|
held.answer("resume");
|
|
12392
12688
|
return;
|
|
12393
12689
|
case "request": {
|
|
@@ -12611,44 +12907,52 @@ function callPlace(frames, cwd = process.cwd(), windows = process.platform === "
|
|
|
12611
12907
|
}
|
|
12612
12908
|
return null;
|
|
12613
12909
|
}
|
|
12614
|
-
function
|
|
12615
|
-
const
|
|
12616
|
-
const title = zone.title ||
|
|
12617
|
-
return
|
|
12910
|
+
function keptCallTitle(zone) {
|
|
12911
|
+
const id = zoneStepId(zone);
|
|
12912
|
+
const title = (id ? layersTitleOf(id) : null) || zone.title || zone.apiName || "call";
|
|
12913
|
+
return keptTitle(title, MAX_POSITION_TITLE);
|
|
12618
12914
|
}
|
|
12619
12915
|
function errorText(error) {
|
|
12620
12916
|
const message = error instanceof Error ? error.message : String(error);
|
|
12621
|
-
|
|
12917
|
+
const cut2 = cutText(hideSecretsInText(message.split("\n").slice(0, 4).join("\n")), MAX_RUN_EVENT_TEXT);
|
|
12918
|
+
return hideKnownValues(cut2, knownSecrets());
|
|
12919
|
+
}
|
|
12920
|
+
function tellPositionOf(zone, place) {
|
|
12921
|
+
try {
|
|
12922
|
+
tellPosition(keptCallTitle(zone), place);
|
|
12923
|
+
} catch {
|
|
12924
|
+
}
|
|
12622
12925
|
}
|
|
12623
12926
|
function watchCalls(playwright) {
|
|
12624
12927
|
const instrumentation = playwright?._instrumentation;
|
|
12625
12928
|
if (!playwright || heard2.has(playwright)) return true;
|
|
12626
12929
|
if (!instrumentation || typeof instrumentation.addListener !== "function") return false;
|
|
12627
12930
|
heard2.add(playwright);
|
|
12628
|
-
const titles = /* @__PURE__ */ new WeakMap();
|
|
12629
12931
|
instrumentation.addListener({
|
|
12630
|
-
onApiCallBegin: (zone
|
|
12932
|
+
onApiCallBegin: (zone) => {
|
|
12631
12933
|
if (positionsWanted()) {
|
|
12632
12934
|
const place = callPlace(zone.frames);
|
|
12633
|
-
if (place)
|
|
12935
|
+
if (place) queueMicrotask(() => tellPositionOf(zone, place));
|
|
12634
12936
|
}
|
|
12635
12937
|
if (!runEventsWanted()) return;
|
|
12636
12938
|
begun.set(zone, Date.now());
|
|
12637
|
-
titles.set(zone, callTitle(zone, channel));
|
|
12638
12939
|
},
|
|
12639
12940
|
onApiCallEnd: (zone) => {
|
|
12640
12941
|
const start = begun.get(zone);
|
|
12641
12942
|
if (start === void 0) return;
|
|
12642
12943
|
begun.delete(zone);
|
|
12643
12944
|
if (!runEventsWanted()) return;
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12945
|
+
try {
|
|
12946
|
+
tellEvent({
|
|
12947
|
+
kind: "call",
|
|
12948
|
+
title: shownTitle(keptCallTitle(zone)),
|
|
12949
|
+
place: callPlace(zone.frames),
|
|
12950
|
+
ok: zone.error === void 0,
|
|
12951
|
+
error: zone.error === void 0 ? null : errorText(zone.error),
|
|
12952
|
+
ms: Date.now() - start
|
|
12953
|
+
});
|
|
12954
|
+
} catch {
|
|
12955
|
+
}
|
|
12652
12956
|
}
|
|
12653
12957
|
});
|
|
12654
12958
|
return true;
|
|
@@ -12706,13 +13010,13 @@ function tellApiCall(call, url) {
|
|
|
12706
13010
|
} catch {
|
|
12707
13011
|
}
|
|
12708
13012
|
}
|
|
12709
|
-
var
|
|
13013
|
+
var waiting2 = /* @__PURE__ */ new Map();
|
|
12710
13014
|
var requestsFollowed = 0;
|
|
12711
13015
|
var waitTimer = null;
|
|
12712
13016
|
function tellWaiting() {
|
|
12713
13017
|
if (!pageEventsWanted()) return forgetWaitingRequests();
|
|
12714
13018
|
const now = Date.now();
|
|
12715
|
-
for (const request of
|
|
13019
|
+
for (const request of waiting2.values()) {
|
|
12716
13020
|
const ms = now - request.began;
|
|
12717
13021
|
if (ms < PENDING_REQUEST_MS * (request.told + 1)) continue;
|
|
12718
13022
|
request.told = Math.floor(ms / PENDING_REQUEST_MS);
|
|
@@ -12727,7 +13031,7 @@ function tellWaiting() {
|
|
|
12727
13031
|
}
|
|
12728
13032
|
}
|
|
12729
13033
|
function forgetWaitingRequests() {
|
|
12730
|
-
|
|
13034
|
+
waiting2.clear();
|
|
12731
13035
|
if (waitTimer) clearInterval(waitTimer);
|
|
12732
13036
|
waitTimer = null;
|
|
12733
13037
|
}
|
|
@@ -12744,9 +13048,9 @@ function watchPageEvents(page) {
|
|
|
12744
13048
|
}
|
|
12745
13049
|
};
|
|
12746
13050
|
const settle2 = (request) => {
|
|
12747
|
-
const followed2 =
|
|
13051
|
+
const followed2 = waiting2.get(request);
|
|
12748
13052
|
if (!followed2) return;
|
|
12749
|
-
|
|
13053
|
+
waiting2.delete(request);
|
|
12750
13054
|
if (!followed2.told || !pageEventsWanted()) return;
|
|
12751
13055
|
const { id, method, url: shown2, began } = followed2;
|
|
12752
13056
|
tellPageEvent({ kind: "request-pending", id, method, url: shown2, ms: Date.now() - began, done: true });
|
|
@@ -12775,10 +13079,10 @@ function watchPageEvents(page) {
|
|
|
12775
13079
|
})
|
|
12776
13080
|
);
|
|
12777
13081
|
page.on("request", (request) => {
|
|
12778
|
-
if (!pageEventsWanted() ||
|
|
13082
|
+
if (!pageEventsWanted() || waiting2.size >= MAX_FOLLOWED_REQUESTS) return;
|
|
12779
13083
|
try {
|
|
12780
13084
|
const method = request.method();
|
|
12781
|
-
|
|
13085
|
+
waiting2.set(request, {
|
|
12782
13086
|
id: ++requestsFollowed,
|
|
12783
13087
|
method,
|
|
12784
13088
|
url: eventUrl(request.url()),
|
|
@@ -12962,7 +13266,7 @@ async function recordFromHere(options) {
|
|
|
12962
13266
|
page.once("close", onGone);
|
|
12963
13267
|
page.once("crash", onGone);
|
|
12964
13268
|
ended?.addEventListener("abort", onEnded, { once: true });
|
|
12965
|
-
const
|
|
13269
|
+
const startWait2 = setTimeout(() => finish("the editor did not start the recording."), START_WAIT_MS);
|
|
12966
13270
|
const release = () => {
|
|
12967
13271
|
const relay = relays.get(context);
|
|
12968
13272
|
if (relay && relay.recording === relayed) relay.recording = null;
|
|
@@ -12972,7 +13276,7 @@ async function recordFromHere(options) {
|
|
|
12972
13276
|
const finish = (said) => {
|
|
12973
13277
|
if (settled) return;
|
|
12974
13278
|
settled = true;
|
|
12975
|
-
clearTimeout(
|
|
13279
|
+
clearTimeout(startWait2);
|
|
12976
13280
|
release();
|
|
12977
13281
|
for (const [call, answer] of answers) {
|
|
12978
13282
|
answers.delete(call);
|
|
@@ -13018,7 +13322,7 @@ async function recordFromHere(options) {
|
|
|
13018
13322
|
await page.evaluate(fs13.readFileSync(bundle, "utf-8"));
|
|
13019
13323
|
if (settled) return release();
|
|
13020
13324
|
recording = true;
|
|
13021
|
-
clearTimeout(
|
|
13325
|
+
clearTimeout(startWait2);
|
|
13022
13326
|
context.on("page", onPage);
|
|
13023
13327
|
send2({ type: "loaded" });
|
|
13024
13328
|
};
|
|
@@ -15678,6 +15982,8 @@ function createSink() {
|
|
|
15678
15982
|
pickOffered: false,
|
|
15679
15983
|
userPick: null,
|
|
15680
15984
|
pause: null,
|
|
15985
|
+
livePause: false,
|
|
15986
|
+
endedFromPiwi: null,
|
|
15681
15987
|
locatorCalls: /* @__PURE__ */ new Map(),
|
|
15682
15988
|
stops: [],
|
|
15683
15989
|
shownStops: /* @__PURE__ */ new Map(),
|
|
@@ -15832,7 +16138,11 @@ async function settleBeforeClose(closing) {
|
|
|
15832
16138
|
async function settleContextClose(context) {
|
|
15833
16139
|
CLOSING_CONTEXTS.add(context);
|
|
15834
16140
|
await settleBeforeClose({ context });
|
|
15835
|
-
if (contextDebugger(context)?.pausedDetails())
|
|
16141
|
+
if (!contextDebugger(context)?.pausedDetails()) return;
|
|
16142
|
+
if (ENDED_CONTEXTS.has(context)) {
|
|
16143
|
+
await Promise.all(openPages(context).map((page) => internalCall(page, () => page.close()).catch(() => void 0)));
|
|
16144
|
+
}
|
|
16145
|
+
await steerDebugger(context, "resume");
|
|
15836
16146
|
}
|
|
15837
16147
|
function isPageClosed(page) {
|
|
15838
16148
|
try {
|
|
@@ -16317,6 +16627,7 @@ function locatorSource(target, method, args) {
|
|
|
16317
16627
|
return renderFailing({ method, args });
|
|
16318
16628
|
}
|
|
16319
16629
|
var PAGE_PAUSES = /* @__PURE__ */ new WeakMap();
|
|
16630
|
+
var ENDED_CONTEXTS = /* @__PURE__ */ new WeakSet();
|
|
16320
16631
|
var CLOSING_CONTEXTS = /* @__PURE__ */ new WeakSet();
|
|
16321
16632
|
var CLOSING_PAGES = /* @__PURE__ */ new WeakMap();
|
|
16322
16633
|
var PLAYWRIGHT_PAUSES = /* @__PURE__ */ new WeakMap();
|
|
@@ -16396,7 +16707,7 @@ function onDebuggerStop(context) {
|
|
|
16396
16707
|
} catch {
|
|
16397
16708
|
if (state) how = goOn(state);
|
|
16398
16709
|
} finally {
|
|
16399
|
-
await steerDebugger(context, how);
|
|
16710
|
+
if (sink?.endedFromPiwi !== context) await steerDebugger(context, how);
|
|
16400
16711
|
}
|
|
16401
16712
|
})();
|
|
16402
16713
|
}
|
|
@@ -16416,14 +16727,17 @@ function stopBarPage(sink, context, of) {
|
|
|
16416
16727
|
return open4[open4.length - 1] ?? null;
|
|
16417
16728
|
}
|
|
16418
16729
|
async function showStop(sink, context, calledAs, location, reason, call, of, failure = null) {
|
|
16419
|
-
const title =
|
|
16730
|
+
const title = keptTitle(calledAs);
|
|
16420
16731
|
const testInfo = sink.testInfo;
|
|
16421
16732
|
const page = stopBarPage(sink, context, of);
|
|
16422
16733
|
const guessed = !("page" in of);
|
|
16423
16734
|
if (!testInfo) return void 0;
|
|
16424
|
-
const
|
|
16735
|
+
const livePause = !failure && reason === "pause" && sink.livePause;
|
|
16736
|
+
const wait = failure?.hold ?? (livePause ? liveViewPause() : null);
|
|
16737
|
+
if (livePause && !wait) return "resume";
|
|
16738
|
+
const bar = !wait && !!page && pauseGateFromTestInfo(testInfo, sink.headless).headless === false;
|
|
16425
16739
|
const place = runChannelOpen() ? callSitePlace(location) : null;
|
|
16426
|
-
if (!bar && !place) return void 0;
|
|
16740
|
+
if (!bar && !place && !wait) return void 0;
|
|
16427
16741
|
const failing = failure?.failed ?? null;
|
|
16428
16742
|
const pickTaken = async (picked) => {
|
|
16429
16743
|
if (call) {
|
|
@@ -16457,9 +16771,10 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16457
16771
|
sink.stops.push(record);
|
|
16458
16772
|
const stoppedAt = callSitePlace(location);
|
|
16459
16773
|
const goneOn = liveViewStopped({
|
|
16460
|
-
reason,
|
|
16774
|
+
reason: failure?.hold ? "held" : reason,
|
|
16461
16775
|
call: { title, file: stoppedAt?.file ?? null, line: stoppedAt?.line ?? null },
|
|
16462
|
-
test: testInfo.title
|
|
16776
|
+
test: testInfo.title,
|
|
16777
|
+
...wait ? { until: wait.until } : {}
|
|
16463
16778
|
});
|
|
16464
16779
|
const noted = { testId: testInfo.testId, retry: testInfo.retry };
|
|
16465
16780
|
noteStop(process.env[PIWI_STOP_NOTES_ENV], {
|
|
@@ -16467,7 +16782,7 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16467
16782
|
...noted,
|
|
16468
16783
|
stop: {
|
|
16469
16784
|
reason,
|
|
16470
|
-
title,
|
|
16785
|
+
title: shownTitle(title),
|
|
16471
16786
|
file: stoppedAt ? stopFile(stoppedAt.file, configDirFromConfig(testInfo.config)) : null,
|
|
16472
16787
|
line: stoppedAt?.line ?? null,
|
|
16473
16788
|
bar,
|
|
@@ -16479,6 +16794,10 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16479
16794
|
const over = new AbortController();
|
|
16480
16795
|
end.signal.addEventListener("abort", () => over.abort(), { once: true });
|
|
16481
16796
|
let fromEditor;
|
|
16797
|
+
void wait?.ended.then((how) => {
|
|
16798
|
+
if (how === "end") fromEditor = "end";
|
|
16799
|
+
over.abort();
|
|
16800
|
+
});
|
|
16482
16801
|
const pickAt = page && !guessed ? async (x, y) => {
|
|
16483
16802
|
try {
|
|
16484
16803
|
const found = await internalCall(page, () => pickAtPoint(page, probe, x, y));
|
|
@@ -16533,7 +16852,9 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16533
16852
|
const onIntent = page && held2 ? (intent, ended) => intent === "assert" ? checkAt(page, testInfo, location, handoffReason, held2.stop, ended) : regionAt(page, location, held2.stop, ended) : void 0;
|
|
16534
16853
|
const shown2 = withTestTimeoutHeld(testInfo, async () => {
|
|
16535
16854
|
if (!bar || !page) {
|
|
16536
|
-
console.log(
|
|
16855
|
+
console.log(
|
|
16856
|
+
wait ? waitLine(failure ? "failure" : "pause", callSiteLine(location), wait.until) : stopLine(failure ? "failure" : reason, callSiteLine(location), shownTitle(title), runHost())
|
|
16857
|
+
);
|
|
16537
16858
|
if (page && intents && held2) {
|
|
16538
16859
|
const stop3 = held2.stop;
|
|
16539
16860
|
await internalCall(
|
|
@@ -16552,7 +16873,7 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16552
16873
|
page,
|
|
16553
16874
|
{
|
|
16554
16875
|
location,
|
|
16555
|
-
call: title,
|
|
16876
|
+
call: shownTitle(title),
|
|
16556
16877
|
attempt: testInfo.retry > 0 ? testInfo.retry + 1 : null,
|
|
16557
16878
|
target: stoppedOn ? {
|
|
16558
16879
|
highlight: () => highlightAtStop(
|
|
@@ -16573,6 +16894,7 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16573
16894
|
)
|
|
16574
16895
|
);
|
|
16575
16896
|
}).finally(async () => {
|
|
16897
|
+
wait?.end();
|
|
16576
16898
|
if (!end.signal.aborted) record.duration = Date.now() - record.startedAt;
|
|
16577
16899
|
else if (end.signal.reason === "ended") releaseCall(sink, call?.settled ?? Promise.resolve());
|
|
16578
16900
|
sink.shownStops.delete(end);
|
|
@@ -16590,12 +16912,18 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
|
|
|
16590
16912
|
const answer = await shown2;
|
|
16591
16913
|
if (!end.signal.aborted) {
|
|
16592
16914
|
const chosen = fromEditor ?? answer;
|
|
16593
|
-
|
|
16915
|
+
if (chosen === "end" && livePause && wait) return endFromPiwi(sink, context, location, wait.by);
|
|
16916
|
+
return chosen === "end" ? endTest(sink, call, shownTitle(title), location, reason) : chosen;
|
|
16594
16917
|
}
|
|
16595
16918
|
if (end.signal.reason === "ended") return "finish";
|
|
16596
16919
|
await settledWithin(stop2.after ? [stop2.after] : [], END_STOP_MS);
|
|
16597
16920
|
return "resume";
|
|
16598
16921
|
}
|
|
16922
|
+
function waitLine(kind, place, until) {
|
|
16923
|
+
const time = new Date(until).toISOString().slice(11, 19);
|
|
16924
|
+
const what = kind === "failure" ? `The test failed at ${place}: held` : `The test is paused at ${place}`;
|
|
16925
|
+
return `[piwi] ${what} for the people watching it on the run page, until ${time} UTC at the latest.`;
|
|
16926
|
+
}
|
|
16599
16927
|
function endTest(sink, call, title, location, reason) {
|
|
16600
16928
|
const line = callSiteLine(location);
|
|
16601
16929
|
if (reason === "failure" || sink.functionEnded || !sink.testInfo) {
|
|
@@ -16619,6 +16947,37 @@ function endTest(sink, call, title, location, reason) {
|
|
|
16619
16947
|
tellHub({ type: "notice", message: said });
|
|
16620
16948
|
return "end";
|
|
16621
16949
|
}
|
|
16950
|
+
function endedFromPiwiError(by) {
|
|
16951
|
+
return new Error(by ? `Ended from Piwi by ${by}` : "Ended from Piwi");
|
|
16952
|
+
}
|
|
16953
|
+
function endFromPiwi(sink, context, location, by) {
|
|
16954
|
+
const testInfo = sink.testInfo;
|
|
16955
|
+
const error = endedFromPiwiError(by);
|
|
16956
|
+
console.log(`[piwi] ${error.message} at ${callSiteLine(location)}: the test fails here.`);
|
|
16957
|
+
sink.ended = true;
|
|
16958
|
+
sink.skip = error;
|
|
16959
|
+
sink.end.abort(error);
|
|
16960
|
+
if (failNow(testInfo, error)) {
|
|
16961
|
+
sink.endedFromPiwi = context;
|
|
16962
|
+
ENDED_CONTEXTS.add(context);
|
|
16963
|
+
return "end";
|
|
16964
|
+
}
|
|
16965
|
+
const callbacks = testInfo._onDidFinishTestFunctionCallbacks;
|
|
16966
|
+
if (callbacks instanceof Set) {
|
|
16967
|
+
callbacks.add(() => {
|
|
16968
|
+
if (testInfo.status === "passed") throw error;
|
|
16969
|
+
});
|
|
16970
|
+
}
|
|
16971
|
+
return "end";
|
|
16972
|
+
}
|
|
16973
|
+
function failNow(testInfo, error) {
|
|
16974
|
+
const runner = testInfo;
|
|
16975
|
+
const reject = runner._timeoutManager?._running?.timeoutPromise?.reject;
|
|
16976
|
+
if (typeof runner._failWithError !== "function" || typeof reject !== "function") return false;
|
|
16977
|
+
runner._failWithError(error);
|
|
16978
|
+
reject.call(runner._timeoutManager._running.timeoutPromise, error);
|
|
16979
|
+
return true;
|
|
16980
|
+
}
|
|
16622
16981
|
function endsNow(sink) {
|
|
16623
16982
|
return sink.ended && !sink.functionEnded;
|
|
16624
16983
|
}
|
|
@@ -16724,7 +17083,9 @@ function regionSecrets(region) {
|
|
|
16724
17083
|
}
|
|
16725
17084
|
async function holdFailure(sink, fallback) {
|
|
16726
17085
|
const testInfo = sink.testInfo;
|
|
16727
|
-
if (sink.failureHeld || !
|
|
17086
|
+
if (sink.failureHeld || !testInfo || sink.ended && sink.livePause) return;
|
|
17087
|
+
const local = !!sink.pause && editorShows("failure");
|
|
17088
|
+
if (!local && !liveViewMayHold()) return;
|
|
16728
17089
|
const { status, expectedStatus } = testInfo;
|
|
16729
17090
|
if (status !== "failed" && status !== "timedOut" || status === expectedStatus) return;
|
|
16730
17091
|
const page = [sink.lastActivePage, fallback].find((open4) => !!open4 && !isPageClosed(open4));
|
|
@@ -16747,10 +17108,12 @@ async function holdFailure(sink, fallback) {
|
|
|
16747
17108
|
await internalCall(page, () => readPageBeforeClose(sink, page)).catch(() => void 0);
|
|
16748
17109
|
sink.frozenAt = Date.now();
|
|
16749
17110
|
await stopSinkCodeReach(sink, { context });
|
|
16750
|
-
const title = hideSecretsInText(`Failed: ${said.trim()
|
|
17111
|
+
const title = cutText(hideSecretsInText(`Failed: ${cutText(said.trim(), 300)}`), 1e3);
|
|
16751
17112
|
const errorText2 = failureError(error?.message ?? error?.value);
|
|
16752
|
-
const named = errorText2 === null ? null : hideSecretsInText(errorText2)
|
|
16753
|
-
|
|
17113
|
+
const named = errorText2 === null ? null : cutText(hideSecretsInText(errorText2), MAX_STOP_ERROR);
|
|
17114
|
+
const hold = local ? null : liveViewHold();
|
|
17115
|
+
if (!local && !hold) return;
|
|
17116
|
+
await showStop(sink, context, title, location, "failure", void 0, { page }, { failed: failed2, error: named, hold });
|
|
16754
17117
|
}
|
|
16755
17118
|
var FAILURE_ERROR_LINES = 4;
|
|
16756
17119
|
function failureError(message) {
|
|
@@ -16760,7 +17123,7 @@ function failureError(message) {
|
|
|
16760
17123
|
lines.push(line.trimEnd());
|
|
16761
17124
|
if (lines.length === FAILURE_ERROR_LINES) break;
|
|
16762
17125
|
}
|
|
16763
|
-
const text = lines.join("\n")
|
|
17126
|
+
const text = cutText(lines.join("\n"), MAX_STOP_ERROR);
|
|
16764
17127
|
return text.trim() ? text : null;
|
|
16765
17128
|
}
|
|
16766
17129
|
function errorPlace(error, windows = process.platform === "win32") {
|
|
@@ -16950,6 +17313,7 @@ function endStopsWithTestFunction(testInfo, sink) {
|
|
|
16950
17313
|
callbacks.clear();
|
|
16951
17314
|
callbacks.add(() => {
|
|
16952
17315
|
sink.functionEnded = true;
|
|
17316
|
+
liveViewTestFunctionEnded();
|
|
16953
17317
|
return endShownStops(sink, "ended");
|
|
16954
17318
|
});
|
|
16955
17319
|
for (const callback of theirs) callbacks.add(callback);
|
|
@@ -17528,7 +17892,7 @@ async function flushSink(sink, testInfo) {
|
|
|
17528
17892
|
if (sink.stops.length > 0) {
|
|
17529
17893
|
await testInfo.attach(ATTACHMENT_NAMES.pauses, {
|
|
17530
17894
|
contentType: "application/json",
|
|
17531
|
-
body: Buffer.from(JSON.stringify(sink.stops))
|
|
17895
|
+
body: Buffer.from(JSON.stringify(sink.stops.map((stop2) => ({ ...stop2, title: shownTitle(stop2.title) }))))
|
|
17532
17896
|
});
|
|
17533
17897
|
}
|
|
17534
17898
|
if (sink.capturedLocators.length > 0) {
|
|
@@ -17738,7 +18102,7 @@ var runControl = {
|
|
|
17738
18102
|
},
|
|
17739
18103
|
giveUp(testId) {
|
|
17740
18104
|
const sink = currentSink;
|
|
17741
|
-
const
|
|
18105
|
+
const waiting3 = sink?.testInfo ? callInProgress(sink.testInfo) : null;
|
|
17742
18106
|
if (!sink?.testInfo || sink.testInfo.testId !== testId || sink.functionEnded || sink.ended) {
|
|
17743
18107
|
if (sink?.pause) sink.pause.pause = false;
|
|
17744
18108
|
pauseNextTest = false;
|
|
@@ -17748,13 +18112,13 @@ var runControl = {
|
|
|
17748
18112
|
});
|
|
17749
18113
|
return;
|
|
17750
18114
|
}
|
|
17751
|
-
const line =
|
|
18115
|
+
const line = waiting3 ? `${runFile(waiting3.place.file)}:${waiting3.place.line}` : null;
|
|
17752
18116
|
const endable = !!line && [...sink.locatorCalls.values()].some((c) => c.endable && callSiteLine(c.location) === line);
|
|
17753
18117
|
sink.ended = true;
|
|
17754
18118
|
if (sink.pause) sink.pause.pause = false;
|
|
17755
18119
|
skipAtFunctionEnd(sink);
|
|
17756
18120
|
sink.end.abort(new Error(ENDED_AT_STOP_REASON));
|
|
17757
|
-
const title =
|
|
18121
|
+
const title = waiting3?.title ? shownTitle(waiting3.title) : "its call";
|
|
17758
18122
|
const said = endable ? `Ended the test while it waited in ${title}: the call is given up, and the test is skipped.` : `Ended the test while it waited in ${title}: the test is skipped as the call returns.`;
|
|
17759
18123
|
console.log(`[piwi] ${said}`);
|
|
17760
18124
|
tellHub({ type: "notice", message: said });
|
|
@@ -17773,6 +18137,24 @@ var runControl = {
|
|
|
17773
18137
|
void armStops(OPEN_CONTEXTS);
|
|
17774
18138
|
}
|
|
17775
18139
|
};
|
|
18140
|
+
var FOLLOWED_BEFORE_PAUSE = "This test's page was followed before the project let its controllers pause, so a pause would stop past its call's wait: the worker's next test can pause.";
|
|
18141
|
+
onLiveViewPause({
|
|
18142
|
+
pause() {
|
|
18143
|
+
const sink = currentSink;
|
|
18144
|
+
if (!sink?.testInfo || sink.ended || sink.ending) return PAUSE_DROPPED.noTest;
|
|
18145
|
+
if (sink.functionEnded) return PAUSE_DROPPED.functionEnded;
|
|
18146
|
+
if ([...OPEN_CONTEXTS].some((context) => followsCallStream(context))) return FOLLOWED_BEFORE_PAUSE;
|
|
18147
|
+
sink.pause ??= pauseState(NO_BREAKPOINTS);
|
|
18148
|
+
sink.livePause = true;
|
|
18149
|
+
sink.pause.pause = true;
|
|
18150
|
+
void armStops(OPEN_CONTEXTS);
|
|
18151
|
+
return null;
|
|
18152
|
+
},
|
|
18153
|
+
drop() {
|
|
18154
|
+
const sink = currentSink;
|
|
18155
|
+
if (sink?.livePause && sink.pause) sink.pause.pause = false;
|
|
18156
|
+
}
|
|
18157
|
+
});
|
|
17776
18158
|
var WAITING_WATCH_MS = 250;
|
|
17777
18159
|
function watchWaiting(sink) {
|
|
17778
18160
|
if (sink.waitingWatch) return;
|
|
@@ -17791,7 +18173,7 @@ ${file}:${call.place.line}` : "";
|
|
|
17791
18173
|
const locatorCall = [...sink.locatorCalls.values()].find((c) => callSiteLine(c.location) === line);
|
|
17792
18174
|
tellHub({
|
|
17793
18175
|
type: "waiting",
|
|
17794
|
-
title:
|
|
18176
|
+
title: shownTitle(call.title, { max: MAX_WAITING_TITLE }),
|
|
17795
18177
|
place: { file, line: call.place.line, ...call.place.column > 0 ? { column: call.place.column } : {} },
|
|
17796
18178
|
ms: locatorCall ? Math.max(0, Date.now() - locatorCall.startedAt) : null,
|
|
17797
18179
|
endable: !!locatorCall?.endable
|
|
@@ -17917,7 +18299,7 @@ var piwiFixtures = {
|
|
|
17917
18299
|
else if (pauseSet.size) logPauseSkipOnce(cannotPause);
|
|
17918
18300
|
}
|
|
17919
18301
|
pauseNextTest = false;
|
|
17920
|
-
if (sink.pause || canRecordFromHere()) endStopsWithTestFunction(testInfo, sink);
|
|
18302
|
+
if (sink.pause || canRecordFromHere() || liveViewOpen()) endStopsWithTestFunction(testInfo, sink);
|
|
17921
18303
|
if (channel) tellHub(testBegin(testInfo, cannotPause));
|
|
17922
18304
|
if (channel && sink.pause) startKeeping();
|
|
17923
18305
|
if (isFlakeMode()) {
|
|
@@ -17964,10 +18346,11 @@ var piwiFixtures = {
|
|
|
17964
18346
|
sink.ending = true;
|
|
17965
18347
|
await endShownStops(sink, "ended");
|
|
17966
18348
|
await awaitReleasedCalls(sink);
|
|
18349
|
+
if (liveViewMayHold() && sink.lastActivePage && !isPageClosed(sink.lastActivePage)) await holdFailure(sink);
|
|
17967
18350
|
await liveViewTestEnded(liveOutcomeStatus(testInfo));
|
|
17968
18351
|
showRunChannel();
|
|
17969
18352
|
currentSink = null;
|
|
17970
|
-
if (sink.pause?.pause) pauseNextTest = true;
|
|
18353
|
+
if (sink.pause?.pause && !sink.livePause) pauseNextTest = true;
|
|
17971
18354
|
if (sink.probeItem) {
|
|
17972
18355
|
const applied = sink.probeInterception?.applied() ?? false;
|
|
17973
18356
|
const level = sink.probeItem.level ?? "client";
|
|
@@ -18044,6 +18427,7 @@ function extendPiwiFixtures(test2) {
|
|
|
18044
18427
|
codeReachRoots,
|
|
18045
18428
|
computeCoreVitals,
|
|
18046
18429
|
configuredCodeReachRoots,
|
|
18430
|
+
endedFromPiwiError,
|
|
18047
18431
|
errorPlace,
|
|
18048
18432
|
extendPiwiFixtures,
|
|
18049
18433
|
failureError,
|