@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/index.js CHANGED
@@ -1790,8 +1790,8 @@ function escapedInQuotes(value) {
1790
1790
  let out = "";
1791
1791
  for (const c of value) {
1792
1792
  const code = c.charCodeAt(0);
1793
- const control2 = code < 32 || code >= 127 && code <= 159;
1794
- out += ARIA_ESCAPES[c] ?? (control2 ? `\\x${code.toString(16).padStart(2, "0")}` : c);
1793
+ const control3 = code < 32 || code >= 127 && code <= 159;
1794
+ out += ARIA_ESCAPES[c] ?? (control3 ? `\\x${code.toString(16).padStart(2, "0")}` : c);
1795
1795
  }
1796
1796
  return out;
1797
1797
  }
@@ -1807,13 +1807,60 @@ function withoutFieldSecrets(snapshot, secrets) {
1807
1807
  }).join("\n");
1808
1808
  return hideKnownValues(out, values);
1809
1809
  }
1810
+ var CUT_MARK = "\u2026";
1811
+ var MIN_CUT_START = 4;
1812
+ function cutText(text2, max) {
1813
+ return text2.length <= max ? text2 : `${text2.slice(0, Math.max(0, max - 1))}${CUT_MARK}`;
1814
+ }
1810
1815
  function hideKnownValues(text2, values) {
1811
- let out = text2;
1812
- for (const value of values) {
1813
- if (value.length < 8) continue;
1814
- for (const written of /* @__PURE__ */ new Set([value, escapedInQuotes(value)])) out = out.split(written).join(HIDDEN_VALUE);
1816
+ return knownValuesHider(values)(text2);
1817
+ }
1818
+ function knownValuesHider(values) {
1819
+ const known = values.filter((v) => v.trim());
1820
+ const wholes = new Set(known.map((v) => v.trim()));
1821
+ const forms = [...new Set(known.filter((v) => v.length >= 8).flatMap((v) => [v, escapedInQuotes(v)]))];
1822
+ return (text2) => hideForms(text2, wholes, forms);
1823
+ }
1824
+ function hideForms(text2, wholes, forms) {
1825
+ const whole = text2.trim();
1826
+ if (whole && wholes.has(whole)) return HIDDEN_VALUE;
1827
+ if (!forms.length) return text2;
1828
+ const places = [];
1829
+ for (const form of forms) {
1830
+ for (let at = text2.indexOf(form); at !== -1; at = text2.indexOf(form, at + 1)) places.push([at, at + form.length]);
1831
+ }
1832
+ for (let mark = text2.indexOf(CUT_MARK); mark !== -1; mark = text2.indexOf(CUT_MARK, mark + 1)) {
1833
+ const start = longestStartBefore(text2, mark, forms);
1834
+ if (start) places.push([Math.max(0, mark - Math.max(start, HIDDEN_VALUE.length)), mark]);
1835
+ }
1836
+ if (!places.length) return text2;
1837
+ places.sort((a, b) => a[0] - b[0]);
1838
+ let out = "";
1839
+ let kept = 0;
1840
+ let open4 = places[0];
1841
+ for (const place of places.slice(1)) {
1842
+ if (place[0] < open4[1]) {
1843
+ open4 = [open4[0], Math.max(open4[1], place[1])];
1844
+ continue;
1845
+ }
1846
+ out += `${text2.slice(kept, open4[0])}${HIDDEN_VALUE}`;
1847
+ kept = open4[1];
1848
+ open4 = place;
1815
1849
  }
1816
- return out;
1850
+ return `${out}${text2.slice(kept, open4[0])}${HIDDEN_VALUE}${text2.slice(open4[1])}`;
1851
+ }
1852
+ function longestStartBefore(text2, mark, forms) {
1853
+ const last = text2.charCodeAt(mark - 1);
1854
+ let longest = 0;
1855
+ for (const form of forms) {
1856
+ for (let length = Math.min(form.length - 1, mark); length >= Math.max(longest + 1, MIN_CUT_START); length--) {
1857
+ if (form.charCodeAt(length - 1) === last && text2.startsWith(form.slice(0, length), mark - length)) {
1858
+ longest = length;
1859
+ break;
1860
+ }
1861
+ }
1862
+ }
1863
+ return longest;
1817
1864
  }
1818
1865
  var FIELD_ROLES = /* @__PURE__ */ new Set(["textbox", "searchbox", "combobox", "spinbutton"]);
1819
1866
  var CARD_WORDS = /* @__PURE__ */ new Set(["card", "cc", "credit", "debit", "kreditkarte", "carte", "tarjeta"]);
@@ -2369,20 +2416,12 @@ function hideSrcset(value) {
2369
2416
  );
2370
2417
  }
2371
2418
  function stringHider(secrets) {
2372
- const values = [...new Set(secrets.filter((value) => value.trim()))];
2373
- const exact = new Set(values.map((value) => value.trim()));
2374
- const long = values.filter((value) => value.length >= 8);
2375
- const own = (value) => {
2376
- const trimmed = value.trim();
2377
- if (!trimmed) return null;
2378
- if (exact.has(trimmed) || looksLikeCardNumber(trimmed)) return HIDDEN_VALUE;
2379
- let out = value;
2380
- for (const secret of long) if (out.includes(secret)) out = out.split(secret).join(HIDDEN_VALUE);
2381
- return out;
2382
- };
2419
+ const hideKnown = knownValuesHider(secrets);
2383
2420
  const by = (hide) => (value) => {
2384
- const out = own(value);
2385
- return out === null ? value : out === HIDDEN_VALUE ? out : hide(out);
2421
+ if (!value.trim()) return value;
2422
+ if (looksLikeCardNumber(value.trim())) return HIDDEN_VALUE;
2423
+ const out = hideKnown(value);
2424
+ return out === HIDDEN_VALUE ? out : hide(out);
2386
2425
  };
2387
2426
  return {
2388
2427
  text: by((value) => besideKeptData(value, (text2) => hideSecretsInText(hideCssUrls(text2)))),
@@ -2783,6 +2822,10 @@ function liveShareRefusal(status) {
2783
2822
  return "Sharing stopped: the instance did not answer. Share the run again to try once more.";
2784
2823
  }
2785
2824
  }
2825
+ var LIVE_VIEW_FEATURES_PARAM = "features";
2826
+ var LIVE_HOLD_FEATURE = "hold";
2827
+ var LIVE_PAUSE_FEATURE = "pause";
2828
+ var MAX_LIVE_HOLD_MINUTES = 15;
2786
2829
  var MAX_LIVE_MASKS = 20;
2787
2830
  var MAX_LIVE_MASK_LENGTH = 200;
2788
2831
  var FRAME_CALLS = /* @__PURE__ */ new Set(["frameLocator", "contentFrame", "owner"]);
@@ -2873,10 +2916,22 @@ function parseInstanceToWorker(data) {
2873
2916
  const full = typeof value.full === "boolean" ? value.full : true;
2874
2917
  const layers = (readLaneLayers(value.layers) ?? []).filter((layer) => layer !== "calls");
2875
2918
  const inspect = value.inspect === true;
2876
- return { type: "view", ...size, fps: Math.min(LIVE_FRAME_FPS, value.fps), full, layers, inspect };
2919
+ const view3 = { type: "view", ...size, fps: Math.min(LIVE_FRAME_FPS, value.fps), full, layers, inspect };
2920
+ return value.controller === true && full ? { ...view3, controller: true } : view3;
2877
2921
  }
2878
2922
  if (value.type === "resend") return { type: "resend" };
2879
2923
  if (value.type === "text") return { type: "text" };
2924
+ if (value.type === "let-go") return { type: "let-go" };
2925
+ if (value.type === "pause") return { type: "pause" };
2926
+ if (value.type === "resume") return { type: "resume" };
2927
+ if (value.type === "end-test") {
2928
+ const by = typeof value.by === "string" ? plainLiveText(value.by, MAX_ASK_BY) : "";
2929
+ return by ? { type: "end-test", by } : { type: "end-test" };
2930
+ }
2931
+ if (value.type === "hold") {
2932
+ const ms2 = isInt(value.ms, 1, MAX_LIVE_HOLD_MINUTES * 6e4) ? value.ms : null;
2933
+ return ms2 !== null && value.pause === true ? { type: "hold", ms: ms2, pause: true } : { type: "hold", ms: ms2 };
2934
+ }
2880
2935
  if (value.type !== "viewers" || !isInt(value.count, 0, 1e6)) return null;
2881
2936
  return { type: "viewers", count: value.count };
2882
2937
  }
@@ -2926,10 +2981,13 @@ function parseLiveAsk(value) {
2926
2981
  if (!isObject5(value) || typeof value.id !== "string" || !ASK_ID.test(value.id) || typeof value.by !== "string") {
2927
2982
  return null;
2928
2983
  }
2929
- const plain = value.by.replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, " ").replace(/[[\]()<>`]/g, " ").replace(/\s+/g, " ").trim();
2930
- const by = Array.from(plain).slice(0, MAX_ASK_BY).join("").trim();
2984
+ const by = plainLiveText(value.by, MAX_ASK_BY);
2931
2985
  return by ? { id: value.id, by } : null;
2932
2986
  }
2987
+ function plainLiveText(value, max) {
2988
+ const plain = value.replace(/[\p{Cc}\p{Cf}\u2028\u2029]/gu, " ").replace(/[[\]()<>`]/g, " ").replace(/\s+/g, " ").trim();
2989
+ return Array.from(plain).slice(0, max).join("").trim();
2990
+ }
2933
2991
  function parseLiveAskAnswer(value) {
2934
2992
  if (!isObject5(value) || typeof value.id !== "string" || !ASK_ID.test(value.id)) return null;
2935
2993
  return value.answer === "not-now" ? { id: value.id, answer: "not-now" } : null;
@@ -3266,11 +3324,11 @@ var FrameAcks = class {
3266
3324
  this.release();
3267
3325
  }
3268
3326
  release() {
3269
- const waiting2 = this.waiting;
3327
+ const waiting3 = this.waiting;
3270
3328
  this.waiting = null;
3271
- if (!waiting2) return;
3272
- clearTimeout(waiting2.timer);
3273
- waiting2.resolve();
3329
+ if (!waiting3) return;
3330
+ clearTimeout(waiting3.timer);
3331
+ waiting3.resolve();
3274
3332
  }
3275
3333
  };
3276
3334
 
@@ -15303,8 +15361,8 @@ function cpuLine(profile) {
15303
15361
  if (total > 0) {
15304
15362
  const top = roles.filter(([, usage]) => (usage?.cpuMs ?? 0) >= total * 0.02).sort((a, b) => (b[1]?.cpuMs ?? 0) - (a[1]?.cpuMs ?? 0)).slice(0, 5).map(([role, usage]) => `${ROLE_LABEL[role]} ${formatHeld(usage.cpuMs)}`);
15305
15363
  parts.push(`${formatHeld(total)} of CPU: ${top.join(" \xB7 ")}`);
15306
- const waiting2 = roles.filter(([, usage]) => (usage?.runWaitMs ?? 0) >= 1e3).sort((a, b) => (b[1]?.runWaitMs ?? 0) - (a[1]?.runWaitMs ?? 0))[0];
15307
- if (waiting2) parts.push(`${ROLE_LABEL[waiting2[0]]} waited ${formatHeld(waiting2[1].runWaitMs)} for a CPU`);
15364
+ const waiting3 = roles.filter(([, usage]) => (usage?.runWaitMs ?? 0) >= 1e3).sort((a, b) => (b[1]?.runWaitMs ?? 0) - (a[1]?.runWaitMs ?? 0))[0];
15365
+ if (waiting3) parts.push(`${ROLE_LABEL[waiting3[0]]} waited ${formatHeld(waiting3[1].runWaitMs)} for a CPU`);
15308
15366
  }
15309
15367
  if (profile.cpu.throttledMs)
15310
15368
  parts.push(`the container's CPU quota held it back ${formatHeld(profile.cpu.throttledMs)}`);
@@ -17795,11 +17853,11 @@ var CoverageCollection = class {
17795
17853
  */
17796
17854
  async settle(boundMs = SETTLE_WAIT_MS) {
17797
17855
  this.collector?.flush();
17798
- const waiting2 = [...this.browserPending, ...[...this.pending].map((entry) => entry.done)];
17799
- if (waiting2.length > 0) {
17856
+ const waiting3 = [...this.browserPending, ...[...this.pending].map((entry) => entry.done)];
17857
+ if (waiting3.length > 0) {
17800
17858
  let timer;
17801
17859
  await Promise.race([
17802
- Promise.all(waiting2),
17860
+ Promise.all(waiting3),
17803
17861
  new Promise((resolve15) => {
17804
17862
  timer = setTimeout(resolve15, boundMs);
17805
17863
  })
@@ -21732,7 +21790,8 @@ function maskSecretFields(page, options) {
21732
21790
  const before = [...reads].reverse().find((r) => r.ended <= frame.at && r.ended >= frame.at - FRESH_MS) ?? null;
21733
21791
  const after = await read();
21734
21792
  if (typeof after === "string" || !after) return after;
21735
- const size = jpegSize(frame.data) ?? frame;
21793
+ const own = jpegSize(frame.data) ?? frame;
21794
+ const size = frame.fit ? fitViewSize(own, frame.fit.width, frame.fit.height) : own;
21736
21795
  if (before && sameBoxes(before.boxes, after.boxes) && showsViewportOf(frame, before) && showsViewportOf(frame, after)) {
21737
21796
  return shown2(frame, after.boxes, await also?.(frame) ?? [], size);
21738
21797
  }
@@ -21768,6 +21827,8 @@ function maskSecretFields(page, options) {
21768
21827
  var SCREENCAST_LAG_MS = 100;
21769
21828
  var BAR_READ_MS = 1e3;
21770
21829
  var UNDATED_MS = 1e3;
21830
+ var FIRST_FRAME_MS = 500;
21831
+ var STILL_SHOTS = 3;
21771
21832
  var HOLDERS = /* @__PURE__ */ new WeakMap();
21772
21833
  var TEST_SCREENCASTS = /* @__PURE__ */ new WeakSet();
21773
21834
  var OWN_SCREENCASTS = /* @__PURE__ */ new WeakMap();
@@ -21893,6 +21954,14 @@ async function openPageView(page, options) {
21893
21954
  if (!viewport) return null;
21894
21955
  let closed = false;
21895
21956
  let last = null;
21957
+ let again = false;
21958
+ let given = 0;
21959
+ let paintedLast = null;
21960
+ let imaged = false;
21961
+ let stills = 0;
21962
+ let stillTimer = null;
21963
+ let stillShot = null;
21964
+ let refreshing = null;
21896
21965
  let sent2 = null;
21897
21966
  let refused = false;
21898
21967
  let screening = false;
@@ -21920,8 +21989,12 @@ async function openPageView(page, options) {
21920
21989
  return bar;
21921
21990
  });
21922
21991
  paintMs = bar.length && painting && jpegCodec() ? Date.now() - painting : 0;
21923
- if (typeof shown2 === "string") return refuse2(shown2);
21924
- if (shown2) deliver(shown2);
21992
+ if (shown2 && typeof shown2 !== "string") {
21993
+ if (frame.data === paintedLast) stills = 0;
21994
+ return deliver(shown2);
21995
+ }
21996
+ if (shown2) refuse2(shown2);
21997
+ dropped(frame);
21925
21998
  };
21926
21999
  const pacer = new LatestPacer({
21927
22000
  intervalMs: interval,
@@ -21930,56 +22003,110 @@ async function openPageView(page, options) {
21930
22003
  send: (frame) => {
21931
22004
  if (!options.live()) return;
21932
22005
  screening = true;
21933
- screened = show(frame).catch(() => void 0).finally(() => {
22006
+ screened = show(frame).catch(() => dropped(frame)).finally(() => {
21934
22007
  screening = false;
21935
22008
  screened = null;
21936
22009
  });
21937
22010
  }
21938
22011
  });
21939
22012
  const shownSize = (shot) => page.viewportSize() ?? jpegSize(shot) ?? viewport;
22013
+ const takeImage = async (quality) => {
22014
+ if (closed) return null;
22015
+ const shot = await internalCall(
22016
+ page,
22017
+ () => page.screenshot({ type: "jpeg", quality, scale: "css", caret: "initial", timeout: 5e3 })
22018
+ ).catch(() => null);
22019
+ if (!shot) return null;
22020
+ const size = shownSize(shot);
22021
+ const asked2 = options.size(size);
22022
+ const own = jpegSize(shot);
22023
+ const larger = !!own && (own.width > asked2.width || own.height > asked2.height);
22024
+ return { data: shot, ...size, ...larger ? { fit: asked2 } : {} };
22025
+ };
21940
22026
  let lighter = null;
22027
+ const standsFor = /* @__PURE__ */ new WeakMap();
21941
22028
  let lighterAt = -Infinity;
21942
22029
  const lighten = () => {
21943
22030
  const now = Date.now();
21944
22031
  if (lighter || now - lighterAt < options.shotMs) return;
21945
22032
  lighterAt = now;
21946
- lighter = internalCall(
21947
- page,
21948
- () => page.screenshot({ type: "jpeg", quality: options.lightQuality, scale: "css", caret: "initial", timeout: 5e3 })
21949
- ).then(
21950
- (shot) => {
21951
- if (closed) return;
21952
- if (shot.length <= options.maxFrameBytes) return pacer.offer({ data: shot, ...shownSize(shot), at: now });
21953
- refuse2();
21954
- },
21955
- () => void 0
21956
- ).finally(() => {
22033
+ const heavy = last;
22034
+ lighter = takeImage(options.lightQuality).then((shot) => {
22035
+ if (!shot || closed) return;
22036
+ const quality = options.lightQuality;
22037
+ const data = shot.fit ? thumbnailOf(shot.data, { ...shot.fit, quality, maxBytes: Number.POSITIVE_INFINITY })?.data ?? shot.data : shot.data;
22038
+ if (data.length > options.maxFrameBytes) return refuse2();
22039
+ if (heavy) standsFor.set(data, heavy);
22040
+ pacer.offer({ data, width: shot.width, height: shot.height, at: now });
22041
+ }).finally(() => {
21957
22042
  lighter = null;
21958
22043
  });
21959
22044
  };
21960
- const onFrame = (data, width, height, at) => {
21961
- if (closed || last?.equals(data)) return;
22045
+ const goingLength = (data, width, height, fit) => {
22046
+ if (!fit) return data.length;
22047
+ const own = jpegSize(data) ?? { width, height };
22048
+ return Math.round(data.length * Math.min(1, fit.width * fit.height / (own.width * own.height)));
22049
+ };
22050
+ const onFrame = (data, width, height, at, painted = false, fit) => {
22051
+ if (closed || last?.equals(data) && !again) return;
22052
+ if (painted) {
22053
+ if (imaged && paintedLast?.equals(data)) return;
22054
+ imaged = false;
22055
+ paintedLast = data;
22056
+ }
22057
+ again = false;
21962
22058
  last = data;
21963
- if (data.length > options.maxFrameBytes) return lighten();
22059
+ given++;
22060
+ if (goingLength(data, width, height, fit) > options.maxFrameBytes) return lighten();
21964
22061
  const named = isViewSize(width, height);
21965
- pacer.offer({ data, width: named ? width : viewport.width, height: named ? height : viewport.height, at });
22062
+ const shown2 = { width: named ? width : viewport.width, height: named ? height : viewport.height };
22063
+ pacer.offer({ data, ...shown2, at, ...fit ? { fit } : {} });
22064
+ };
22065
+ const imageNow = async () => {
22066
+ const at = Date.now();
22067
+ const before = given;
22068
+ const shot = await takeImage(options.quality);
22069
+ if (given !== before) return true;
22070
+ if (!shot) return false;
22071
+ imaged = true;
22072
+ onFrame(shot.data, shot.width, shot.height, at, false, shot.fit);
22073
+ return true;
22074
+ };
22075
+ const stillLater = (ms2) => {
22076
+ if (closed || stills >= STILL_SHOTS) return;
22077
+ if (stillTimer) clearTimeout(stillTimer);
22078
+ const before = given;
22079
+ stillTimer = setTimeout(() => {
22080
+ stillTimer = null;
22081
+ if (closed || shooting || stillShot || given !== before || !options.live()) return;
22082
+ stills++;
22083
+ const taking = imageNow().then((taken) => {
22084
+ if (stillShot === taking) stillShot = null;
22085
+ if (!taken) stillLater(options.shotMs);
22086
+ });
22087
+ stillShot = taking;
22088
+ }, ms2);
22089
+ stillTimer.unref?.();
22090
+ };
22091
+ const dropped = (frame) => {
22092
+ if (closed || (standsFor.get(frame.data) ?? frame.data) !== last || stills >= STILL_SHOTS) return;
22093
+ again = true;
22094
+ if (shooting) stills++;
22095
+ else stillLater(options.shotMs);
21966
22096
  };
21967
22097
  const screencast = screencastOf(page);
21968
22098
  let end = null;
21969
22099
  let shots = null;
21970
22100
  let shooting = false;
22101
+ let timed = null;
21971
22102
  const shoot = async () => {
21972
22103
  shots = null;
21973
22104
  if (closed || page.isClosed()) return;
21974
22105
  const at = Date.now();
21975
- const shot = await internalCall(
21976
- page,
21977
- () => page.screenshot({ type: "jpeg", quality: options.quality, scale: "css", caret: "initial", timeout: 5e3 })
21978
- ).catch(() => null);
21979
- if (shot) {
21980
- const size = shownSize(shot);
21981
- onFrame(shot, size.width, size.height, at);
21982
- }
22106
+ timed = takeImage(options.quality);
22107
+ const shot = await timed;
22108
+ timed = null;
22109
+ if (shot) onFrame(shot.data, shot.width, shot.height, at, true, shot.fit);
21983
22110
  if (!closed) {
21984
22111
  shots = setTimeout(() => void shoot(), options.shotMs);
21985
22112
  shots.unref?.();
@@ -22006,6 +22133,7 @@ async function openPageView(page, options) {
22006
22133
  };
22007
22134
  if (typeof screencast?.start === "function" && !TEST_SCREENCASTS.has(page)) {
22008
22135
  holders.add(holder);
22136
+ stillLater(FIRST_FRAME_MS);
22009
22137
  starting = internalCall(
22010
22138
  page,
22011
22139
  () => screencast.start({
@@ -22014,7 +22142,7 @@ async function openPageView(page, options) {
22014
22142
  onFrame: (frame) => {
22015
22143
  const now = Date.now();
22016
22144
  const at = typeof frame.timestamp === "number" && Number.isFinite(frame.timestamp) ? Math.min(frame.timestamp, now) - SCREENCAST_LAG_MS : Number.NEGATIVE_INFINITY;
22017
- onFrame(frame.data, frame.viewportWidth, frame.viewportHeight, at);
22145
+ onFrame(frame.data, frame.viewportWidth, frame.viewportHeight, at, true);
22018
22146
  return acks.next();
22019
22147
  }
22020
22148
  })
@@ -22052,17 +22180,12 @@ async function openPageView(page, options) {
22052
22180
  if (closed) return;
22053
22181
  sent2 = null;
22054
22182
  last = null;
22055
- const at = Date.now();
22056
- void internalCall(
22057
- page,
22058
- () => page.screenshot({ type: "jpeg", quality: options.quality, scale: "css", caret: "initial", timeout: 5e3 })
22059
- ).then(
22060
- (shot) => {
22061
- const size = shownSize(shot);
22062
- onFrame(shot, size.width, size.height, at);
22063
- },
22064
- () => void 0
22065
- );
22183
+ stills = 0;
22184
+ const taking = imageNow().then((taken) => {
22185
+ if (refreshing === taking) refreshing = null;
22186
+ if (!taken) stillLater(options.shotMs);
22187
+ });
22188
+ refreshing = taking;
22066
22189
  },
22067
22190
  close: async () => {
22068
22191
  closed = true;
@@ -22070,8 +22193,9 @@ async function openPageView(page, options) {
22070
22193
  acks.close();
22071
22194
  pacer.close();
22072
22195
  if (shots) clearTimeout(shots);
22196
+ if (stillTimer) clearTimeout(stillTimer);
22073
22197
  holders.delete(holder);
22074
- await Promise.all([lighter, screened]);
22198
+ await Promise.all([lighter, timed, stillShot, refreshing, screened]);
22075
22199
  const stop2 = end;
22076
22200
  end = null;
22077
22201
  if (stop2 && !page.isClosed()) await stop2().catch(() => void 0);
@@ -22851,11 +22975,11 @@ async function readSnapshot(page, depth, image) {
22851
22975
  var heldIn = (el, args) => {
22852
22976
  const field = el;
22853
22977
  const tag = (field.tagName ?? "").toLowerCase();
22854
- const control2 = tag === "input" || tag === "textarea" || tag === "select";
22978
+ const control3 = tag === "input" || tag === "textarea" || tag === "select";
22855
22979
  const type = typeof field.type === "string" ? field.type.toLowerCase() : null;
22856
22980
  const secret = typeof field.matches === "function" && field.matches(args.secretFields);
22857
22981
  const words = typeof field.textContent === "string" ? field.textContent.replace(/\u200b/g, "").replace(/\s+/g, " ").trim() : "";
22858
- const value = control2 && !secret && typeof field.value === "string" ? field.value : null;
22982
+ const value = control3 && !secret && typeof field.value === "string" ? field.value : null;
22859
22983
  return {
22860
22984
  secret,
22861
22985
  text: words ? { read: words.slice(0, args.read), length: words.length } : null,
@@ -23117,20 +23241,23 @@ function hearLine(call, line) {
23117
23241
  if (call.secretField !== true && namesSecretField(dropped)) call.secretField = true;
23118
23242
  }
23119
23243
  function settle(call, titleOf) {
23120
- call.title ??= hideSecretsInText(hideTypedText(titleOf(call.id) ?? call.named)).slice(0, MAX_TITLE);
23244
+ call.title ??= cutText(hideSecretsInText(hideTypedText(titleOf(call.id) ?? call.named)), MAX_TITLE);
23121
23245
  call.secretField ??= call.selector ? isSecretLocator(call.selector) : false;
23122
23246
  for (const line of call.heardLines) {
23123
23247
  call.secretField ||= namesSecretField(line);
23124
- call.lines.push(hideSecretsInText(hideSecretsInLog(line, call.secretField)).slice(0, MAX_LINE2));
23248
+ call.lines.push(cutText(hideSecretsInText(hideSecretsInLog(line, call.secretField)), MAX_LINE2));
23125
23249
  }
23126
23250
  call.heardLines = [];
23127
23251
  if (call.lines.length > KEPT_LINES) call.lines.splice(0, call.lines.length - KEPT_LINES);
23128
23252
  if (call.heardError !== null) {
23129
- call.error = hideSecretsInText(hideSecretsInLog(call.heardError, call.secretField)).slice(0, MAX_LINE2);
23253
+ call.error = cutText(hideSecretsInText(hideSecretsInLog(call.heardError, call.secretField)), MAX_LINE2);
23130
23254
  call.heardError = null;
23131
23255
  }
23132
23256
  }
23133
23257
  var followed = /* @__PURE__ */ new WeakMap();
23258
+ function followsCallStream(context) {
23259
+ return followed.has(context);
23260
+ }
23134
23261
  var listened = /* @__PURE__ */ new WeakMap();
23135
23262
  function take(state, update) {
23136
23263
  if (typeof update?.id !== "string" || typeof update.title !== "string") return;
@@ -23372,8 +23499,7 @@ async function followCallLog(page, since2, onLog, options = {}) {
23372
23499
  if (stopped || !shown2) return;
23373
23500
  settle(shown2, calls.titleOf);
23374
23501
  const here = onThisPage();
23375
- const known = secrets();
23376
- const hidden2 = (text2) => hideKnownValues(text2, known);
23502
+ const hidden2 = knownValuesHider(secrets());
23377
23503
  onLog({
23378
23504
  id: shown2.id,
23379
23505
  call: { title: hidden2(shown2.title), file: shown2.file, line: shown2.line },
@@ -23458,9 +23584,20 @@ function layersTestEnded() {
23458
23584
  function layersTest() {
23459
23585
  return current;
23460
23586
  }
23587
+ var MAX_TITLE2 = 300;
23588
+ function keptTitle(title, max) {
23589
+ const hidden2 = hideSecretsInText(hideTypedText(title));
23590
+ return max === void 0 ? hidden2 : cutText(hidden2, max);
23591
+ }
23592
+ function shownTitle(title, options = {}) {
23593
+ return hideKnownValues(keptTitle(title, options.max), options.secrets ?? knownSecrets());
23594
+ }
23461
23595
  function layersTitleOf(id) {
23462
23596
  const title = current?.titleOf(id) ?? null;
23463
- return title === null ? null : hideSecretsInText(hideTypedText(title)).slice(0, 300);
23597
+ return title === null ? null : keptTitle(title, MAX_TITLE2);
23598
+ }
23599
+ function shownThumb(thumb) {
23600
+ return { ...thumb, title: shownTitle(thumb.title, { max: MAX_TITLE2 }) };
23464
23601
  }
23465
23602
  var eventSubscribers = /* @__PURE__ */ new Set();
23466
23603
  function subscribePageEvents(send2) {
@@ -24722,12 +24859,12 @@ var LiveInspect = class {
24722
24859
  * for the page's main frame. The frame's snapshots waiting stay (`kept`: they come before it), go up to a full one,
24723
24860
  * which starts its chain again (`until-full`: they come after it), or all go (`none`).
24724
24861
  */
24725
- stopChain(frame, main, why, waiting2) {
24862
+ stopChain(frame, main, why, waiting3) {
24726
24863
  let restarts = false;
24727
- if (waiting2 !== "kept") {
24864
+ if (waiting3 !== "kept") {
24728
24865
  const kept = [];
24729
24866
  for (const one of this.queue) {
24730
- if (one.fields.frame === frame && one.fields.full && waiting2 === "until-full") restarts = true;
24867
+ if (one.fields.frame === frame && one.fields.full && waiting3 === "until-full") restarts = true;
24731
24868
  if (one.fields.frame === frame && !restarts) this.queued -= one.bytes;
24732
24869
  else kept.push(one);
24733
24870
  }
@@ -24818,8 +24955,8 @@ var LiveInspect = class {
24818
24955
  * Post a snapshot, what the page's secrets show and its credentials removed, after the resources it names that did not
24819
24956
  * go yet; its frame's chain stops when it does not go.
24820
24957
  */
24821
- async send(waiting2) {
24822
- const { fields, snapshot } = waiting2;
24958
+ async send(waiting3) {
24959
+ const { fields, snapshot } = waiting3;
24823
24960
  const secrets = await this.readSecrets();
24824
24961
  if (this.closed) return;
24825
24962
  if (!secrets) return this.stopChain(fields.frame, fields.main, UNREAD_SECRETS2, "until-full");
@@ -24839,17 +24976,22 @@ var LiveInspect = class {
24839
24976
  const shownUrl2 = this.link.sent.has(sha1) ? hideResourceUrl(url, secrets) : null;
24840
24977
  if (shownUrl2) named.push({ url: shownUrl2, sha1 });
24841
24978
  }
24842
- const live = { ...fields, title: this.titleOf(fields.call, snapshot.callId), resources: named };
24979
+ const live = {
24980
+ ...fields,
24981
+ title: this.titleOf(fields.call, snapshot.callId, secrets),
24982
+ resources: named
24983
+ };
24843
24984
  const body = encodeLiveMessage(liveSnapshotHeader(this.link.id, live, this.link.test()), data);
24844
24985
  this.link.budget.spend(body.length);
24845
24986
  await this.link.post(body);
24846
24987
  }
24847
- /** The call's title: the runner's, else the trace's own; the text it types and its credentials hidden. */
24848
- titleOf(step, callId) {
24849
- const runner = layersTitleOf(step);
24850
- if (runner) return runner;
24988
+ /**
24989
+ * The call's title: the runner's, else the trace's own, shown as `shownTitle` shows it with the attempt's `secrets`,
24990
+ * 300 characters at most.
24991
+ */
24992
+ titleOf(step, callId, secrets) {
24851
24993
  const own = typeof callId === "string" ? this.calls.get(callId)?.title : void 0;
24852
- return hideSecretsInText(hideTypedText(own ?? "Call")).slice(0, 300);
24994
+ return shownTitle(layersTitleOf(step) || (own ?? "Call"), { max: 300, secrets });
24853
24995
  }
24854
24996
  /**
24855
24997
  * Post a resource from the trace folder's `resources/`, its bytes of the kind its content type says, once per run,
@@ -24934,9 +25076,24 @@ var VIEW_END_MS = 1e3;
24934
25076
  var MAX_EVENT_POSTS = 8;
24935
25077
  var GIVE_UP = /* @__PURE__ */ new Set([403, 410]);
24936
25078
  var NOT_NOW = /* @__PURE__ */ new Set([401, 404]);
25079
+ var GONE_NOW = /* @__PURE__ */ new Set([404, 409]);
24937
25080
  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.`;
24938
25081
  var NO_PAGE = "This test has no page to show yet.";
24939
25082
  var NO_TEST = "No test runs on this worker now: the next one shows once it opens its page.";
25083
+ var PAUSE_DROPPED = {
25084
+ noTest: "No test runs on this worker now.",
25085
+ stopped: "This worker's test stands at a stop.",
25086
+ left: "Nobody who may control the run watches this worker in full now.",
25087
+ off: "The project's setting is off.",
25088
+ resumed: "Resume came before the test paused.",
25089
+ ended: "The test ended before its next call.",
25090
+ functionEnded: "The test's function ended before its next call."
25091
+ };
25092
+ var waiting = null;
25093
+ var pauseHandlers = null;
25094
+ function onLiveViewPause(handlers) {
25095
+ pauseHandlers = handlers;
25096
+ }
24940
25097
  var layerRuns = { events: null, text: null, texts: null, thumbs: null, inspect: null };
24941
25098
  var budget = new LiveByteBudget();
24942
25099
  var inspectSent = /* @__PURE__ */ new Set();
@@ -24986,7 +25143,7 @@ function liveViewOpen() {
24986
25143
  return link !== null;
24987
25144
  }
24988
25145
  function liveViewMayPause() {
24989
- return link !== null && !link.ci;
25146
+ return link !== null && (!link.ci || link.hold !== null && link.pause);
24990
25147
  }
24991
25148
  function active(own) {
24992
25149
  return !own.ended && own.refused === null && own.sharing;
@@ -25057,7 +25214,10 @@ function openLiveView(worker, env = process.env, ci = detectCi(env)) {
25057
25214
  logTimer: null,
25058
25215
  logRefused: false,
25059
25216
  masks: [],
25060
- asked: null
25217
+ asked: null,
25218
+ hold: null,
25219
+ pause: false,
25220
+ pauseAsked: false
25061
25221
  };
25062
25222
  if (link.sharing) connect2(link);
25063
25223
  unhearLane = onLanePage(lanePageChanged);
@@ -25072,6 +25232,7 @@ function openLiveView(worker, env = process.env, ci = detectCi(env)) {
25072
25232
  return true;
25073
25233
  }
25074
25234
  function closeLiveView() {
25235
+ letWaitGo(PAUSE_DROPPED.noTest);
25075
25236
  const own = link;
25076
25237
  link = null;
25077
25238
  running = null;
@@ -25146,6 +25307,7 @@ async function liveViewTestEnded(status) {
25146
25307
  if (!running) return;
25147
25308
  const ended = running;
25148
25309
  running = null;
25310
+ if (link) dropPause(link, PAUSE_DROPPED.ended);
25149
25311
  const outcome = status ? { test: ended.title, status, ms: Math.max(0, Date.now() - ended.began) } : null;
25150
25312
  await stopView();
25151
25313
  const own = link;
@@ -25156,16 +25318,18 @@ async function liveViewTestEnded(status) {
25156
25318
  function liveViewStopped(stop2) {
25157
25319
  const own = link;
25158
25320
  if (!own || own.ended) return () => void 0;
25159
- const shown2 = { ...stop2, call: hideCallSecrets(stop2.call) };
25160
- own.stop = shown2;
25161
- postState(own, { type: "stop", ...own.id, stop: shown2 });
25321
+ own.stop = stop2;
25322
+ postState(own, { type: "stop", ...own.id, stop: shownStop(stop2) });
25162
25323
  return () => {
25163
- if (own.stop === shown2) own.stop = null;
25324
+ if (own.stop === stop2) own.stop = null;
25164
25325
  postState(own, { type: "stop", ...own.id, stop: null });
25165
25326
  };
25166
25327
  }
25167
25328
  function hideCallSecrets(call) {
25168
- return { ...call, title: hideSecretsInText(hideTypedText(call.title)) };
25329
+ return { ...call, title: shownTitle(call.title) };
25330
+ }
25331
+ function shownStop(stop2) {
25332
+ return { ...stop2, call: hideCallSecrets(stop2.call) };
25169
25333
  }
25170
25334
  function postState(own, message) {
25171
25335
  if (!active(own) || own.statesWaiting >= MAX_STATES_WAITING) return;
@@ -25181,6 +25345,7 @@ function connect2(own) {
25181
25345
  if (own.id.shard !== null) url.searchParams.set("shard", String(own.id.shard));
25182
25346
  if (own.id.slot !== void 0) url.searchParams.set("slot", String(own.id.slot));
25183
25347
  if (own.after !== null) url.searchParams.set(LIVE_VIEW_AFTER_PARAM, String(own.after));
25348
+ if (own.ci) url.searchParams.set(LIVE_VIEW_FEATURES_PARAM, `${LIVE_HOLD_FEATURE},${LIVE_PAUSE_FEATURE}`);
25184
25349
  let openedAt = null;
25185
25350
  let dropped = false;
25186
25351
  const drop = (status) => {
@@ -25194,6 +25359,7 @@ function connect2(own) {
25194
25359
  if (openedAt !== null && Date.now() - openedAt >= STEADY_MS) own.retries = 0;
25195
25360
  if (status !== null) own.answered = status;
25196
25361
  if (status !== null && GIVE_UP.has(status)) return void refuse(own, status);
25362
+ if (status !== null && GONE_NOW.has(status) && own === link) letWaitGo(PAUSE_DROPPED.left);
25197
25363
  retry(own, status !== null && NOT_NOW.has(status));
25198
25364
  };
25199
25365
  const request3 = own.client.request(url, {
@@ -25228,7 +25394,7 @@ function connect2(own) {
25228
25394
  }, STEADY_MS);
25229
25395
  own.backTimer.unref?.();
25230
25396
  }
25231
- if (own.stop) postState(own, { type: "stop", ...own.id, stop: own.stop });
25397
+ if (own.stop) postState(own, { type: "stop", ...own.id, stop: shownStop(own.stop) });
25232
25398
  response.setEncoding("utf8");
25233
25399
  let text2 = "";
25234
25400
  response.on("data", (chunk) => {
@@ -25244,7 +25410,12 @@ function connect2(own) {
25244
25410
  else if (message?.type === "view") setAsked(own, message);
25245
25411
  else if (message?.type === "resend") resendView(own);
25246
25412
  else if (message?.type === "text") sendText(own);
25413
+ else if (message?.type === "hold") setHold(own, message.ms, message.pause === true);
25414
+ else if (message?.type === "let-go" || message?.type === "pause") control(own, request3, message.type);
25415
+ else if (message?.type === "resume") control(own, request3, "resume");
25416
+ else if (message?.type === "end-test") control(own, request3, "end-test", message.by ?? null);
25247
25417
  else if (message) setViewers(own, message.count);
25418
+ if (message?.type === "view" || message?.type === "viewers") keepHold(own, message);
25248
25419
  }
25249
25420
  });
25250
25421
  response.on("error", () => drop(null));
@@ -25298,6 +25469,7 @@ function lostCause(status) {
25298
25469
  }
25299
25470
  function refuse(own, status) {
25300
25471
  if (own.refused !== null) return;
25472
+ if (own === link) letWaitGo(PAUSE_DROPPED.left);
25301
25473
  own.refused = liveShareRefusal(status);
25302
25474
  own.answered = status;
25303
25475
  if (own.ci) goDark(own, "It stays off for this worker.");
@@ -25308,6 +25480,7 @@ function refuse(own, status) {
25308
25480
  changed();
25309
25481
  }
25310
25482
  function giveUp(own) {
25483
+ if (own === link) letWaitGo(PAUSE_DROPPED.left);
25311
25484
  own.sharing = false;
25312
25485
  own.lost = liveShareRefusal(own.answered);
25313
25486
  own.viewers = 0;
@@ -25335,6 +25508,118 @@ function resendView(own) {
25335
25508
  if (own.log && shownInFull(own)) postLog(own, own.log);
25336
25509
  if (layerAsked(own, "filmstrip")) queueStrip(own);
25337
25510
  }
25511
+ function setHold(own, ms2, pause) {
25512
+ own.hold = ms2;
25513
+ own.pause = ms2 !== null && pause;
25514
+ if (own !== link) return;
25515
+ if (!own.pause) dropPause(own, PAUSE_DROPPED.off);
25516
+ const wait = waiting;
25517
+ if (!wait) return;
25518
+ if (ms2 === null || wait.kind === "pause" && !own.pause) return endWait();
25519
+ const until = wait.began + ms2;
25520
+ if (until <= Date.now()) return endWait();
25521
+ clearTimeout(wait.timer);
25522
+ wait.until = until;
25523
+ wait.timer = setTimeout(() => endWait(), until - Date.now());
25524
+ if (own.stop?.reason === wait.kind) {
25525
+ own.stop.until = until;
25526
+ postState(own, { type: "stop", ...own.id, stop: shownStop(own.stop) });
25527
+ }
25528
+ }
25529
+ function control(own, request3, command, by = null) {
25530
+ if (own !== link || !own.ci || own.stream !== request3 || own.hold === null) return;
25531
+ if (command === "let-go") {
25532
+ if (waiting?.kind === "held") endWait();
25533
+ return;
25534
+ }
25535
+ if (!own.pause) return;
25536
+ if (command === "pause") {
25537
+ if (own.pauseAsked) return;
25538
+ const why = waiting ? PAUSE_DROPPED.stopped : !running || !active(own) ? PAUSE_DROPPED.noTest : !controllerWatches(own) ? PAUSE_DROPPED.left : pauseHandlers ? pauseHandlers.pause() : PAUSE_DROPPED.noTest;
25539
+ if (why) return void postState(own, { type: "pause-asked", ...own.id, waiting: false, why });
25540
+ own.pauseAsked = true;
25541
+ postState(own, { type: "pause-asked", ...own.id, waiting: true });
25542
+ } else if (waiting?.kind === "pause") {
25543
+ endWait(command === "end-test" ? "end" : "resume", by);
25544
+ } else if (command === "resume") {
25545
+ dropPause(own, PAUSE_DROPPED.resumed);
25546
+ }
25547
+ }
25548
+ function dropPause(own, why) {
25549
+ if (!own.pauseAsked) return;
25550
+ own.pauseAsked = false;
25551
+ pauseHandlers?.drop();
25552
+ postState(own, { type: "pause-asked", ...own.id, waiting: false, why });
25553
+ }
25554
+ function liveViewTestFunctionEnded() {
25555
+ if (link) dropPause(link, PAUSE_DROPPED.functionEnded);
25556
+ }
25557
+ function controllerWatches(own) {
25558
+ return own.viewers > 0 && !!own.asked?.full && own.asked.controller === true;
25559
+ }
25560
+ function keepHold(own, message) {
25561
+ const left = message.type === "view" ? !message.full || message.controller !== true : message.count === 0;
25562
+ if (own === link && left) letWaitGo(PAUSE_DROPPED.left);
25563
+ }
25564
+ function endWait(how = "resume", by = null) {
25565
+ waiting?.end(how, by);
25566
+ }
25567
+ function letWaitGo(why) {
25568
+ endWait();
25569
+ if (link) dropPause(link, why);
25570
+ }
25571
+ function liveViewMayHold() {
25572
+ const own = link;
25573
+ return !!own && own.ci && !waiting && !!running && active(own) && own.hold !== null && controllerWatches(own);
25574
+ }
25575
+ function startWait(kind, ms2) {
25576
+ let resolve15;
25577
+ const ended = new Promise((settle2) => resolve15 = settle2);
25578
+ const began = Date.now();
25579
+ const wait = {
25580
+ kind,
25581
+ began,
25582
+ until: began + ms2,
25583
+ timer: setTimeout(() => endWait(), ms2),
25584
+ ended,
25585
+ by: null,
25586
+ over: false,
25587
+ end: (how = "resume", by = null) => {
25588
+ if (wait.over) return;
25589
+ wait.over = true;
25590
+ clearTimeout(wait.timer);
25591
+ if (waiting === wait) waiting = null;
25592
+ wait.by = by;
25593
+ resolve15(how);
25594
+ }
25595
+ };
25596
+ waiting = wait;
25597
+ return {
25598
+ get until() {
25599
+ return wait.until;
25600
+ },
25601
+ get by() {
25602
+ return wait.by;
25603
+ },
25604
+ ended,
25605
+ end: () => wait.end()
25606
+ };
25607
+ }
25608
+ function liveViewHold() {
25609
+ const own = link;
25610
+ if (!own || own.hold === null || !liveViewMayHold()) return null;
25611
+ return startWait("held", own.hold);
25612
+ }
25613
+ function liveViewPause() {
25614
+ const own = link;
25615
+ if (!own?.pauseAsked) return null;
25616
+ if (!own.pause || own.hold === null || !liveViewMayHold()) {
25617
+ dropPause(own, controllerWatches(own) ? PAUSE_DROPPED.noTest : PAUSE_DROPPED.left);
25618
+ return null;
25619
+ }
25620
+ own.pauseAsked = false;
25621
+ return startWait("pause", own.hold);
25622
+ }
25338
25623
  function setMasks(own, locators) {
25339
25624
  if (JSON.stringify(locators) === JSON.stringify(own.masks)) return;
25340
25625
  own.masks = locators;
@@ -25457,7 +25742,11 @@ function startThumbPosts(own) {
25457
25742
  if (thumbPosts.posting || !thumbPosts.queue.length || !own.asked || !layerAsked(own, "filmstrip")) return;
25458
25743
  const next = thumbPosts.queue.shift();
25459
25744
  thumbPosts.posting = true;
25460
- void postBody(own, encodeLiveMessage(liveThumbHeader(own.id, next.thumb, next.test), next.data), LIVE_FRAME_TYPE).catch(() => void 0).finally(() => {
25745
+ void postBody(
25746
+ own,
25747
+ encodeLiveMessage(liveThumbHeader(own.id, shownThumb(next.thumb), next.test), next.data),
25748
+ LIVE_FRAME_TYPE
25749
+ ).catch(() => void 0).finally(() => {
25461
25750
  thumbPosts.posting = false;
25462
25751
  });
25463
25752
  }, 1e3 / LANE_THUMBS_PER_SECOND);
@@ -25525,7 +25814,7 @@ function followCalls(own) {
25525
25814
  const wanted = !!running && !own.logRefused && shownInFull(own);
25526
25815
  if (wanted && !shown2.following) {
25527
25816
  const { page } = shown2;
25528
- const source2 = own.ci && !running.mayPause ? "stream" : "listener";
25817
+ const source2 = callSource(own);
25529
25818
  shown2.following = followCallLog(
25530
25819
  page,
25531
25820
  running.began,
@@ -25540,6 +25829,9 @@ function followCalls(own) {
25540
25829
  forgetLog(own);
25541
25830
  }
25542
25831
  }
25832
+ function callSource(own) {
25833
+ return own.ci && !running?.mayPause && !liveViewMayPause() ? "stream" : "listener";
25834
+ }
25543
25835
  function forgetLog(own) {
25544
25836
  own.log = null;
25545
25837
  if (own.logTimer) clearTimeout(own.logTimer);
@@ -25672,7 +25964,7 @@ var VIEW_FRAMES = {
25672
25964
  };
25673
25965
  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.";
25674
25966
  var socket = null;
25675
- var control = null;
25967
+ var control2 = null;
25676
25968
  var shown = /* @__PURE__ */ new Set();
25677
25969
  var host = null;
25678
25970
  var stops = 0;
@@ -25749,7 +26041,7 @@ async function openRunChannel(worker, handlers, env = process.env) {
25749
26041
  return false;
25750
26042
  }
25751
26043
  socket = opening;
25752
- control = handlers;
26044
+ control2 = handlers;
25753
26045
  shown = /* @__PURE__ */ new Set();
25754
26046
  runName = `piwi-${ref}-w${worker.workerIndex}`;
25755
26047
  eventsOn = false;
@@ -25846,7 +26138,7 @@ function editorSendAddress(env = process.env) {
25846
26138
  function closeRunChannel() {
25847
26139
  socket?.end();
25848
26140
  socket = null;
25849
- control = null;
26141
+ control2 = null;
25850
26142
  filmstrip2?.close();
25851
26143
  filmstrip2 = null;
25852
26144
  }
@@ -25892,7 +26184,7 @@ function sendPendingPosition() {
25892
26184
  pendingPosition = null;
25893
26185
  if (!position || !positionsWanted()) return;
25894
26186
  positionToldAt = performance.now();
25895
- tellHub({ type: "position", testId: runningTestId, title: position.title, place: position.place });
26187
+ tellHub({ type: "position", testId: runningTestId, title: shownTitle(position.title), place: position.place });
25896
26188
  }
25897
26189
  function dropPendingPosition() {
25898
26190
  pendingPosition = null;
@@ -25947,16 +26239,17 @@ function holdStop(stop2, onAnswer) {
25947
26239
  browser: stop2.browser ?? null
25948
26240
  };
25949
26241
  held = holding;
26242
+ const known = knownSecrets();
25950
26243
  tellHub({
25951
26244
  type: "stopped",
25952
26245
  stop: id,
25953
26246
  reason: stop2.reason,
25954
- // The text the stopped call types stays in the worker, as on every surface.
25955
- title: hideSecretsInText(hideTypedText(stop2.title)),
26247
+ // The text the stopped call types, and each value the attempt knows, stay in the worker, as on every surface.
26248
+ title: shownTitle(stop2.title),
25956
26249
  place: stop2.place,
25957
- locator: stop2.locator,
26250
+ locator: stop2.locator === null ? null : hideKnownValues(stop2.locator, known),
25958
26251
  bar: stop2.bar,
25959
- ...stop2.error ? { error: stop2.error } : {}
26252
+ ...stop2.error ? { error: hideKnownValues(stop2.error, known) } : {}
25960
26253
  });
25961
26254
  laneStopped(id, stop2.page);
25962
26255
  if (!runChannelOpen() && !stop2.bar) holding.answer("resume");
@@ -26178,7 +26471,7 @@ function startLaneStrip() {
26178
26471
  const next = strip.queue.shift();
26179
26472
  const now = laneAt().test;
26180
26473
  if (next && (now === null || next.test === now)) {
26181
- tellLayer({ layer: "filmstrip", thumb: next.thumb, data: next.data.toString("base64") }, next.test);
26474
+ tellLayer({ layer: "filmstrip", thumb: shownThumb(next.thumb), data: next.data.toString("base64") }, next.test);
26182
26475
  }
26183
26476
  }, 1e3 / LANE_THUMBS_PER_SECOND);
26184
26477
  send2.unref?.();
@@ -26433,13 +26726,13 @@ function onMessage(message) {
26433
26726
  void shareLiveView(message.on, message.after ?? null).then(tellLive);
26434
26727
  return;
26435
26728
  case "breakpoints":
26436
- control?.breakpoints(message.places);
26729
+ control2?.breakpoints(message.places);
26437
26730
  return;
26438
26731
  case "control":
26439
26732
  if (message.action === "pause") {
26440
- if (!held) control?.pause();
26733
+ if (!held) control2?.pause();
26441
26734
  } else if (message.action === "give-up") {
26442
- if (!held) control?.giveUp(message.testId);
26735
+ if (!held) control2?.giveUp(message.testId);
26443
26736
  else
26444
26737
  tellHub({
26445
26738
  type: "notice",
@@ -26449,7 +26742,7 @@ function onMessage(message) {
26449
26742
  return;
26450
26743
  case "run-to":
26451
26744
  if (held?.stop !== message.stop) return;
26452
- control?.runTo(message.place);
26745
+ control2?.runTo(message.place);
26453
26746
  held.answer("resume");
26454
26747
  return;
26455
26748
  case "request": {
@@ -26673,44 +26966,52 @@ function callPlace(frames, cwd = process.cwd(), windows = process.platform === "
26673
26966
  }
26674
26967
  return null;
26675
26968
  }
26676
- function callTitle(zone, channel) {
26677
- const selector = typeof channel?.params?.selector === "string" ? ` ${channel.params.selector}` : "";
26678
- const title = zone.title || `${zone.apiName || "call"}${selector}`;
26679
- return hideSecretsInText(hideTypedText(title)).slice(0, MAX_POSITION_TITLE);
26969
+ function keptCallTitle(zone) {
26970
+ const id = zoneStepId(zone);
26971
+ const title = (id ? layersTitleOf(id) : null) || zone.title || zone.apiName || "call";
26972
+ return keptTitle(title, MAX_POSITION_TITLE);
26680
26973
  }
26681
26974
  function errorText(error) {
26682
26975
  const message = error instanceof Error ? error.message : String(error);
26683
- return hideSecretsInText(message.split("\n").slice(0, 4).join("\n")).slice(0, MAX_RUN_EVENT_TEXT);
26976
+ const cut3 = cutText(hideSecretsInText(message.split("\n").slice(0, 4).join("\n")), MAX_RUN_EVENT_TEXT);
26977
+ return hideKnownValues(cut3, knownSecrets());
26978
+ }
26979
+ function tellPositionOf(zone, place) {
26980
+ try {
26981
+ tellPosition(keptCallTitle(zone), place);
26982
+ } catch {
26983
+ }
26684
26984
  }
26685
26985
  function watchCalls(playwright) {
26686
26986
  const instrumentation = playwright?._instrumentation;
26687
26987
  if (!playwright || heard2.has(playwright)) return true;
26688
26988
  if (!instrumentation || typeof instrumentation.addListener !== "function") return false;
26689
26989
  heard2.add(playwright);
26690
- const titles = /* @__PURE__ */ new WeakMap();
26691
26990
  instrumentation.addListener({
26692
- onApiCallBegin: (zone, channel) => {
26991
+ onApiCallBegin: (zone) => {
26693
26992
  if (positionsWanted()) {
26694
26993
  const place = callPlace(zone.frames);
26695
- if (place) tellPosition(callTitle(zone, channel), place);
26994
+ if (place) queueMicrotask(() => tellPositionOf(zone, place));
26696
26995
  }
26697
26996
  if (!runEventsWanted()) return;
26698
26997
  begun.set(zone, Date.now());
26699
- titles.set(zone, callTitle(zone, channel));
26700
26998
  },
26701
26999
  onApiCallEnd: (zone) => {
26702
27000
  const start = begun.get(zone);
26703
27001
  if (start === void 0) return;
26704
27002
  begun.delete(zone);
26705
27003
  if (!runEventsWanted()) return;
26706
- tellEvent({
26707
- kind: "call",
26708
- title: titles.get(zone) ?? callTitle(zone, void 0),
26709
- place: callPlace(zone.frames),
26710
- ok: zone.error === void 0,
26711
- error: zone.error === void 0 ? null : errorText(zone.error),
26712
- ms: Date.now() - start
26713
- });
27004
+ try {
27005
+ tellEvent({
27006
+ kind: "call",
27007
+ title: shownTitle(keptCallTitle(zone)),
27008
+ place: callPlace(zone.frames),
27009
+ ok: zone.error === void 0,
27010
+ error: zone.error === void 0 ? null : errorText(zone.error),
27011
+ ms: Date.now() - start
27012
+ });
27013
+ } catch {
27014
+ }
26714
27015
  }
26715
27016
  });
26716
27017
  return true;
@@ -26768,13 +27069,13 @@ function tellApiCall(call, url) {
26768
27069
  } catch {
26769
27070
  }
26770
27071
  }
26771
- var waiting = /* @__PURE__ */ new Map();
27072
+ var waiting2 = /* @__PURE__ */ new Map();
26772
27073
  var requestsFollowed = 0;
26773
27074
  var waitTimer = null;
26774
27075
  function tellWaiting() {
26775
27076
  if (!pageEventsWanted()) return forgetWaitingRequests();
26776
27077
  const now = Date.now();
26777
- for (const request3 of waiting.values()) {
27078
+ for (const request3 of waiting2.values()) {
26778
27079
  const ms2 = now - request3.began;
26779
27080
  if (ms2 < PENDING_REQUEST_MS * (request3.told + 1)) continue;
26780
27081
  request3.told = Math.floor(ms2 / PENDING_REQUEST_MS);
@@ -26789,7 +27090,7 @@ function tellWaiting() {
26789
27090
  }
26790
27091
  }
26791
27092
  function forgetWaitingRequests() {
26792
- waiting.clear();
27093
+ waiting2.clear();
26793
27094
  if (waitTimer) clearInterval(waitTimer);
26794
27095
  waitTimer = null;
26795
27096
  }
@@ -26806,9 +27107,9 @@ function watchPageEvents(page) {
26806
27107
  }
26807
27108
  };
26808
27109
  const settle2 = (request3) => {
26809
- const followed2 = waiting.get(request3);
27110
+ const followed2 = waiting2.get(request3);
26810
27111
  if (!followed2) return;
26811
- waiting.delete(request3);
27112
+ waiting2.delete(request3);
26812
27113
  if (!followed2.told || !pageEventsWanted()) return;
26813
27114
  const { id, method, url: shown2, began } = followed2;
26814
27115
  tellPageEvent({ kind: "request-pending", id, method, url: shown2, ms: Date.now() - began, done: true });
@@ -26837,10 +27138,10 @@ function watchPageEvents(page) {
26837
27138
  })
26838
27139
  );
26839
27140
  page.on("request", (request3) => {
26840
- if (!pageEventsWanted() || waiting.size >= MAX_FOLLOWED_REQUESTS) return;
27141
+ if (!pageEventsWanted() || waiting2.size >= MAX_FOLLOWED_REQUESTS) return;
26841
27142
  try {
26842
27143
  const method = request3.method();
26843
- waiting.set(request3, {
27144
+ waiting2.set(request3, {
26844
27145
  id: ++requestsFollowed,
26845
27146
  method,
26846
27147
  url: eventUrl(request3.url()),
@@ -27011,7 +27312,7 @@ async function recordFromHere(options) {
27011
27312
  page.once("close", onGone);
27012
27313
  page.once("crash", onGone);
27013
27314
  ended?.addEventListener("abort", onEnded, { once: true });
27014
- const startWait = setTimeout(() => finish("the editor did not start the recording."), START_WAIT_MS);
27315
+ const startWait2 = setTimeout(() => finish("the editor did not start the recording."), START_WAIT_MS);
27015
27316
  const release2 = () => {
27016
27317
  const relay = relays.get(context);
27017
27318
  if (relay && relay.recording === relayed) relay.recording = null;
@@ -27021,7 +27322,7 @@ async function recordFromHere(options) {
27021
27322
  const finish = (said) => {
27022
27323
  if (settled) return;
27023
27324
  settled = true;
27024
- clearTimeout(startWait);
27325
+ clearTimeout(startWait2);
27025
27326
  release2();
27026
27327
  for (const [call, answer] of answers) {
27027
27328
  answers.delete(call);
@@ -27067,7 +27368,7 @@ async function recordFromHere(options) {
27067
27368
  await page.evaluate(fs35.readFileSync(bundle, "utf-8"));
27068
27369
  if (settled) return release2();
27069
27370
  recording = true;
27070
- clearTimeout(startWait);
27371
+ clearTimeout(startWait2);
27071
27372
  context.on("page", onPage);
27072
27373
  send2({ type: "loaded" });
27073
27374
  };
@@ -27766,6 +28067,8 @@ function createSink() {
27766
28067
  pickOffered: false,
27767
28068
  userPick: null,
27768
28069
  pause: null,
28070
+ livePause: false,
28071
+ endedFromPiwi: null,
27769
28072
  locatorCalls: /* @__PURE__ */ new Map(),
27770
28073
  stops: [],
27771
28074
  shownStops: /* @__PURE__ */ new Map(),
@@ -27920,7 +28223,11 @@ async function settleBeforeClose(closing) {
27920
28223
  async function settleContextClose(context) {
27921
28224
  CLOSING_CONTEXTS.add(context);
27922
28225
  await settleBeforeClose({ context });
27923
- if (contextDebugger(context)?.pausedDetails()) await steerDebugger(context, "resume");
28226
+ if (!contextDebugger(context)?.pausedDetails()) return;
28227
+ if (ENDED_CONTEXTS.has(context)) {
28228
+ await Promise.all(openPages(context).map((page) => internalCall(page, () => page.close()).catch(() => void 0)));
28229
+ }
28230
+ await steerDebugger(context, "resume");
27924
28231
  }
27925
28232
  function isPageClosed(page) {
27926
28233
  try {
@@ -28405,6 +28712,7 @@ function locatorSource(target, method, args) {
28405
28712
  return renderFailing({ method, args });
28406
28713
  }
28407
28714
  var PAGE_PAUSES = /* @__PURE__ */ new WeakMap();
28715
+ var ENDED_CONTEXTS = /* @__PURE__ */ new WeakSet();
28408
28716
  var CLOSING_CONTEXTS = /* @__PURE__ */ new WeakSet();
28409
28717
  var CLOSING_PAGES = /* @__PURE__ */ new WeakMap();
28410
28718
  var PLAYWRIGHT_PAUSES = /* @__PURE__ */ new WeakMap();
@@ -28484,7 +28792,7 @@ function onDebuggerStop(context) {
28484
28792
  } catch {
28485
28793
  if (state) how = goOn(state);
28486
28794
  } finally {
28487
- await steerDebugger(context, how);
28795
+ if (sink?.endedFromPiwi !== context) await steerDebugger(context, how);
28488
28796
  }
28489
28797
  })();
28490
28798
  }
@@ -28504,14 +28812,17 @@ function stopBarPage(sink, context, of) {
28504
28812
  return open4[open4.length - 1] ?? null;
28505
28813
  }
28506
28814
  async function showStop(sink, context, calledAs, location, reason, call, of, failure = null) {
28507
- const title = hideSecretsInText(hideTypedText(calledAs));
28815
+ const title = keptTitle(calledAs);
28508
28816
  const testInfo = sink.testInfo;
28509
28817
  const page = stopBarPage(sink, context, of);
28510
28818
  const guessed = !("page" in of);
28511
28819
  if (!testInfo) return void 0;
28512
- const bar = !!page && pauseGateFromTestInfo(testInfo, sink.headless).headless === false;
28820
+ const livePause = !failure && reason === "pause" && sink.livePause;
28821
+ const wait = failure?.hold ?? (livePause ? liveViewPause() : null);
28822
+ if (livePause && !wait) return "resume";
28823
+ const bar = !wait && !!page && pauseGateFromTestInfo(testInfo, sink.headless).headless === false;
28513
28824
  const place = runChannelOpen() ? callSitePlace(location) : null;
28514
- if (!bar && !place) return void 0;
28825
+ if (!bar && !place && !wait) return void 0;
28515
28826
  const failing = failure?.failed ?? null;
28516
28827
  const pickTaken = async (picked) => {
28517
28828
  if (call) {
@@ -28545,9 +28856,10 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28545
28856
  sink.stops.push(record);
28546
28857
  const stoppedAt = callSitePlace(location);
28547
28858
  const goneOn = liveViewStopped({
28548
- reason,
28859
+ reason: failure?.hold ? "held" : reason,
28549
28860
  call: { title, file: stoppedAt?.file ?? null, line: stoppedAt?.line ?? null },
28550
- test: testInfo.title
28861
+ test: testInfo.title,
28862
+ ...wait ? { until: wait.until } : {}
28551
28863
  });
28552
28864
  const noted = { testId: testInfo.testId, retry: testInfo.retry };
28553
28865
  noteStop(process.env[PIWI_STOP_NOTES_ENV], {
@@ -28555,7 +28867,7 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28555
28867
  ...noted,
28556
28868
  stop: {
28557
28869
  reason,
28558
- title,
28870
+ title: shownTitle(title),
28559
28871
  file: stoppedAt ? stopFile(stoppedAt.file, configDirFromConfig(testInfo.config)) : null,
28560
28872
  line: stoppedAt?.line ?? null,
28561
28873
  bar,
@@ -28567,6 +28879,10 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28567
28879
  const over = new AbortController();
28568
28880
  end.signal.addEventListener("abort", () => over.abort(), { once: true });
28569
28881
  let fromEditor;
28882
+ void wait?.ended.then((how) => {
28883
+ if (how === "end") fromEditor = "end";
28884
+ over.abort();
28885
+ });
28570
28886
  const pickAt = page && !guessed ? async (x, y) => {
28571
28887
  try {
28572
28888
  const found = await internalCall(page, () => pickAtPoint(page, probe, x, y));
@@ -28621,7 +28937,9 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28621
28937
  const onIntent = page && held2 ? (intent, ended) => intent === "assert" ? checkAt(page, testInfo, location, handoffReason, held2.stop, ended) : regionAt(page, location, held2.stop, ended) : void 0;
28622
28938
  const shown2 = withTestTimeoutHeld(testInfo, async () => {
28623
28939
  if (!bar || !page) {
28624
- console.log(stopLine(failure ? "failure" : reason, callSiteLine(location), title, runHost()));
28940
+ console.log(
28941
+ wait ? waitLine(failure ? "failure" : "pause", callSiteLine(location), wait.until) : stopLine(failure ? "failure" : reason, callSiteLine(location), shownTitle(title), runHost())
28942
+ );
28625
28943
  if (page && intents && held2) {
28626
28944
  const stop3 = held2.stop;
28627
28945
  await internalCall(
@@ -28640,7 +28958,7 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28640
28958
  page,
28641
28959
  {
28642
28960
  location,
28643
- call: title,
28961
+ call: shownTitle(title),
28644
28962
  attempt: testInfo.retry > 0 ? testInfo.retry + 1 : null,
28645
28963
  target: stoppedOn ? {
28646
28964
  highlight: () => highlightAtStop(
@@ -28661,6 +28979,7 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28661
28979
  )
28662
28980
  );
28663
28981
  }).finally(async () => {
28982
+ wait?.end();
28664
28983
  if (!end.signal.aborted) record.duration = Date.now() - record.startedAt;
28665
28984
  else if (end.signal.reason === "ended") releaseCall(sink, call?.settled ?? Promise.resolve());
28666
28985
  sink.shownStops.delete(end);
@@ -28678,12 +28997,18 @@ async function showStop(sink, context, calledAs, location, reason, call, of, fai
28678
28997
  const answer = await shown2;
28679
28998
  if (!end.signal.aborted) {
28680
28999
  const chosen = fromEditor ?? answer;
28681
- return chosen === "end" ? endTest(sink, call, title, location, reason) : chosen;
29000
+ if (chosen === "end" && livePause && wait) return endFromPiwi(sink, context, location, wait.by);
29001
+ return chosen === "end" ? endTest(sink, call, shownTitle(title), location, reason) : chosen;
28682
29002
  }
28683
29003
  if (end.signal.reason === "ended") return "finish";
28684
29004
  await settledWithin(stop2.after ? [stop2.after] : [], END_STOP_MS);
28685
29005
  return "resume";
28686
29006
  }
29007
+ function waitLine(kind, place, until) {
29008
+ const time = new Date(until).toISOString().slice(11, 19);
29009
+ const what = kind === "failure" ? `The test failed at ${place}: held` : `The test is paused at ${place}`;
29010
+ return `[piwi] ${what} for the people watching it on the run page, until ${time} UTC at the latest.`;
29011
+ }
28687
29012
  function endTest(sink, call, title, location, reason) {
28688
29013
  const line = callSiteLine(location);
28689
29014
  if (reason === "failure" || sink.functionEnded || !sink.testInfo) {
@@ -28707,6 +29032,37 @@ function endTest(sink, call, title, location, reason) {
28707
29032
  tellHub({ type: "notice", message: said });
28708
29033
  return "end";
28709
29034
  }
29035
+ function endedFromPiwiError(by) {
29036
+ return new Error(by ? `Ended from Piwi by ${by}` : "Ended from Piwi");
29037
+ }
29038
+ function endFromPiwi(sink, context, location, by) {
29039
+ const testInfo = sink.testInfo;
29040
+ const error = endedFromPiwiError(by);
29041
+ console.log(`[piwi] ${error.message} at ${callSiteLine(location)}: the test fails here.`);
29042
+ sink.ended = true;
29043
+ sink.skip = error;
29044
+ sink.end.abort(error);
29045
+ if (failNow(testInfo, error)) {
29046
+ sink.endedFromPiwi = context;
29047
+ ENDED_CONTEXTS.add(context);
29048
+ return "end";
29049
+ }
29050
+ const callbacks = testInfo._onDidFinishTestFunctionCallbacks;
29051
+ if (callbacks instanceof Set) {
29052
+ callbacks.add(() => {
29053
+ if (testInfo.status === "passed") throw error;
29054
+ });
29055
+ }
29056
+ return "end";
29057
+ }
29058
+ function failNow(testInfo, error) {
29059
+ const runner = testInfo;
29060
+ const reject = runner._timeoutManager?._running?.timeoutPromise?.reject;
29061
+ if (typeof runner._failWithError !== "function" || typeof reject !== "function") return false;
29062
+ runner._failWithError(error);
29063
+ reject.call(runner._timeoutManager._running.timeoutPromise, error);
29064
+ return true;
29065
+ }
28710
29066
  function endsNow(sink) {
28711
29067
  return sink.ended && !sink.functionEnded;
28712
29068
  }
@@ -28812,7 +29168,9 @@ function regionSecrets(region) {
28812
29168
  }
28813
29169
  async function holdFailure(sink, fallback) {
28814
29170
  const testInfo = sink.testInfo;
28815
- if (sink.failureHeld || !sink.pause || !testInfo || !editorShows("failure")) return;
29171
+ if (sink.failureHeld || !testInfo || sink.ended && sink.livePause) return;
29172
+ const local = !!sink.pause && editorShows("failure");
29173
+ if (!local && !liveViewMayHold()) return;
28816
29174
  const { status, expectedStatus } = testInfo;
28817
29175
  if (status !== "failed" && status !== "timedOut" || status === expectedStatus) return;
28818
29176
  const page = [sink.lastActivePage, fallback].find((open4) => !!open4 && !isPageClosed(open4));
@@ -28835,10 +29193,12 @@ async function holdFailure(sink, fallback) {
28835
29193
  await internalCall(page, () => readPageBeforeClose(sink, page)).catch(() => void 0);
28836
29194
  sink.frozenAt = Date.now();
28837
29195
  await stopSinkCodeReach(sink, { context });
28838
- const title = hideSecretsInText(`Failed: ${said.trim().slice(0, 300)}`).slice(0, 1e3);
29196
+ const title = cutText(hideSecretsInText(`Failed: ${cutText(said.trim(), 300)}`), 1e3);
28839
29197
  const errorText2 = failureError(error?.message ?? error?.value);
28840
- const named = errorText2 === null ? null : hideSecretsInText(errorText2).slice(0, MAX_STOP_ERROR);
28841
- await showStop(sink, context, title, location, "failure", void 0, { page }, { failed: failed2, error: named });
29198
+ const named = errorText2 === null ? null : cutText(hideSecretsInText(errorText2), MAX_STOP_ERROR);
29199
+ const hold = local ? null : liveViewHold();
29200
+ if (!local && !hold) return;
29201
+ await showStop(sink, context, title, location, "failure", void 0, { page }, { failed: failed2, error: named, hold });
28842
29202
  }
28843
29203
  var FAILURE_ERROR_LINES = 4;
28844
29204
  function failureError(message) {
@@ -28848,7 +29208,7 @@ function failureError(message) {
28848
29208
  lines.push(line.trimEnd());
28849
29209
  if (lines.length === FAILURE_ERROR_LINES) break;
28850
29210
  }
28851
- const text2 = lines.join("\n").slice(0, MAX_STOP_ERROR);
29211
+ const text2 = cutText(lines.join("\n"), MAX_STOP_ERROR);
28852
29212
  return text2.trim() ? text2 : null;
28853
29213
  }
28854
29214
  function errorPlace(error, windows = process.platform === "win32") {
@@ -29038,6 +29398,7 @@ function endStopsWithTestFunction(testInfo, sink) {
29038
29398
  callbacks.clear();
29039
29399
  callbacks.add(() => {
29040
29400
  sink.functionEnded = true;
29401
+ liveViewTestFunctionEnded();
29041
29402
  return endShownStops(sink, "ended");
29042
29403
  });
29043
29404
  for (const callback of theirs) callbacks.add(callback);
@@ -29616,7 +29977,7 @@ async function flushSink(sink, testInfo) {
29616
29977
  if (sink.stops.length > 0) {
29617
29978
  await testInfo.attach(ATTACHMENT_NAMES.pauses, {
29618
29979
  contentType: "application/json",
29619
- body: Buffer.from(JSON.stringify(sink.stops))
29980
+ body: Buffer.from(JSON.stringify(sink.stops.map((stop2) => ({ ...stop2, title: shownTitle(stop2.title) }))))
29620
29981
  });
29621
29982
  }
29622
29983
  if (sink.capturedLocators.length > 0) {
@@ -29826,7 +30187,7 @@ var runControl = {
29826
30187
  },
29827
30188
  giveUp(testId) {
29828
30189
  const sink = currentSink;
29829
- const waiting2 = sink?.testInfo ? callInProgress(sink.testInfo) : null;
30190
+ const waiting3 = sink?.testInfo ? callInProgress(sink.testInfo) : null;
29830
30191
  if (!sink?.testInfo || sink.testInfo.testId !== testId || sink.functionEnded || sink.ended) {
29831
30192
  if (sink?.pause) sink.pause.pause = false;
29832
30193
  pauseNextTest = false;
@@ -29836,13 +30197,13 @@ var runControl = {
29836
30197
  });
29837
30198
  return;
29838
30199
  }
29839
- const line = waiting2 ? `${runFile(waiting2.place.file)}:${waiting2.place.line}` : null;
30200
+ const line = waiting3 ? `${runFile(waiting3.place.file)}:${waiting3.place.line}` : null;
29840
30201
  const endable = !!line && [...sink.locatorCalls.values()].some((c) => c.endable && callSiteLine(c.location) === line);
29841
30202
  sink.ended = true;
29842
30203
  if (sink.pause) sink.pause.pause = false;
29843
30204
  skipAtFunctionEnd(sink);
29844
30205
  sink.end.abort(new Error(ENDED_AT_STOP_REASON));
29845
- const title = waiting2?.title ? hideSecretsInText(hideTypedText(waiting2.title)) : "its call";
30206
+ const title = waiting3?.title ? shownTitle(waiting3.title) : "its call";
29846
30207
  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.`;
29847
30208
  console.log(`[piwi] ${said}`);
29848
30209
  tellHub({ type: "notice", message: said });
@@ -29861,6 +30222,24 @@ var runControl = {
29861
30222
  void armStops(OPEN_CONTEXTS);
29862
30223
  }
29863
30224
  };
30225
+ 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.";
30226
+ onLiveViewPause({
30227
+ pause() {
30228
+ const sink = currentSink;
30229
+ if (!sink?.testInfo || sink.ended || sink.ending) return PAUSE_DROPPED.noTest;
30230
+ if (sink.functionEnded) return PAUSE_DROPPED.functionEnded;
30231
+ if ([...OPEN_CONTEXTS].some((context) => followsCallStream(context))) return FOLLOWED_BEFORE_PAUSE;
30232
+ sink.pause ??= pauseState(NO_BREAKPOINTS);
30233
+ sink.livePause = true;
30234
+ sink.pause.pause = true;
30235
+ void armStops(OPEN_CONTEXTS);
30236
+ return null;
30237
+ },
30238
+ drop() {
30239
+ const sink = currentSink;
30240
+ if (sink?.livePause && sink.pause) sink.pause.pause = false;
30241
+ }
30242
+ });
29864
30243
  var WAITING_WATCH_MS = 250;
29865
30244
  function watchWaiting(sink) {
29866
30245
  if (sink.waitingWatch) return;
@@ -29879,7 +30258,7 @@ ${file}:${call.place.line}` : "";
29879
30258
  const locatorCall = [...sink.locatorCalls.values()].find((c) => callSiteLine(c.location) === line);
29880
30259
  tellHub({
29881
30260
  type: "waiting",
29882
- title: hideSecretsInText(hideTypedText(call.title)).slice(0, MAX_WAITING_TITLE),
30261
+ title: shownTitle(call.title, { max: MAX_WAITING_TITLE }),
29883
30262
  place: { file, line: call.place.line, ...call.place.column > 0 ? { column: call.place.column } : {} },
29884
30263
  ms: locatorCall ? Math.max(0, Date.now() - locatorCall.startedAt) : null,
29885
30264
  endable: !!locatorCall?.endable
@@ -30005,7 +30384,7 @@ var piwiFixtures = {
30005
30384
  else if (pauseSet.size) logPauseSkipOnce(cannotPause);
30006
30385
  }
30007
30386
  pauseNextTest = false;
30008
- if (sink.pause || canRecordFromHere()) endStopsWithTestFunction(testInfo, sink);
30387
+ if (sink.pause || canRecordFromHere() || liveViewOpen()) endStopsWithTestFunction(testInfo, sink);
30009
30388
  if (channel) tellHub(testBegin(testInfo, cannotPause));
30010
30389
  if (channel && sink.pause) startKeeping();
30011
30390
  if (isFlakeMode()) {
@@ -30052,10 +30431,11 @@ var piwiFixtures = {
30052
30431
  sink.ending = true;
30053
30432
  await endShownStops(sink, "ended");
30054
30433
  await awaitReleasedCalls(sink);
30434
+ if (liveViewMayHold() && sink.lastActivePage && !isPageClosed(sink.lastActivePage)) await holdFailure(sink);
30055
30435
  await liveViewTestEnded(liveOutcomeStatus(testInfo));
30056
30436
  showRunChannel();
30057
30437
  currentSink = null;
30058
- if (sink.pause?.pause) pauseNextTest = true;
30438
+ if (sink.pause?.pause && !sink.livePause) pauseNextTest = true;
30059
30439
  if (sink.probeItem) {
30060
30440
  const applied = sink.probeInterception?.applied() ?? false;
30061
30441
  const level = sink.probeItem.level ?? "client";