mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Only call the focus/blur callbacks when it's necessary (bug 1851517)
Focus callback must be called only when the element has been blurred. For example, blur callback (which implies some potential validation) is not called because the newly focused element is an other tab, an alert dialog, ... so consequently the focus callback mustn't be called when the element gets its focus back.
This commit is contained in:
parent
92792a8215
commit
d03494eeff
2 changed files with 92 additions and 5 deletions
|
@ -2154,4 +2154,50 @@ describe("Interaction", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Textfields and focus", () => {
|
||||
let pages;
|
||||
let otherPages;
|
||||
|
||||
beforeAll(async () => {
|
||||
otherPages = await Promise.all(
|
||||
global.integrationSessions.map(async session =>
|
||||
session.browser.newPage()
|
||||
)
|
||||
);
|
||||
pages = await loadAndWait("evaljs.pdf", getSelector("55R"));
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
await Promise.all(otherPages.map(page => page.close()));
|
||||
});
|
||||
|
||||
it("must check that focus/blur callbacks aren't called", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page], i) => {
|
||||
await page.waitForFunction(
|
||||
"window.PDFViewerApplication.scriptingReady === true"
|
||||
);
|
||||
|
||||
await page.click(getSelector("55R"));
|
||||
await page.type(getSelector("55R"), "Hello", { delay: 10 });
|
||||
await page.click(getSelector("56R"));
|
||||
await page.waitForTimeout(10);
|
||||
|
||||
await page.click(getSelector("55R"));
|
||||
await page.type(getSelector("55R"), " World", { delay: 10 });
|
||||
await page.waitForTimeout(10);
|
||||
|
||||
await otherPages[i].bringToFront();
|
||||
await otherPages[i].waitForTimeout(100);
|
||||
await page.bringToFront();
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
const text = await page.$eval(getSelector("55R"), el => el.value);
|
||||
expect(text).withContext(`In ${browserName}`).toEqual("Hello World");
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue