Add unit-tests for PR 6531

This commit is contained in:
Jonas Jenwald 2015-10-16 18:48:26 +02:00
parent d1d81de6fc
commit 34cbee9bd3
4 changed files with 101 additions and 0 deletions

View File

@ -55,6 +55,8 @@
!pdfkit_compressed.pdf !pdfkit_compressed.pdf
!TAMReview.pdf !TAMReview.pdf
!pr4922.pdf !pr4922.pdf
!pr6531_1.pdf
!pr6531_2.pdf
!bug900822.pdf !bug900822.pdf
!issue918.pdf !issue918.pdf
!issue1905.pdf !issue1905.pdf

BIN
test/pdfs/pr6531_1.pdf Normal file

Binary file not shown.

44
test/pdfs/pr6531_2.pdf Normal file
View File

@ -0,0 +1,44 @@
%PDF-1.4
%Çì<C387>¢
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\263\347\232\225\267n\023\271\301\265\n\332. f\316\300\260\217\005)/Producer(\230\322\240\225E\246\220\001\277\331\225JC\321\362\016\030U\351\237\3163F\243\305a\254\342\372\264\225\240w\271@\253\t\rY\357\346Q\225\236Q\215\026\027)>>
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\215\315\036\354s\017\334\346m\000\344\222\277\326\347#\347r"f\003NC\266)/DS(\201\2323\356\332\26605\216\266q\340c\027\356\226\364'f\365w\257\021\265\366\352\027\207\033\350\377\323\325w\232\345K~\b\031\321\032\237\312\206\002\321\216*\274\216\262\370&[\253\0179\311\007\326\023"H\032\t\226t>\003\304=\302+\234\250t&d\324wr+Q\264\313\306\374\027\\\344\327\341\242\250Ej\376\352h\317\(\245\275\(\215\005\242\n\265\320\207)/M(e\333\215\b\321ZA2\315\037\337z\263XM\355;\335\025A\006\022\230\227\223\216\205\253\276\017\251\3002X\020m~\357\303\334I8\203\216\312\017\350\331)/AP<</N 9 0 R>>/Rect[33.30177 551.7525 488.2271 746.2612]/NM(|\362Z\355\322b{\302j\347\374\212\260\017\013\260\205\030\216\f\200?L\235\344\321{\255\202\327\231\346\206BB\023\031\261\021\2148\006\245\n\256\253\251\257)/RC(_\251h\256\336\266\205&Y\000!\273\326\264\2016@\242'\270\037|\315\220<\322\020\371\245\276\277\266\\\242\361\('\355A\322\242*W.\254\367u8\221\377\220\275\025\372\0035\021X0\034\203r\272@\024\224<ST\000;e\213\275QY\324\303\243\363\234:\254.o\352\n\273\230\004\301\b\363\320^\322W\371\260TY\357\020\262l\353\201NJ\2311\271\371\357\273\271\355\rNW\023\257\021 \376V\275\350\037\322\fK\221}\332W\226\265\214\201\305\r\324W9\230\032\270\305\256\221ot\267C\227\306\006\251\377\222'\374\362\352*\247l\304\311\364\215E\271"{\027\365\216O\343\276\356\033\303\266\251\247rJ\365\317^\037\234\255\276\266\004\324b\211\273\237`\244\347\346\016\235L^\000\ns\306\f\312\025\313N\211E\335\247,\306g\027\024-\357!\033\314\310\037\315M\374 1\034\307=\004\227\f\360`;eb\036<\177\2269\007_\201\367\243Fi\246SgP\311Ix\302\233E\330\204\345\222\365\246\345;\373\007J\024U\037\006\234\367\361P\231\021\212\205\321\232\204\024\345\367|\323\250\2548\361#\023\372Z\336\261\216^\f{\221\333o?\306\372\273DNg\211%f\034:%\035O\362\021\202\352\360\322J?\211\223\324\\\213\350i\300_"\034o+\031N\341\2205x8\203\025)/Contents(h\202cp\273\000\303\002`\312\235\350\\\265\200\275"L\212\246\271\307\255%\221\342\024\311\024\341{8\224\236\314\004O\322nH\263\334\304\375\tJ\033\262m\3413\270\0232\200`\342?\207\2570\036\241\227)>>
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/currency 166/brokenbar 168/dieresis/copyright/ordfeminine 172/logicalnot/.notdef/registered/macron/degree/plusminus/twosuperior/threesuperior/acute/mu 183/periodcentered/cedilla/onesuperior/ordmasculine 188/onequarter/onehalf/threequarters 192/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]>>>>
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|¸l¨¶k 'aBþ
\¾‡@dó»rørÒ¹çÀ[§îËâ­O<4F>è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<ccc462e482f6889af01993d4adf4f363>>>
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

View File

@ -2,6 +2,7 @@
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */ /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
/* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor, /* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor,
InvalidPDFException, MissingPDFException, StreamType, FontType, InvalidPDFException, MissingPDFException, StreamType, FontType,
PDFDocumentProxy, PasswordException, PasswordResponses,
PDFPageProxy */ PDFPageProxy */
'use strict'; 'use strict';
@ -97,6 +98,60 @@ describe('api', function() {
expect(error instanceof MissingPDFException).toEqual(true); 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() { describe('PDFDocument', function() {