Skip to content

Conversation

@ananyapahwa
Copy link

Summary:

This PR enables the historyUpdateUrl preference to work with local PDF files (file:// protocol), allowing the browser to remember and restore the last viewed position when the preference is enabled.

Problem:

Currently, the historyUpdateUrl preference only updates the URL hash for web-based PDFs. Local PDF files are explicitly excluded from this feature, even when the user has enabled the preference in about:config. This inconsistency means users cannot benefit from position restoration when viewing local files.

Solution:

Removed the protocol check that prevented file:// URLs from updating the browser history. The change is minimal and focused:

  • Modified web/pdf_history.js to remove the if (protocol !== "file:") condition in the #pushOrReplaceState method
  • This allows local files to update the URL hash (e.g., #page=5) when scrolling, just like web-based PDFs

Testing:

  1. All unit tests pass (npx gulp unittestcli - 1055 specs, 0 failures)
  2. Linting passes (npx gulp lint)
  3. The change leverages the existing historyUpdateUrl preference mechanism without introducing new code paths

Related Issue:

Fixes : #20370

Note: This change only affects behavior when users explicitly enable pdfjs.historyUpdateUrl in Firefox preferences. The default behavior remains unchanged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add last view position to local files as about:config

2 participants