Skip to content

Commit

Permalink
Merge pull request #11445 from timvandermeij/openaction-print-unit-test
Browse files Browse the repository at this point in the history
Include a unit test for OpenAction dictionaries without `Type` entries (PR 11443 follow-up)
  • Loading branch information
timvandermeij authored Dec 26, 2019
2 parents 81af207 + dfe42a5 commit db8fcdf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
!operator-in-TJ-array.pdf
!issue7878.pdf
!font_ascent_descent.pdf
!issue11442_reduced.pdf
!issue8097_reduced.pdf
!transparent.pdf
!xobject-image.pdf
Expand Down
Binary file added test/pdfs/issue11442_reduced.pdf
Binary file not shown.
22 changes: 20 additions & 2 deletions test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ describe("api", function() {
// detect whether or not to automatically start printing.
var viewerPrintRegExp = /\bprint\s*\(/;
it("gets javascript with printing instructions (Print action)", function(done) {
// PDF document with "Print" Named action in OpenAction
// PDF document with "Print" Named action in the OpenAction dictionary.
var loadingTask = getDocument(buildGetDocumentParams("bug1001080.pdf"));
var promise = loadingTask.promise.then(function(doc) {
return doc.getJavaScript();
Expand All @@ -902,8 +902,25 @@ describe("api", function() {
})
.catch(done.fail);
});
it("gets javascript with printing instructions (Print action without type)", function(done) {
// PDF document with "Print" Named action in the OpenAction dictionary,
// but the OpenAction dictionary is missing the `Type` entry.
var loadingTask = getDocument(
buildGetDocumentParams("issue11442_reduced.pdf")
);
var promise = loadingTask.promise.then(function(doc) {
return doc.getJavaScript();
});
promise
.then(function(data) {
expect(data).toEqual(["print({});"]);
expect(data[0]).toMatch(viewerPrintRegExp);
loadingTask.destroy().then(done);
})
.catch(done.fail);
});
it("gets javascript with printing instructions (JS action)", function(done) {
// PDF document with "JavaScript" action in OpenAction
// PDF document with "JavaScript" action in the OpenAction dictionary.
var loadingTask = getDocument(buildGetDocumentParams("issue6106.pdf"));
var promise = loadingTask.promise.then(function(doc) {
return doc.getJavaScript();
Expand All @@ -918,6 +935,7 @@ describe("api", function() {
})
.catch(done.fail);
});

it("gets non-existent outline", function(done) {
var loadingTask = getDocument(buildGetDocumentParams("tracemonkey.pdf"));

Expand Down

0 comments on commit db8fcdf

Please sign in to comment.