1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Avoid to display an alert or a confirm dialog if the message is empty

It fixes #19171.
This commit is contained in:
Calixte Denizet 2024-12-05 21:03:54 +01:00
parent f180de41f3
commit d1db8d6294
2 changed files with 49 additions and 0 deletions

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 () {