mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Fix a couple of edge-cases in PDFViewerApplication._initializeJavaScript
(PR 12432 follow-up)
- Return early in `PDFViewerApplication._initializeJavaScript` for PDF documents without any `fieldObjects`, which is the vast majority of all documents, to prevent errors when trying to parse a non-existent object. - Similar to the other `PDFViewerApplication._initialize*` methods, ignore the `fieldObjects` if the document was closed before the data resolved. - Fix the JSDoc comment for the `generateRandomStringForSandbox` helper function, since there's currently a bit too much copy-and-paste going on :-) - Change `FirefoxScripting` to a class with static methods, which is consistent with the surrounding code in `web/firefoxcom.js`.
This commit is contained in:
parent
1eaf9c961b
commit
7bf9a872ed
3 changed files with 18 additions and 12 deletions
|
@ -1345,10 +1345,14 @@ const PDFViewerApplication = {
|
|||
* @private
|
||||
*/
|
||||
async _initializeJavaScript(pdfDocument) {
|
||||
if (!AppOptions.get("enableScripting")) {
|
||||
const objects = await pdfDocument.getFieldObjects();
|
||||
|
||||
if (pdfDocument !== this.pdfDocument) {
|
||||
return; // The document was closed while the JavaScript data resolved.
|
||||
}
|
||||
if (!objects || !AppOptions.get("enableScripting")) {
|
||||
return;
|
||||
}
|
||||
const objects = await pdfDocument.getFieldObjects();
|
||||
const scripting = this.externalServices.scripting;
|
||||
|
||||
window.addEventListener("updateFromSandbox", function (event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue