@ai-ecoverse/slicc-shared-web 2.10.0 → 2.10.2

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
@@ -273,7 +273,7 @@ SLICC_UNIT_ALL=1 git commit
273
273
 
274
274
  ## Integration-test harness
275
275
 
276
- `harness/` drives Chromium over raw CDP on `--remote-debugging-pipe`, as its only client, from `node --test`. On CI (`CI` set, as GitHub Actions does) Chrome runs headed, since headless Chrome behaves slightly differently; the pipeline starts Xvfb when the runner has no display. On a developer machine (no `CI`) it runs headless, so a test run doesn't open windows. `SLICC_HEADLESS=1` or `0`, or `launch({ headless })`, overrides either way. On Linux, a headed Chrome on CI (or with no `DISPLAY`) gets an Xvfb display of its own, started with `-displayfd` so it picks a free number and stopped with the browser: browsers launched side by side, as `node --test` runs files with `--test-concurrency`, never share a screen, so none takes another's window focus (four on one display broke `:focus-visible` checks in slicc-spectrum#572). This needs `Xvfb` on `PATH`; without it, Chrome uses `DISPLAY`, and on a Linux desktop without `CI` it always does. A repo that launches its own Chrome, for example on a TCP debugging port that `launch()` doesn't offer, matches this with the same exports: `headlessByDefault(env)` says whether to run headless, `modeFlags(headless)` gives the flags for that mode, and `screenFor(headed, env)` starts the private Xvfb when one is needed and returns `{ env, child, close }`, whose `env` the Chrome process gets. A headed Chrome gets `--enable-unsafe-swiftshader`, so WebGL falls back to software on a display without a GPU, as headless Chrome's does (slicc-bios#901's splash scene saw no WebGL2 otherwise). Every page, service worker, shared worker and dedicated worker, nested ones included, starts paused, gets coverage (and the CPU profiler, when profiling is on) switched on in the same tick, and only then runs. With nothing to collect (`coverage: []` and profiling off) only pages start paused: service and shared workers are left out of the auto-attach and attached once they exist, so they never wait for the harness. A held start that Chrome repeats when it stops and restarts a service worker during an update left the updated worker installed and the next navigation unanswered whenever the harness was slow to run it (slicc-bios#844, #836, #789). Each test gets its own browser context and leaves `artifacts/<suite>/<test>/` behind: a screenshot per tab and a `console.log` of every target. Lines logged before the first test, such as an extension service worker's at startup, go into the first test's `console.log`. The global teardown merges the raw coverage into `coverage/` (console table, lcov, V8 HTML) and writes `artifacts/hotspots.md`.
276
+ `harness/` drives Chromium over raw CDP on `--remote-debugging-pipe`, as its only client, from `node --test`. On CI (`CI` set, as GitHub Actions does) Chrome runs headed, since headless Chrome behaves slightly differently; the pipeline starts Xvfb when the runner has no display. On a developer machine (no `CI`) it runs headless, so a test run doesn't open windows. `SLICC_HEADLESS=1` or `0`, or `launch({ headless })`, overrides either way. On Linux, a headed Chrome on CI (or with no `DISPLAY`) gets an Xvfb display of its own, started with `-displayfd` so it picks a free number and stopped with the browser: browsers launched side by side, as `node --test` runs files with `--test-concurrency`, never share a screen, so none takes another's window focus (four on one display broke `:focus-visible` checks in slicc-spectrum#572). This needs `Xvfb` on `PATH`; without it, Chrome uses `DISPLAY`, and on a Linux desktop without `CI` it always does. A repo that launches its own Chrome, for example on a TCP debugging port that `launch()` doesn't offer, matches this with the same exports: `headlessByDefault(env)` says whether to run headless, `modeFlags(headless)` gives the flags for that mode, and `screenFor(headed, env)` starts the private Xvfb when one is needed and returns `{ env, child, close }`, whose `env` the Chrome process gets. A headed Chrome gets `--enable-unsafe-swiftshader`, so WebGL falls back to software on a display without a GPU, as headless Chrome's does (slicc-bios#901's splash scene saw no WebGL2 otherwise). Every page, service worker, shared worker and dedicated worker, nested ones included, starts paused, gets coverage (and the CPU profiler, when profiling is on) switched on in the same tick, and only then runs. With nothing to collect (`coverage: []` and profiling off) pages and shared workers start paused, and service workers are left out of the auto-attach and attached once they exist, so they never wait for the harness. A held start that Chrome repeats when it stops and restarts a service worker during an update left the updated worker installed and the next navigation unanswered whenever the harness was slow to run it (slicc-bios#844, #836, #789). Shared workers stay in the held auto-attach: attaching one after the fact races its teardown, and Chrome's browser process then crashes on a failed `worker_host_` check in `shared_worker_devtools_agent_host.cc` (slicc-bios#901). Each test gets its own browser context and leaves `artifacts/<suite>/<test>/` behind: a screenshot per tab and a `console.log` of every target. Lines logged before the first test, such as an extension service worker's at startup, go into the first test's `console.log`. The global teardown merges the raw coverage into `coverage/` (console table, lcov, V8 HTML) and writes `artifacts/hotspots.md`.
277
277
 
278
278
  CPU profiling is off by default. V8's sampler interrupts each page and worker thread every 100 µs with a signal, and the renderer SIGSEGVs in slicc-bios#114 all fault inside a signal handler walking the interrupted thread's frames, which points at it. Turn it on with `profile: true` or `SLICC_PROFILE=1` to get one CPU profile per target and snapshot in the test's artifact directory, and the 15 frames with the most self time in the repo's own scripts in `hotspots.md`. Without it, `hotspots.md` says that profiling is off.
279
279
 
@@ -307,7 +307,7 @@ test('boots', async (t) => {
307
307
  | `roots` | `[urlPrefix, directory]` pairs the local server serves, first match wins | `[['/', 'src/']]` |
308
308
  | `aliases` | Extra `[urlPrefix, directory]` pairs used only to map coverage and profiles back to files, for scripts that something else serves, such as a service worker | none |
309
309
  | `isolated` | Send COOP, COEP and CORP on every response, so pages are cross-origin isolated | `false` |
310
- | `coverage` | URL prefixes whose `.js`/`.mjs` scripts count for coverage. `node_modules/` never does. A `.map` next to a file is used. `[]` collects nothing: without profiling, no target gets the debugger, the profiler, exit breakpoints or a `beforeunload` pause, and no worker, service and shared workers included, waits for the harness to start | `['/']` |
310
+ | `coverage` | URL prefixes whose `.js`/`.mjs` scripts count for coverage. `node_modules/` never does. A `.map` next to a file is used. `[]` collects nothing: without profiling, no target gets the debugger, the profiler, exit breakpoints or a `beforeunload` pause, and only pages and shared workers wait for the harness to start | `['/']` |
311
311
  | `exits` | `{ urlPath: [regex, ...] }`: a breakpoint on the first line matching each pattern in that worker script, where the harness takes the worker's coverage and profile before it closes itself | none |
312
312
  | `intercept` | Remote URL prefixes answered from a disk cache in `node_modules/.cache/`. Registry documents (anything on a `registry.*` host but a `/-/….tgz` tarball: packuments, abbreviated or full, and dist-tags) are fetched fresh once per test process and only served from the disk cache when the registry can't be reached (a `4xx` is passed on) | none |
313
313
  | `extensions` | Unpacked extension directories to load. They are loaded with `Extensions.loadUnpacked` (behind `--enable-unsafe-extension-debugging`) once the harness is attached, so their service workers start paused like every other target. Their scripts are covered and profiled like the repo's own, and tests then run in the default browser context, closing their tabs when they end, because Chrome does not run extensions in the per-test contexts | none |
package/harness/cdn.mjs CHANGED
@@ -96,9 +96,15 @@ export async function cdn(cdp, remotes) {
96
96
  const failure = { requestId, responseCode: state.status, responseHeaders: cors };
97
97
  return cdp.send('Fetch.fulfillRequest', failure);
98
98
  }
99
+ let refused = 0;
99
100
  const body = await download(request.url).catch((error) => {
101
+ refused = Number(/^(4\d\d) /.exec(error.message)?.[1] ?? 0);
100
102
  console.warn(`harness: could not serve ${request.url}: ${error.message}`);
101
103
  });
104
+ if (refused) {
105
+ const answer = { requestId, responseCode: refused, responseHeaders: cors };
106
+ return cdp.send('Fetch.fulfillRequest', answer);
107
+ }
102
108
  if (!body) return cdp.send('Fetch.failRequest', { requestId, errorReason: 'Failed' });
103
109
  const sent = Buffer.from(body);
104
110
  if (state.corrupt) sent[sent.length - 1] ^= 0xff;
@@ -10,7 +10,7 @@ import { bounded, ignore, raw, samples, sleep, TIMED_OUT } from './util.mjs';
10
10
  const Util = mcrUtil.Util ?? mcrUtil.default;
11
11
 
12
12
  const profiled = new Set(['page', 'worker', 'service_worker', 'shared_worker']);
13
- const unheld = ['service_worker', 'shared_worker'];
13
+ const unheld = ['service_worker'];
14
14
  const sampling = [['Profiler.setSamplingInterval', { interval: 100 }], ['Profiler.start']];
15
15
  const unloading = 'sliccHarnessUnload';
16
16
  const unload = `addEventListener('beforeunload', function ${unloading}() { debugger; })`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "2.10.0",
3
+ "version": "2.10.2",
4
4
  "description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -66,12 +66,12 @@
66
66
  "release": "semantic-release"
67
67
  },
68
68
  "devDependencies": {
69
- "@ai-ecoverse/slicc-browsers": "1.18.7",
70
- "@ai-ecoverse/slicc-cdp": "1.31.3",
69
+ "@ai-ecoverse/slicc-browsers": "1.18.8",
70
+ "@ai-ecoverse/slicc-cdp": "1.31.4",
71
71
  "@biomejs/biome": "2.5.15",
72
72
  "lefthook": "2.2.2",
73
73
  "monocart-coverage-reports": "2.13.2",
74
- "pnpm": "12.13.0",
74
+ "pnpm": "12.14.0",
75
75
  "semantic-release": "25.0.9"
76
76
  },
77
77
  "peerDependencies": {