Skip to content

Catch getPermissions errors in PDFViewer.prototype.setDocument - #22168

Merged
timvandermeij merged 1 commit into
mozilla:masterfrom
Snuffleupagus:viewer-catch-getPermissions
Oct 13, 2026
Merged

timvandermeij merged 1 commit into
mozilla:masterfrom
Snuffleupagus:viewer-catch-getPermissions

Conversation

@Snuffleupagus

Copy link
Copy Markdown
Collaborator

If permissions are enabled and the getPermissions API-method somehow rejects, the viewer would fail to initialize and nothing would be rendered.

Note: This is based solely on code inspection, and it's similar to how we ignore errors elsewhere in the viewer:

pdf.js/web/app.js

Lines 1681 to 1691 in 6c71c0b

// Since the `setInitialView` call below depends on this being resolved,
// fetch it early to avoid delaying initial rendering of the PDF document.
const pageLayoutPromise = pdfDocument.getPageLayout().catch(() => {
/* Avoid breaking initial rendering; ignoring errors. */
});
const pageModePromise = pdfDocument.getPageMode().catch(() => {
/* Avoid breaking initial rendering; ignoring errors. */
});
const openActionPromise = pdfDocument.getOpenAction().catch(() => {
/* Avoid breaking initial rendering; ignoring errors. */
});

If permissions are enabled and the `getPermissions` API-method somehow rejects, the viewer would fail to initialize and nothing would be rendered.

*Note:* This is based solely on code inspection, and it's similar to how we ignore errors elsewhere in the viewer: https://github.com/mozilla/pdf.js/blob/6c71c0bf2670e38d689b9ed28cdd9c709e45b758/web/app.js#L1681-L1691
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Viewer preview

πŸ—‘οΈ Viewer previews removed.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 13, 2026
@codecov-commenter

codecov-commenter commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
βœ… Project coverage is 90.34%. Comparing base (6c71c0b) to head (e5a6107).

Files with missing lines Patch % Lines
web/pdf_viewer.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master   #22168   +/-   ##
=======================================
  Coverage   90.34%   90.34%           
=======================================
  Files         277      277           
  Lines       68030    68031    +1     
=======================================
+ Hits        61461    61462    +1     
  Misses       6569     6569           
Flag Coverage Ξ”
integrationtest 69.36% <0.00%> (-0.01%) ⬇️
unittest 60.44% <0.00%> (+0.01%) ⬆️
unittestcli 58.32% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • πŸ“¦ JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@timvandermeij
timvandermeij merged commit 925ef9f into mozilla:master Oct 13, 2026
28 of 30 checks passed
@timvandermeij

Copy link
Copy Markdown
Collaborator

It seems best to ensure this can't break the viewer indeed; thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants