@ai-ecoverse/slicc-shared-web 1.18.0 → 1.19.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.
package/README.md CHANGED
@@ -20,7 +20,7 @@ Install it from npm, and pin the reusable workflow to the matching `vX.Y.Z` tag.
20
20
  npm install --save-dev --save-exact @ai-ecoverse/slicc-shared-web
21
21
  ```
22
22
 
23
- The hooks expect two scripts in each repo: `test:unit`, which writes `coverage/unit/lcov.info` (unit tests stay out of git), and, in TypeScript repos, `typecheck`. The reusable workflow expects `lint`, plus `test` for the integration tests, with a `pretest` that installs Chromium (`slicc-cdp install-browser --version <x.y.z.w>`, or `playwright-core install --no-shell chromium`). Its inputs `lint`, `test`, `chromium` and `node-version` override those, and `timeout-minutes` (20 by default) gives a long job, such as a background-tab measurement, more time. `runs-on` (`ubuntu-latest` by default) picks the runner label, such as a self-hosted pool or one an earlier job chose; the caller decides which runner may run which code, so a fork's pull request should stay on a GitHub-hosted runner. With `chromium` on, Chromium's system libraries are installed with `playwright-core install-deps` only where it runs as root or `sudo -n true` works; on a runner without root (one with "no new privileges", say) the step is skipped with a notice and the image must already ship them. The `pretest` download needs no root either way. The diff-coverage hook runs `diff-cover` through `uvx`, so install [uv](https://docs.astral.sh/uv/) once.
23
+ The hooks expect two scripts in each repo: `test:unit`, which writes `coverage/unit/lcov.info` (unit tests stay out of git), and, in TypeScript repos, `typecheck`. The reusable workflow expects `lint`, plus `test` for the integration tests, with a `pretest` that installs Chromium (`slicc-cdp install-browser --version <x.y.z.w>`, or `playwright-core install --no-shell chromium`). Its inputs `lint`, `test`, `chromium`, `chromium-cache` and `node-version` override those, and `timeout-minutes` (20 by default) gives a long job, such as a background-tab measurement, more time. `runs-on` (`ubuntu-latest` by default) picks the runner label, such as a self-hosted pool or one an earlier job chose; the caller decides which runner may run which code, so a fork's pull request should stay on a GitHub-hosted runner. With `chromium` on, Chromium's system libraries are installed with `playwright-core install-deps` only where it runs as root or `sudo -n true` works; on a runner without root (one with "no new privileges", say) the step is skipped with a notice and the image must already ship them. The `pretest` download needs no root either way. With `chromium` on, the workflow also caches Playwright's browser directory (`~/.cache/ms-playwright`, or `$PLAYWRIGHT_BROWSERS_PATH`) with `actions/cache`, keyed on the runner's OS and architecture and the `playwright-core` version in `package-lock.json`, so a warm `pretest` skips the download and a `playwright-core` bump starts a fresh cache. A repo without `playwright-core` in its lockfile gets no cache; `chromium-cache: false` turns it off. The diff-coverage hook runs `diff-cover` through `uvx`, so install [uv](https://docs.astral.sh/uv/) once.
24
24
 
25
25
  ## Rules every repo follows
26
26
 
@@ -150,7 +150,7 @@ A pause in one target blocks every page in the same renderer process, so those p
150
150
  Why it works the way it does:
151
151
 
152
152
  - Playwright detaches from shared workers, which resumes them early, so their coverage started late about half the time. Raw CDP keeps every worker paused until the profiler runs.
153
- - `debugger;` pauses in `beforeunload` but not in `pagehide` or `pageswap`, so a `beforeunload` hook, installed after `Page.enable`, takes the coverage of a page before it navigates. The pause only answers CDP when the page itself starts the navigation, so `goto` and `reload` go through `location`, never `Page.navigate` or `Page.reload`. Navigating away from `about:blank` skips the coverage dump so the first real load is not held in `beforeunload` for a useless snapshot.
153
+ - `debugger;` pauses in `beforeunload` but not in `pagehide` or `pageswap`, so a `beforeunload` hook, installed after `Page.enable`, takes the coverage of a page before it navigates. The pause only answers CDP when the page itself starts the navigation, so `goto` and `reload` go through `location`, never `Page.navigate` or `Page.reload`; they schedule it with `setTimeout` in an isolated world of the page (so page code that replaces its timers can't stop it), so the `Runtime.evaluate` that starts it answers before the old document goes, which otherwise loses the race on a slow runner ("Inspected target navigated or closed"). Navigating away from `about:blank` skips the coverage dump so the first real load is not held in `beforeunload` for a useless snapshot.
154
154
  - `goto` used to return as soon as the document swapped (`window.stale` cleared), which is before `readyState` is `complete` and before module scripts run. About 1 load in 20 then looked blank to the next assertion. It now waits for a complete, non-blank document.
155
155
  - `takePreciseCoverage` resets the counters, so every snapshot is a delta, and all of them are kept and summed.
156
156
  - monocart's `add()` from parallel test processes loses data, so each test writes raw JSON and the teardown merges it once.
package/harness/page.mjs CHANGED
@@ -187,7 +187,12 @@ export function page(
187
187
  async function navigate(expression) {
188
188
  for (let attempt = 0; attempt < 2; attempt++) {
189
189
  await evaluate(mark);
190
- await send('Runtime.evaluate', { expression });
190
+ const { frameTree } = await send('Page.getFrameTree');
191
+ const { executionContextId: contextId } = await send('Page.createIsolatedWorld', {
192
+ frameId: frameTree.frame.id,
193
+ worldName: 'slicc-harness-navigate',
194
+ });
195
+ await send('Runtime.evaluate', { expression, contextId });
191
196
  try {
192
197
  await until(fresh);
193
198
  return;
@@ -207,8 +212,11 @@ export function page(
207
212
  within,
208
213
  probed: () => Promise.all(probes),
209
214
  press,
210
- goto: (path) => navigate(`location.assign(${JSON.stringify(new URL(path, server.url).href)})`),
211
- reload: () => navigate('location.reload()'),
215
+ goto: (path) =>
216
+ navigate(
217
+ `setTimeout(() => location.assign(${JSON.stringify(new URL(path, server.url).href)}))`
218
+ ),
219
+ reload: () => navigate('setTimeout(() => location.reload())'),
212
220
  insert: (text) => send('Input.insertText', { text }),
213
221
  close: () => cdp.send('Target.closeTarget', { targetId }),
214
222
  enter: () => press('Enter'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
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",