1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

[api-minor] Add basic support for Launch actions (issue 1778, issue 3897, issue 6616)

In general we neither want, nor can, support arbitrary `Launch` actions. But in practice, all the cases we've seen so far just contains relative URLs to other PDF files. Building on PR 7689, we can thus at least support basic `Launch` actions.
This commit is contained in:
Jonas Jenwald 2016-10-21 13:29:15 +02:00
parent 7e392c0205
commit 2b79782377
3 changed files with 49 additions and 0 deletions

View file

@ -505,6 +505,45 @@ describe('Annotation layer', function() {
expect(data.newWindow).toBeFalsy();
});
it('should correctly parse a Launch action, where the FileSpec dict ' +
'contains a relative URL, with the "docBaseUrl" parameter specified',
function() {
var fileSpecDict = new Dict();
fileSpecDict.set('Type', Name.get('FileSpec'));
fileSpecDict.set('F', 'Part II/Part II.pdf');
fileSpecDict.set('UF', 'Part II/Part II.pdf');
var actionDict = new Dict();
actionDict.set('Type', Name.get('Action'));
actionDict.set('S', Name.get('Launch'));
actionDict.set('F', fileSpecDict);
actionDict.set('NewWindow', true);
var annotationDict = new Dict();
annotationDict.set('Type', Name.get('Annot'));
annotationDict.set('Subtype', Name.get('Link'));
annotationDict.set('A', actionDict);
var annotationRef = new Ref(88, 0);
var xref = new XRefMock([
{ ref: annotationRef, data: annotationDict, }
]);
var pdfManager = new PDFManagerMock({
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf',
});
var annotation = annotationFactory.create(xref, annotationRef,
pdfManager);
var data = annotation.data;
expect(data.annotationType).toEqual(AnnotationType.LINK);
expect(data.url).toEqual(
new URL('http://www.example.com/test/pdfs/Part II/Part II.pdf').href);
expect(data.unsafeUrl).toEqual('Part II/Part II.pdf');
expect(data.dest).toBeUndefined();
expect(data.newWindow).toEqual(true);
});
it('should correctly parse a Named action', function() {
var actionDict = new Dict();
actionDict.set('Type', Name.get('Action'));