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

Add tooltip if any in annotations layer

This commit is contained in:
calixteman 2020-09-06 17:14:56 +02:00 committed by Calixte Denizet
parent b8c856a53a
commit 20b12d2bda
3 changed files with 61 additions and 3 deletions

View file

@ -2436,6 +2436,49 @@ describe("annotation", function () {
})
.catch(done.fail);
});
it("should handle push buttons", function (done) {
const buttonWidgetRef = Ref.get(124, 0);
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
buttonWidgetDict.set("A", "whatever");
const xref = new XRefMock([
{ ref: buttonWidgetRef, data: buttonWidgetDict },
]);
AnnotationFactory.create(
xref,
buttonWidgetRef,
pdfManagerMock,
idFactoryMock
).then(({ data }) => {
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
expect(data.pushButton).toEqual(true);
done();
}, done.fail);
});
it("should handle push buttons that act as a tooltip only", function (done) {
const buttonWidgetRef = Ref.get(124, 0);
buttonWidgetDict.set("Ff", AnnotationFieldFlag.PUSHBUTTON);
buttonWidgetDict.set("TU", "An alternative text");
const xref = new XRefMock([
{ ref: buttonWidgetRef, data: buttonWidgetDict },
]);
AnnotationFactory.create(
xref,
buttonWidgetRef,
pdfManagerMock,
idFactoryMock
).then(({ data }) => {
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
expect(data.pushButton).toEqual(true);
expect(data.alternativeText).toEqual("An alternative text");
done();
}, done.fail);
});
});
describe("ChoiceWidgetAnnotation", function () {