@ai-ecoverse/slicc-shared-web 1.30.8 → 1.30.9
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 +2 -2
- package/harness/chrome.mjs +4 -6
- package/harness/recorder.mjs +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -248,7 +248,7 @@ SLICC_UNIT_ALL=1 git commit
|
|
|
248
248
|
|
|
249
249
|
## Integration-test harness
|
|
250
250
|
|
|
251
|
-
`harness/` drives Chromium over raw CDP on `--remote-debugging-pipe`, as its only client, from `node --test`. 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. 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`.
|
|
251
|
+
`harness/` drives Chromium over raw CDP on `--remote-debugging-pipe`, as its only client, from `node --test`. 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`.
|
|
252
252
|
|
|
253
253
|
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.
|
|
254
254
|
|
|
@@ -282,7 +282,7 @@ test('boots', async (t) => {
|
|
|
282
282
|
| `roots` | `[urlPrefix, directory]` pairs the local server serves, first match wins | `[['/', 'src/']]` |
|
|
283
283
|
| `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 |
|
|
284
284
|
| `isolated` | Send COOP, COEP and CORP on every response, so pages are cross-origin isolated | `false` |
|
|
285
|
-
| `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 workers
|
|
285
|
+
| `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 | `['/']` |
|
|
286
286
|
| `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 |
|
|
287
287
|
| `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 |
|
|
288
288
|
| `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/chrome.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
unpacked,
|
|
19
19
|
} from './extensions.mjs';
|
|
20
20
|
import { page } from './page.mjs';
|
|
21
|
-
import { breakpoints, recorder } from './recorder.mjs';
|
|
21
|
+
import { autoAttach, breakpoints, recorder, unpaused } from './recorder.mjs';
|
|
22
22
|
import { serve } from './server.mjs';
|
|
23
23
|
import { artifacts, bounded, ignore, sleep, slug, TIMED_OUT } from './util.mjs';
|
|
24
24
|
|
|
@@ -362,11 +362,9 @@ export async function launch({
|
|
|
362
362
|
});
|
|
363
363
|
const remote = await cdn(cdp, intercept);
|
|
364
364
|
await cdp.send('Target.setDiscoverTargets', { discover: true });
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
flatten: true,
|
|
369
|
-
});
|
|
365
|
+
const attaching = autoAttach({ coverage, profiling: profile });
|
|
366
|
+
if (attaching.filter) cdp.on((event) => unpaused(cdp, event));
|
|
367
|
+
await cdp.send('Target.setAutoAttach', attaching);
|
|
370
368
|
const harnessExtension = await (async () => {
|
|
371
369
|
const own = builtin ? await installBuiltin(cdp) : null;
|
|
372
370
|
await install(cdp, found);
|
package/harness/recorder.mjs
CHANGED
|
@@ -10,6 +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
14
|
const sampling = [['Profiler.setSamplingInterval', { interval: 100 }], ['Profiler.start']];
|
|
14
15
|
const unloading = 'sliccHarnessUnload';
|
|
15
16
|
const unload = `addEventListener('beforeunload', function ${unloading}() { debugger; })`;
|
|
@@ -176,6 +177,19 @@ export function ownership(parents) {
|
|
|
176
177
|
};
|
|
177
178
|
}
|
|
178
179
|
|
|
180
|
+
export function autoAttach({ coverage = ['/'], profiling } = {}) {
|
|
181
|
+
const attach = { autoAttach: true, waitForDebuggerOnStart: true, flatten: true };
|
|
182
|
+
if (coverage.length > 0 || profiling) return attach;
|
|
183
|
+
const skipped = [...unheld, 'browser', 'tab'].map((type) => ({ type, exclude: true }));
|
|
184
|
+
return { ...attach, filter: [...skipped, {}] };
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function unpaused(cdp, { method, params }) {
|
|
188
|
+
if (method !== 'Target.targetCreated' || !unheld.includes(params.targetInfo.type)) return null;
|
|
189
|
+
const { targetId } = params.targetInfo;
|
|
190
|
+
return cdp.send('Target.attachToTarget', { targetId, flatten: true }).catch(ignore);
|
|
191
|
+
}
|
|
192
|
+
|
|
179
193
|
export function retain(scripts, result) {
|
|
180
194
|
for (const script of result) {
|
|
181
195
|
const prev = scripts.get(script.url);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.9",
|
|
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",
|