From c68ffcf9785db3b4f0cfb196384622f376892b31 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 14 May 2014 12:43:20 +0200 Subject: [PATCH 1/2] Check if the Names dictionary actually contains a Dests dictionary before attempting to get the destinations --- src/core/obj.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/obj.js b/src/core/obj.js index 8d6145235..9c2c77ffd 100644 --- a/src/core/obj.js +++ b/src/core/obj.js @@ -419,7 +419,7 @@ var Catalog = (function CatalogClosure() { var xref = this.xref; var dests = {}, nameTreeRef, nameDictionaryRef; var obj = this.catDict.get('Names'); - if (obj) { + if (obj && obj.has('Dests')) { nameTreeRef = obj.getRaw('Dests'); } else if (this.catDict.has('Dests')) { nameDictionaryRef = this.catDict.get('Dests'); From 3adab8b183e81a0aaffd6c85b0b9ab6613e89e43 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 14 May 2014 12:54:18 +0200 Subject: [PATCH 2/2] Fix unit test for getDestinations --- test/unit/api_spec.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index ff2286012..bb74d5576 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -65,7 +65,8 @@ describe('api', function() { it('gets destinations', function() { var promise = doc.getDestinations(); waitsForPromise(promise, function(data) { - // TODO this seems to be broken for the test pdf + expect(data).toEqual({ chapter1: [{ gen: 0, num: 17 }, { name: 'XYZ' }, + 0, 841.89, null] }); }); }); it('gets outline', function() {