1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

For text widgets, get the text from the AP stream instead of from the format callback (bug 1825002)

When fixing bug 1766987, I thought the field formatted value came from
the result of the format callback: I was wrong. The format callback is ran
but the value is unused (maybe it's useful to set some global vars... or
it's just a bug in Acrobat). Anyway the value to display is the one rendered
in the AP stream.
The field value setter has been simplified and that fixes issue #16409.
This commit is contained in:
Calixte Denizet 2023-05-16 23:03:01 +02:00
parent 5ae353cf4d
commit 177036e6ae
7 changed files with 93 additions and 35 deletions

View file

@ -1897,4 +1897,70 @@ describe("Interaction", () => {
);
});
});
describe("in bug1825002.pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("bug1825002.pdf", getSelector("23R"));
});
afterAll(async () => {
await closePages(pages);
});
it("must check that a field has the correct formatted value", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);
let text = await page.$eval(getSelector("23R"), el => el.value);
expect(text)
.withContext(`In ${browserName}`)
.toEqual("ABCDEFGHIJKLMN");
await page.click(getSelector("23R"));
await page.waitForFunction(
`${getQuerySelector("23R")}.value !== "ABCDEFGHIJKLMN"`
);
text = await page.$eval(getSelector("23R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("123,45.7A");
})
);
});
it("must check that a field is empty", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);
let text = await page.$eval(getSelector("26R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("");
await page.click(getSelector("26R"));
await page.type(getSelector("26R"), "abcde", { delay: 10 });
await page.click(getSelector("23R"));
await page.waitForTimeout(10);
await page.click(getSelector("26R"));
await page.keyboard.down("Control");
await page.keyboard.press("A");
await page.keyboard.up("Control");
await page.keyboard.press("Backspace");
await page.click(getSelector("23R"));
await page.waitForTimeout(10);
text = await page.$eval(getSelector("26R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("");
})
);
});
});
});

View file

@ -591,3 +591,4 @@
!issue16316.pdf
!issue14565.pdf
!multiline.pdf
!bug1825002.pdf

BIN
test/pdfs/bug1825002.pdf Executable file

Binary file not shown.