[Pkg-javascript-commits] [pdf.js] 66/174: Add unit-tests for PR 6531

David Prévot taffit at moszumanska.debian.org
Thu Nov 19 18:45:13 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 34cbee9bd36f4519571499a5ff996778b6894352
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Fri Oct 16 18:48:26 2015 +0200

    Add unit-tests for PR 6531
---
 test/pdfs/.gitignore   |   2 ++
 test/pdfs/pr6531_1.pdf | Bin 0 -> 43414 bytes
 test/pdfs/pr6531_2.pdf |  44 +++++++++++++++++++++++++++++++++++++++
 test/unit/api_spec.js  |  55 +++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 101 insertions(+)

diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 62bfa3a..db9276a 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -55,6 +55,8 @@
 !pdfkit_compressed.pdf
 !TAMReview.pdf
 !pr4922.pdf
+!pr6531_1.pdf
+!pr6531_2.pdf
 !bug900822.pdf
 !issue918.pdf
 !issue1905.pdf
diff --git a/test/pdfs/pr6531_1.pdf b/test/pdfs/pr6531_1.pdf
new file mode 100644
index 0000000..b1f905f
Binary files /dev/null and b/test/pdfs/pr6531_1.pdf differ
diff --git a/test/pdfs/pr6531_2.pdf b/test/pdfs/pr6531_2.pdf
new file mode 100644
index 0000000..396e18b
--- /dev/null
+++ b/test/pdfs/pr6531_2.pdf
@@ -0,0 +1,44 @@
+%PDF-1.4
+%�쏢
+1 0 obj<</CreationDate(\323P\336\233\024]x\344\356L-?\034\331\031d?\312\273_\237yj\303\305\223r\004\354:\037QE\2705nU\306\260w]/ \337\332\343\256e)/ModDate(|\327\240"L\250\373\225\315e\366\346\017@\262Y\034YAhg\250F\316E\274\205\0057\311\r\262\226\036\252\275\027\315\354"\2073\312\013-\351F\320)/Author(\235\205\223r\323{\027\306\214\001d\)\242\276F9\346\2050u\222\345\336\302]\247_\351}t\356\240)/Creator(\037/\271\363\341:;+TI\314\255f\221\324\255\266jy\254\035\212\340q\316\031\251\266\26 [...]
+endobj
+2 0 obj<</Type/Catalog/Pages 3 0 R>>
+endobj
+3 0 obj<</Type/Pages/Kids[4 0 R]/Count 1>>
+endobj
+4 0 obj<</Type/Pages/Kids[5 0 R]/Count 1/Parent 3 0 R>>
+endobj
+5 0 obj<</Type/Page/Parent 4 0 R/MediaBox[0 0 612 792]/Annots 7 0 R>>
+endobj
+6 0 obj<</Subj(\037\274\306\337\206\276vcIh\035\211\255i_\371G\326/\030\200\021$\277\310#_\253\347:G\327)/Type/Annot/P 5 0 R/F 4/C[]/CreationDate(+\266\220\316\036\257\363x\235\2673\b\243\360\346\202\241wt\300^.k\223\003\200\224\) f\033\366\0212\222\373\323\000v\355\306\375\251\246k=\025})/T(V\275\215\250\311\364'\330\\<K\333\210\006RV\255\231\221;S|:?\231\001\232\351?\030\3541)/Subtype/FreeText/BS<</W 0/S/S/Type/Border>>/DA(y\232\036\214A#\357n\310NA\315\213m\277X7\302\301\264\254!x\331 [...]
+endobj
+7 0 obj[6 0 R]
+endobj
+8 0 obj<</Name/Helv/Type/Font/BaseFont/Helvetica/Subtype/Type1/Encoding<</Type/Encoding/Differences[24/breve/caron/circumflex/dotaccent/hungarumlaut/ogonek/ring/tilde 39/quotesingle 96/grave 127/.notdef/bullet/dagger/daggerdbl/ellipsis/emdash/endash/florin/fraction/guilsinglleft/guilsinglright/minus/perthousand/quotedblbase/quotedblleft/quotedblright/quoteleft/quoteright/quotesinglbase/trademark/fi/fl/Lslash/OE/Scaron/Ydieresis/Zcaron/dotlessi/lslash/oe/scaron/zcaron/.notdef/Euro 164/cur [...]
+endobj
+9 0 obj<</Type/XObject/Subtype/Form/FormType 1/BBox[33.30177 551.7525 488.2271 746.2612]/Resources<</ProcSet[/PDF/Text]/Font<</Helv 8 0 R>>>>/Matrix[1 0 0 1 -33.30179 -551.7524]/Length 160>>
+stream
+�\,��#�+Ǟzӂv�EU0	Z�g�˶�u[_i�E� �[ed|��b�l��k 'aB�
+\��@d�r�rҹ��[������O���OB�z�]�f$i�r9iК�\k�S��:�/�'Ц7Z�P5�N��M�̳��Y��<�J�KdW���]�J*_G
+endstream
+endobj
+11 0 obj<</Filter/Standard/V 5/Length 256/R 6/CF<</StdCF<</AuthEvent/DocOpen/CFM/AESV3/Length 32>>>>/StmF/StdCF/StrF/StdCF/P -4/U<86270432ecb25433a37e461bfc3721bed1d73810583503f1be6afb42ad523da86adfe4b76358edf0738fbc8e053fb121>/UE<556ca676e248a3198b38f63302d3ff73c316b0e5b60010714ba511ae91687686>/O<384415c370731d581955244d1e475204d084d4b5be9a943e55f0a21d0a354d86002175233d6899ac4a244104ea74aaaa>/OE<f7f37b88c6dd4b324fab3d67ba09f6293b2cd9d2b6433a06a93bd81d9dd9e5ea>/Perms<ccc462e482f6889af019 [...]
+endobj
+xref
+0 12
+0000000000 65535 f 
+0000000015 00000 n 
+0000000744 00000 n 
+0000000788 00000 n 
+0000000838 00000 n 
+0000000901 00000 n 
+0000000978 00000 n 
+0000003557 00000 n 
+0000003579 00000 n 
+0000004847 00000 n 
+0000000000 65535 f 
+0000005223 00000 n 
+trailer<</Size 12/Info 1 0 R/ID[<208de94dfc78329ba23e0da6154335b8><b25bbe1b4d6660ce6ba8d657d1f50617>]/Root 2 0 R/Encrypt 11 0 R>>
+startxref
+5738
+%%EOF
diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js
index 5a85a54..4a7a782 100644
--- a/test/unit/api_spec.js
+++ b/test/unit/api_spec.js
@@ -2,6 +2,7 @@
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor,
            InvalidPDFException, MissingPDFException, StreamType, FontType,
+           PDFDocumentProxy, PasswordException, PasswordResponses,
            PDFPageProxy */
 
 'use strict';
@@ -97,6 +98,60 @@ describe('api', function() {
           expect(error instanceof MissingPDFException).toEqual(true);
         });
       });
+      it('creates pdf doc from PDF file protected with user and owner password',
+         function () {
+        var url = combineUrl(window.location.href, '../pdfs/pr6531_1.pdf');
+
+        var passwordNeededPromise = PDFJS.getDocument({
+          url: url, password: '',
+        });
+        waitsForPromiseRejected(passwordNeededPromise, function (data) {
+          expect(data instanceof PasswordException).toEqual(true);
+          expect(data.code).toEqual(PasswordResponses.NEED_PASSWORD);
+        });
+
+        var passwordIncorrectPromise = PDFJS.getDocument({
+          url: url, password: 'qwerty',
+        });
+        waitsForPromiseRejected(passwordIncorrectPromise, function (data) {
+          expect(data instanceof PasswordException).toEqual(true);
+          expect(data.code).toEqual(PasswordResponses.INCORRECT_PASSWORD);
+        });
+
+        var passwordAcceptedPromise = PDFJS.getDocument({
+          url: url, password: 'asdfasdf',
+        });
+        waitsForPromiseResolved(passwordAcceptedPromise, function (data) {
+          expect(data instanceof PDFDocumentProxy).toEqual(true);
+        });
+      });
+      it('creates pdf doc from PDF file protected with only a user password',
+         function () {
+        var url = combineUrl(window.location.href, '../pdfs/pr6531_2.pdf');
+
+        var passwordNeededPromise = PDFJS.getDocument({
+          url: url, password: '',
+        });
+        waitsForPromiseRejected(passwordNeededPromise, function (data) {
+          expect(data instanceof PasswordException).toEqual(true);
+          expect(data.code).toEqual(PasswordResponses.NEED_PASSWORD);
+        });
+
+        var passwordIncorrectPromise = PDFJS.getDocument({
+          url: url, password: 'qwerty',
+        });
+        waitsForPromiseRejected(passwordIncorrectPromise, function (data) {
+          expect(data instanceof PasswordException).toEqual(true);
+          expect(data.code).toEqual(PasswordResponses.INCORRECT_PASSWORD);
+        });
+
+        var passwordAcceptedPromise = PDFJS.getDocument({
+          url: url, password: 'asdfasdf',
+        });
+        waitsForPromiseResolved(passwordAcceptedPromise, function (data) {
+          expect(data instanceof PDFDocumentProxy).toEqual(true);
+        });
+      });
     });
   });
   describe('PDFDocument', function() {

-- 
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