mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Don't stop calculating field values when a Calculate callback throws
It fixes #18561.
This commit is contained in:
parent
c60c0d1c6d
commit
ad12f33999
4 changed files with 39 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
serializeError,
|
||||||
USERACTIVATION_CALLBACKID,
|
USERACTIVATION_CALLBACKID,
|
||||||
USERACTIVATION_MAXTIME_VALIDITY,
|
USERACTIVATION_MAXTIME_VALIDITY,
|
||||||
} from "./app_utils.js";
|
} from "./app_utils.js";
|
||||||
|
@ -344,7 +345,15 @@ class EventDispatcher {
|
||||||
event.value = null;
|
event.value = null;
|
||||||
const target = this._objects[targetId];
|
const target = this._objects[targetId];
|
||||||
let savedValue = target.obj._getValue();
|
let savedValue = target.obj._getValue();
|
||||||
|
try {
|
||||||
this.runActions(source, target, event, "Calculate");
|
this.runActions(source, target, event, "Calculate");
|
||||||
|
} catch (error) {
|
||||||
|
const fieldId = target.obj._id;
|
||||||
|
const serializedError = serializeError(error);
|
||||||
|
serializedError.value = `Error when calculating value for field "${fieldId}"\n${serializedError.value}`;
|
||||||
|
this._externalCall("send", [serializedError]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!event.rc) {
|
if (!event.rc) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2510,4 +2510,32 @@ describe("Interaction", () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Calculate field value even if one callback throws", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("issue18561.pdf", getSelector("24R"));
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that the product is computed although a callback threw", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page], i) => {
|
||||||
|
await waitForScripting(page);
|
||||||
|
|
||||||
|
const inputSelector = getSelector("24R");
|
||||||
|
await page.click(inputSelector);
|
||||||
|
await page.type(inputSelector, "123");
|
||||||
|
await page.click(getSelector("25R"));
|
||||||
|
await page.waitForFunction(
|
||||||
|
`${getQuerySelector("28R")}.value === "12300"`
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -660,3 +660,4 @@
|
||||||
!issue18099_reduced.pdf
|
!issue18099_reduced.pdf
|
||||||
!file_pdfjs_test.pdf
|
!file_pdfjs_test.pdf
|
||||||
!issue18536.pdf
|
!issue18536.pdf
|
||||||
|
!issue18561.pdf
|
||||||
|
|
BIN
test/pdfs/issue18561.pdf
Executable file
BIN
test/pdfs/issue18561.pdf
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue