mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 23:58:07 +02:00
JS - Fix setting a color on an annotation
- strokeColor corresponds to borderColor; - support fillColor and textColor; - support colors on the different annotations; - fix typo in aforms (+test).
This commit is contained in:
parent
0fa9976268
commit
4a5f1d1b7a
7 changed files with 125 additions and 8 deletions
|
@ -630,4 +630,53 @@ describe("Interaction", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("in js-colors.pdf", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("js-colors.pdf", "#\\33 4R");
|
||||
});
|
||||
|
||||
it("must changes colors", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
for (const [name, ref] of [
|
||||
["Text1", "#\\33 4R"],
|
||||
["Check1", "#\\33 5R"],
|
||||
["Radio1", "#\\33 7R"],
|
||||
["Choice1", "#\\33 8R"],
|
||||
]) {
|
||||
await clearInput(page, "#\\33 4R");
|
||||
await page.type("#\\33 4R", `${name}`, {
|
||||
delay: 10,
|
||||
});
|
||||
await page.click("[data-annotation-id='41R']");
|
||||
let color = await page.$eval(
|
||||
ref,
|
||||
el => getComputedStyle(el).backgroundColor
|
||||
);
|
||||
expect(color)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("rgb(255, 0, 0)");
|
||||
|
||||
await page.click("[data-annotation-id='43R']");
|
||||
color = await page.$eval(ref, el => getComputedStyle(el).color);
|
||||
expect(color)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("rgb(0, 255, 0)");
|
||||
|
||||
await page.click("[data-annotation-id='44R']");
|
||||
color = await page.$eval(
|
||||
ref,
|
||||
el => getComputedStyle(el)["border-top-color"]
|
||||
);
|
||||
expect(color)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("rgb(0, 0, 255)");
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
|
@ -245,6 +245,7 @@
|
|||
!personwithdog.pdf
|
||||
!helloworld-bad.pdf
|
||||
!zerowidthline.pdf
|
||||
!js-colors.pdf
|
||||
!issue12841_reduced.pdf
|
||||
!bug868745.pdf
|
||||
!mmtype1.pdf
|
||||
|
|
BIN
test/pdfs/js-colors.pdf
Normal file
BIN
test/pdfs/js-colors.pdf
Normal file
Binary file not shown.
|
@ -1166,6 +1166,18 @@ describe("Scripting", function () {
|
|||
value: "3F?",
|
||||
selRange: [3, 3],
|
||||
});
|
||||
|
||||
send_queue.delete(refId);
|
||||
await sandbox.dispatchEventInSandbox({
|
||||
id: refId,
|
||||
value: "3F?",
|
||||
change: "0",
|
||||
name: "Keystroke",
|
||||
willCommit: true,
|
||||
selStart: 3,
|
||||
selEnd: 3,
|
||||
});
|
||||
expect(send_queue.has(refId)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue