diff --git a/src/scripting_api/aform.js b/src/scripting_api/aform.js index d72e545223efe..74cd5a7c535b7 100644 --- a/src/scripting_api/aform.js +++ b/src/scripting_api/aform.js @@ -514,14 +514,12 @@ class AForm { } for (const child of field.getArray()) { const number = this.AFMakeNumber(child.value); - if (number !== null) { - values.push(number); - } + values.push(number ?? 0); } } if (values.length === 0) { - event.value = cFunction === "PRD" ? 1 : 0; + event.value = 0; return; } diff --git a/test/integration/scripting_spec.mjs b/test/integration/scripting_spec.mjs index f41c271b882ea..94e5f3a7e2e73 100644 --- a/test/integration/scripting_spec.mjs +++ b/test/integration/scripting_spec.mjs @@ -2466,4 +2466,48 @@ describe("Interaction", () => { ); }); }); + + describe("Compute product of different fields", () => { + let pages; + let otherPages; + + beforeAll(async () => { + otherPages = await Promise.all( + global.integrationSessions.map(async session => + session.browser.newPage() + ) + ); + pages = await loadAndWait("issue18536.pdf", getSelector("34R")); + }); + + afterAll(async () => { + await closePages(pages); + await Promise.all(otherPages.map(page => page.close())); + }); + + it("must check that the product are null", async () => { + await Promise.all( + pages.map(async ([browserName, page], i) => { + await waitForScripting(page); + + const inputSelector = getSelector("34R"); + await page.click(inputSelector); + await page.type(inputSelector, "123"); + await page.click(getSelector("28R")); + await page.waitForFunction( + `${getQuerySelector("36R")}.value !== "0"` + ); + + let text = await page.$eval(getSelector("30R"), el => el.value); + expect(text).withContext(`In ${browserName}`).toEqual("0"); + + text = await page.$eval(getSelector("35R"), el => el.value); + expect(text).withContext(`In ${browserName}`).toEqual("0"); + + text = await page.$eval(getSelector("36R"), el => el.value); + expect(text).withContext(`In ${browserName}`).toEqual("123"); + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index dde1c01660e87..b353f8d31926d 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -659,3 +659,4 @@ !issue18360.pdf !issue18099_reduced.pdf !file_pdfjs_test.pdf +!issue18536.pdf diff --git a/test/pdfs/issue18536.pdf b/test/pdfs/issue18536.pdf new file mode 100755 index 0000000000000..39121efe6ad52 Binary files /dev/null and b/test/pdfs/issue18536.pdf differ