Don't avoid to execute the Blur callback when blurring a text field (bug 1863910)

This commit is contained in:
Calixte Denizet 2023-11-09 13:50:33 +01:00
parent 42f3d57365
commit ec396c2150
4 changed files with 49 additions and 3 deletions

View File

@ -1288,7 +1288,9 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
}
elementData.lastCommittedValue = target.value;
elementData.commitKey = 1;
elementData.focused = true;
if (!this.data.actions?.Focus) {
elementData.focused = true;
}
});
element.addEventListener("updatefromsandbox", jsEvent => {
@ -1397,7 +1399,9 @@ class TextWidgetAnnotationElement extends WidgetAnnotationElement {
if (!elementData.focused || !event.relatedTarget) {
return;
}
elementData.focused = false;
if (!this.data.actions?.Blur) {
elementData.focused = false;
}
const { value } = event.target;
elementData.userValue = value;
if (elementData.lastCommittedValue !== value) {

View File

@ -2183,4 +2183,46 @@ describe("Interaction", () => {
);
});
});
describe("Textfield with a Blur callback", () => {
let pages;
let otherPages;
beforeAll(async () => {
otherPages = await Promise.all(
global.integrationSessions.map(async session =>
session.browser.newPage()
)
);
pages = await loadAndWait("bug1863910.pdf", getSelector("25R"));
});
afterAll(async () => {
await closePages(pages);
await Promise.all(otherPages.map(page => page.close()));
});
it("must check that blur callback is called", async () => {
await Promise.all(
pages.map(async ([browserName, page], i) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);
await page.click(getSelector("25R"));
await page.waitForTimeout(10);
await page.click(getSelector("26R"));
await page.waitForFunction(
sel => document.querySelector(sel).value !== "",
{},
getSelector("26R")
);
const text = await page.$eval(getSelector("26R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("hello");
})
);
});
});
});

View File

@ -618,4 +618,4 @@
!issue17065.pdf
!issue17069.pdf
!issue17215.pdf
!bug1863910.pdf

BIN
test/pdfs/bug1863910.pdf Executable file

Binary file not shown.