diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 8d6334972..e6555745c 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -1993,6 +1993,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement { selectElement.addEventListener("input", event => { const exportValue = getValue(/* isExport */ true); + const change = getValue(/* isExport */ false); storage.setValue(id, { value: exportValue }); event.preventDefault(); @@ -2003,6 +2004,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement { id, name: "Keystroke", value: selectedValues, + change, changeEx: exportValue, willCommit: false, commitKey: 1, diff --git a/test/integration/scripting_spec.mjs b/test/integration/scripting_spec.mjs index a17b2ef00..acbbd0f60 100644 --- a/test/integration/scripting_spec.mjs +++ b/test/integration/scripting_spec.mjs @@ -2425,4 +2425,47 @@ describe("Interaction", () => { ); }); }); + + describe("Value of event.change when a choice list is modified", () => { + let pages; + let otherPages; + + beforeAll(async () => { + otherPages = await Promise.all( + global.integrationSessions.map(async session => + session.browser.newPage() + ) + ); + pages = await loadAndWait("issue17998.pdf", getSelector("7R")); + }); + + afterAll(async () => { + await closePages(pages); + await Promise.all(otherPages.map(page => page.close())); + }); + + it("must check the properties of the event", async () => { + await Promise.all( + pages.map(async ([browserName, page], i) => { + await page.waitForFunction( + "window.PDFViewerApplication.scriptingReady === true" + ); + + for (const [value, expected] of [ + ["b", "change=B,changeEx=b,value=A"], + ["c", "change=C,changeEx=c,value=B"], + ["a", "change=A,changeEx=a,value=C"], + ]) { + await page.select(getSelector("7R"), value); + await page.waitForFunction( + `${getQuerySelector("10R")}.value !== ""` + ); + const text = await page.$eval(getSelector("10R"), el => el.value); + expect(text).withContext(`In ${browserName}`).toEqual(expected); + await clearInput(page, getSelector("10R")); + } + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 5460d43a5..c14796e4f 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -644,3 +644,4 @@ !issue17929.pdf !issue12213.pdf !tracemonkey_freetext.pdf +!issue17998.pdf diff --git a/test/pdfs/issue17998.pdf b/test/pdfs/issue17998.pdf new file mode 100755 index 000000000..1624b1815 Binary files /dev/null and b/test/pdfs/issue17998.pdf differ