diff --git a/src/scripting_api/aform.js b/src/scripting_api/aform.js index d72e545223efed..74cd5a7c535b77 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 f41c271b882ea6..94e5f3a7e2e73c 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"); + }) + ); + }); + }); });