[CRX] Re-initialize initialBookmark after URL rewrite

`PDFViewerApplication` reads from `location.hash` to initialize
`initialBookmark`. But when extensions/chromium/pdfHandler.js prepares
the redirect URL, the reference fragment is encoded instead of bare.
`rewriteUrlClosure` in `chromecom.js` is responsible for decoding the
URL, but that currently runs too late.

To fix this, update `initialBookmark` after rewriting the URL.

This was not a problem in the past because `rewriteUrlClosure` in
`chromecom.js` executed before the initialization of `initialBookmark`.
This commit is contained in:
Rob Wu 2023-07-02 15:28:33 +02:00
parent 2c74323e3d
commit 1d07ef401e

View File

@ -42,6 +42,9 @@ if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
}
AppOptions.set("defaultUrl", defaultUrl);
// Ensure that PDFViewerApplication.initialBookmark reflects the current hash,
// in case the URL rewrite above results in a different hash.
PDFViewerApplication.initialBookmark = location.hash.slice(1);
})();
const ChromeCom = {