|
|
@ -58,20 +58,19 @@ describe('api', function () { |
|
|
|
expect(data[0].loaded / data[0].total > 0).toEqual(true); |
|
|
|
expect(data[0].loaded / data[0].total > 0).toEqual(true); |
|
|
|
expect(data[1] instanceof _api.PDFDocumentProxy).toEqual(true); |
|
|
|
expect(data[1] instanceof _api.PDFDocumentProxy).toEqual(true); |
|
|
|
expect(loadingTask).toEqual(data[1].loadingTask); |
|
|
|
expect(loadingTask).toEqual(data[1].loadingTask); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from URL and aborts before worker initialized', function (done) { |
|
|
|
it('creates pdf doc from URL and aborts before worker initialized', function (done) { |
|
|
|
var loadingTask = _global.PDFJS.getDocument(basicApiUrl); |
|
|
|
var loadingTask = _global.PDFJS.getDocument(basicApiUrl); |
|
|
|
loadingTask.destroy(); |
|
|
|
var destroyed = loadingTask.destroy(); |
|
|
|
loadingTask.promise.then(function (reason) { |
|
|
|
loadingTask.promise.then(function (reason) { |
|
|
|
done.fail('shall fail loading'); |
|
|
|
done.fail('shall fail loading'); |
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
expect(true).toEqual(true); |
|
|
|
expect(true).toEqual(true); |
|
|
|
done(); |
|
|
|
destroyed.then(done); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from URL and aborts loading after worker initialized', function (done) { |
|
|
|
it('creates pdf doc from URL and aborts loading after worker initialized', function (done) { |
|
|
@ -115,8 +114,7 @@ describe('api', function () { |
|
|
|
var loadingTask = _global.PDFJS.getDocument(typedArrayPdf); |
|
|
|
var loadingTask = _global.PDFJS.getDocument(typedArrayPdf); |
|
|
|
loadingTask.promise.then(function (data) { |
|
|
|
loadingTask.promise.then(function (data) { |
|
|
|
expect(data instanceof _api.PDFDocumentProxy).toEqual(true); |
|
|
|
expect(data instanceof _api.PDFDocumentProxy).toEqual(true); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -128,8 +126,7 @@ describe('api', function () { |
|
|
|
done.fail('shall fail loading'); |
|
|
|
done.fail('shall fail loading'); |
|
|
|
}).catch(function (error) { |
|
|
|
}).catch(function (error) { |
|
|
|
expect(error instanceof _util.InvalidPDFException).toEqual(true); |
|
|
|
expect(error instanceof _util.InvalidPDFException).toEqual(true); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from non-existent URL', function (done) { |
|
|
|
it('creates pdf doc from non-existent URL', function (done) { |
|
|
@ -139,8 +136,7 @@ describe('api', function () { |
|
|
|
done.fail('shall fail loading'); |
|
|
|
done.fail('shall fail loading'); |
|
|
|
}).catch(function (error) { |
|
|
|
}).catch(function (error) { |
|
|
|
expect(error instanceof _util.MissingPDFException).toEqual(true); |
|
|
|
expect(error instanceof _util.MissingPDFException).toEqual(true); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates pdf doc from PDF file protected with user and owner password', function (done) { |
|
|
|
it('creates pdf doc from PDF file protected with user and owner password', function (done) { |
|
|
@ -168,8 +164,7 @@ describe('api', function () { |
|
|
|
var promises = [passwordNeededCapability.promise, passwordIncorrectCapability.promise, loadingTask.promise]; |
|
|
|
var promises = [passwordNeededCapability.promise, passwordIncorrectCapability.promise, loadingTask.promise]; |
|
|
|
Promise.all(promises).then(function (data) { |
|
|
|
Promise.all(promises).then(function (data) { |
|
|
|
expect(data[2] instanceof _api.PDFDocumentProxy).toEqual(true); |
|
|
|
expect(data[2] instanceof _api.PDFDocumentProxy).toEqual(true); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -221,9 +216,10 @@ describe('api', function () { |
|
|
|
url: url, |
|
|
|
url: url, |
|
|
|
password: 'qwerty' |
|
|
|
password: 'qwerty' |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
var passwordNeededDestroyed = void 0; |
|
|
|
passwordNeededLoadingTask.onPassword = function (callback, reason) { |
|
|
|
passwordNeededLoadingTask.onPassword = function (callback, reason) { |
|
|
|
if (reason === _util.PasswordResponses.NEED_PASSWORD) { |
|
|
|
if (reason === _util.PasswordResponses.NEED_PASSWORD) { |
|
|
|
passwordNeededLoadingTask.destroy(); |
|
|
|
passwordNeededDestroyed = passwordNeededLoadingTask.destroy(); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
expect(false).toEqual(true); |
|
|
|
expect(false).toEqual(true); |
|
|
@ -234,6 +230,7 @@ describe('api', function () { |
|
|
|
}, function (reason) { |
|
|
|
}, function (reason) { |
|
|
|
expect(reason instanceof _util.PasswordException).toEqual(true); |
|
|
|
expect(reason instanceof _util.PasswordException).toEqual(true); |
|
|
|
expect(reason.code).toEqual(_util.PasswordResponses.NEED_PASSWORD); |
|
|
|
expect(reason.code).toEqual(_util.PasswordResponses.NEED_PASSWORD); |
|
|
|
|
|
|
|
return passwordNeededDestroyed; |
|
|
|
}); |
|
|
|
}); |
|
|
|
passwordIncorrectLoadingTask.onPassword = function (callback, reason) { |
|
|
|
passwordIncorrectLoadingTask.onPassword = function (callback, reason) { |
|
|
|
if (reason === _util.PasswordResponses.INCORRECT_PASSWORD) { |
|
|
|
if (reason === _util.PasswordResponses.INCORRECT_PASSWORD) { |
|
|
@ -342,8 +339,8 @@ describe('api', function () { |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
afterAll(function () { |
|
|
|
afterAll(function (done) { |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('gets number of pages', function () { |
|
|
|
it('gets number of pages', function () { |
|
|
|
expect(doc.numPages).toEqual(3); |
|
|
|
expect(doc.numPages).toEqual(3); |
|
|
@ -466,8 +463,7 @@ describe('api', function () { |
|
|
|
gen: 0 |
|
|
|
gen: 0 |
|
|
|
}, { name: 'XYZ' }, 0, 375, null] |
|
|
|
}, { name: 'XYZ' }, 0, 375, null] |
|
|
|
}); |
|
|
|
}); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -483,8 +479,7 @@ describe('api', function () { |
|
|
|
num: 1, |
|
|
|
num: 1, |
|
|
|
gen: 0 |
|
|
|
gen: 0 |
|
|
|
}, { name: 'XYZ' }, 0, 375, null]); |
|
|
|
}, { name: 'XYZ' }, 0, 375, null]); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -497,8 +492,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
promise.then(function (destination) { |
|
|
|
promise.then(function (destination) { |
|
|
|
expect(destination).toEqual(null); |
|
|
|
expect(destination).toEqual(null); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -538,11 +532,7 @@ describe('api', function () { |
|
|
|
expect(pageLabels[1]).toEqual(['Front Page1']); |
|
|
|
expect(pageLabels[1]).toEqual(['Front Page1']); |
|
|
|
expect(pageLabels[2]).toEqual(['1', '2']); |
|
|
|
expect(pageLabels[2]).toEqual(['1', '2']); |
|
|
|
expect(pageLabels[3]).toEqual(['X3']); |
|
|
|
expect(pageLabels[3]).toEqual(['X3']); |
|
|
|
loadingTask0.destroy(); |
|
|
|
Promise.all([loadingTask0.destroy(), loadingTask1.destroy(), loadingTask2.destroy(), loadingTask3.destroy()]).then(done); |
|
|
|
loadingTask1.destroy(); |
|
|
|
|
|
|
|
loadingTask2.destroy(); |
|
|
|
|
|
|
|
loadingTask3.destroy(); |
|
|
|
|
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -567,8 +557,7 @@ describe('api', function () { |
|
|
|
expect(attachment.filename).toEqual('Press Quality.joboptions'); |
|
|
|
expect(attachment.filename).toEqual('Press Quality.joboptions'); |
|
|
|
expect(attachment.content instanceof Uint8Array).toBeTruthy(); |
|
|
|
expect(attachment.content instanceof Uint8Array).toBeTruthy(); |
|
|
|
expect(attachment.content.length).toEqual(30098); |
|
|
|
expect(attachment.content.length).toEqual(30098); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -592,8 +581,7 @@ describe('api', function () { |
|
|
|
promise.then(function (data) { |
|
|
|
promise.then(function (data) { |
|
|
|
expect(data).toEqual(['print({});']); |
|
|
|
expect(data).toEqual(['print({});']); |
|
|
|
expect(data[0]).toMatch(viewerPrintRegExp); |
|
|
|
expect(data[0]).toMatch(viewerPrintRegExp); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -607,8 +595,7 @@ describe('api', function () { |
|
|
|
promise.then(function (data) { |
|
|
|
promise.then(function (data) { |
|
|
|
expect(data).toEqual(['this.print({bUI:true,bSilent:false,bShrinkToFit:true});']); |
|
|
|
expect(data).toEqual(['this.print({bUI:true,bSilent:false,bShrinkToFit:true});']); |
|
|
|
expect(data[0]).toMatch(viewerPrintRegExp); |
|
|
|
expect(data[0]).toMatch(viewerPrintRegExp); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -621,8 +608,7 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
promise.then(function (outline) { |
|
|
|
promise.then(function (outline) { |
|
|
|
expect(outline).toEqual(null); |
|
|
|
expect(outline).toEqual(null); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -665,8 +651,7 @@ describe('api', function () { |
|
|
|
expect(outlineItemOne.bold).toEqual(false); |
|
|
|
expect(outlineItemOne.bold).toEqual(false); |
|
|
|
expect(outlineItemOne.italic).toEqual(true); |
|
|
|
expect(outlineItemOne.italic).toEqual(true); |
|
|
|
expect(outlineItemOne.color).toEqual(new Uint8Array([0, 0, 0])); |
|
|
|
expect(outlineItemOne.color).toEqual(new Uint8Array([0, 0, 0])); |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
done(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
@ -728,9 +713,7 @@ describe('api', function () { |
|
|
|
expect(typeof fingerprint2 === 'undefined' ? 'undefined' : _typeof(fingerprint2)).toEqual('string'); |
|
|
|
expect(typeof fingerprint2 === 'undefined' ? 'undefined' : _typeof(fingerprint2)).toEqual('string'); |
|
|
|
expect(fingerprint2.length > 0).toEqual(true); |
|
|
|
expect(fingerprint2.length > 0).toEqual(true); |
|
|
|
expect(fingerprint1).not.toEqual(fingerprint2); |
|
|
|
expect(fingerprint1).not.toEqual(fingerprint2); |
|
|
|
loadingTask1.destroy(); |
|
|
|
Promise.all([loadingTask1.destroy(), loadingTask2.destroy()]).then(done); |
|
|
|
loadingTask2.destroy(); |
|
|
|
|
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -751,8 +734,8 @@ describe('api', function () { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
afterAll(function () { |
|
|
|
afterAll(function (done) { |
|
|
|
loadingTask.destroy(); |
|
|
|
loadingTask.destroy().then(done); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('gets page number', function () { |
|
|
|
it('gets page number', function () { |
|
|
|
expect(page.pageNumber).toEqual(1); |
|
|
|
expect(page.pageNumber).toEqual(1); |
|
|
@ -833,10 +816,7 @@ describe('api', function () { |
|
|
|
expect(docBaseUrlAnnotations[0].unsafeUrl).toEqual('../../0021/002156/215675E.pdf#nameddest=15'); |
|
|
|
expect(docBaseUrlAnnotations[0].unsafeUrl).toEqual('../../0021/002156/215675E.pdf#nameddest=15'); |
|
|
|
expect(invalidDocBaseUrlAnnotations[0].url).toBeUndefined(); |
|
|
|
expect(invalidDocBaseUrlAnnotations[0].url).toBeUndefined(); |
|
|
|
expect(invalidDocBaseUrlAnnotations[0].unsafeUrl).toEqual('../../0021/002156/215675E.pdf#nameddest=15'); |
|
|
|
expect(invalidDocBaseUrlAnnotations[0].unsafeUrl).toEqual('../../0021/002156/215675E.pdf#nameddest=15'); |
|
|
|
defaultLoadingTask.destroy(); |
|
|
|
Promise.all([defaultLoadingTask.destroy(), docBaseUrlLoadingTask.destroy(), invalidDocBaseUrlLoadingTask.destroy()]).then(done); |
|
|
|
docBaseUrlLoadingTask.destroy(); |
|
|
|
|
|
|
|
invalidDocBaseUrlLoadingTask.destroy(); |
|
|
|
|
|
|
|
done(); |
|
|
|
|
|
|
|
}).catch(function (reason) { |
|
|
|
}).catch(function (reason) { |
|
|
|
done.fail(reason); |
|
|
|
done.fail(reason); |
|
|
|
}); |
|
|
|
}); |
|
|
|