File size: 2,834 Bytes
af1e456
c172b70
af1e456
d101ec0
 
af1e456
 
 
eeb144a
af1e456
c172b70
af1e456
 
 
 
 
 
eeb144a
af1e456
 
 
9bec131
 
af1e456
 
 
 
 
 
 
 
 
70e4ef8
d101ec0
 
 
 
 
af1e456
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import {spawnSync} from 'node:child_process';
import {hasPassingTapContracts} from '../check_tap_contracts.mjs';

// Node 26/V8 scope: this file under synthetic URL/session and shell contracts.
// Native browser traversal, rendering and speech still require browser tests.
const minimum = [31.96, 81.82, 27.27];
const result = spawnSync(process.execPath, [
  '--test', '--test-reporter=tap', '--experimental-test-coverage',
  '--test-coverage-include=**/static/search/reader-host/application/navigation.js',
  ...minimum.map((value, index) => `--test-coverage-${['lines', 'branches', 'functions'][index]}=${value}`),
  'tests/search/reader-navigation/test_reader_navigation_baseline.mjs'
], {encoding: 'utf8'});
if (result.stdout) process.stdout.write(result.stdout);
if (result.stderr) process.stderr.write(result.stderr);
if (result.error) throw result.error;
const text = result.stdout || '';
const rows = text.split(/\r?\n/).flatMap(line => {
  const match = /^\s*#\s*navigation\.js\s*\|\s*(\d+(?:\.\d+)?)\s*\|\s*(\d+(?:\.\d+)?)\s*\|\s*(\d+(?:\.\d+)?)\s*\|/.exec(line);
  return match ? [match.slice(1).map(Number)] : [];
});
const required = [
  'parked reuse keeps the new navigation identity through replacement and recovery',
  'ordinary frames expose a changed src and replacement rejects unowned history',
  'parse accepts only the same-origin reader pathname',
  'ordinary query merging replaces only selected keys and keeps repeated values',
  'hash query merging preserves route and unrelated query components',
  'merge without selected keys preserves existing query and returns a new URL',
  'prepare records the return location and removes the previous handoff',
  'prepare tolerates unavailable storage or token generation without skipping destination validation',
  'remember stores a private reader URL but exposes a sanitized history URL',
  'remember still updates history when storage fails and saved rejects malformed JSON',
  'clear removes only the matching session and selected return token',
  'messages are rejected when no reader iframe is active',
  'pathname and search parameter prototype overrides retain their original effects',
  'replacement revision preserves a Reader opened synchronously during disposal',
  'ordinary replacement carries handoff and focus while releasing background ownership',
  'close recovery validates both search routes without changing history or private handoff',
  'recovery survives late shell load and records handoff only on native link activation'
].map(name => ({name}));
if (result.status !== 0 || rows.length !== 1 || rows[0].some((value, index) => value < minimum[index]) ||
    !hasPassingTapContracts(text, required)) {
  console.error('Reader navigation requires all named baseline contracts and one source row above each minimum');
  process.exitCode = 1;
}