Merge pull request #12345 from calixteman/save_btn

Don't try to save something for a button which is neither a checkbox nor a radio
This commit is contained in:
Brendan Dahl 2020-09-08 15:44:04 -07:00 committed by GitHub
commit e51e9d1f33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View File

@ -1510,7 +1510,8 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
return this._saveRadioButton(evaluator, task, annotationStorage); return this._saveRadioButton(evaluator, task, annotationStorage);
} }
return super.save(evaluator, task, annotationStorage); // Nothing to save
return null;
} }
async _saveCheckbox(evaluator, task, annotationStorage) { async _saveCheckbox(evaluator, task, annotationStorage) {

View File

@ -2317,6 +2317,29 @@ describe("annotation", function () {
done(); done();
}, done.fail); }, done.fail);
}); });
it("should save nothing", function (done) {
const buttonWidgetRef = Ref.get(124, 0);
const xref = new XRefMock([
{ ref: buttonWidgetRef, data: buttonWidgetDict },
]);
const task = new WorkerTask("test save");
AnnotationFactory.create(
xref,
buttonWidgetRef,
pdfManagerMock,
idFactoryMock
)
.then(annotation => {
return annotation.save(partialEvaluator, task, {});
})
.then(data => {
expect(data).toEqual(null);
done();
})
.catch(done.fail);
});
}); });
describe("ChoiceWidgetAnnotation", function () { describe("ChoiceWidgetAnnotation", function () {