[JS] Skip throwing actions
It fixes #19505. We were invaliding throwing actions (in setting event.rc to false) and all the event process was stopped. Now we're just dumping the exception in the console: the action is skipped and event.rc is not set else the input fields aren't updated wit KeyStroke actions.
This commit is contained in:
parent
affce70a09
commit
8f9232202f
@ -175,9 +175,16 @@ class Doc extends PDFObject {
|
|||||||
|
|
||||||
_runActions(name) {
|
_runActions(name) {
|
||||||
const actions = this._actions.get(name);
|
const actions = this._actions.get(name);
|
||||||
if (actions) {
|
if (!actions) {
|
||||||
for (const action of actions) {
|
return;
|
||||||
|
}
|
||||||
|
for (const action of actions) {
|
||||||
|
try {
|
||||||
this._globalEval(action);
|
this._globalEval(action);
|
||||||
|
} catch (error) {
|
||||||
|
const serializedError = serializeError(error);
|
||||||
|
serializedError.value = `Error when executing "${name}" for document\n${serializedError.value}`;
|
||||||
|
this._send(serializedError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,7 +14,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
serializeError,
|
|
||||||
USERACTIVATION_CALLBACKID,
|
USERACTIVATION_CALLBACKID,
|
||||||
USERACTIVATION_MAXTIME_VALIDITY,
|
USERACTIVATION_MAXTIME_VALIDITY,
|
||||||
} from "./app_utils.js";
|
} from "./app_utils.js";
|
||||||
@ -311,12 +310,7 @@ class EventDispatcher {
|
|||||||
const source = this._objects[first];
|
const source = this._objects[first];
|
||||||
globalThis.event = new Event({});
|
globalThis.event = new Event({});
|
||||||
|
|
||||||
try {
|
this.runCalculate(source, globalThis.event);
|
||||||
this.runCalculate(source, globalThis.event);
|
|
||||||
} catch (error) {
|
|
||||||
this._isCalculating = false;
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._isCalculating = false;
|
this._isCalculating = false;
|
||||||
}
|
}
|
||||||
@ -345,15 +339,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
import { createActionsMap, FieldType, getFieldType } from "./common.js";
|
import { createActionsMap, FieldType, getFieldType } from "./common.js";
|
||||||
import { Color } from "./color.js";
|
import { Color } from "./color.js";
|
||||||
import { PDFObject } from "./pdf_object.js";
|
import { PDFObject } from "./pdf_object.js";
|
||||||
|
import { serializeError } from "./app_utils.js";
|
||||||
|
|
||||||
class Field extends PDFObject {
|
class Field extends PDFObject {
|
||||||
constructor(data) {
|
constructor(data) {
|
||||||
@ -552,14 +553,15 @@ class Field extends PDFObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const actions = this._actions.get(eventName);
|
const actions = this._actions.get(eventName);
|
||||||
try {
|
for (const action of actions) {
|
||||||
for (const action of actions) {
|
try {
|
||||||
// Action evaluation must happen in the global scope
|
// Action evaluation must happen in the global scope
|
||||||
this._globalEval(action);
|
this._globalEval(action);
|
||||||
|
} catch (error) {
|
||||||
|
const serializedError = serializeError(error);
|
||||||
|
serializedError.value = `Error when executing "${eventName}" for field "${this._id}"\n${serializedError.value}`;
|
||||||
|
this._send(serializedError);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
event.rc = false;
|
|
||||||
throw error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -2528,4 +2528,33 @@ describe("Interaction", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Skip throwing actions (issue 19505)", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("issue19505.pdf", "[data-annotation-id='24R']");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that date entered are in the input", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await waitForScripting(page);
|
||||||
|
|
||||||
|
const fieldSelector = getSelector("24R");
|
||||||
|
for (const c of "Hello World") {
|
||||||
|
await page.type(fieldSelector, c);
|
||||||
|
await waitForSandboxTrip(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = await page.$eval(fieldSelector, el => el.value);
|
||||||
|
expect(value).withContext(`In ${browserName}`).toEqual("Hello World");
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -704,3 +704,4 @@
|
|||||||
!issue19360.pdf
|
!issue19360.pdf
|
||||||
!bug1019475_1.pdf
|
!bug1019475_1.pdf
|
||||||
!bug1019475_2.pdf
|
!bug1019475_2.pdf
|
||||||
|
!issue19505.pdf
|
||||||
|
|||||||
BIN
test/pdfs/issue19505.pdf
Executable file
BIN
test/pdfs/issue19505.pdf
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user