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:
commit
f0a8a799a7
@ -447,6 +447,9 @@ class App extends PDFObject {
|
|||||||
cMsg = cMsg.cMsg;
|
cMsg = cMsg.cMsg;
|
||||||
}
|
}
|
||||||
cMsg = (cMsg || "").toString();
|
cMsg = (cMsg || "").toString();
|
||||||
|
if (!cMsg) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
nType =
|
nType =
|
||||||
typeof nType !== "number" || isNaN(nType) || nType < 0 || nType > 3
|
typeof nType !== "number" || isNaN(nType) || nType < 0 || nType > 3
|
||||||
? 0
|
? 0
|
||||||
|
|||||||
@ -607,6 +607,52 @@ describe("Scripting", function () {
|
|||||||
value = await myeval(`app.platform = "hello"`);
|
value = await myeval(`app.platform = "hello"`);
|
||||||
expect(value).toEqual("app.platform is read-only");
|
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 () {
|
describe("AForm", function () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user