Add unit-tests for PR 6531
This commit is contained in:
parent
d1d81de6fc
commit
34cbee9bd3
4 changed files with 101 additions and 0 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue