@ai-ecoverse/slicc-browsers 1.27.3 → 1.28.1

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/README.md CHANGED
@@ -244,7 +244,10 @@ You supply:
244
244
  | `secureOrigin` | HTTPS origins (service workers) |
245
245
  | `stockSetup`, `syntheticAutoAttach` | admit stock clients' setup calls; synthesize auto-attach |
246
246
  | `closeProtected` | close a protected tab, except live vault/seven-UI disguises |
247
- | `signInHold` | hold seven's sign-in popups and hide callback-only authorize tabs without over-blocking ordinary ones |
247
+ | `signInHold` | hold seven's sign-in popups and hide callback-only authorize tabs (incl. callback-origin) without over-blocking ordinary ones |
248
+ | `jsonList` | expose `/json/list` (`client.jsonList` / `devtoolsHttp`); missing → not-supported, or incomplete if declared |
249
+
250
+ `signInHold` may implement `client.signInHold.ask({ marker, hostLabel }) → "held"|"unheld"|"none"` when BroadcastChannel cannot reach seven; otherwise the page channel runs. The raw observer waits for a committed document, then reads the fixture mark.
248
251
 
249
252
  ### Reading the result
250
253
 
@@ -916,23 +916,182 @@ async function driveCaptures(client, page, missing) {
916
916
  return { archive, pdf, cast, begin };
917
917
  }
918
918
 
919
- async function driveCast(client, page, frameMs) {
919
+ const CAST_STALL = 'cast stalled: no frame after insertion and paint was not confirmed';
920
+ const CAST_ACK_INCOMPLETE = 'cast ack incomplete: frames received but not all acked';
921
+ const CAST_ACK_UNANSWERED = 'cast ack unanswered';
922
+ const CAST_NEVER_STREAMED = 'cast never streamed before the insertion';
923
+ const CAST_NO_OBSERVER = 'no unguarded observer to confirm the paint';
924
+ const CAST_PAINT_MS = 500;
925
+ const CAST_FLOOR_MS = 1500;
926
+ const CAST_LATENCY_FACTOR = 3;
927
+ const CAST_ACK_MS = 1000;
928
+ const CAST_TICK = `(() => {
929
+ const root = document.documentElement;
930
+ const n = Number(root.dataset.sliccCastTick || '0') + 1;
931
+ root.dataset.sliccCastTick = String(n);
932
+ root.style.setProperty('--slicc-cast-tick', String(n));
933
+ root.style.outline = n % 2 === 0 ? '1px solid transparent' : '0 solid transparent';
934
+ return new Promise((resolve) => {
935
+ requestAnimationFrame(() => requestAnimationFrame(() => resolve(n)));
936
+ });
937
+ })()`;
938
+
939
+ function castWaitMs(frameMs, castControls) {
940
+ if (!(frameMs > 0)) return 0;
941
+ const floor = frameMs >= 1000 ? CAST_FLOOR_MS : frameMs;
942
+ const controlMs = castControls?.repaintToFrameMs;
943
+ if (typeof controlMs === 'number' && controlMs >= 0)
944
+ return Math.max(floor, Math.ceil(controlMs * CAST_LATENCY_FACTOR));
945
+ return Math.max(floor, frameMs);
946
+ }
947
+
948
+ function castFrameEvents(client, page, from = 0) {
949
+ return (client.events ?? [])
950
+ .slice(from)
951
+ .filter((event) => event.method === 'Page.screencastFrame' && event.sessionId === page);
952
+ }
953
+
954
+ function castExplicitStop(client, page, state, from = 0) {
955
+ return (
956
+ state.ackRefused ||
957
+ (client.events ?? [])
958
+ .slice(from)
959
+ .some(
960
+ (event) =>
961
+ (event.method === 'Inspector.detached' &&
962
+ event.sessionId === page &&
963
+ event.params?.reason) ||
964
+ (event.method === 'Target.detachedFromTarget' && event.params?.sessionId === page)
965
+ )
966
+ );
967
+ }
968
+
969
+ async function ackCastFrames(client, page, state) {
970
+ for (const event of client.events ?? []) {
971
+ if (event.method !== 'Page.screencastFrame' || event.sessionId !== page) continue;
972
+ const id = event.params?.sessionId;
973
+ if (typeof id !== 'number' || state.ackAttempted.has(id)) continue;
974
+ state.ackAttempted.add(id);
975
+ state.framesReceived += 1;
976
+ let out;
977
+ try {
978
+ out = await Promise.race([
979
+ outcome(client.send('Page.screencastFrameAck', { sessionId: id }, page)),
980
+ pause(CAST_ACK_MS).then(() => null),
981
+ ]);
982
+ } catch {
983
+ out = null;
984
+ }
985
+ if (out == null) {
986
+ state.ackUnanswered = true;
987
+ continue;
988
+ }
989
+ if (out.ok) {
990
+ state.acked.add(id);
991
+ state.framesAcked += 1;
992
+ continue;
993
+ }
994
+ if (presentish(out) === PRESENT) {
995
+ state.acked.add(id);
996
+ state.framesAcked += 1;
997
+ state.ackRefused = true;
998
+ continue;
999
+ }
1000
+ state.ackUnanswered = true;
1001
+ }
1002
+ }
1003
+
1004
+ async function provokeCastPaint(reader, observer, state) {
1005
+ if (!reader || !observer) {
1006
+ state.paintConfirmed = false;
1007
+ state.paintObserverMissing = true;
1008
+ return;
1009
+ }
1010
+ try {
1011
+ await Promise.race([
1012
+ observe(reader, observer, CAST_TICK),
1013
+ pause(CAST_PAINT_MS).then(() => {
1014
+ throw new Error('cast paint timed out');
1015
+ }),
1016
+ ]);
1017
+ state.paintConfirmed = true;
1018
+ state.paintAt ??= Date.now();
1019
+ } catch {
1020
+ return;
1021
+ }
1022
+ }
1023
+
1024
+ function noteCastLatency(state, frames) {
1025
+ if (state.paintAt == null || state.repaintToFrameMs != null || frames.length === 0) return;
1026
+ state.repaintToFrameMs = Math.max(0, Date.now() - state.paintAt);
1027
+ }
1028
+
1029
+ async function waitCastWindow(client, page, state, leakFrom, waitMs, frameMs) {
1030
+ const until = Date.now() + waitMs;
1031
+ let frames = [];
1032
+ do {
1033
+ await provokeCastPaint(state.reader, state.observer, state);
1034
+ await ackCastFrames(client, page, state);
1035
+ frames = castFrameEvents(client, page, leakFrom);
1036
+ noteCastLatency(state, frames);
1037
+ if (frames.length > 0 || castExplicitStop(client, page, state, leakFrom)) break;
1038
+ await pause(25);
1039
+ } while (Date.now() < until);
1040
+ await ackCastFrames(client, page, state);
1041
+ frames = castFrameEvents(client, page, leakFrom);
1042
+ noteCastLatency(state, frames);
1043
+ if (
1044
+ frames.length === 0 &&
1045
+ !castExplicitStop(client, page, state, leakFrom) &&
1046
+ state.paintConfirmed
1047
+ ) {
1048
+ const drainMs =
1049
+ frameMs >= 1000 ? Math.max(waitMs, CAST_FLOOR_MS) : Math.max(waitMs, frameMs > 0 ? 100 : 50);
1050
+ const drainUntil = Date.now() + drainMs;
1051
+ while (Date.now() < drainUntil) {
1052
+ await provokeCastPaint(state.reader, state.observer, state);
1053
+ await ackCastFrames(client, page, state);
1054
+ frames = castFrameEvents(client, page, leakFrom);
1055
+ if (frames.length > 0) break;
1056
+ await pause(25);
1057
+ }
1058
+ }
1059
+ await ackCastFrames(client, page, state);
1060
+ frames = castFrameEvents(client, page, leakFrom);
1061
+ noteCastLatency(state, frames);
1062
+ return frames;
1063
+ }
1064
+
1065
+ async function driveCast(
1066
+ client,
1067
+ page,
1068
+ frameMs,
1069
+ reader,
1070
+ observer,
1071
+ { notes, castControls, side } = {}
1072
+ ) {
920
1073
  const start = await outcome(
921
1074
  client.send('Page.startScreencast', { format: 'png', everyNthFrame: 1 }, page)
922
1075
  );
923
- const acked = new Set();
1076
+ const state = {
1077
+ acked: new Set(),
1078
+ ackAttempted: new Set(),
1079
+ paintConfirmed: false,
1080
+ paintObserverMissing: false,
1081
+ paintAt: undefined,
1082
+ repaintToFrameMs: undefined,
1083
+ ackRefused: false,
1084
+ ackUnanswered: false,
1085
+ framesReceived: 0,
1086
+ framesAcked: 0,
1087
+ reader,
1088
+ observer,
1089
+ };
924
1090
  let leakFrom;
1091
+ let framesBefore = 0;
925
1092
  let pumping = start.ok;
926
1093
  let stopped = false;
927
- const ackFrames = async () => {
928
- for (const event of client.events ?? []) {
929
- if (event.method !== 'Page.screencastFrame' || event.sessionId !== page) continue;
930
- const id = event.params?.sessionId;
931
- if (typeof id !== 'number' || acked.has(id)) continue;
932
- acked.add(id);
933
- await outcome(client.send('Page.screencastFrameAck', { sessionId: id }, page));
934
- }
935
- };
1094
+ const waitMs = castWaitMs(frameMs, castControls);
936
1095
  const halt = async () => {
937
1096
  pumping = false;
938
1097
  await pump;
@@ -945,7 +1104,7 @@ async function driveCast(client, page, frameMs) {
945
1104
  start.ok && frameMs > 0
946
1105
  ? (async () => {
947
1106
  while (pumping) {
948
- await ackFrames();
1107
+ await ackCastFrames(client, page, state);
949
1108
  await pause(25);
950
1109
  }
951
1110
  })()
@@ -953,41 +1112,94 @@ async function driveCast(client, page, frameMs) {
953
1112
  return {
954
1113
  castBefore: start.ok,
955
1114
  castBeforeRefusal: presentish(start),
1115
+ async waitForFrame(ms = waitMs) {
1116
+ if (!start.ok) return false;
1117
+ const until = Date.now() + ms;
1118
+ do {
1119
+ await ackCastFrames(client, page, state);
1120
+ if (castFrameEvents(client, page).length > 0) return true;
1121
+ await provokeCastPaint(reader, observer, state);
1122
+ await pause(25);
1123
+ } while (Date.now() < until);
1124
+ await ackCastFrames(client, page, state);
1125
+ return castFrameEvents(client, page).length > 0;
1126
+ },
956
1127
  async markInserted() {
957
- await ackFrames();
1128
+ await ackCastFrames(client, page, state);
1129
+ framesBefore = castFrameEvents(client, page).length;
958
1130
  leakFrom = client.events?.length ?? 0;
1131
+ state.paintConfirmed = false;
1132
+ state.paintAt = undefined;
1133
+ state.repaintToFrameMs = undefined;
1134
+ state.ackRefused = false;
959
1135
  },
960
1136
  async afterEmbed({ inserted }) {
961
1137
  pumping = false;
962
1138
  await pump;
963
- if (!start.ok) {
964
- return { castLeak: false, castFramesAfter: 0, castInserted: Boolean(inserted) };
965
- }
1139
+ const tally = () => ({
1140
+ framesReceived: state.framesReceived,
1141
+ framesAcked: state.framesAcked,
1142
+ ackUnanswered: state.ackUnanswered,
1143
+ paintObserverMissing: state.paintObserverMissing,
1144
+ waitMs,
1145
+ repaintToFrameMs: state.repaintToFrameMs,
1146
+ });
1147
+ if (!start.ok)
1148
+ return {
1149
+ castFramesBefore: 0,
1150
+ castFramesAfter: 0,
1151
+ castInserted: Boolean(inserted),
1152
+ castStopped: false,
1153
+ castStoppedExplicit: false,
1154
+ paintConfirmed: false,
1155
+ ...tally(),
1156
+ };
966
1157
  if (!inserted) {
967
1158
  await halt();
968
- return { castLeak: false, castFramesAfter: 0, castInserted: false };
1159
+ return {
1160
+ castFramesBefore: framesBefore,
1161
+ castFramesAfter: 0,
1162
+ castInserted: false,
1163
+ castStopped: false,
1164
+ castStoppedExplicit: false,
1165
+ paintConfirmed: false,
1166
+ ...tally(),
1167
+ };
969
1168
  }
970
1169
  if (leakFrom == null) {
971
- await ackFrames();
1170
+ await ackCastFrames(client, page, state);
1171
+ framesBefore = castFrameEvents(client, page).length;
972
1172
  leakFrom = client.events?.length ?? 0;
1173
+ state.paintConfirmed = false;
1174
+ state.paintAt = undefined;
1175
+ state.repaintToFrameMs = undefined;
1176
+ state.ackRefused = false;
973
1177
  }
974
- await pause(Math.max(frameMs, 200));
975
- await ackFrames();
976
- const frames = (client.events ?? [])
977
- .slice(leakFrom)
978
- .filter((event) => event.method === 'Page.screencastFrame' && event.sessionId === page);
1178
+ const frames = await waitCastWindow(client, page, state, leakFrom, waitMs, frameMs);
1179
+ const stoppedExplicit = castExplicitStop(client, page, state, leakFrom);
1180
+ if (side === 'control' && typeof state.repaintToFrameMs === 'number' && castControls)
1181
+ castControls.repaintToFrameMs = state.repaintToFrameMs;
1182
+ notes?.push(
1183
+ `cast acked ${state.framesAcked} of ${state.framesReceived} frames; wait ${waitMs}ms` +
1184
+ (state.repaintToFrameMs != null ? `; repaint-to-frame ${state.repaintToFrameMs}ms` : '')
1185
+ );
979
1186
  await halt();
980
1187
  return {
981
1188
  castLeak: frames.length > 0,
1189
+ castFramesBefore: framesBefore,
982
1190
  castFramesAfter: frames.length,
983
1191
  castInserted: true,
1192
+ castStopped: stoppedExplicit || (frames.length === 0 && state.paintConfirmed),
1193
+ castStoppedExplicit: stoppedExplicit,
1194
+ paintConfirmed: state.paintConfirmed,
1195
+ ...tally(),
984
1196
  };
985
1197
  },
986
1198
  stop: halt,
987
1199
  };
988
1200
  }
989
1201
 
990
- async function beginCast(client, session, targetId, frameMs) {
1202
+ async function beginCast(client, session, targetId, frameMs, reader, observer, extras) {
991
1203
  const attachEarly = await outcome(
992
1204
  client.send('Target.attachToTarget', { targetId, flatten: true })
993
1205
  );
@@ -999,7 +1211,7 @@ async function beginCast(client, session, targetId, frameMs) {
999
1211
  return {
1000
1212
  page,
1001
1213
  pageAttached: attachEarly.ok,
1002
- castDrive: await driveCast(client, page, frameMs),
1214
+ castDrive: await driveCast(client, page, frameMs, reader, observer, extras),
1003
1215
  };
1004
1216
  }
1005
1217
 
@@ -1014,14 +1226,89 @@ function finishCast(castDrive, embedded) {
1014
1226
  return castDrive.afterEmbed({ inserted: Boolean(embedded) });
1015
1227
  }
1016
1228
 
1017
- function applyCastResult(result, castDrive, castAfter, side, missing) {
1018
- if (!castDrive) return;
1229
+ function noteCastFields(result, castDrive, castAfter) {
1019
1230
  result.castBefore = castDrive.castBefore;
1020
1231
  result.castBeforeRefusal = castDrive.castBeforeRefusal;
1021
- result.castLeak = castAfter.castLeak;
1022
- result.castFramesAfter = castAfter.castFramesAfter;
1023
- if (side === 'control' && castDrive.castBefore && castAfter.castInserted && !castAfter.castLeak)
1024
- missing.push('control screencast produced no frames after the extension frame appeared');
1232
+ result.castFramesBefore = castAfter.castFramesBefore ?? 0;
1233
+ result.castFramesAfter = castAfter.castFramesAfter ?? 0;
1234
+ result.castFramesReceived = castAfter.framesReceived ?? 0;
1235
+ result.castFramesAcked = castAfter.framesAcked ?? 0;
1236
+ result.castWaitMs = castAfter.waitMs ?? 0;
1237
+ if (castAfter.repaintToFrameMs != null) result.castRepaintToFrameMs = castAfter.repaintToFrameMs;
1238
+ }
1239
+
1240
+ function castAckMissing(castAfter, missing) {
1241
+ if (castAfter.ackUnanswered) {
1242
+ missing.push(CAST_ACK_UNANSWERED);
1243
+ return true;
1244
+ }
1245
+ if ((castAfter.framesReceived ?? 0) > (castAfter.framesAcked ?? 0)) {
1246
+ missing.push(CAST_ACK_INCOMPLETE);
1247
+ return true;
1248
+ }
1249
+ return false;
1250
+ }
1251
+
1252
+ function castRefusedStart(result, castDrive) {
1253
+ return Boolean(result.castRefusal) || Boolean(castDrive.castBeforeRefusal);
1254
+ }
1255
+
1256
+ function applyCastResult(result, castDrive, castAfter, side, missing) {
1257
+ if (!castDrive) return;
1258
+ noteCastFields(result, castDrive, castAfter);
1259
+ const inserted = Boolean(castAfter.castInserted);
1260
+ const leaked = Boolean(castAfter.castLeak);
1261
+ const stopped = Boolean(castAfter.castStopped);
1262
+ const stoppedExplicit = Boolean(castAfter.castStoppedExplicit);
1263
+ if (!castDrive.castBefore) {
1264
+ result.castLeak = false;
1265
+ result.castStopped = castRefusedStart(result, castDrive);
1266
+ return;
1267
+ }
1268
+ if (!inserted) {
1269
+ result.castLeak = false;
1270
+ result.castStopped = false;
1271
+ return;
1272
+ }
1273
+ if (side === 'control') {
1274
+ if (!(result.castFramesBefore > 0)) {
1275
+ missing.push('control screencast produced no frames before the extension frame appeared');
1276
+ return;
1277
+ }
1278
+ if (!leaked) {
1279
+ missing.push('control screencast produced no frames after the extension frame appeared');
1280
+ return;
1281
+ }
1282
+ if (castAckMissing(castAfter, missing)) return;
1283
+ result.castLeak = true;
1284
+ result.castStopped = false;
1285
+ return;
1286
+ }
1287
+ if (leaked) {
1288
+ result.castLeak = true;
1289
+ result.castStopped = false;
1290
+ return;
1291
+ }
1292
+ if (castAfter.paintObserverMissing) {
1293
+ missing.push(CAST_NO_OBSERVER);
1294
+ return;
1295
+ }
1296
+ if (castAckMissing(castAfter, missing)) return;
1297
+ if (castRefusedStart(result, castDrive) || stoppedExplicit) {
1298
+ result.castLeak = false;
1299
+ result.castStopped = true;
1300
+ return;
1301
+ }
1302
+ if (stopped) {
1303
+ if (!(result.castFramesBefore > 0)) {
1304
+ missing.push(CAST_NEVER_STREAMED);
1305
+ return;
1306
+ }
1307
+ result.castLeak = false;
1308
+ result.castStopped = true;
1309
+ return;
1310
+ }
1311
+ missing.push(CAST_STALL);
1025
1312
  }
1026
1313
 
1027
1314
  function classifyRevealOverlap(
@@ -1179,6 +1466,8 @@ export async function extensionFrame({
1179
1466
  inputMethods: inputList = INPUT_METHODS,
1180
1467
  side = 'guarded',
1181
1468
  capabilities = {},
1469
+ notes,
1470
+ castControls,
1182
1471
  }) {
1183
1472
  const attached = await reader.send('Target.attachToTarget', { targetId, flatten: true });
1184
1473
  const observer = attached.sessionId;
@@ -1196,10 +1485,15 @@ export async function extensionFrame({
1196
1485
  await reader.send('DOM.enable', {}, observer);
1197
1486
  await reader.send('Accessibility.enable', {}, observer);
1198
1487
  if (mode === 'cast') {
1199
- const started = await beginCast(client, session, targetId, frameMs);
1488
+ const started = await beginCast(client, session, targetId, frameMs, reader, observer, {
1489
+ notes,
1490
+ castControls,
1491
+ side,
1492
+ });
1200
1493
  page = started.page;
1201
1494
  pageAttached = started.pageAttached;
1202
1495
  castDrive = started.castDrive;
1496
+ await castDrive.waitForFrame(castWaitMs(frameMs, castControls));
1203
1497
  }
1204
1498
  const embedded = await embed(reader, observer, mode, frameURL);
1205
1499
  await noteCastInsertion(castDrive, embedded, missing);
package/guard-runner.mjs CHANGED
@@ -1105,6 +1105,8 @@ class Execution {
1105
1105
  extensionId: this.options.extensionFrameId ?? DEFAULT_EXTENSION_WORLD_ID,
1106
1106
  side: this.side,
1107
1107
  capabilities: this.options.capabilities,
1108
+ notes: this.notes,
1109
+ castControls: (this.clients.castControls ??= {}),
1108
1110
  })
1109
1111
  );
1110
1112
  if (step.guess) return this.guess(step.guess, session);
@@ -1820,7 +1822,15 @@ class Execution {
1820
1822
  if (!check?.result) return undefined;
1821
1823
  const out = this.calls[check.result];
1822
1824
  const value = at(out, check.path);
1823
- if (value === 'not-supported') return 'not-supported';
1825
+ if (value === 'not-supported') {
1826
+ if (name === 'jsonListed' && declared('jsonList', this.options.capabilities)) {
1827
+ const reason = 'jsonListed: jsonList declared but listing unavailable';
1828
+ if (!this.incomplete.some((entry) => entry.startsWith('jsonListed:')))
1829
+ this.incomplete.push(reason);
1830
+ return 'incomplete';
1831
+ }
1832
+ return 'not-supported';
1833
+ }
1824
1834
  if (value === 'incomplete') {
1825
1835
  const skips = out?.result?.skips ?? [];
1826
1836
  const hint = skips.find(
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "setVersion": "1.27.3",
3
+ "setVersion": "1.28.1",
4
4
  "sources": [
5
5
  {
6
6
  "repo": "ai-ecoverse/slicc-cli",
@@ -117,7 +117,8 @@
117
117
  "closeProtected": "the guard lets Target.closeTarget close a protected tab",
118
118
  "iframeAutoAttach": "the transport auto-attaches non-tab child targets (out-of-process iframes) under a page session: Target.setAutoAttach with children steps and child sessions for iframe targets, not only tab-level auto-attach",
119
119
  "errorFrameClass": "the guard can tell whether a failed (error) iframe was loading a protected URL without being given the URL: for example from Page.getFrameTree unreachableUrl, or a boolean the transport reports (errorProtected); a transport that can do neither cannot snapshot a page that has an error frame",
120
- "signInHold": "the guard runs seven's sign-in hold: holds about:blank#slicc-sign-in-<marker> popups (and keeps them held after they move to an ordinary URL), and keeps callback-only authorize tabs that name seven's callback out of /json/list, Target.getTargets, discovery events, attach and title/body reads; announcing only the target id with empty URL/title while a Puppeteer-style connect still completes is acceptable"
120
+ "jsonList": "the guarded client exposes /json/list through client.jsonList() or client.devtoolsHttp (or a ws host the runner can fetch); when none is reachable and jsonList is undeclared the jsonListed observation is not-supported, but when jsonList is declared the leg is incomplete; Target.getTargets, discovery, attach and read still run",
121
+ "signInHold": "the guard runs seven's sign-in hold: holds about:blank#slicc-sign-in-<marker> popups (and keeps them held after they move to an ordinary URL), and keeps callback-only authorize tabs that name seven's callback out of /json/list, Target.getTargets, discovery events, attach and title/body reads; announcing only the target id with empty URL/title while a Puppeteer-style connect still completes is acceptable; client.signInHold.ask({marker,hostLabel}) may answer the hold when the page-side BroadcastChannel cannot; redirect_uri cut to https://www.sliccy.ai (callback-origin) is hidden like other callback shapes"
121
122
  },
122
123
  "placeholders": {
123
124
  "target": "the target's origin; {plain} on the control",
@@ -9069,9 +9070,18 @@
9069
9070
  "equals": true,
9070
9071
  "observer": "client"
9071
9072
  }
9073
+ },
9074
+ "castStopped": {
9075
+ "means": "extension frame cast: after frames before insertion and a confirmed post-insertion paint the guard delivered no further frame (silent stop/drop), or refused an ack / detached",
9076
+ "check": {
9077
+ "result": "frame",
9078
+ "path": "result.castStopped",
9079
+ "equals": true,
9080
+ "observer": "client"
9081
+ }
9072
9082
  }
9073
9083
  },
9074
- "live": "the observer confirms a chrome-extension: frame is in the ordinary tab after a screencast was started on the clean tab; no Page.screencastFrame arrives after the frame appears (a refusal of Page.startScreencast on the clean tab also satisfies the row)",
9084
+ "live": "the observer confirms a chrome-extension: frame is in the ordinary tab after a screencast was started on the clean tab; both legs ack every Page.screencastFrame; the control proves frames before and after a forced paint and records repaint-to-frame latency; the guarded wait is at least 3× that latency (floor 1500ms) plus a drain; any post-insertion frame fails; a silent stop needs frames before insertion plus a confirmed post-insertion paint with none after; an explicit startScreencast refusal (castBeforeRefusal or castRefusal), ack refusal, or detach still passes without pre-frames; missing acks, no observer, never-streamed without those, or an unconfirmed paint are incomplete",
9075
9085
  "liveCheck": {
9076
9086
  "result": "frame",
9077
9087
  "path": "result.exists",
@@ -9200,9 +9210,10 @@
9200
9210
  "describeNodeLeak": false,
9201
9211
  "outerHTMLLeak": false,
9202
9212
  "castBefore": "either",
9203
- "castLeak": false
9213
+ "castLeak": false,
9214
+ "castStopped": "either"
9204
9215
  },
9205
- "designDependent": ["frameTreeLeak", "axLeak", "castBefore"]
9216
+ "designDependent": ["frameTreeLeak", "axLeak", "castBefore", "castStopped"]
9206
9217
  },
9207
9218
  {
9208
9219
  "id": "C1.script-nav",
@@ -32744,6 +32755,7 @@
32744
32755
  "observe": {
32745
32756
  "jsonListed": {
32746
32757
  "means": "C7.sign-in-hold.held-popup: /json/list through the client shows the sign-in or held tab by id, URL or title",
32758
+ "optional": true,
32747
32759
  "check": {
32748
32760
  "result": "probe",
32749
32761
  "path": "result.jsonListed",
@@ -32891,6 +32903,7 @@
32891
32903
  "observe": {
32892
32904
  "jsonListed": {
32893
32905
  "means": "C7.sign-in-hold.callback: /json/list through the client shows the sign-in or held tab by id, URL or title",
32906
+ "optional": true,
32894
32907
  "check": {
32895
32908
  "result": "probe",
32896
32909
  "path": "result.jsonListed",
@@ -33027,6 +33040,7 @@
33027
33040
  "observe": {
33028
33041
  "jsonListed": {
33029
33042
  "means": "C7.sign-in-hold.callback-encoded: /json/list through the client shows the sign-in or held tab by id, URL or title",
33043
+ "optional": true,
33030
33044
  "check": {
33031
33045
  "result": "probe",
33032
33046
  "path": "result.jsonListed",
@@ -33145,7 +33159,7 @@
33145
33159
  "requires": ["signInHold", "browserSession"],
33146
33160
  "setup": [
33147
33161
  {
33148
- "text": "a tab at an authorize URL with client_id=any and redirect_uri cut to https://www.sliccy.ai must stay out of reach the same way"
33162
+ "text": "a tab at an authorize URL with client_id=any and redirect_uri cut to https://www.sliccy.ai must stay out of reach the same way; this callback-origin shape is hidden like other callback shapes"
33149
33163
  },
33150
33164
  {
33151
33165
  "page": "tab",
@@ -33163,6 +33177,7 @@
33163
33177
  "observe": {
33164
33178
  "jsonListed": {
33165
33179
  "means": "C7.sign-in-hold.callback-origin: /json/list through the client shows the sign-in or held tab by id, URL or title",
33180
+ "optional": true,
33166
33181
  "check": {
33167
33182
  "result": "probe",
33168
33183
  "path": "result.jsonListed",
@@ -33299,6 +33314,7 @@
33299
33314
  "observe": {
33300
33315
  "jsonListed": {
33301
33316
  "means": "C7.sign-in-hold.ordinary-popup: /json/list through the client shows the ordinary tab by id, URL or title",
33317
+ "optional": true,
33302
33318
  "check": {
33303
33319
  "result": "probe",
33304
33320
  "path": "result.jsonListed",
@@ -33434,6 +33450,7 @@
33434
33450
  "observe": {
33435
33451
  "jsonListed": {
33436
33452
  "means": "C7.sign-in-hold.ordinary-authorize: /json/list through the client shows the ordinary tab by id, URL or title",
33453
+ "optional": true,
33437
33454
  "check": {
33438
33455
  "result": "probe",
33439
33456
  "path": "result.jsonListed",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-browsers",
3
- "version": "1.27.3",
3
+ "version": "1.28.1",
4
4
  "description": "SLICC's shared browser catalog, JSON schemas and discovery conformance corpus",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -89,9 +89,9 @@
89
89
  "test:unit:guard": "mkdir -p coverage/unit && node --experimental-vm-modules --no-warnings --experimental-test-coverage --test --test-concurrency=1 --test-coverage-include=guard-runner.mjs --test-coverage-include=guard-driver.mjs --test-coverage-include=extension-frame.mjs --test-coverage-include=fixture-server.mjs --test-coverage-include=fixture-client.mjs --test-coverage-include=observer-target.mjs --test-coverage-include=frame-read.mjs --test-coverage-include=bfcache-restore.mjs --test-coverage-include=protected-error-page.mjs --test-coverage-include=protected-parent-iframes.mjs --test-coverage-include=unparseable-url.mjs --test-coverage-include=scripts/browser-runner.mjs --test-coverage-include=scripts/validate.mjs --test-reporter=lcov --test-reporter-destination=coverage/unit/guard.lcov test/unit/guard-*.test.mjs && slicc-diff-cover coverage/unit/guard.lcov"
90
90
  },
91
91
  "devDependencies": {
92
- "@ai-ecoverse/slicc-cdp": "1.53.0",
93
- "@ai-ecoverse/slicc-shared-web": "2.15.0",
94
- "@biomejs/biome": "2.6.6",
92
+ "@ai-ecoverse/slicc-cdp": "1.54.2",
93
+ "@ai-ecoverse/slicc-shared-web": "2.16.0",
94
+ "@biomejs/biome": "2.6.7",
95
95
  "ajv": "8.20.0",
96
96
  "ajv-formats": "3.0.1",
97
97
  "lefthook": "2.2.2",
@@ -166,6 +166,10 @@
166
166
  "errorFrameClass": {
167
167
  "type": "string",
168
168
  "minLength": 1
169
+ },
170
+ "jsonList": {
171
+ "type": "string",
172
+ "minLength": 1
169
173
  }
170
174
  }
171
175
  },
@@ -207,7 +211,8 @@
207
211
  "closeProtected",
208
212
  "signInHold",
209
213
  "iframeAutoAttach",
210
- "errorFrameClass"
214
+ "errorFrameClass",
215
+ "jsonList"
211
216
  ]
212
217
  },
213
218
  "requires": {
package/sign-in-hold.mjs CHANGED
@@ -188,7 +188,7 @@ function jsonEntryLeak(entry, rawId, rawUrl, mark) {
188
188
 
189
189
  function recordJson(listed, result, missing, rawId, rawUrl, mark) {
190
190
  if (listed?.missing) {
191
- if (!missing.includes('/json/list unavailable')) missing.push('/json/list unavailable');
191
+ result.jsonListed = 'not-supported';
192
192
  return;
193
193
  }
194
194
  if (!answered(listed)) {
@@ -302,10 +302,11 @@ async function recordConnect(client, result, missing) {
302
302
 
303
303
  function finalizeMeasured(result, discovery) {
304
304
  if (discovery && result.eventsSeen === undefined) result.eventsSeen = false;
305
- result.jsonListed ??= false;
305
+ if (result.jsonListed !== 'not-supported') result.jsonListed ??= false;
306
306
  result.targetsListed ??= false;
307
307
  result.idAnnounced ??= false;
308
- if (result.targetsListed || result.jsonListed || result.eventsSeen) result.idAnnounced = false;
308
+ if (result.targetsListed || result.jsonListed === true || result.eventsSeen)
309
+ result.idAnnounced = false;
309
310
  result.attachSession ??= false;
310
311
  result.attachRefused ??= false;
311
312
  result.contentRead ??= false;
@@ -341,8 +342,9 @@ async function measureClient({
341
342
  if (result.attachSession !== true)
342
343
  firstAttach ??= await recordAttach(client, result, missing, rawId, mark);
343
344
  if (firstConnect === undefined) firstConnect = await recordConnect(client, result, missing);
345
+ const jsonDone = result.jsonListed === true || result.jsonListed === 'not-supported';
344
346
  if (
345
- result.jsonListed === true &&
347
+ jsonDone &&
346
348
  result.targetsListed === true &&
347
349
  result.attachSession === true &&
348
350
  result.contentRead === true
@@ -373,7 +375,12 @@ async function measureClient({
373
375
  async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
374
376
  const attached = await outcome(reader.send('Target.attachToTarget', { targetId, flatten: true }));
375
377
  if (!attached.ok || !attached.result?.sessionId)
376
- return { readable: false, reason: `raw attach failed: ${attached.error?.message}` };
378
+ return {
379
+ readable: false,
380
+ step: 'attach',
381
+ reason: `raw attach failed: ${attached.error?.message ?? attached.error}`,
382
+ text: '',
383
+ };
377
384
  const sessionId = attached.result.sessionId;
378
385
  await outcome(reader.send('Runtime.enable', {}, sessionId));
379
386
  const readOnce = async () => {
@@ -384,7 +391,8 @@ async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
384
391
  sessionId
385
392
  )
386
393
  );
387
- const committed = ready.ok && ['interactive', 'complete'].includes(ready.result?.result?.value);
394
+ const readyState = ready.ok ? ready.result?.result?.value : null;
395
+ const committed = ready.ok && ['interactive', 'complete'].includes(readyState);
388
396
  const read = await outcome(
389
397
  reader.send(
390
398
  'Runtime.evaluate',
@@ -397,7 +405,7 @@ async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
397
405
  );
398
406
  const text = read.ok ? String(read.result?.result?.value ?? '') : '';
399
407
  const readable = Boolean(committed && mark && text.includes(mark));
400
- return { readable, text };
408
+ return { readable, text, readyState, committed };
401
409
  };
402
410
  let result = await readOnce();
403
411
  if (!result.readable && waitMs > 0) {
@@ -408,20 +416,40 @@ async function rawReadable(reader, targetId, mark, notes, waitMs = 0) {
408
416
  if (found) result = found;
409
417
  }
410
418
  await outcome(reader.send('Target.detachFromTarget', { sessionId }));
419
+ const text = String(result.text ?? '');
420
+ if (result.readable) {
421
+ note(notes, 'sign-in-hold.raw-read', {
422
+ targetId,
423
+ readable: true,
424
+ text: text.slice(0, 120),
425
+ readyState: result.readyState,
426
+ });
427
+ return { readable: true, text, readyState: result.readyState };
428
+ }
429
+ const step = 'mark';
430
+ const reason = `text without the mark; last readyState=${result.readyState} text=${JSON.stringify(text.slice(0, 80))}`;
411
431
  note(notes, 'sign-in-hold.raw-read', {
412
432
  targetId,
413
- readable: result.readable,
414
- text: result.text.slice(0, 120),
433
+ readable: false,
434
+ step,
435
+ text: text.slice(0, 120),
436
+ readyState: result.readyState,
415
437
  });
416
- return result;
438
+ return { readable: false, step, reason, text, readyState: result.readyState };
417
439
  }
418
440
 
419
- function holdExpression(control, ordinary, tag, marker, heldUrl) {
441
+ function holdExpression(control, ordinary, tag, marker, heldUrl, { askHook = false } = {}) {
420
442
  if (control)
421
443
  return `(async () => {
422
444
  const popup = window.open(${JSON.stringify(`${ordinary}/held?n=${tag}`)}, 'slicc-ordinary', 'popup,width=520,height=720');
423
445
  return { answer: 'none', opened: Boolean(popup) };
424
446
  })()`;
447
+ if (askHook)
448
+ return `(async () => {
449
+ const marker = ${JSON.stringify(marker)};
450
+ const popup = window.open('about:blank#${MARK_PREFIX}' + marker, 'slicc-sign-in', 'popup,width=520,height=720');
451
+ return { answer: 'pending', opened: Boolean(popup), marker };
452
+ })()`;
425
453
  return `(async () => {
426
454
  const marker = ${JSON.stringify(marker)};
427
455
  const heldUrl = ${JSON.stringify(heldUrl)};
@@ -442,6 +470,46 @@ function holdExpression(control, ordinary, tag, marker, heldUrl) {
442
470
  })()`;
443
471
  }
444
472
 
473
+ function hostLabelOf(origin) {
474
+ try {
475
+ return new URL(origin).host;
476
+ } catch {
477
+ return String(origin ?? '');
478
+ }
479
+ }
480
+
481
+ async function askHold(client, { marker, hostLabel, notes }) {
482
+ const hold = client?.signInHold;
483
+ if (typeof hold?.ask !== 'function') return { used: false };
484
+ note(notes, 'sign-in-hold.ask', { via: 'signInHold.ask', marker, hostLabel });
485
+ let timer;
486
+ try {
487
+ const answer = await Promise.race([
488
+ Promise.resolve(hold.ask({ marker, hostLabel })),
489
+ new Promise((_, reject) => {
490
+ timer = setTimeout(() => {
491
+ const error = new Error('signInHold.ask timed out');
492
+ error.code = 'ask-timeout';
493
+ reject(error);
494
+ }, 6000);
495
+ }),
496
+ ]);
497
+ if (!['held', 'unheld', 'none'].includes(answer))
498
+ return {
499
+ used: true,
500
+ incomplete: `signInHold.ask returned ${JSON.stringify(answer)}, want held|unheld|none`,
501
+ };
502
+ return { used: true, answer };
503
+ } catch (error) {
504
+ return {
505
+ used: true,
506
+ incomplete: `signInHold.ask failed: ${error?.message ?? error}`,
507
+ };
508
+ } finally {
509
+ if (timer) clearTimeout(timer);
510
+ }
511
+ }
512
+
445
513
  function matchPopup(info, known, openerId, heldUrl, control) {
446
514
  if (info.type !== 'page' || known.has(info.targetId) || info.targetId === openerId) return false;
447
515
  const url = info.url ?? '';
@@ -496,11 +564,12 @@ async function heldPopup({
496
564
  const { sessionId, targetId: openerId } = opened.result;
497
565
  const before = await outcome(reader.send('Target.getTargets', {}));
498
566
  const known = new Set((before.result?.targetInfos ?? []).map((info) => info.targetId));
567
+ const useAsk = !control && typeof client?.signInHold?.ask === 'function';
499
568
  const asked = await outcome(
500
569
  reader.send(
501
570
  'Runtime.evaluate',
502
571
  {
503
- expression: holdExpression(control, ordinary, tag, marker, heldUrl),
572
+ expression: holdExpression(control, ordinary, tag, marker, heldUrl, { askHook: useAsk }),
504
573
  awaitPromise: true,
505
574
  returnByValue: true,
506
575
  userGesture: true,
@@ -514,12 +583,22 @@ async function heldPopup({
514
583
  incomplete: `hold evaluate failed: ${asked.error?.message ?? asked.error}`,
515
584
  openerId,
516
585
  };
517
- const holdAnswer = asked.result?.result?.value?.answer ?? 'missing';
586
+ let holdAnswer = asked.result?.result?.value?.answer ?? 'missing';
518
587
  const openedPopup = asked.result?.result?.value?.opened;
588
+ if (useAsk) {
589
+ const askedHold = await askHold(client, {
590
+ marker,
591
+ hostLabel: hostLabelOf(openerOrigin ?? ordinary),
592
+ notes,
593
+ });
594
+ if (askedHold.incomplete) return { live: false, incomplete: askedHold.incomplete, openerId };
595
+ holdAnswer = askedHold.answer;
596
+ }
519
597
  note(notes, 'sign-in-hold.hold', {
520
598
  holdAnswer,
521
599
  control: Boolean(control),
522
600
  opened: openedPopup,
601
+ askHook: useAsk,
523
602
  });
524
603
  if (openedPopup === false)
525
604
  return {
@@ -556,11 +635,11 @@ async function heldPopup({
556
635
  Math.min(budget, 3000)
557
636
  );
558
637
  const rawUrl = settled?.url ?? raw.url ?? heldUrl;
559
- const { readable } = await rawReadable(reader, raw.targetId, mark, notes);
560
- if (!readable)
638
+ const read = await rawReadable(reader, raw.targetId, mark, notes, Math.min(budget, 3000));
639
+ if (!read.readable)
561
640
  return {
562
641
  live: false,
563
- incomplete: 'raw leg could not read the popup body mark',
642
+ incomplete: `raw leg could not read the popup body mark (${read.step}): ${read.reason}`,
564
643
  holdAnswer,
565
644
  openerId,
566
645
  targetId: raw.targetId,
@@ -623,10 +702,12 @@ async function callbackTab({
623
702
  const targetId = created.result?.targetId;
624
703
  if (!targetId) return { live: false, incomplete: 'createTarget returned no targetId' };
625
704
 
705
+ let lastSeenUrl = null;
626
706
  const ready = await until(async () => {
627
707
  const info = await outcome(reader.send('Target.getTargetInfo', { targetId }));
628
708
  if (!info.ok) return null;
629
709
  const current = info.result?.targetInfo;
710
+ if (current?.url) lastSeenUrl = current.url;
630
711
  if (current?.url && (current.url.includes('/ims/authorize') || current.url === url))
631
712
  return current;
632
713
  return null;
@@ -635,15 +716,15 @@ async function callbackTab({
635
716
  if (!ready)
636
717
  return {
637
718
  live: false,
638
- incomplete: 'callback tab did not settle in the raw leg',
719
+ incomplete: `callback tab did not settle in the raw leg; last seen URL ${JSON.stringify(lastSeenUrl)}`,
639
720
  targetId,
640
721
  };
641
722
 
642
- const { readable } = await rawReadable(reader, targetId, mark, notes, Math.min(budget, 3000));
643
- if (!readable)
723
+ const read = await rawReadable(reader, targetId, mark, notes, Math.min(budget, 3000));
724
+ if (!read.readable)
644
725
  return {
645
726
  live: false,
646
- incomplete: 'raw leg could not read the callback tab mark',
727
+ incomplete: `raw leg could not read the callback tab mark (${read.step}): ${read.reason}`,
647
728
  targetId,
648
729
  };
649
730
 
@@ -683,7 +764,7 @@ export async function signInHold({
683
764
  }) {
684
765
  if (!reader) return { incomplete: 'missing unguarded reader' };
685
766
  if (!ordinary) return { incomplete: 'missing {ordinary} placeholder' };
686
- if (!cross && String(mode).startsWith('callback'))
767
+ if (!cross && (String(mode).startsWith('callback') || mode === 'ordinary-authorize'))
687
768
  return { incomplete: 'missing {cross} placeholder' };
688
769
  if (discovery) {
689
770
  await outcome(client.send('Target.setDiscoverTargets', { discover: true }));