cosmic-pdf

Verification

Run npm test for settings, URL handling, takeover/native exemptions, OCR geometry/cancellation and resource limits. Run npm run check for syntax, manifests, bilingual version entries and third-party integrity.

Run PDF_CHROME=/path/to/chrome PDF_PLAYWRIGHT=/path/to/playwright/index.mjs npm run test:browser for integration checks. This uses its own temporary Chrome profile and local authored PDFs, never a user’s open tabs. No fixture contains private documents. Screenshots and metrics are written outside the repository.

The integration suite exercises response-based takeover, signed query preservation, attachment and HTML exceptions, native-reader return, local opening, initial zoom, zoom steps, dark appearance, OCR recognition/cancellation, settings snapshotting and sandbox network isolation. Also check real documents with mixed fonts, scanned pages, passwords, outlines, large images and page sizes. Check 1×/4×/6× at ordinary and high zoom, scrolling, keyboard search, print range validation, disabled sharpening, and visible paper edges in both themes.

Manually verify Chrome printing UI, file permission toggles, attachment and reader save-dialog preferences, authenticated PDFs on representative sites and fullscreen on the target OS. The automated suite also covers fullscreen, 6× high zoom and OCR worker release. Automatic takeover cannot cover every endpoint; native fallback and file selection must stay available after errors.

Do not convert unit-test passing into a claim that every website or PDF works. Browser automation runs only in an isolated temporary profile unless the user explicitly requests their live Chrome.

UI regression checks cover Settings and reader language checkboxes, combined recognition, persistence, last-selection protection, preference snapshotting, minimum font sizes, dark text contrast and narrow layout. Visually inspect both languages and light/dark screenshots after icon or layout changes. Verify the date-format dropdown matches standard select widths and alignment, with all date labels fitting; check both languages around the 680px breakpoint and at 320–360px, including that the wider OCR dropdown stays inside its card.

Navigation/loading regressions include same-tab homepage Settings and Back/Forward, website → PDF → Back → Forward, a deliberately delayed response with an immediately usable toolbar in both themes, its divider loading indicator, disabled document controls, parser-worker preparation during transfer, and unchanged toolbar height after first paint. Page counts are checked for equal widths and stable spacing across digit changes. Invalid bytes and parser errors must dispose the shell and show recovery actions. Toolbar regressions cover all four checkbox combinations, live synchronization without document reparse, persistence, long filenames, narrow widths, and a single appearance button with stable bilingual tooltip in all layouts. Physical macOS trackpad history gestures still require manual OS-level verification; automated checks cover history entries, unconsumed shortcuts, and horizontal scrolling/overscroll policy.

Document properties checks use an authored PDF with known metadata: verify Print → Document properties → Settings ordering, lazy module/metadata reads, plain-text handling of markup-like fields, the original file URL directly below File name with query parameters intact and no active link, decimal size, dates, PDF version, dimensions, empty fields, cached reopening, English/Chinese labels, and narrow-window reflow. A locally picked file has no source URL and shows a dash. Long URLs must wrap without horizontal overflow. Toolbar actions must not overlap the reading controls at layout breakpoints. Click or keyboard-activate the filename in both filename-visible modes, including when Properties is hidden in More actions; verify the same dialog, cached metadata, loading-disabled state and focus return. At short viewport heights, open and reopen after scrolling to the bottom: the heading receives focus and both scroll offsets start at zero.

Find checks cover uncancelled ⌘F/Ctrl+F in default Chrome mode, unconditional built-in Find button/menu behavior, no shortcut banner, explicit Cosmic PDF mode intercepting both shortcuts, orange selected/other matches in light/dark appearance, full-document search, live preference changes preserving an open search and both locales.

More actions checks cover content-sized width for the longest localized label, concise Find/Properties/Chrome reader menu labels, factory-hidden markers in both languages, all eleven settings, default selections in every identity mode, persisted explicit overrides and immediate updates without reparsing. Exercise every delegated action, both members of each paired action, disabled states during loading/page boundaries, keyboard focus, Escape, outside dismissal and repeated trigger-click/keyboard toggling, percentage input validation, icon retention and narrow-menu bounds. Check Settings opens directly when nothing is hidden, and in either mode creates a tab immediately after the source PDF despite tabs already existing to its right. Check single-row geometry at widths below the old fixed breakpoint for each compact identity mode, with default/all-hidden/all-visible controls; verify real narrow-space wrapping, resize recovery and no overlaps.

Date/locale regressions cover every date format, source offsets, absent zones, partial dates, invalid dates and optional seconds (including zero), spaced Chinese dates and the English default. Switch language and format while properties are open without reparsing the document; check other open readers/homepages/Settings tabs, the active OCR panel and menus. Check the compact 560px width/height caps within the viewport, with unchanged font size and spacing; clicks inside do not close it and clicks outside do.

OCR interaction checks cover the current-page default, English/Simplified Chinese defaults, current plus 5/10 pages clipped at EOF, panel mode, toolbar/menu long press and pointer cancellation. Use an authored multi-page scan with bounded QA-only worker delay to verify early page layers during an unfinished batch, continuing after panel closure, and language switches during recognition. Verify selectable/copyable overlays, English spaces/Chinese continuity, retained layers after zoom/rotation, explicit stop, cleared results and worker teardown. Use PDF_QA=ocr-priority npm run test:browser for the focused native/OCR handover check: browser Find must see only the new text on recognized pages, including after zoom/rotation; unprocessed pages, empty recognition, cancellation and Clear must retain or restore their original text. Copy tests intercept the browser event in the QA document and do not write to the OS clipboard.

Check Pages remains at the leading edge in every identity mode. A sole filename or branding sits after it with a visible gap and does not overlap centered tools. Both enabled retains two rows, with Pages at the far left of the tool row (narrow windows may reflow). Toggle appearance twice for Auto/Light/Dark, change layout while overridden and switch the browser theme; no reparse, unintended reset or second appearance button is allowed.

Automated black-paper checks use authored fixtures only: near-black paper with sparse white writing, ordinary white paper, a large star field on white paper, a white inset, dark-gray paper with black/white writing, light-gray paper, noise/gradients, color and transparent pixels. Exercise staged early rejection, confirmation veto, error defaults, zoom/rotation/detail canvases, thumbnail reuse and light/dark toggling without repeat analysis. Never infer a real-world false-positive rate from these fixtures; white margins and any uncertain case must keep normal inversion.

Verify the default-on dark-paper switch in both languages, saved opt-out, zero detector reads while disabled and live changes in already-open readers without reparsing or repeat sampling.

For both interface languages and both checkbox values, switch Appearance among Light/Dark/Auto and reload Settings. The complete Preserve dark-paper colors row must disappear only in Light, retain its value and occupy no space; Auto remains visible even with a light browser theme.

Confirm dense black/gray layouts with colored callouts, near-edge footer content and outlined/type text using the existing display-cache evidence. Reject a dark picture on white paper, white-first paint, triangle and clipped fills with page-sized bounds, and a small white panel straddling tile borders. Verify evidence is read lazily at most once per uncached candidate and missing evidence retains normal inversion. User-supplied sample PDFs stay local and ignored; never include them or their contents in tracked fixtures. Test toolbar defaults in a fresh profile (Filename checked, branding unchecked) and preserve explicit saved choices.

Exercise Settings replacement from homepage navigation, both reader menu modes, direct URL/hash, Duplicate and another window. Verify only the newest Settings tab survives rapid creations, reload is harmless, unrelated/PDF tabs survive, and a tab navigating away before removal is not closed. Keep normal/incognito contexts isolated.

Click web/mailto/tel/sms PDF annotations and external outline entries with document links and capture enabled. Toggle capture in Settings and confirm live web-prompt dismissal/direct web opening, persistent copy-only protocol prompts, persistence and restored capture without reparsing; internal outline destinations remain direct. Web navigation/network requests require the Open choice; mailto/tel/sms never offer Open or launch applications, even with capture disabled; Copy preserves decoded recipients/fields, plus signs and line breaks. Exercise middle/modifier clicks, keyboard, outside/Escape dismissal, long fields, both languages/themes, narrow viewports and disabled links. Reject script/file/data schemes, credentials, control bytes and oversized URLs. Do not launch real mail/phone applications or write the system clipboard during automation; intercept those actions within QA and verify web hrefs, absent protocol Open actions and copied text.

Delay a visible page’s render completion while navigating: no immediate progress flash, no page-interior loading pseudo-element, then only the toolbar-divider line after 200 ms. Assert unchanged workspace geometry, immediate clearing after completion, and no indicator for offscreen pending pages. Repeat with cached/fast navigation, both themes and a hidden/disposed reader; initial transfer and printing retain their existing feedback.

PDF sandbox regressions must assert a real Worker port, not just successful rendering, and fail on fake-worker fallback or CSP/Permissions Policy warnings. Verify whole-document Copy uses the write-only policy while clipboard read remains denied (intercept writes in QA, never overwrite the user’s clipboard). Check modal title/input focus, top scroll position, Escape and outside dismissal, and prohibit autofocus attributes in the opaque reader. Exercise cancellation/disposal during worker startup and render errors.

External Links Capture covers application-protocol PDF annotations and outlines, middle clicks, a second trusted Open action and copy-only email/telephone/SMS. The browser suite cancels application navigation after observing that second click; do not launch installed apps during QA. Keep malformed, executable, internal and local-file URL rejection covered in unit tests.

Permission regressions verify the installed extension has only the fixed storage/host-scoped request API permissions and no downloads API. Real remote and locally selected PDF downloads must retain their filenames and original bytes without navigating or opening another tab. Automatic response-based takeover, attachment exceptions, native-reader exemptions, OCR and Settings must still work with the reduced manifest. No optional grant or permission prompt is part of these flows.

The focused PDF_QA=ocr-priority browser test also drags through a middle OCR row in both directions at several vertical hit positions, before and after zoom/rotation. Unrelated rows must not enter the selection. The same test preserves native-text suppression, empty-result fallback, cancellation, and Clear.

Focused lifecycle regression

PDF_QA=lifecycle PDF_PLAYWRIGHT=/path/to/playwright/index.mjs PDF_CHROME=/path/to/chrome node scripts/test-browser.mjs runs dialog reopening/Escape, modal keys, invalid page numbers, rapid locale/settings edits, external settings updates, and native-reader handover in an isolated temporary profile. The ordinary unit suite includes failed native handover/storage rollback and delayed settings callbacks. No OCR rerun is needed for these paths. See test-dist/README.md for local retained outputs; never connect a personal browser for this check.

Brand assets

After editing extension/icons/icon.svg, regenerate with scripts/render-icons.mjs (PDF_PLAYWRIGHT/PDF_CHROME) and run node scripts/check.mjs. Check that every first-party HTML page has a fingerprinted favicon and matching logo URL, all four manifest PNG sizes use the current palette, and the Settings footer displays the manifest version. In a disposable browser, verify logo loading/colors and favicon URLs in light/dark appearances on Settings, the homepage and viewer shell. The reusable local fixture and logo-only crops live in ignored test-dist/brand-assets/; no real document or personal profile is needed.

AI regression route

Run PDF_QA=ai with the existing browser script and an isolated Chrome for Testing profile. The disposable extension copy replaces only fixed API endpoints with localhost mock SSE/JSON; the shipped extension retains its fixed HTTPS endpoints and unchanged opaque-sandbox CSP. No real credentials, paid API calls or private files enter this test. Reusable screenshots/report are saved under ignored test-dist/ai-api-<version>, with its own README.

Cover native mouse-drag and OCR-row selections, default-off behavior, neutral sparkle placement/state, all three provider streams, follow-ups, explicit context, Stop/off/disposal, missing/invalid credentials, saved-key rows, an empty draft when replacing a key, cancellation without saving, per-row Test/Stop, sanitized Gemini authentication/access errors and confirmed individual deletion. Verify real Chrome IndexedDB stores nonextractable AES-GCM keys/ciphertext, never plaintext, and deleting the last saved key removes the encryption root while retaining preferences. Assert no bulk-delete button and no real key in rendered saved rows. Internal clear-all coverage remains in unit tests. Check both interface languages/themes and narrow layouts; the Explanation language default label must fit its desktop control. Unit tests cover forged role/tag strings, bounded requests/events, incomplete streams, sanitized errors and stale-port cancellation. Passing mock tests does not verify a real account’s API/model entitlement; an explicitly authorized live key is required for that verification.

For prompt-only edits, run node --test test/ai.test.mjs; a browser/OCR rerun is unnecessary if the transport and UI have not changed. Keyword/abbreviation/equation/longer-text fixtures verify exact quoted content, flexible shared instructions, natural user questions, language and distinct API/website role boundaries. These are construction checks, not model-quality evaluations. When separately authorized to evaluate real answers, check that isolated terms receive useful explanations, ambiguity is handled without invented context, examples are relevant, and quoted malicious instructions are explained rather than followed.

For subscription mode run PDF_QA=ai-web in the same isolated browser harness. The disposable copy replaces only the two fixed handoff destinations with localhost mock pages. Check radio choice order (API first, website second), the subscription default without default suffixes, single-selection and saved choice after reload, no-key/native selection, same-window right-adjacent opening, reuse/provider changes, reload/closure recovery, no source-token forwarding, optional context/language, and full long-question Copy/Open without a partial URL. Retain API mode, its keys and its existing regression route. Screenshots/report/README live in ignored test-dist/ai-subscription-3.2.1. Unit tests cover createSplit capability/rejection, pre-existing splits, moved/repurposed companions, worker restarts, stale owners and cancellation. Real Chrome 155+ split behavior and real signed-in prefill behavior require that runtime/account; do not describe mocked splitting or logged-out pages as verification of a subscription account.

The optional anonymous public-link smoke check returned HTTP 403 from both websites in this test environment. Signed-in prefill and submission are therefore not claimed as verified; the local handoff, encoding, ownership and fallback behavior are verified separately.

PDF_QA=selection checks PDF-only selection clearing on blank/toolbar clicks and focus moving into another still-visible frame, retained right-click Copy, successful AI handoff after selection preservation, OCR-only context and cross-page suppression of native duplicates. It runs real local OCR once on an authored two-page scan: AI off performs no recognition; AI on recognizes only the current page; switch-off cancels unfinished automatic work. Unit coverage checks debounce, manual priority, nonempty/failed layers, empty-result retry suppression and disposal. The peer frame exercises the focus boundary used by split panes, not Chrome’s native split UI. Reusable scan/report/README/screenshots live in ignored test-dist/selection-.