@ai-ecoverse/slicc-browsers 1.24.0 → 1.24.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.
@@ -920,24 +920,110 @@ async function driveCast(client, page, frameMs) {
920
920
  const start = await outcome(
921
921
  client.send('Page.startScreencast', { format: 'png', everyNthFrame: 1 }, page)
922
922
  );
923
- const cursor = client.events?.length ?? 0;
923
+ const acked = new Set();
924
+ let leakFrom;
925
+ let pumping = start.ok;
926
+ 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
+ };
936
+ const halt = async () => {
937
+ pumping = false;
938
+ await pump;
939
+ if (start.ok && !stopped) {
940
+ stopped = true;
941
+ await outcome(client.send('Page.stopScreencast', {}, page));
942
+ }
943
+ };
944
+ const pump =
945
+ start.ok && frameMs > 0
946
+ ? (async () => {
947
+ while (pumping) {
948
+ await ackFrames();
949
+ await pause(25);
950
+ }
951
+ })()
952
+ : Promise.resolve();
924
953
  return {
925
954
  castBefore: start.ok,
926
955
  castBeforeRefusal: presentish(start),
927
- async afterEmbed() {
956
+ async markInserted() {
957
+ await ackFrames();
958
+ leakFrom = client.events?.length ?? 0;
959
+ },
960
+ async afterEmbed({ inserted }) {
961
+ pumping = false;
962
+ await pump;
963
+ if (!start.ok) {
964
+ return { castLeak: false, castFramesAfter: 0, castInserted: Boolean(inserted) };
965
+ }
966
+ if (!inserted) {
967
+ await halt();
968
+ return { castLeak: false, castFramesAfter: 0, castInserted: false };
969
+ }
970
+ if (leakFrom == null) {
971
+ await ackFrames();
972
+ leakFrom = client.events?.length ?? 0;
973
+ }
928
974
  await pause(Math.max(frameMs, 200));
975
+ await ackFrames();
929
976
  const frames = (client.events ?? [])
930
- .slice(cursor)
977
+ .slice(leakFrom)
931
978
  .filter((event) => event.method === 'Page.screencastFrame' && event.sessionId === page);
932
- if (start.ok) await outcome(client.send('Page.stopScreencast', {}, page));
979
+ await halt();
933
980
  return {
934
981
  castLeak: frames.length > 0,
935
982
  castFramesAfter: frames.length,
983
+ castInserted: true,
936
984
  };
937
985
  },
986
+ stop: halt,
987
+ };
988
+ }
989
+
990
+ async function beginCast(client, session, targetId, frameMs) {
991
+ const attachEarly = await outcome(
992
+ client.send('Target.attachToTarget', { targetId, flatten: true })
993
+ );
994
+ const page = attachEarly.ok ? attachEarly.result.sessionId : session;
995
+ if (attachEarly.ok) {
996
+ await outcome(client.send('DOM.enable', {}, page));
997
+ await outcome(client.send('Accessibility.enable', {}, page));
998
+ }
999
+ return {
1000
+ page,
1001
+ pageAttached: attachEarly.ok,
1002
+ castDrive: await driveCast(client, page, frameMs),
938
1003
  };
939
1004
  }
940
1005
 
1006
+ async function noteCastInsertion(castDrive, embedded, missing) {
1007
+ if (!castDrive) return;
1008
+ if (embedded) await castDrive.markInserted();
1009
+ else missing.push('extension frame insertion was not confirmed');
1010
+ }
1011
+
1012
+ function finishCast(castDrive, embedded) {
1013
+ if (!castDrive) return null;
1014
+ return castDrive.afterEmbed({ inserted: Boolean(embedded) });
1015
+ }
1016
+
1017
+ function applyCastResult(result, castDrive, castAfter, side, missing) {
1018
+ if (!castDrive) return;
1019
+ result.castBefore = castDrive.castBefore;
1020
+ 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');
1025
+ }
1026
+
941
1027
  function classifyRevealOverlap(
942
1028
  captureStartedAt,
943
1029
  revealAt,
@@ -1101,6 +1187,7 @@ export async function extensionFrame({
1101
1187
  const frameURL = `chrome-extension://${extensionId}/frame.html`;
1102
1188
  let page;
1103
1189
  let pageAttached = false;
1190
+ let castDrive;
1104
1191
  const discovery = hasCapability(capabilities, 'discovery')
1105
1192
  ? await outcome(client.send('Target.setDiscoverTargets', { discover: true }))
1106
1193
  : { ok: false };
@@ -1108,18 +1195,14 @@ export async function extensionFrame({
1108
1195
  await reader.send('Runtime.enable', {}, observer);
1109
1196
  await reader.send('DOM.enable', {}, observer);
1110
1197
  await reader.send('Accessibility.enable', {}, observer);
1111
- let castDrive;
1112
1198
  if (mode === 'cast') {
1113
- const attachEarly = await outcome(
1114
- client.send('Target.attachToTarget', { targetId, flatten: true })
1115
- );
1116
- page = attachEarly.ok ? attachEarly.result.sessionId : session;
1117
- pageAttached = attachEarly.ok;
1118
- await outcome(client.send('DOM.enable', {}, page));
1119
- await outcome(client.send('Accessibility.enable', {}, page));
1120
- castDrive = await driveCast(client, page, frameMs);
1199
+ const started = await beginCast(client, session, targetId, frameMs);
1200
+ page = started.page;
1201
+ pageAttached = started.pageAttached;
1202
+ castDrive = started.castDrive;
1121
1203
  }
1122
- await embed(reader, observer, mode, frameURL);
1204
+ const embedded = await embed(reader, observer, mode, frameURL);
1205
+ await noteCastInsertion(castDrive, embedded, missing);
1123
1206
  const want = mode === 'focused' ? 1 : 2;
1124
1207
  const frames = await frameTargets(
1125
1208
  reader,
@@ -1132,7 +1215,7 @@ export async function extensionFrame({
1132
1215
  const frame = frames[0];
1133
1216
  await paintMarker(reader, frame, mode === 'focused');
1134
1217
  await painted(reader, observer, frameMs);
1135
- const castAfter = castDrive ? await castDrive.afterEmbed() : null;
1218
+ const castAfter = await finishCast(castDrive, embedded);
1136
1219
  if (!page) {
1137
1220
  const attach = await outcome(
1138
1221
  client.send('Target.attachToTarget', { targetId, flatten: true })
@@ -1179,14 +1262,7 @@ export async function extensionFrame({
1179
1262
  input,
1180
1263
  captures,
1181
1264
  });
1182
- if (castDrive) {
1183
- result.castBefore = castDrive.castBefore;
1184
- result.castBeforeRefusal = castDrive.castBeforeRefusal;
1185
- result.castLeak = castAfter.castLeak;
1186
- result.castFramesAfter = castAfter.castFramesAfter;
1187
- if (side === 'control' && castDrive.castBefore && !castAfter.castLeak)
1188
- missing.push('control screencast produced no frames after the extension frame appeared');
1189
- }
1265
+ applyCastResult(result, castDrive, castAfter, side, missing);
1190
1266
  if (mode === 'revealed')
1191
1267
  Object.assign(
1192
1268
  result,
@@ -1226,6 +1302,7 @@ export async function extensionFrame({
1226
1302
  result.alive = alive.ok && alive.result.result?.value === origin && !carries(alive.result);
1227
1303
  return missing.length ? { ...result, incomplete: missing.join('; ') } : result;
1228
1304
  } finally {
1305
+ if (castDrive) await castDrive.stop();
1229
1306
  if (pageAttached) await outcome(client.send('Target.detachFromTarget', { sessionId: page }));
1230
1307
  if (discovery.ok) await outcome(client.send('Target.setDiscoverTargets', { discover: false }));
1231
1308
  await outcome(reader.send('Target.detachFromTarget', { sessionId: observer }));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "setVersion": "1.24.0",
3
+ "setVersion": "1.24.1",
4
4
  "sources": [
5
5
  {
6
6
  "repo": "ai-ecoverse/slicc-cli",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-browsers",
3
- "version": "1.24.0",
3
+ "version": "1.24.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",
@@ -76,7 +76,7 @@
76
76
  "validate": "node scripts/validate.mjs",
77
77
  "lint": "slicc-lint && test -z \"$(gofmt -l .)\" && go mod tidy -diff && go vet ./... && GOOS=darwin go vet ./... && GOOS=windows go vet ./... && golangci-lint run && cargo fmt --check && cargo clippy --all-features --all-targets -- -D warnings && cargo check --target wasm32-wasip1 --no-default-features && cargo check --target wasm32-wasip1 --features serde && cargo check --target wasm32-wasip1 --all-features",
78
78
  "format": "biome check --write . && gofmt -w . && cargo fmt",
79
- "test": "export PATH=\"$HOME/.cargo/bin:$PATH\" && node --test --test-concurrency=1 test/integration/debugger-stage1-packaging.test.mjs test/integration/debugger-raw-control.test.mjs test/integration/debugger-cleanup.test.mjs test/integration/debugger-stage1-install-vectors.test.mjs test/integration/protected-premise.test.mjs test/integration/debugger-stage1-vectors.test.mjs test/integration/self-contained.test.mjs test/integration/seven-corpus.test.mjs test/integration/browser-runner.test.mjs test/integration/fixture-client.test.mjs test/integration/guard-redirect-carrier.test.mjs test/integration/guard-redirect-session-end.test.mjs test/integration/guard-redirect-history.test.mjs test/integration/guard-redirect-iframe.test.mjs test/integration/guard-incomplete.test.mjs test/integration/guard-unparseable-wipe.test.mjs test/integration/guard-browser-ui.test.mjs test/integration/guard-snapshot-settle.test.mjs test/integration/guard-stall.test.mjs test/integration/guard-forged.test.mjs test/integration/guard-trusted-emulation.test.mjs test/integration/guard-exit-steps.test.mjs test/integration/guard-exit-refusal.test.mjs test/integration/guard-frame-read.test.mjs test/integration/guard-bfcache.test.mjs test/integration/guard-bfcache-marker.test.mjs test/integration/guard-bfcache-history.test.mjs test/integration/guard-bfcache-review.test.mjs test/integration/guard-bfcache-quarantine.test.mjs test/integration/guard-error-page-navigation.test.mjs test/integration/guard-error-page-events.test.mjs test/integration/guard-error-page-reload.test.mjs test/integration/guard-close-protected.test.mjs test/integration/guard-close-protected-shapes.test.mjs test/integration/guard-close-protected-shapes-chrome.test.mjs test/integration/guard-protected-parent-iframes.test.mjs test/integration/guard-protected-parent-iframes-chrome.test.mjs test/integration/guard-world-paint.test.mjs test/integration/gates.test.mjs test/integration/validate.test.mjs test/integration/validate-guard-stock-setup.test.mjs test/integration/go.test.mjs test/integration/cargo.test.mjs test/integration/workflows.test.mjs test/integration/guard-refusable-nav.test.mjs test/integration/guard-protected-worker.test.mjs test/integration/guard-protected-worker-chrome-narrow.test.mjs test/integration/guard-protected-worker-chrome-hide.test.mjs test/integration/guard-protected-worker-chrome-hide-cut.test.mjs test/integration/guard-protected-worker-chrome-admit.test.mjs test/integration/guard-protected-worker-chrome-late.test.mjs test/integration/guard-protected-worker-chrome-rewrite.test.mjs test/integration/guard-protected-worker-chrome-rewrite-late.test.mjs test/integration/guard-sweep-union.test.mjs && node --test --test-concurrency=2 test/integration/guard-lifecycle.test.mjs test/integration/chromium-launch.test.mjs test/integration/guard-fit.test.mjs test/integration/guard-chain.test.mjs test/integration/guard-validation.test.mjs test/integration/guard-liveness.test.mjs test/integration/guard-observations.test.mjs test/integration/guard-child-latency.test.mjs test/integration/guard-adoption.test.mjs test/integration/guard-scoping.test.mjs test/integration/guard-late-pause.test.mjs test/integration/guard-legs.test.mjs test/integration/guard-fetch-enable.test.mjs test/integration/guard-diagnostics.test.mjs test/integration/guard-chrome.test.mjs test/integration/guard-worlds.test.mjs test/integration/guard-world-discovery.test.mjs test/integration/guard-world-guesses.test.mjs test/integration/guard-unparseable.test.mjs test/integration/guard-redirect-secret.test.mjs test/integration/guard-error-page.test.mjs test/integration/guard-discovery.test.mjs test/integration/guard-bfcache-chrome.test.mjs test/integration/guard-browser-page.test.mjs test/integration/guard-scales.test.mjs test/integration/guard-shared-log.test.mjs test/integration/guard-pre-beacon.test.mjs test/integration/guard-world-pause.test.mjs test/integration/guard-reveal-overlap.test.mjs test/integration/guard-extension-frame-mouse.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-stock-attack.test.mjs test/integration/guard-parallel.test.mjs test/integration/guard-client-exit.test.mjs test/integration/guard-runner.test.mjs test/integration/guard-sweep-ordinary.test.mjs test/integration/guard-sweep-seven.test.mjs test/integration/guard-sweep-vault.test.mjs test/integration/guard-sweep-vault-x.test.mjs test/integration/guard-sweep-apex.test.mjs test/integration/guard-sweep-others.test.mjs",
79
+ "test": "export PATH=\"$HOME/.cargo/bin:$PATH\" && node --test --test-concurrency=1 test/integration/debugger-stage1-packaging.test.mjs test/integration/debugger-raw-control.test.mjs test/integration/debugger-cleanup.test.mjs test/integration/debugger-stage1-install-vectors.test.mjs test/integration/protected-premise.test.mjs test/integration/debugger-stage1-vectors.test.mjs test/integration/self-contained.test.mjs test/integration/seven-corpus.test.mjs test/integration/browser-runner.test.mjs test/integration/fixture-client.test.mjs test/integration/guard-redirect-carrier.test.mjs test/integration/guard-redirect-session-end.test.mjs test/integration/guard-redirect-history.test.mjs test/integration/guard-redirect-iframe.test.mjs test/integration/guard-incomplete.test.mjs test/integration/guard-unparseable-wipe.test.mjs test/integration/guard-browser-ui.test.mjs test/integration/guard-snapshot-settle.test.mjs test/integration/guard-stall.test.mjs test/integration/guard-forged.test.mjs test/integration/guard-trusted-emulation.test.mjs test/integration/guard-exit-steps.test.mjs test/integration/guard-exit-refusal.test.mjs test/integration/guard-frame-read.test.mjs test/integration/guard-bfcache.test.mjs test/integration/guard-bfcache-marker.test.mjs test/integration/guard-bfcache-history.test.mjs test/integration/guard-bfcache-review.test.mjs test/integration/guard-bfcache-quarantine.test.mjs test/integration/guard-error-page-navigation.test.mjs test/integration/guard-error-page-events.test.mjs test/integration/guard-error-page-reload.test.mjs test/integration/guard-close-protected.test.mjs test/integration/guard-close-protected-shapes.test.mjs test/integration/guard-close-protected-shapes-chrome.test.mjs test/integration/guard-protected-parent-iframes.test.mjs test/integration/guard-protected-parent-iframes-chrome.test.mjs test/integration/guard-world-paint.test.mjs test/integration/gates.test.mjs test/integration/validate.test.mjs test/integration/validate-guard-stock-setup.test.mjs test/integration/go.test.mjs test/integration/cargo.test.mjs test/integration/workflows.test.mjs test/integration/guard-refusable-nav.test.mjs test/integration/guard-protected-worker.test.mjs test/integration/guard-protected-worker-chrome-narrow.test.mjs test/integration/guard-protected-worker-chrome-hide.test.mjs test/integration/guard-protected-worker-chrome-hide-cut.test.mjs test/integration/guard-protected-worker-chrome-admit.test.mjs test/integration/guard-protected-worker-chrome-late.test.mjs test/integration/guard-protected-worker-chrome-rewrite.test.mjs test/integration/guard-protected-worker-chrome-rewrite-late.test.mjs test/integration/guard-sweep-union.test.mjs && node --test --test-concurrency=2 test/integration/guard-lifecycle.test.mjs test/integration/chromium-launch.test.mjs test/integration/guard-fit.test.mjs test/integration/guard-chain.test.mjs test/integration/guard-validation.test.mjs test/integration/guard-liveness.test.mjs test/integration/guard-observations.test.mjs test/integration/guard-child-latency.test.mjs test/integration/guard-adoption.test.mjs test/integration/guard-scoping.test.mjs test/integration/guard-late-pause.test.mjs test/integration/guard-legs.test.mjs test/integration/guard-fetch-enable.test.mjs test/integration/guard-diagnostics.test.mjs test/integration/guard-chrome.test.mjs test/integration/guard-worlds.test.mjs test/integration/guard-world-discovery.test.mjs test/integration/guard-world-guesses.test.mjs test/integration/guard-unparseable.test.mjs test/integration/guard-redirect-secret.test.mjs test/integration/guard-error-page.test.mjs test/integration/guard-discovery.test.mjs test/integration/guard-bfcache-chrome.test.mjs test/integration/guard-browser-page.test.mjs test/integration/guard-scales.test.mjs test/integration/guard-shared-log.test.mjs test/integration/guard-pre-beacon.test.mjs test/integration/guard-world-pause.test.mjs test/integration/guard-reveal-overlap.test.mjs test/integration/guard-extension-frame-cast.test.mjs test/integration/guard-extension-frame-mouse.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-stock-attack.test.mjs test/integration/guard-parallel.test.mjs test/integration/guard-client-exit.test.mjs test/integration/guard-runner.test.mjs test/integration/guard-sweep-ordinary.test.mjs test/integration/guard-sweep-seven.test.mjs test/integration/guard-sweep-vault.test.mjs test/integration/guard-sweep-vault-x.test.mjs test/integration/guard-sweep-apex.test.mjs test/integration/guard-sweep-others.test.mjs",
80
80
  "test:unit": "mkdir -p coverage/unit && node --experimental-test-coverage --test --test-concurrency=1 --test-reporter=lcov --test-reporter-destination=coverage/unit/lcov.info test/unit/*.test.mjs && go test -race -cover ./...",
81
81
  "build": "go build ./... && cargo build --all-features && cargo build --target wasm32-wasip1 --all-features && npm pack --dry-run",
82
82
  "prepublishOnly": "node scripts/set-crate-version.mjs \"$npm_package_version\"",
@@ -87,9 +87,9 @@
87
87
  "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"
88
88
  },
89
89
  "devDependencies": {
90
- "@ai-ecoverse/slicc-cdp": "1.48.10",
91
- "@ai-ecoverse/slicc-shared-web": "2.14.2",
92
- "@biomejs/biome": "2.6.5",
90
+ "@ai-ecoverse/slicc-cdp": "1.50.1",
91
+ "@ai-ecoverse/slicc-shared-web": "2.14.4",
92
+ "@biomejs/biome": "2.6.6",
93
93
  "ajv": "8.20.0",
94
94
  "ajv-formats": "3.0.1",
95
95
  "lefthook": "2.2.2",