mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Add a unit-test that attempts to fetch a non-existent named destination
Doing this helped uncover an issue with the `getDestination` implementation. Currently if a named destination doesn't exist, the method (in `obj.js`) may return `undefined` which leads to the promise being stuck in a pending state. *Note:* returning `null` for this case is consistent with other methods, e.g. `getOutline` and `getAttachments`.
This commit is contained in:
parent
eb2ad11571
commit
940bedf75f
2 changed files with 7 additions and 1 deletions
|
@ -485,7 +485,7 @@ var Catalog = (function CatalogClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var xref = this.xref;
|
var xref = this.xref;
|
||||||
var dest, nameTreeRef, nameDictionaryRef;
|
var dest = null, nameTreeRef, nameDictionaryRef;
|
||||||
var obj = this.catDict.get('Names');
|
var obj = this.catDict.get('Names');
|
||||||
if (obj && obj.has('Dests')) {
|
if (obj && obj.has('Dests')) {
|
||||||
nameTreeRef = obj.getRaw('Dests');
|
nameTreeRef = obj.getRaw('Dests');
|
||||||
|
|
|
@ -129,6 +129,12 @@ describe('api', function() {
|
||||||
0, 841.89, null]);
|
0, 841.89, null]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
it('gets a non-existent destination', function() {
|
||||||
|
var promise = doc.getDestination('non-existent-named-destination');
|
||||||
|
waitsForPromiseResolved(promise, function(data) {
|
||||||
|
expect(data).toEqual(null);
|
||||||
|
});
|
||||||
|
});
|
||||||
it('gets attachments', function() {
|
it('gets attachments', function() {
|
||||||
var promise = doc.getAttachments();
|
var promise = doc.getAttachments();
|
||||||
waitsForPromiseResolved(promise, function (data) {
|
waitsForPromiseResolved(promise, function (data) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue