Download scripts/search/check_reader_navigation_baseline.mjs from VoiceOfML/Search: direct link, hf CLI and curl.
- Browser
- Download file 2.83 kB
-
https://huggingface.co/spaces/VoiceOfML/Search/resolve/main/scripts/search/check_reader_navigation_baseline.mjs
- Command line
-
hf download hf://spaces/VoiceOfML/Search/scripts/search/check_reader_navigation_baseline.mjs
-
curl -L -o check_reader_navigation_baseline.mjs https://huggingface.co/spaces/VoiceOfML/Search/resolve/main/scripts/search/check_reader_navigation_baseline.mjs
2.83 kB
| 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; | |
| } | |