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

Merge pull request #17882 from calixteman/bug1889122

Use the string value of the field when calling the Format callback (bug 1889122)
This commit is contained in:
calixteman 2024-04-10 09:40:54 +02:00 committed by GitHub
commit 77ee914bd6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 85 additions and 3 deletions

View file

@ -27,6 +27,7 @@ import {
loadAndWait,
scrollIntoView,
waitForEntryInStorage,
waitForSandboxTrip,
waitForTimeout,
} from "./test_utils.mjs";
@ -2367,4 +2368,41 @@ describe("Interaction", () => {
);
});
});
describe("Textfield with a zip code starting with 0", () => {
let pages;
let otherPages;
beforeAll(async () => {
otherPages = await Promise.all(
global.integrationSessions.map(async session =>
session.browser.newPage()
)
);
pages = await loadAndWait("bug1889122.pdf", getSelector("24R"));
});
afterAll(async () => {
await closePages(pages);
await Promise.all(otherPages.map(page => page.close()));
});
it("must check the zip code is correctly formatted", async () => {
await Promise.all(
pages.map(async ([browserName, page], i) => {
await page.waitForFunction(
"window.PDFViewerApplication.scriptingReady === true"
);
await page.click(getSelector("24R"));
await page.type(getSelector("24R"), "01234", { delay: 10 });
await page.keyboard.press("Tab");
await waitForSandboxTrip(page);
const text = await page.$eval(getSelector("24R"), el => el.value);
expect(text).withContext(`In ${browserName}`).toEqual("01234");
})
);
});
});
});

View file

@ -85,6 +85,16 @@ function closePages(pages) {
);
}
async function waitForSandboxTrip(page) {
const handle = await page.evaluateHandle(() => [
new Promise(resolve => {
window.addEventListener("sandboxtripend", resolve, { once: true });
window.PDFViewerApplication.pdfScriptingManager.sandboxTrip();
}),
]);
await awaitPromise(handle);
}
function waitForTimeout(milliseconds) {
/**
* Wait for the given number of milliseconds.
@ -583,6 +593,7 @@ export {
waitForAnnotationEditorLayer,
waitForEntryInStorage,
waitForEvent,
waitForSandboxTrip,
waitForSelectedEditor,
waitForSerialized,
waitForStorageEntries,

View file

@ -640,3 +640,4 @@
!issue17808.pdf
!issue17871_bottom_right.pdf
!issue17871_top_right.pdf
!bug1889122.pdf

BIN
test/pdfs/bug1889122.pdf Normal file

Binary file not shown.