1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[api-minor] Add support for OpenAction destinations (issue 10332)

Note that the OpenAction dictionary may contain other information besides just a destination array, e.g. instructions for auto-printing[1].
Given first of all that an arbitrary `Dict` cannot be sent from the Worker (since cloning would fail), and second of all that the data obviously needs to be validated, this patch purposely only adds support for fetching a destination from the OpenAction entry[2].

---
[1] This information is, currently in PDF.js, being included through the `getJavaScript` API method.

[2] This significantly reduces the complexity of the implementation, which seems fine for now. If there's ever need for other kinds of OpenAction to be fetched, additional API methods could/should be implemented as necessary (could e.g. follow the `getOpenActionWhatever` naming scheme).
This commit is contained in:
Jonas Jenwald 2018-12-05 20:09:15 +01:00
parent ba2edeae18
commit b05f053287
4 changed files with 57 additions and 0 deletions

View file

@ -650,6 +650,24 @@ describe('api', function() {
}).catch(done.fail);
});
it('gets default open action destination', function(done) {
var loadingTask = getDocument(buildGetDocumentParams('tracemonkey.pdf'));
loadingTask.promise.then(function(pdfDocument) {
return pdfDocument.getOpenActionDestination();
}).then(function(dest) {
expect(dest).toEqual(null);
loadingTask.destroy().then(done);
}).catch(done.fail);
});
it('gets non-default open action destination', function(done) {
doc.getOpenActionDestination().then(function(dest) {
expect(dest).toEqual([{ num: 15, gen: 0, }, { name: 'FitH', }, null]);
done();
}).catch(done.fail);
});
it('gets non-existent attachments', function(done) {
var promise = doc.getAttachments();
promise.then(function (data) {