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

Merge pull request #13005 from calixteman/colors

JS - Fix setting a color on an annotation
This commit is contained in:
Tim van der Meij 2021-02-21 14:50:03 +01:00 committed by GitHub
commit f3aa4408a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 125 additions and 8 deletions

View file

@ -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)");
}
})
);
});
});
});

View file

@ -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

Binary file not shown.

View file

@ -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);
});
});