@ai-ecoverse/slicc-browsers 1.30.2 → 1.32.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.
@@ -621,7 +621,25 @@ async function targetListExposure(client, frameURL, extensionId, missing, result
621
621
  }
622
622
  }
623
623
 
624
- function targetEventExposure(
624
+ function matchTargetEvent(event, page, ids, frameURL, extensionId, seen) {
625
+ if (
626
+ event.method === 'Target.attachedToTarget' &&
627
+ event.sessionId === page &&
628
+ ids.has(event.params?.targetInfo?.targetId) &&
629
+ typeof event.params.sessionId === 'string'
630
+ )
631
+ seen.attached.add(event.params.targetInfo.targetId);
632
+ if (
633
+ !seen.eventURL &&
634
+ ['Target.attachedToTarget', 'Target.targetCreated', 'Target.targetInfoChanged'].includes(
635
+ event.method
636
+ ) &&
637
+ exposesExtension(event.params, extensionId, frameURL)
638
+ )
639
+ seen.eventURL = true;
640
+ }
641
+
642
+ async function targetEventExposure(
625
643
  client,
626
644
  page,
627
645
  ids,
@@ -630,34 +648,48 @@ function targetEventExposure(
630
648
  eventStart,
631
649
  missing,
632
650
  result,
633
- { autoAttach, discovery }
651
+ { autoAttach, attachWait, discovery, budgetMs, notes }
634
652
  ) {
635
653
  if (eventStart === undefined || !Array.isArray(client.events)) {
636
654
  missing.push('target event stream is unavailable');
655
+ return undefined;
656
+ }
657
+ const seen = { attached: new Set(), eventURL: false };
658
+ const done = () =>
659
+ (!attachWait || seen.attached.size >= ids.size) && (!discovery || seen.eventURL);
660
+ const started = Date.now();
661
+ let cursor = eventStart;
662
+ for (;;) {
663
+ for (; cursor < client.events.length; cursor++)
664
+ matchTargetEvent(client.events[cursor], page, ids, frameURL, extensionId, seen);
665
+ const elapsed = Date.now() - started;
666
+ if (done() || elapsed >= budgetMs) break;
667
+ await pause(Math.min(25, budgetMs - elapsed));
668
+ }
669
+ const waitedMs = Date.now() - started;
670
+ if (autoAttach) result.autoAttached = seen.attached.size > 0;
671
+ if (discovery) result.eventURL = seen.eventURL;
672
+ const parts = [
673
+ ...(autoAttach ? [`autoAttached ${seen.attached.size} of ${ids.size} frames`] : []),
674
+ ...(discovery ? [`eventURL ${seen.eventURL ? 'seen' : 'not seen'}`] : []),
675
+ ];
676
+ notes?.push(`target events after ${waitedMs}ms (budget ${budgetMs}ms): ${parts.join(', ')}`);
677
+ return waitedMs;
678
+ }
679
+
680
+ function silentAttach({ side, attachControls, result, refused, waitedMs, budgetMs, missing }) {
681
+ if (side === 'control') {
682
+ if (attachControls) attachControls.autoAttached = result.autoAttached === true;
637
683
  return;
638
684
  }
639
- const events = client.events.slice(eventStart);
640
- if (autoAttach)
641
- result.autoAttached = events.some(
642
- (event) =>
643
- event.method === 'Target.attachedToTarget' &&
644
- event.sessionId === page &&
645
- ids.has(event.params?.targetInfo?.targetId) &&
646
- typeof event.params.sessionId === 'string'
647
- );
648
- if (discovery)
649
- result.eventURL = events.some(
650
- (event) =>
651
- ['Target.attachedToTarget', 'Target.targetCreated', 'Target.targetInfoChanged'].includes(
652
- event.method
653
- ) && exposesExtension(event.params, extensionId, frameURL)
654
- );
685
+ if (attachControls?.autoAttached !== true || result.autoAttached !== false || refused) return;
686
+ missing.push(
687
+ `autoAttached: the control auto-attached the frame; the guarded leg saw neither an attach event nor a refusal after ${waitedMs ?? 0}ms (budget ${budgetMs}ms)`
688
+ );
655
689
  }
656
690
 
657
691
  async function targetExposure({
658
692
  client,
659
- reader,
660
- observer,
661
693
  page,
662
694
  frames,
663
695
  frameURL,
@@ -666,6 +698,10 @@ async function targetExposure({
666
698
  frameMs,
667
699
  missing,
668
700
  capabilities = {},
701
+ side,
702
+ notes,
703
+ attachControls,
704
+ attachRefused = false,
669
705
  }) {
670
706
  const result = { autoAttached: false, eventURL: false, listed: false };
671
707
  const ids = new Set(frames.map((frame) => frame.targetId));
@@ -684,13 +720,30 @@ async function targetExposure({
684
720
  )
685
721
  : { ok: false };
686
722
  try {
687
- if (autoAttach || discovery) {
688
- await painted(reader, observer, frameMs);
689
- targetEventExposure(client, page, ids, frameURL, extensionId, eventStart, missing, result, {
690
- autoAttach,
691
- discovery,
723
+ const budgetMs = Number.isFinite(frameMs) && frameMs > 0 ? frameMs : 0;
724
+ let waitedMs;
725
+ if (autoAttach || discovery)
726
+ waitedMs = await targetEventExposure(
727
+ client,
728
+ page,
729
+ ids,
730
+ frameURL,
731
+ extensionId,
732
+ eventStart,
733
+ missing,
734
+ result,
735
+ { autoAttach, attachWait: autoAttach && auto.ok, discovery, budgetMs, notes }
736
+ );
737
+ if (autoAttach)
738
+ silentAttach({
739
+ side,
740
+ attachControls,
741
+ result,
742
+ refused: attachRefused || (!auto.ok && protectedRefusal(auto)),
743
+ waitedMs,
744
+ budgetMs,
745
+ missing,
692
746
  });
693
- }
694
747
  if (browserSession) await targetListExposure(client, frameURL, extensionId, missing, result);
695
748
  return result;
696
749
  } finally {
@@ -1542,6 +1595,7 @@ export async function extensionFrame({
1542
1595
  capabilities = {},
1543
1596
  notes,
1544
1597
  castControls,
1598
+ attachControls,
1545
1599
  }) {
1546
1600
  const attached = await reader.send('Target.attachToTarget', { targetId, flatten: true });
1547
1601
  const observer = attached.sessionId;
@@ -1637,10 +1691,12 @@ export async function extensionFrame({
1637
1691
  await driveReveal(client, reader, page, observer, frameMs, missing, side)
1638
1692
  );
1639
1693
  result.frameAttach = false;
1694
+ let attachRefused = false;
1640
1695
  for (const entry of frames) {
1641
1696
  const frameAttach = await outcome(
1642
1697
  client.send('Target.attachToTarget', { targetId: entry.targetId, flatten: true })
1643
1698
  );
1699
+ if (!frameAttach.ok && protectedRefusal(frameAttach)) attachRefused = true;
1644
1700
  if (frameAttach.ok) {
1645
1701
  result.frameAttach = true;
1646
1702
  await outcome(
@@ -1652,8 +1708,6 @@ export async function extensionFrame({
1652
1708
  result,
1653
1709
  await targetExposure({
1654
1710
  client,
1655
- reader,
1656
- observer,
1657
1711
  page,
1658
1712
  frames,
1659
1713
  frameURL,
@@ -1662,6 +1716,10 @@ export async function extensionFrame({
1662
1716
  frameMs,
1663
1717
  missing,
1664
1718
  capabilities,
1719
+ side,
1720
+ notes,
1721
+ attachControls,
1722
+ attachRefused,
1665
1723
  })
1666
1724
  );
1667
1725
  const alive = await outcome(
package/guard-runner.mjs CHANGED
@@ -1358,6 +1358,7 @@ class Execution {
1358
1358
  capabilities: this.options.capabilities,
1359
1359
  notes: this.notes,
1360
1360
  castControls: (this.clients.castControls ??= {}),
1361
+ attachControls: (this.clients.attachControls ??= {}),
1361
1362
  })
1362
1363
  );
1363
1364
  if (step.rawTarget) return outcome(this.rawTarget(step.rawTarget));
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "setVersion": "1.30.2",
3
+ "setVersion": "1.32.0",
4
4
  "sources": [
5
5
  {
6
6
  "repo": "ai-ecoverse/slicc-cli",
@@ -31443,6 +31443,18 @@
31443
31443
  "explicitAttach"
31444
31444
  ]
31445
31445
  },
31446
+ {
31447
+ "cdp": "Target.getTargetInfo",
31448
+ "params": {
31449
+ "targetId": "{rawTarget}"
31450
+ },
31451
+ "session": "browser",
31452
+ "via": "unguarded",
31453
+ "as": "mapped",
31454
+ "requires": [
31455
+ "explicitAttach"
31456
+ ]
31457
+ },
31446
31458
  {
31447
31459
  "cdp": "Target.getTargets",
31448
31460
  "params": {},
@@ -31643,7 +31655,7 @@
31643
31655
  }
31644
31656
  },
31645
31657
  "listed": {
31646
- "means": "Target.getTargets lists the raw target id",
31658
+ "means": "Target.getTargets lists the raw target id, asked after the unguarded observer used that id",
31647
31659
  "check": {
31648
31660
  "result": "listed",
31649
31661
  "path": "result.targetInfos",
@@ -31801,6 +31813,18 @@
31801
31813
  "explicitAttach"
31802
31814
  ]
31803
31815
  },
31816
+ {
31817
+ "cdp": "Target.getTargetInfo",
31818
+ "params": {
31819
+ "targetId": "{rawTarget}"
31820
+ },
31821
+ "session": "browser",
31822
+ "via": "unguarded",
31823
+ "as": "mapped",
31824
+ "requires": [
31825
+ "explicitAttach"
31826
+ ]
31827
+ },
31804
31828
  {
31805
31829
  "cdp": "Target.getTargets",
31806
31830
  "params": {},
@@ -31966,7 +31990,7 @@
31966
31990
  "dependsOn": []
31967
31991
  },
31968
31992
  "listed": {
31969
- "means": "Target.getTargets lists the raw target id",
31993
+ "means": "Target.getTargets lists the raw target id, asked after the unguarded observer used that id",
31970
31994
  "check": {
31971
31995
  "result": "listed",
31972
31996
  "path": "result.targetInfos",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-browsers",
3
- "version": "1.30.2",
3
+ "version": "1.32.0",
4
4
  "description": "SLICC's shared browser catalog, JSON schemas and discovery conformance corpus",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -79,7 +79,7 @@
79
79
  "validate": "node scripts/validate.mjs",
80
80
  "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",
81
81
  "format": "biome check --write . && gofmt -w . && cargo fmt",
82
- "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-redirect-through.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-credential-export.test.mjs test/integration/guard-protected-parent-iframes.test.mjs test/integration/guard-protected-parent-iframes-chrome.test.mjs test/integration/guard-error-frame-class.test.mjs test/integration/guard-sign-in-hold.test.mjs test/integration/guard-cookie-plant-chrome.test.mjs test/integration/guard-cookie-plant.test.mjs test/integration/guard-protected-parent-page.test.mjs test/integration/guard-protected-parent-page-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/validate-guard-explicit.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 test/integration/guard-explicit-attach-chrome.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-child-latency-stress.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-frame-click.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-explicit-attach.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-record.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-idp.test.mjs test/integration/guard-sweep-others.test.mjs",
82
+ "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-redirect-through.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-credential-export.test.mjs test/integration/guard-protected-parent-iframes.test.mjs test/integration/guard-protected-parent-iframes-chrome.test.mjs test/integration/guard-error-frame-class.test.mjs test/integration/guard-sign-in-hold.test.mjs test/integration/guard-cookie-plant-chrome.test.mjs test/integration/guard-cookie-plant.test.mjs test/integration/guard-protected-parent-page.test.mjs test/integration/guard-protected-parent-page-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/validate-guard-explicit.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 test/integration/guard-explicit-attach-chrome.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-child-latency-stress.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-frame-click.test.mjs test/integration/guard-extension-frame-attach.test.mjs test/integration/guard-extension-frames.test.mjs test/integration/guard-stock-setup.test.mjs test/integration/guard-explicit-attach.test.mjs test/integration/guard-explicit-order.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-record.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-idp.test.mjs test/integration/guard-sweep-others.test.mjs",
83
83
  "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 ./...",
84
84
  "build": "go build ./... && cargo build --all-features && cargo build --target wasm32-wasip1 --all-features && npm pack --dry-run",
85
85
  "prepublishOnly": "node scripts/set-crate-version.mjs \"$npm_package_version\"",
@@ -90,8 +90,8 @@
90
90
  "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"
91
91
  },
92
92
  "devDependencies": {
93
- "@ai-ecoverse/slicc-cdp": "2.1.11",
94
- "@ai-ecoverse/slicc-shared-web": "2.16.1",
93
+ "@ai-ecoverse/slicc-cdp": "2.1.14",
94
+ "@ai-ecoverse/slicc-shared-web": "2.17.0",
95
95
  "@biomejs/biome": "2.6.7",
96
96
  "ajv": "8.20.0",
97
97
  "ajv-formats": "3.0.1",