1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-21 23:58:07 +02:00

JS -- add support for choice widget (#12826)

This commit is contained in:
calixteman 2021-01-25 14:40:57 -08:00 committed by GitHub
parent 6249ef517d
commit a3f6882b06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 516 additions and 114 deletions

View file

@ -489,10 +489,6 @@ describe("Interaction", () => {
pages = await loadAndWait("js-authors.pdf", "#\\32 5R");
});
afterAll(async () => {
await closePages(pages);
});
it("must print authors in a text field", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
@ -506,4 +502,132 @@ describe("Interaction", () => {
);
});
});
describe("in listbox_actions.pdf", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait("listbox_actions.pdf", "#\\33 3R");
});
afterAll(async () => {
await closePages(pages);
});
it("must print selected value in a text field", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
for (const num of [7, 6, 4, 3, 2, 1]) {
await page.click(`option[value=Export${num}]`);
await page.waitForFunction(
`document.querySelector("#\\\\33 3R").value !== ""`
);
const text = await page.$eval("#\\33 3R", el => el.value);
expect(text)
.withContext(`In ${browserName}`)
.toEqual(`Item${num},Export${num}`);
}
})
);
});
it("must clear and restore list elements", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
// Click on ClearItems button.
await page.click("[data-annotation-id='34R']");
await page.waitForFunction(
`document.querySelector("#\\\\33 0R").children.length === 0`
);
// Click on Restore button.
await page.click("[data-annotation-id='37R']");
await page.waitForFunction(
`document.querySelector("#\\\\33 0R").children.length !== 0`
);
for (const num of [7, 6, 4, 3, 2, 1]) {
await page.click(`option[value=Export${num}]`);
await page.waitForFunction(
`document.querySelector("#\\\\33 3R").value !== ""`
);
const text = await page.$eval("#\\33 3R", el => el.value);
expect(text)
.withContext(`In ${browserName}`)
.toEqual(`Item${num},Export${num}`);
}
})
);
});
it("must insert new elements", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
let len = 6;
for (const num of [1, 3, 5, 6, 431, -1, 0]) {
++len;
await clearInput(page, "#\\33 9R");
await page.type("#\\33 9R", `${num},Insert${num},Tresni${num}`, {
delay: 10,
});
// Click on AddItem button.
await page.click("[data-annotation-id='38R']");
await page.waitForFunction(
`document.querySelector("#\\\\33 0R").children.length === ${len}`
);
// Click on newly added option.
await page.select("#\\33 0R", `Tresni${num}`);
await page.waitForFunction(
`document.querySelector("#\\\\33 3R").value !== ""`
);
const text = await page.$eval("#\\33 3R", el => el.value);
expect(text)
.withContext(`In ${browserName}`)
.toEqual(`Insert${num},Tresni${num}`);
}
})
);
});
it("must delete some element", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
let len = 6;
// Click on Restore button.
await page.click("[data-annotation-id='37R']");
await page.waitForFunction(
`document.querySelector("#\\\\33 0R").children.length === ${len}`
);
for (const num of [2, 5]) {
--len;
await clearInput(page, "#\\33 9R");
await page.type("#\\33 9R", `${num}`);
// Click on DeleteItem button.
await page.click("[data-annotation-id='36R']");
await page.waitForFunction(
`document.querySelector("#\\\\33 0R").children.length === ${len}`
);
}
for (const num of [6, 4, 2, 1]) {
await page.click(`option[value=Export${num}]`);
await page.waitForFunction(
`document.querySelector("#\\\\33 3R").value !== ""`
);
const text = await page.$eval("#\\33 3R", el => el.value);
expect(text)
.withContext(`In ${browserName}`)
.toEqual(`Item${num},Export${num}`);
}
})
);
});
});
});

View file

@ -403,6 +403,7 @@
!operator-in-TJ-array.pdf
!issue7878.pdf
!font_ascent_descent.pdf
!listbox_actions.pdf
!issue11442_reduced.pdf
!issue11549_reduced.pdf
!issue8097_reduced.pdf

Binary file not shown.