Repository navigation
Make the tests check what they claim - #78
Merged
Merged
Conversation
Several tests passed whether or not the feature worked (#76): - "should render the PDF file" opened a PDF that exists nowhere and asserted inside a handler it never awaited. It now opens a PDF in the repository and waits for a page to be drawn. - "should not render PDF with wrong url" asserted before the load could finish. It now waits for the load to fail, and fails if pages load. - "should open the external file with base64 source": getFileData() fetched the base64 string as a relative URL, and PDF.js 6 rejects a bare Uint8Array. It now opens { data } and checks the document's text. - "defaults to resources that ship next to the runtime files" checked HEAD for a 200, which the dev server also returns for a missing file. It now checks the content type. - 14 tests set src to a missing PDF they didn't need; that's removed. PdfViewerApplicationOpenParameters no longer allows a bare Uint8Array, which PDF.js rejects at runtime. Closes #76 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 tasks done
alekswebnet
added a commit
that referenced
this pull request
Nov 7, 2026
Make the tests check what they claim (land #78 on master)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #76: several browser tests passed whether or not the feature worked. This PR is stacked on #77. Merge that one first, and this one retargets to
master.Rewritten tests:
/sample-pdf-10MB.pdf, which exists nowhere, and asserted inside apagesloadedhandler it never awaited. It now opens a PDF the repository tracks and waits until a page is drawn.documenterror, and fails if pages load instead.getFileData(), which fetched the base64 string as a relative URL and so returned the dev server's HTML page. PDF.js 6 also rejects a bareUint8Array. The test now opens{ data }and checks for the document's own text, "Hello, world!".HEADfor a 200, which the dev server also returns for a missing file. It now checks that the response isn't the HTML page.Also:
srcto that missing PDF without needing a document. Removing it stops a failed load in each of them. It also stops the worker CSP test from downloading a worker from jsDelivr.PdfViewerApplicationOpenParametersno longer includesUint8Array. PDF.js rejects that at runtime withgetDocument - expected either `data`, `range`, or `url` parameter. TypeScript code that passed raw bytes now gets a compile error instead of that runtime error. The docs already useopen({ data }).I reviewed every other test, and each one asserts something real. For example, "should hide the download button" fails without the injected style. Two tests still load an old viewer build from jsDelivr, so they depend on the network: "should load runtime files from assets-base" and "should prefer worker-src over assets-base…". I left those as they are.
Validation
pnpm test -- --run: 40 passed, both normally and with thepublic/fixtures moved away, as CI sees the repository.getFileData();pnpm exec tsc --noEmitandpnpm buildpass, andtypes/pdfjs-viewer-element.d.tsis regenerated.Checklist
open({ data }).🤖 Generated with Claude Code