Merge pull request #12522 from Snuffleupagus/_initializeJavaScript-fixes
Fix a couple of edge-cases in `PDFViewerApplication._initializeJavaScript` (PR 12432 follow-up)
This commit is contained in:
commit
e8e029dfb5
@ -1345,10 +1345,14 @@ const PDFViewerApplication = {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
async _initializeJavaScript(pdfDocument) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
const objects = await pdfDocument.getFieldObjects();
|
|
||||||
const scripting = this.externalServices.scripting;
|
const scripting = this.externalServices.scripting;
|
||||||
|
|
||||||
window.addEventListener("updateFromSandbox", function (event) {
|
window.addEventListener("updateFromSandbox", function (event) {
|
||||||
|
@ -254,17 +254,19 @@ class FirefoxComDataRangeTransport extends PDFDataRangeTransport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const FirefoxScripting = {
|
class FirefoxScripting {
|
||||||
createSandbox(data) {
|
static createSandbox(data) {
|
||||||
FirefoxCom.requestSync("createSandbox", data);
|
FirefoxCom.requestSync("createSandbox", data);
|
||||||
},
|
}
|
||||||
dispatchEventInSandbox(event, sandboxID) {
|
|
||||||
|
static dispatchEventInSandbox(event, sandboxID) {
|
||||||
FirefoxCom.requestSync("dispatchEventInSandbox", event);
|
FirefoxCom.requestSync("dispatchEventInSandbox", event);
|
||||||
},
|
}
|
||||||
destroySandbox() {
|
|
||||||
|
static destroySandbox() {
|
||||||
FirefoxCom.requestSync("destroySandbox", null);
|
FirefoxCom.requestSync("destroySandbox", null);
|
||||||
},
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
class FirefoxExternalServices extends DefaultExternalServices {
|
class FirefoxExternalServices extends DefaultExternalServices {
|
||||||
static updateFindControlState(data) {
|
static updateFindControlState(data) {
|
||||||
|
@ -1010,8 +1010,8 @@ function getActiveOrFocusedElement() {
|
|||||||
/**
|
/**
|
||||||
* Generate a random string which is not define somewhere in actions.
|
* Generate a random string which is not define somewhere in actions.
|
||||||
*
|
*
|
||||||
* @param {WaitOnEventOrTimeoutParameters}
|
* @param {Object} objects - The value returned by `getFieldObjects` in the API.
|
||||||
* @returns {Promise} A promise that is resolved with a {WaitOnType} value.
|
* @returns {string} A unique string.
|
||||||
*/
|
*/
|
||||||
function generateRandomStringForSandbox(objects) {
|
function generateRandomStringForSandbox(objects) {
|
||||||
const allObjects = Object.values(objects).flat(2);
|
const allObjects = Object.values(objects).flat(2);
|
||||||
|
Loading…
Reference in New Issue
Block a user