[Pkg-javascript-commits] [pdf.js] 42/174: Add a unit-test for bug 1020226

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit e8ad6c9d131dd629b176860f3eea5bbaff81a1a9
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Fri Oct 2 18:04:08 2015 +0200

    Add a unit-test for bug 1020226
    
    For reference, see PR 4902 and https://bugzilla.mozilla.org/show_bug.cgi?id=1020226.
---
 test/pdfs/.gitignore     |  1 +
 test/pdfs/bug1020226.pdf | 24 ++++++++++++++++++++++++
 test/unit/api_spec.js    | 12 +++++++++++-
 3 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index de2d8b7..2c286cf 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -114,6 +114,7 @@
 !bug1065245.pdf
 !bug1151216.pdf
 !bug1175962.pdf
+!bug1020226.pdf
 !basicapi.pdf
 !mixedfonts.pdf
 !shading_extend.pdf
diff --git a/test/pdfs/bug1020226.pdf b/test/pdfs/bug1020226.pdf
new file mode 100644
index 0000000..655b4fa
--- /dev/null
+++ b/test/pdfs/bug1020226.pdf
@@ -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
+>>
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 2668368..5a85a54 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -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');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list