Add a unit-test for bug 1020226

For reference, see PR 4902 and https://bugzilla.mozilla.org/show_bug.cgi?id=1020226.
This commit is contained in:
Jonas Jenwald 2015-10-02 18:04:08 +02:00
parent 41a75b1423
commit e8ad6c9d13
3 changed files with 36 additions and 1 deletions

View File

@ -114,6 +114,7 @@
!bug1065245.pdf
!bug1151216.pdf
!bug1175962.pdf
!bug1020226.pdf
!basicapi.pdf
!mixedfonts.pdf
!shading_extend.pdf

24
test/pdfs/bug1020226.pdf Normal file
View File

@ -0,0 +1,24 @@
%PDF-1.4
1 0 obj
<<
/Pages 2 0 R
2 0 obj
<<
/Resources
>>
/Contents 811 0 R
811 0 obj
<<
/Length 17863
>>
stream
BI
/W 62
/H 62
/D[1
0]
/F/CCFŠ/DP<</K -1
trailer
<<
/Root 1 0 R
>>

View File

@ -1,7 +1,8 @@
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor,
MissingPDFException, StreamType, FontType, PDFPageProxy */
InvalidPDFException, MissingPDFException, StreamType, FontType,
PDFPageProxy */
'use strict';
@ -79,6 +80,15 @@ describe('api', function() {
expect(true).toEqual(true);
});
});
it('creates pdf doc from invalid PDF file', function() {
// A severely corrupt PDF file (even Adobe Reader fails to open it).
var url = combineUrl(window.location.href, '../pdfs/bug1020226.pdf');
var promise = PDFJS.getDocument(url);
waitsForPromiseRejected(promise, function (error) {
expect(error instanceof InvalidPDFException).toEqual(true);
});
});
it('creates pdf doc from non-existent URL', function() {
var nonExistentUrl = combineUrl(window.location.href,
'../pdfs/non-existent.pdf');