mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Annotations] charLimit === 0 means unlimited (bug 1782564)
Changing the charLimit in JS had no impact, so this patch aims to fix that and add an integration test for it.
This commit is contained in:
parent
b05010c3eb
commit
c06c5f7cbd
8 changed files with 122 additions and 12 deletions
|
@ -1492,4 +1492,65 @@ describe("Interaction", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("in bug1782564.pdf", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("bug1782564.pdf", getSelector("7R"));
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that charLimit is correctly set", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.waitForFunction(
|
||||
"window.PDFViewerApplication.scriptingReady === true"
|
||||
);
|
||||
|
||||
await clearInput(page, getSelector("7R"));
|
||||
// By default the charLimit is 0 which means that the input
|
||||
// length is unlimited.
|
||||
await page.type(getSelector("7R"), "abcdefghijklmnopq", {
|
||||
delay: 10,
|
||||
});
|
||||
|
||||
let value = await page.$eval(getSelector("7R"), el => el.value);
|
||||
expect(value)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("abcdefghijklmnopq");
|
||||
|
||||
// charLimit is set to 1
|
||||
await page.click(getSelector("9R"));
|
||||
|
||||
await page.waitForFunction(
|
||||
`document.querySelector('${getSelector(
|
||||
"7R"
|
||||
)}').value !== "abcdefgh"`
|
||||
);
|
||||
|
||||
value = await page.$eval(getSelector("7R"), el => el.value);
|
||||
expect(value).withContext(`In ${browserName}`).toEqual("a");
|
||||
|
||||
await clearInput(page, getSelector("7R"));
|
||||
await page.type(getSelector("7R"), "xyz", { delay: 10 });
|
||||
|
||||
value = await page.$eval(getSelector("7R"), el => el.value);
|
||||
expect(value).withContext(`In ${browserName}`).toEqual("x");
|
||||
|
||||
// charLimit is set to 2
|
||||
await page.click(getSelector("9R"));
|
||||
|
||||
await clearInput(page, getSelector("7R"));
|
||||
await page.type(getSelector("7R"), "xyz", { delay: 10 });
|
||||
|
||||
value = await page.$eval(getSelector("7R"), el => el.value);
|
||||
expect(value).withContext(`In ${browserName}`).toEqual("xy");
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -535,3 +535,4 @@
|
|||
!issue15092.pdf
|
||||
!bug1782186.pdf
|
||||
!tracemonkey_a11y.pdf
|
||||
!bug1782564.pdf
|
||||
|
|
BIN
test/pdfs/bug1782564.pdf
Executable file
BIN
test/pdfs/bug1782564.pdf
Executable file
Binary file not shown.
|
@ -1454,7 +1454,7 @@ describe("annotation", function () {
|
|||
);
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
expect(data.textAlignment).toEqual(null);
|
||||
expect(data.maxLen).toEqual(null);
|
||||
expect(data.maxLen).toEqual(0);
|
||||
expect(data.readOnly).toEqual(false);
|
||||
expect(data.hidden).toEqual(false);
|
||||
expect(data.multiLine).toEqual(false);
|
||||
|
@ -1478,7 +1478,7 @@ describe("annotation", function () {
|
|||
);
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
expect(data.textAlignment).toEqual(null);
|
||||
expect(data.maxLen).toEqual(null);
|
||||
expect(data.maxLen).toEqual(0);
|
||||
expect(data.readOnly).toEqual(false);
|
||||
expect(data.hidden).toEqual(false);
|
||||
expect(data.multiLine).toEqual(false);
|
||||
|
|
|
@ -1390,7 +1390,7 @@ describe("api", function () {
|
|||
defaultValue: "",
|
||||
multiline: false,
|
||||
password: false,
|
||||
charLimit: null,
|
||||
charLimit: 0,
|
||||
comb: false,
|
||||
editable: true,
|
||||
hidden: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue