[JS] Send a Validate action on change on Choice widget

This commit is contained in:
Calixte Denizet 2023-02-19 16:33:05 +01:00
parent 255e982542
commit dca54c8f8a
4 changed files with 42 additions and 1 deletions

View File

@ -1765,8 +1765,9 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
["mouseleave", "Mouse Exit"],
["mouseup", "Mouse Up"],
["input", "Action"],
["input", "Validate"],
],
event => event.target.checked
event => event.target.value
);
} else {
selectElement.addEventListener("input", function (event) {

View File

@ -1854,4 +1854,43 @@ describe("Interaction", () => {
);
});
});
describe("in issue16067.pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("issue16067.pdf", getSelector("6R"));
});
afterAll(async () => {
await closePages(pages);
});
it("must check that a field has the correct value when a choice is changed", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);
let text = await page.$eval(getSelector("44R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("");
await page.select(getSelector("6R"), "Yes");
await page.waitForTimeout(10);
text = await page.$eval(getSelector("44R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("Yes");
await clearInput(page, getSelector("44R"));
await page.select(getSelector("6R"), "No");
await page.waitForTimeout(10);
text = await page.$eval(getSelector("44R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("No");
})
);
});
});
});

View File

@ -575,3 +575,4 @@
!issue16021.pdf
!bug1770750.pdf
!issue16063.pdf
!issue16067.pdf

BIN
test/pdfs/issue16067.pdf Executable file

Binary file not shown.