1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19177 from calixteman/issue19171

Avoid to display an alert or a confirm dialog if the message is empty
This commit is contained in:
Tim van der Meij 2024-12-05 21:36:54 +01:00 committed by GitHub
commit f0a8a799a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 49 additions and 0 deletions

View file

@ -447,6 +447,9 @@ class App extends PDFObject {
cMsg = cMsg.cMsg;
}
cMsg = (cMsg || "").toString();
if (!cMsg) {
return 0;
}
nType =
typeof nType !== "number" || isNaN(nType) || nType < 0 || nType > 3
? 0

View file

@ -607,6 +607,52 @@ describe("Scripting", function () {
value = await myeval(`app.platform = "hello"`);
expect(value).toEqual("app.platform is read-only");
});
it("shouldn't display an alert", async () => {
const refId = getId();
const data = {
objects: {
field: [
{
id: refId,
value: "",
actions: {
Validate: [`app.alert(event.value);`],
},
type: "text",
name: "MyField",
},
],
},
appInfo: { language: "en-US", platform: "Linux x86_64" },
calculationOrder: [],
dispatchEventName: "_dispatchMe",
};
sandbox.createSandbox(data);
await sandbox.dispatchEventInSandbox({
id: refId,
value: "hello",
name: "Keystroke",
willCommit: true,
});
expect(send_queue.has("alert")).toEqual(true);
expect(send_queue.get("alert")).toEqual({
command: "alert",
value: "hello",
});
send_queue.delete(refId);
send_queue.delete("alert");
await sandbox.dispatchEventInSandbox({
id: refId,
value: "",
name: "Keystroke",
willCommit: true,
});
expect(send_queue.has("alert")).toEqual(false);
send_queue.delete(refId);
});
});
describe("AForm", function () {