vomebook commited on
Commit ยท
2db6cf4
1
Parent(s): b2c4db9
Organize chapter layout and image reader contracts
Browse filesFiles changed (17)
- README.md+3-1
- eslint.config.mjs+1-1
- scripts/reader/README.txt+5
- scripts/check_reader_core_coverage.mjs โ scripts/reader/check_reader_core_coverage.mjsRenamed+9-9
- scripts/check_reader_image_loader_coverage.mjs โ scripts/reader/check_reader_image_loader_coverage.mjsRenamed+3-3
- tests/reader/chapters/README.txtAdded+15
- tests/test_reader_chapter_preload.js โ tests/reader/chapters/test_reader_chapter_preload.jsRenamed+1-1
- tests/test_reader_chapter_repository.js โ tests/reader/chapters/test_reader_chapter_repository.jsRenamed+3-3
- tests/test_reader_chapter_scheduler.js โ tests/reader/chapters/test_reader_chapter_scheduler.jsRenamed+1-1
- tests/reader/images/README.txtAdded+15
- tests/test_reader_image_loader.mjs โ tests/reader/images/test_reader_image_loader.mjsRenamed+1-1
- tests/test_reader_image_loader_contract.mjs โ tests/reader/images/test_reader_image_loader_contract.mjsRenamed+1-1
- tests/test_reader_image_memory.mjs โ tests/reader/images/test_reader_image_memory.mjsRenamed+1-1
- tests/reader/layout/README.txtAdded+12
- tests/test_reader_scroll_anchor.js โ tests/reader/layout/test_reader_scroll_anchor.jsRenamed+2-2
- tests/test_reader_section_virtualizer.js โ tests/reader/layout/test_reader_section_virtualizer.jsRenamed+2-2
- tests/test_static_checks.py+14-14
16 unmodified lines1718192021222311 unmodified lines35363738394016 unmodified lines- `app.py`ใ`backend/`๏ผๆๅกๅ ฅๅฃไธๅ็ซฏๆจกๅ๏ผ`backend/native/` ไธบๆฌๅฐๆ็ดข็ดขๅผๆฉๅฑๆบ็ ใ- `static/`๏ผSpace ็ๆ็ดขใ้ ่ฏปๅจๅ Service Worker ่ตๆบ๏ผ`data/` ไธบๆ็ดข็ดขๅผๅ็ฎๅฝๆฐๆฎใ- `tests/`๏ผๅ็ซฏใNode ๅๆต่งๅจๆต่ฏ๏ผๅทฒๆด็็้ขๅๆต่ฏๆพๅจ `tests/search/`ใ`tests/reader/` ็ญ็ฎๅฝใPDF ๅ จๆๆ็ดข่ง `tests/reader/pdf-search/README.txt`๏ผPDF ็ฝ็ป่ง `tests/reader/pdf-network/README.txt`๏ผ่ฏทๆฑๅๆๆกฃๅ ่ฝฝ่ง `tests/reader/transport/README.txt`ใ- `scripts/build/`ใ`scripts/benchmarks/`๏ผๆๅปบๅๅบๅ๏ผ`scripts/reader/`ใ`scripts/search/` ๆฏๆ้ขๅๅฝ็ป็ๆฃๆฅ๏ผๅ ถไปๆฃๆฅๆ็ๅจ `scripts/`ใ- `quality/`๏ผ่ฆ็็ใไธฅๆ ผๆฃๆฅๅ mutation ๅฎกๆ ธๅบ็บฟ๏ผ`Dockerfile` ๅฎไนๆๅปบๅ้จ็ฝฒ้จ็ฆใ11 unmodified linesnode scripts/reader/check_document_loader_coverage.mjsnode scripts/reader/check_pdf_network_coverage.mjsnode scripts/reader/check_pdf_network_mutations.mjs```ๆต่งๅจๆต่ฏ่ฟ้่ฆ Playwrightใๆต่งๅจๅ Reader vendor๏ผๅฎๆดๅ็ซๆต่ฏ้ๆฉ่ง GitHub ไปๅบ็ `.github/workflows/reader-refactor.yml`ใAndroid ๅ ฑไบซๅญๅจๅธธไปฅ `noexec` ๆ่ฝฝ๏ผๅบๅจๆฏๆๆง่กๅ็ฌฆๅท้พๆฅ็็ฎๅฝไธญๅฎ่ฃ ไพ่ตๅ่ฟ่กๆฃๆฅใไฟฎๆนไธ่ชๅจๅๅธ๏ผๆถๅๅไปๅบ็ๅๆดๅบๅ ๅๅธ Space๏ผๅๅๅธ GitHub ไปๅบๅนถๆฃๆฅๅ็ซ CI๏ผGitHub ๅทฅไฝๆตไผๆๅ Space ็ main๏ผใ16 unmodified lines1718192021222311 unmodified lines353637383940414216 unmodified lines- `app.py`ใ`backend/`๏ผๆๅกๅ ฅๅฃไธๅ็ซฏๆจกๅ๏ผ`backend/native/` ไธบๆฌๅฐๆ็ดข็ดขๅผๆฉๅฑๆบ็ ใ- `static/`๏ผSpace ็ๆ็ดขใ้ ่ฏปๅจๅ Service Worker ่ตๆบ๏ผ`data/` ไธบๆ็ดข็ดขๅผๅ็ฎๅฝๆฐๆฎใ- `tests/`๏ผๅ็ซฏใNode ๅๆต่งๅจๆต่ฏ๏ผๅทฒๆด็็้ขๅๆต่ฏๆพๅจ `tests/search/`ใ`tests/reader/` ็ญ็ฎๅฝใPDF ๅ จๆๆ็ดข่ง `tests/reader/pdf-search/README.txt`๏ผPDF ็ฝ็ป่ง `tests/reader/pdf-network/README.txt`๏ผ่ฏทๆฑๅๆๆกฃๅ ่ฝฝ่ง `tests/reader/transport/README.txt`๏ผ็ซ ่ๅๅธๅฑ่ง `tests/reader/chapters/` ไธ `tests/reader/layout/`๏ผๅพ็ๅ ่ฝฝ่ง `tests/reader/images/`ใ- `scripts/build/`ใ`scripts/benchmarks/`๏ผๆๅปบๅๅบๅ๏ผ`scripts/reader/`ใ`scripts/search/` ๆฏๆ้ขๅๅฝ็ป็ๆฃๆฅ๏ผๅ ถไปๆฃๆฅๆ็ๅจ `scripts/`ใ- `quality/`๏ผ่ฆ็็ใไธฅๆ ผๆฃๆฅๅ mutation ๅฎกๆ ธๅบ็บฟ๏ผ`Dockerfile` ๅฎไนๆๅปบๅ้จ็ฝฒ้จ็ฆใ11 unmodified linesnode scripts/reader/check_document_loader_coverage.mjsnode scripts/reader/check_pdf_network_coverage.mjsnode scripts/reader/check_pdf_network_mutations.mjsnode scripts/reader/check_reader_core_coverage.mjsnode scripts/reader/check_reader_image_loader_coverage.mjs```ๆต่งๅจๆต่ฏ่ฟ้่ฆ Playwrightใๆต่งๅจๅ Reader vendor๏ผๅฎๆดๅ็ซๆต่ฏ้ๆฉ่ง GitHub ไปๅบ็ `.github/workflows/reader-refactor.yml`ใAndroid ๅ ฑไบซๅญๅจๅธธไปฅ `noexec` ๆ่ฝฝ๏ผๅบๅจๆฏๆๆง่กๅ็ฌฆๅท้พๆฅ็็ฎๅฝไธญๅฎ่ฃ ไพ่ตๅ่ฟ่กๆฃๆฅใไฟฎๆนไธ่ชๅจๅๅธ๏ผๆถๅๅไปๅบ็ๅๆดๅบๅ ๅๅธ Space๏ผๅๅๅธ GitHub ไปๅบๅนถๆฃๆฅๅ็ซ CI๏ผGitHub ๅทฅไฝๆตไผๆๅ Space ็ main๏ผใ
56 unmodified lines57585960616256 unmodified lines{ files: ["{scripts,tests}/**/*.js"], languageOptions: { sourceType: "commonjs" } },{ files: ["tests/reader/djvu/test_reader_djvu_only.mjs"], languageOptions: { globals: { VoiceOfMLReader: "readonly" } } },{ files: ["tests/reader/djvu/test_reader_djvu_png.mjs"], languageOptions: { globals: { VoiceOfMLReaderSecurity: "readonly" } } },{ files: ["tests/test_reader_image_memory.mjs"], languageOptions: { globals: { window: "readonly" } } },{ files: ["tests/test_reader_pdf_scroll_scheduling.mjs"], languageOptions: { globals: { document: "readonly" } } }];56 unmodified lines57585960616256 unmodified lines{ files: ["{scripts,tests}/**/*.js"], languageOptions: { sourceType: "commonjs" } },{ files: ["tests/reader/djvu/test_reader_djvu_only.mjs"], languageOptions: { globals: { VoiceOfMLReader: "readonly" } } },{ files: ["tests/reader/djvu/test_reader_djvu_png.mjs"], languageOptions: { globals: { VoiceOfMLReaderSecurity: "readonly" } } },{ files: ["tests/reader/images/test_reader_image_memory.mjs"], languageOptions: { globals: { window: "readonly" } } },{ files: ["tests/test_reader_pdf_scroll_scheduling.mjs"], languageOptions: { globals: { document: "readonly" } } }];
7 unmodified lines8910111213147 unmodified linesnode scripts/reader/check_document_loader_coverage.mjsnode scripts/reader/check_pdf_network_coverage.mjsnode scripts/reader/check_pdf_network_mutations.mjsThe PDF network gates are documented in `tests/reader/pdf-network/README.txt`.The request and document loading gates are documented in`tests/reader/transport/README.txt`.7 unmodified lines89101112131415161718197 unmodified linesnode scripts/reader/check_document_loader_coverage.mjsnode scripts/reader/check_pdf_network_coverage.mjsnode scripts/reader/check_pdf_network_mutations.mjsnode scripts/reader/check_reader_core_coverage.mjsnode scripts/reader/check_reader_image_loader_coverage.mjsThe image contracts are documented in `tests/reader/images/README.txt`.The chapter and layout gate is documented in `tests/reader/chapters/README.txt`and `tests/reader/layout/README.txt`.The PDF network gates are documented in `tests/reader/pdf-network/README.txt`.The request and document loading gates are documented in`tests/reader/transport/README.txt`.
1234567891011121314151613 unmodified lines3031323334353637383940import { spawnSync } from "node:child_process";import {hasPassingTapContracts} from "./check_tap_contracts.mjs";// Each run includes exactly one own-source file, so Node's aggregate// thresholds cannot hide a regression in another file or in an empty report.// Baseline measured 2026-11-03 on Node v26.11.1, using the named tests only.const gates = [{ source:"reader-section-virtualizer.js", directory:"formats", lines:100, branches:100, functions:100,tests:["tests/test_reader_section_virtualizer.js"] },{ source:"reader-chapter-repository.js", directory:"formats", lines:100, branches:98.86, functions:100,tests:["tests/test_reader_chapter_repository.js", "tests/test_reader_chapter_scheduler.js", "tests/test_reader_chapter_preload.js"] },{ source:"reader-scroll-anchor.js", directory:"ui", lines:100, branches:89.61, functions:100,tests:["tests/test_reader_scroll_anchor.js"] }];for (const gate of gates) {13 unmodified lines});const values = rows.length === 1 ? rows[0].split("|").slice(1,4).map(value=>Number(value.trim())) : [];const text = result.stdout || "";const expected = {"tests/test_reader_section_virtualizer.js": "reader section virtualizer contracts passed","tests/test_reader_chapter_repository.js": "reader chapter repository contracts passed","tests/test_reader_chapter_scheduler.js": "reader chapter scheduler contracts passed","tests/test_reader_chapter_preload.js": "chapter manifest preload validation, reuse, body deadline and disposal passed","tests/test_reader_scroll_anchor.js": "reader scroll anchor contracts passed"};const missingTests = gate.tests.some(name => typeof expected[name] !== "string") ||!hasPassingTapContracts(text, gate.tests.map(name => ({name, marker: expected[name]})));if (result.status !== 0 || rows.length !== 1 ||1234567891011121314151613 unmodified lines3031323334353637383940import { spawnSync } from "node:child_process";import {hasPassingTapContracts} from "../check_tap_contracts.mjs";// Each run includes exactly one own-source file, so Node's aggregate// thresholds cannot hide a regression in another file or in an empty report.// Baseline measured 2026-11-03 on Node v26.11.1, using the named tests only.const gates = [{ source:"reader-section-virtualizer.js", directory:"formats", lines:100, branches:100, functions:100,tests:["tests/reader/layout/test_reader_section_virtualizer.js"] },{ source:"reader-chapter-repository.js", directory:"formats", lines:100, branches:98.86, functions:100,tests:["tests/reader/chapters/test_reader_chapter_repository.js", "tests/reader/chapters/test_reader_chapter_scheduler.js", "tests/reader/chapters/test_reader_chapter_preload.js"] },{ source:"reader-scroll-anchor.js", directory:"ui", lines:100, branches:89.61, functions:100,tests:["tests/reader/layout/test_reader_scroll_anchor.js"] }];for (const gate of gates) {13 unmodified lines});const values = rows.length === 1 ? rows[0].split("|").slice(1,4).map(value=>Number(value.trim())) : [];const text = result.stdout || "";const expected = {"tests/reader/layout/test_reader_section_virtualizer.js": "reader section virtualizer contracts passed","tests/reader/chapters/test_reader_chapter_repository.js": "reader chapter repository contracts passed","tests/reader/chapters/test_reader_chapter_scheduler.js": "reader chapter scheduler contracts passed","tests/reader/chapters/test_reader_chapter_preload.js": "chapter manifest preload validation, reuse, body deadline and disposal passed","tests/reader/layout/test_reader_scroll_anchor.js": "reader scroll anchor contracts passed"};const missingTests = gate.tests.some(name => typeof expected[name] !== "string") ||!hasPassingTapContracts(text, gate.tests.map(name => ({name, marker: expected[name]})));if (result.status !== 0 || rows.length !== 1 ||
123451 unmodified line789101112134 unmodified lines18192021222324import {spawnSync} from 'node:child_process';import {hasPassingTapContracts} from './check_tap_contracts.mjs';// Node 26/V8, this module only, under the synthetic contracts below.const minimum = [100, 87.18, 91.67];1 unmodified line'--test', '--test-concurrency=1', '--test-reporter=tap', '--experimental-test-coverage','--test-coverage-include=**/static/reader/formats/reader-image-loader.mjs',...minimum.map((value, index) => `--test-coverage-${['lines', 'branches', 'functions'][index]}=${value}`),'tests/test_reader_image_loader.mjs', 'tests/test_reader_image_loader_contract.mjs'], {encoding: 'utf8'});if (result.stdout) process.stdout.write(result.stdout);if (result.stderr) process.stderr.write(result.stderr);4 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const required = [{name: 'tests/test_reader_image_loader.mjs', marker: 'Reader image loader: direct load, cleanup, cancellation, HTTP errors and bounded fallback passed'},{name: 'direct image success clears handlers and the tracked resource'},{name: 'image cancellation settles immediately even when the reader stays active'},{name: 'resource disposal settles without retaining handlers or starting fallback'}123451 unmodified line789101112134 unmodified lines18192021222324import {spawnSync} from 'node:child_process';import {hasPassingTapContracts} from '../check_tap_contracts.mjs';// Node 26/V8, this module only, under the synthetic contracts below.const minimum = [100, 87.18, 91.67];1 unmodified line'--test', '--test-concurrency=1', '--test-reporter=tap', '--experimental-test-coverage','--test-coverage-include=**/static/reader/formats/reader-image-loader.mjs',...minimum.map((value, index) => `--test-coverage-${['lines', 'branches', 'functions'][index]}=${value}`),'tests/reader/images/test_reader_image_loader.mjs', 'tests/reader/images/test_reader_image_loader_contract.mjs'], {encoding: 'utf8'});if (result.stdout) process.stdout.write(result.stdout);if (result.stderr) process.stderr.write(result.stderr);4 unmodified linesreturn match ? [match.slice(1).map(Number)] : [];});const required = [{name: 'tests/reader/images/test_reader_image_loader.mjs', marker: 'Reader image loader: direct load, cleanup, cancellation, HTTP errors and bounded fallback passed'},{name: 'direct image success clears handlers and the tracked resource'},{name: 'image cancellation settles immediately even when the reader stays active'},{name: 'resource disposal settles without retaining handlers or starting fallback'}
123456789101112131415Reader chapter repository, scheduling and preload contracts===========================================================
Run from the repository root with Node 26:
node scripts/reader/check_reader_core_coverage.mjs
The chapter contracts exercise shared loads, bounded demand scheduling,cancellation, disposal, preload validation and resource ownership. The gatemeasures reader-chapter-repository.js only for this group and requires 100%lines, 98.86% branches and 100% functions. It also independently gates thesection virtualizer and scroll-anchor modules described in ../layout/README.txt.
These synthetic Node contracts do not replace Reader browser integration tests.The chapter preload test accepts an optional repository root argument.1 unmodified line23456781 unmodified lineconst fs = require('fs');const path = require('path');const vm = require('vm');const root = process.argv[2] ? path.resolve(process.argv[2]) : path.resolve(__dirname, '..');const contract = fs.readFileSync(path.join(root, 'static/reader/core/reader-contract.js'), 'utf8');const security = fs.readFileSync(path.join(root, 'static/reader/core/reader-security.js'), 'utf8');const source = 'https://voiceofml-search.hf.space/api/reader-bucket-resource?path=' + encodeURIComponent(1 unmodified line23456781 unmodified lineconst fs = require('fs');const path = require('path');const vm = require('vm');const root = process.argv[2] ? path.resolve(process.argv[2]) : path.resolve(__dirname, '../../..');const contract = fs.readFileSync(path.join(root, 'static/reader/core/reader-contract.js'), 'utf8');const security = fs.readFileSync(path.join(root, 'static/reader/core/reader-security.js'), 'utf8');const source = 'https://voiceofml-search.hf.space/api/reader-bucket-resource?path=' + encodeURIComponent(
5 unmodified lines678910111251 unmodified lines6465666768697027 unmodified lines98991001011021031045 unmodified linesfunction createRepository(options) {const sandbox = { self: {}, DOMException };sandbox.self = sandbox;const filename = path.join(__dirname, "../static/reader/formats/reader-chapter-repository.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });return sandbox.VoiceOfMLReaderChapters.createChapterRepository(options);}51 unmodified linessandbox.self = sandbox;vm.createContext(sandbox);vm.runInContext('Array.from = () => new Array(1)', sandbox);const filename = path.join(__dirname, "../static/reader/formats/reader-chapter-repository.js");vm.runInContext(fs.readFileSync(filename, "utf8"), sandbox, {filename});let finds = 0;const sparse = sandbox.VoiceOfMLReaderChapters.createChapterRepository({count:1,27 unmodified linesassert.strictEqual(cancelled.pending.length, 0);const fallback = { DOMException, AbortController };const filename = path.join(__dirname, "../static/reader/formats/reader-chapter-repository.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), fallback, { filename });assert.strictEqual(typeof fallback.VoiceOfMLReaderChapters.createChapterRepository, "function");console.log("reader chapter repository contracts passed");5 unmodified lines678910111251 unmodified lines6465666768697027 unmodified lines98991001011021031045 unmodified linesfunction createRepository(options) {const sandbox = { self: {}, DOMException };sandbox.self = sandbox;const filename = path.join(__dirname, "../../../static/reader/formats/reader-chapter-repository.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });return sandbox.VoiceOfMLReaderChapters.createChapterRepository(options);}51 unmodified linessandbox.self = sandbox;vm.createContext(sandbox);vm.runInContext('Array.from = () => new Array(1)', sandbox);const filename = path.join(__dirname, "../../../static/reader/formats/reader-chapter-repository.js");vm.runInContext(fs.readFileSync(filename, "utf8"), sandbox, {filename});let finds = 0;const sparse = sandbox.VoiceOfMLReaderChapters.createChapterRepository({count:1,27 unmodified linesassert.strictEqual(cancelled.pending.length, 0);const fallback = { DOMException, AbortController };const filename = path.join(__dirname, "../../../static/reader/formats/reader-chapter-repository.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), fallback, { filename });assert.strictEqual(typeof fallback.VoiceOfMLReaderChapters.createChapterRepository, "function");console.log("reader chapter repository contracts passed");
5 unmodified lines67891011125 unmodified linesasync function main() {const sandbox = { DOMException, AbortController };sandbox.self = sandbox;const filename = path.join(__dirname, "../static/reader/formats/reader-chapter-repository.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });const starts = [], held = new Map();const scheduler = sandbox.VoiceOfMLReaderChapters.createChapterScheduler({5 unmodified lines67891011125 unmodified linesasync function main() {const sandbox = { DOMException, AbortController };sandbox.self = sandbox;const filename = path.join(__dirname, "../../../static/reader/formats/reader-chapter-repository.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });const starts = [], held = new Map();const scheduler = sandbox.VoiceOfMLReaderChapters.createChapterScheduler({
123456789101112131415Reader image loading and memory contracts=========================================
Run from the repository root with Node 26:
node tests/reader/images/test_reader_image_loader.mjs node scripts/reader/check_reader_image_loader_coverage.mjs node tests/reader/images/test_reader_image_memory.mjs
The image-loader gate runs named synthetic lifecycle, fallback and cancellationcontracts for static/reader/formats/reader-image-loader.mjs only. Its V8 floorsare 100% lines, 87.18% branches and 91.67% functions. The separate memory testexercises PDF/image rendering and eviction; it is not included in that gate.The memory test accepts an optional repository root argument. Site-specificexpectations remain distinct. Both sites run these tests in the Reader workflow.12345import assert from "node:assert/strict";import { createReaderImageLoader } from "../static/reader/formats/reader-image-loader.mjs";const oldLocation = globalThis.location;const oldNavigator = Object.getOwnPropertyDescriptor(globalThis, "navigator");12345import assert from "node:assert/strict";import { createReaderImageLoader } from "../../../static/reader/formats/reader-image-loader.mjs";const oldLocation = globalThis.location;const oldNavigator = Object.getOwnPropertyDescriptor(globalThis, "navigator");
123456import assert from 'node:assert/strict';import test from 'node:test';import {createReaderImageLoader} from '../static/reader/formats/reader-image-loader.mjs';function fixture() {const controller = new AbortController(), tracked = new Set(), requests = [];123456import assert from 'node:assert/strict';import test from 'node:test';import {createReaderImageLoader} from '../../../static/reader/formats/reader-image-loader.mjs';function fixture() {const controller = new AbortController(), tracked = new Set(), requests = [];
1 unmodified line23456781 unmodified lineimport path from 'node:path';import {fileURLToPath, pathToFileURL} from 'node:url';const root = path.resolve(process.argv[2] || path.join(path.dirname(fileURLToPath(import.meta.url)), '..'));const load = name => import(pathToFileURL(path.join(root, 'static/reader', name)).href);const {createReaderPdfScheduler} = await load('pdf/reader-pdf-scheduler.mjs');const {createReaderPdfRenderer, pdfOutputScale} = await load('pdf/reader-pdf-renderer.mjs');1 unmodified line23456781 unmodified lineimport path from 'node:path';import {fileURLToPath, pathToFileURL} from 'node:url';const root = path.resolve(process.argv[2] || path.join(path.dirname(fileURLToPath(import.meta.url)), '../../..'));const load = name => import(pathToFileURL(path.join(root, 'static/reader', name)).href);const {createReaderPdfScheduler} = await load('pdf/reader-pdf-scheduler.mjs');const {createReaderPdfRenderer, pdfOutputScale} = await load('pdf/reader-pdf-renderer.mjs');
123456789101112Reader layout contracts=======================
Run from the repository root with Node 26:
node scripts/reader/check_reader_core_coverage.mjs
The section virtualizer contracts require 100% lines, branches and functionsfor reader-section-virtualizer.js. The scroll-anchor contracts require 100%lines, 89.61% branches and 100% functions for reader-scroll-anchor.js. The gatealso independently measures the chapter repository; see ../chapters/README.txt.All thresholds are source-specific, not whole-Reader or browser coverage.5 unmodified lines6789101112134 unmodified lines1471481491501511521535 unmodified linesfunction loadManager(options) {const sandbox = { self: {} };sandbox.self = sandbox;const filename = path.join(__dirname, "../static/reader/ui/reader-scroll-anchor.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });return sandbox.VoiceOfMLReaderScroll.createScrollAnchorManager(options);}134 unmodified linesassert.strictEqual(noObserver.capture(), null);noObserver.dispose();const filename = path.join(__dirname, "../static/reader/ui/reader-scroll-anchor.js");const fallback = {};vm.runInNewContext(fs.readFileSync(filename, "utf8"), fallback, { filename });assert.strictEqual(typeof fallback.VoiceOfMLReaderScroll.createScrollAnchorManager, "function");5 unmodified lines6789101112134 unmodified lines1471481491501511521535 unmodified linesfunction loadManager(options) {const sandbox = { self: {} };sandbox.self = sandbox;const filename = path.join(__dirname, "../../../static/reader/ui/reader-scroll-anchor.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });return sandbox.VoiceOfMLReaderScroll.createScrollAnchorManager(options);}134 unmodified linesassert.strictEqual(noObserver.capture(), null);noObserver.dispose();const filename = path.join(__dirname, "../../../static/reader/ui/reader-scroll-anchor.js");const fallback = {};vm.runInNewContext(fs.readFileSync(filename, "utf8"), fallback, { filename });assert.strictEqual(typeof fallback.VoiceOfMLReaderScroll.createScrollAnchorManager, "function");
5 unmodified lines678910111224 unmodified lines373839404142435 unmodified linesfunction loadVirtualizer(options) {const sandbox = { self: {} };sandbox.self = sandbox;const filename = path.join(__dirname, "../static/reader/formats/reader-section-virtualizer.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });return sandbox.VoiceOfMLReaderVirtual.createSectionVirtualizer(options);}24 unmodified linesvirtualizer.dispose();assert.strictEqual(virtualizer.trim(0).removed, 0);const fallback = {};const filename = path.join(__dirname, "../static/reader/formats/reader-section-virtualizer.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), fallback, { filename });assert.strictEqual(typeof fallback.VoiceOfMLReaderVirtual.createSectionVirtualizer, "function");console.log("reader section virtualizer contracts passed");5 unmodified lines678910111224 unmodified lines373839404142435 unmodified linesfunction loadVirtualizer(options) {const sandbox = { self: {} };sandbox.self = sandbox;const filename = path.join(__dirname, "../../../static/reader/formats/reader-section-virtualizer.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), sandbox, { filename });return sandbox.VoiceOfMLReaderVirtual.createSectionVirtualizer(options);}24 unmodified linesvirtualizer.dispose();assert.strictEqual(virtualizer.trim(0).removed, 0);const fallback = {};const filename = path.join(__dirname, "../../../static/reader/formats/reader-section-virtualizer.js");vm.runInNewContext(fs.readFileSync(filename, "utf8"), fallback, { filename });assert.strictEqual(typeof fallback.VoiceOfMLReaderVirtual.createSectionVirtualizer, "function");console.log("reader section virtualizer contracts passed");
1121 unmodified lines1122112311241125112611271128112911301131113211331134113511361137113811391140114113 unmodified lines11551156115711581159116011611162116311641165286 unmodified lines1452145314541455145614571458145914601121 unmodified linespaths = ["static/reader/formats/reader-section-virtualizer.js","static/reader/formats/reader-chapter-repository.js","static/reader/ui/reader-scroll-anchor.js", "static/reader/core/reader-contract.js","static/reader/core/reader-security.js", "scripts/check_reader_core_coverage.mjs","tests/test_reader_section_virtualizer.js", "tests/test_reader_chapter_repository.js","tests/test_reader_chapter_scheduler.js", "tests/test_reader_chapter_preload.js","tests/test_reader_scroll_anchor.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", "scripts/check_reader_core_coverage.mjs"]self.assert_check(self.run_check(*check), True, "reader-chapter-repository.js")gate = self.root / "scripts/check_reader_core_coverage.mjs"original_gate = gate.read_text()first = 'tests/test_reader_chapter_repository.js'second = 'tests/test_reader_chapter_scheduler.js'list_anchor = '"' + first + '", "' + second + '",'self.assertEqual(original_gate.count(list_anchor), 1)gate.write_text(original_gate.replace(list_anchor, '"' + first + '", "' + first + '",'))13 unmodified lineschapter_test.write_text(original_test.replace('reader chapter repository contracts passed', 'renamed success marker'))self.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test)(self.root / "tests/test_reader_scroll_anchor.js").write_text('const test = require("node:test"); test("empty", () => {});\n')self.assert_check(self.run_check(*check), False, "reader-scroll-anchor.js")(self.root / "tests/test_reader_scroll_anchor.js").write_text('require("../static/reader/ui/reader-scroll-anchor.js");\n')self.assert_check(self.run_check(*check), False, "coverage")def test_pdf_network_safety_mutation_gate_rejects_unexpected_failure(self):286 unmodified linesself.assert_check(self.run_check(*check), False, 'one source row above each minimum')def test_reader_image_loader_coverage_gate_fails_closed(self):paths = ["static/reader/formats/reader-image-loader.mjs", "scripts/check_reader_image_loader_coverage.mjs","scripts/check_tap_contracts.mjs", "tests/test_reader_image_loader.mjs","tests/test_reader_image_loader_contract.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)1121 unmodified lines1122112311241125112611271128112911301131113211331134113511361137113811391140114113 unmodified lines11551156115711581159116011611162116311641165286 unmodified lines1452145314541455145614571458145914601121 unmodified linespaths = ["static/reader/formats/reader-section-virtualizer.js","static/reader/formats/reader-chapter-repository.js","static/reader/ui/reader-scroll-anchor.js", "static/reader/core/reader-contract.js","static/reader/core/reader-security.js", "scripts/reader/check_reader_core_coverage.mjs","tests/reader/layout/test_reader_section_virtualizer.js", "tests/reader/chapters/test_reader_chapter_repository.js","tests/reader/chapters/test_reader_chapter_scheduler.js", "tests/reader/chapters/test_reader_chapter_preload.js","tests/reader/layout/test_reader_scroll_anchor.js"]for path in [*paths, "scripts/check_tap_contracts.mjs"]:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)shutil.copyfile(ROOT / path, target)check = ["node", paths[5]]self.assert_check(self.run_check(*check), True, "reader-chapter-repository.js")gate = self.root / paths[5]original_gate = gate.read_text()first = 'tests/reader/chapters/test_reader_chapter_repository.js'second = 'tests/reader/chapters/test_reader_chapter_scheduler.js'list_anchor = '"' + first + '", "' + second + '",'self.assertEqual(original_gate.count(list_anchor), 1)gate.write_text(original_gate.replace(list_anchor, '"' + first + '", "' + first + '",'))13 unmodified lineschapter_test.write_text(original_test.replace('reader chapter repository contracts passed', 'renamed success marker'))self.assert_check(self.run_check(*check), False, "passing named tests")chapter_test.write_text(original_test)(self.root / paths[10]).write_text('const test = require("node:test"); test("empty", () => {});\n')self.assert_check(self.run_check(*check), False, "reader-scroll-anchor.js")(self.root / paths[10]).write_text('require("../../../static/reader/ui/reader-scroll-anchor.js");\n')self.assert_check(self.run_check(*check), False, "coverage")def test_pdf_network_safety_mutation_gate_rejects_unexpected_failure(self):286 unmodified linesself.assert_check(self.run_check(*check), False, 'one source row above each minimum')def test_reader_image_loader_coverage_gate_fails_closed(self):paths = ["static/reader/formats/reader-image-loader.mjs", "scripts/reader/check_reader_image_loader_coverage.mjs","scripts/check_tap_contracts.mjs", "tests/reader/images/test_reader_image_loader.mjs","tests/reader/images/test_reader_image_loader_contract.mjs"]for path in paths:target = self.root / pathtarget.parent.mkdir(parents=True, exist_ok=True)
README.md+3-1
eslint.config.mjs+1-1
scripts/reader/README.txt+5
scripts/check_reader_core_coverage.mjs โ scripts/reader/check_reader_core_coverage.mjsRenamed+9-9
scripts/check_reader_image_loader_coverage.mjs โ scripts/reader/check_reader_image_loader_coverage.mjsRenamed+3-3
tests/reader/chapters/README.txtAdded+15
tests/test_reader_chapter_preload.js โ tests/reader/chapters/test_reader_chapter_preload.jsRenamed+1-1
tests/test_reader_chapter_repository.js โ tests/reader/chapters/test_reader_chapter_repository.jsRenamed+3-3
tests/test_reader_chapter_scheduler.js โ tests/reader/chapters/test_reader_chapter_scheduler.jsRenamed+1-1
tests/reader/images/README.txtAdded+15
tests/test_reader_image_loader.mjs โ tests/reader/images/test_reader_image_loader.mjsRenamed+1-1
tests/test_reader_image_loader_contract.mjs โ tests/reader/images/test_reader_image_loader_contract.mjsRenamed+1-1
tests/test_reader_image_memory.mjs โ tests/reader/images/test_reader_image_memory.mjsRenamed+1-1
tests/reader/layout/README.txtAdded+12
tests/test_reader_scroll_anchor.js โ tests/reader/layout/test_reader_scroll_anchor.jsRenamed+2-2
tests/test_reader_section_virtualizer.js โ tests/reader/layout/test_reader_section_virtualizer.jsRenamed+2-2
tests/test_static_checks.py+14-14