|
|
@ -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() { |
|
|
|