Updates Jasmine version.

This commit is contained in:
Yury Delendik 2016-03-29 09:34:13 -05:00
parent df7afcf004
commit 0a700fa29d
25 changed files with 876 additions and 3803 deletions

View file

@ -1,4 +1,4 @@
/* globals PDFJS, expect, it, describe, Promise, combineUrl, waitsFor,
/* globals PDFJS, expect, it, describe, Promise, combineUrl,
InvalidPDFException, MissingPDFException, StreamType, FontType,
PDFDocumentProxy, PasswordException, PasswordResponses,
PDFPageProxy, createPromiseCapability, beforeEach, afterEach */
@ -8,35 +8,7 @@
describe('api', function() {
var basicApiUrl = combineUrl(window.location.href, '../pdfs/basicapi.pdf');
var basicApiFileLength = 105779; // bytes
var TEST_TIMEOUT = 20000;
function waitsForPromiseResolved(promise, successCallback) {
var resolved = false;
promise.then(function(val) {
resolved = true;
successCallback(val);
},
function(error) {
// Shouldn't get here.
expect(error).toEqual('the promise should not have been rejected');
});
waitsFor(function() {
return resolved;
}, TEST_TIMEOUT);
}
function waitsForPromiseRejected(promise, failureCallback) {
var rejected = false;
promise.then(function(val) {
// Shouldn't get here.
expect(false).toEqual(true);
},
function(error) {
rejected = true;
failureCallback(error);
});
waitsFor(function() {
return rejected;
}, TEST_TIMEOUT);
}
function waitSome(callback) {
var WAIT_TIMEOUT = 10;
setTimeout(function () {
@ -46,7 +18,7 @@ describe('api', function() {
describe('PDFJS', function() {
describe('getDocument', function() {
it('creates pdf doc from URL', function() {
it('creates pdf doc from URL', function(done) {
var loadingTask = PDFJS.getDocument(basicApiUrl);
var isProgressReportedResolved = false;
@ -65,34 +37,43 @@ describe('api', function() {
progressReportedCapability.promise,
loadingTask.promise
];
waitsForPromiseResolved(Promise.all(promises), function (data) {
Promise.all(promises).then(function (data) {
expect((data[0].loaded / data[0].total) > 0).toEqual(true);
expect(data[1] instanceof PDFDocumentProxy).toEqual(true);
expect(loadingTask).toEqual(data[1].loadingTask);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('creates pdf doc from URL and aborts before worker initialized',
function() {
function(done) {
var loadingTask = PDFJS.getDocument(basicApiUrl);
loadingTask.destroy();
waitsForPromiseRejected(loadingTask.promise, function(reason) {
loadingTask.promise.then(function(reason) {
done.fail('shall fail loading');
}).catch(function (reason) {
expect(true).toEqual(true);
done();
});
});
it('creates pdf doc from URL and aborts loading after worker initialized',
function() {
function(done) {
var loadingTask = PDFJS.getDocument(basicApiUrl);
// This can be somewhat random -- we cannot guarantee perfect
// 'Terminate' message to the worker before/after setting up pdfManager.
var destroyed = loadingTask._worker.promise.then(function () {
return loadingTask.destroy();
});
waitsForPromiseResolved(destroyed, function (data) {
destroyed.then(function (data) {
expect(true).toEqual(true);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('creates pdf doc from typed array', function() {
it('creates pdf doc from typed array', function(done) {
var nonBinaryRequest = PDFJS.disableWorker;
var request = new XMLHttpRequest();
request.open('GET', basicApiUrl, false);
@ -123,32 +104,41 @@ describe('api', function() {
expect(typedArrayPdf.length).toEqual(basicApiFileLength);
var loadingTask = PDFJS.getDocument(typedArrayPdf);
waitsForPromiseResolved(loadingTask.promise, function(data) {
loadingTask.promise.then(function(data) {
expect(data instanceof PDFDocumentProxy).toEqual(true);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('creates pdf doc from invalid PDF file', function() {
it('creates pdf doc from invalid PDF file', function(done) {
// A severely corrupt PDF file (even Adobe Reader fails to open it).
var url = combineUrl(window.location.href, '../pdfs/bug1020226.pdf');
var loadingTask = PDFJS.getDocument(url);
waitsForPromiseRejected(loadingTask.promise, function (error) {
loadingTask.promise.then(function () {
done.fail('shall fail loading');
}).catch(function (error) {
expect(error instanceof InvalidPDFException).toEqual(true);
loadingTask.destroy();
done();
});
});
it('creates pdf doc from non-existent URL', function() {
it('creates pdf doc from non-existent URL', function(done) {
var nonExistentUrl = combineUrl(window.location.href,
'../pdfs/non-existent.pdf');
var loadingTask = PDFJS.getDocument(nonExistentUrl);
waitsForPromiseRejected(loadingTask.promise, function(error) {
loadingTask.promise.then(function(error) {
done.fail('shall fail loading');
}).catch(function (error) {
expect(error instanceof MissingPDFException).toEqual(true);
loadingTask.destroy();
done();
});
});
it('creates pdf doc from PDF file protected with user and owner password',
function () {
function (done) {
var url = combineUrl(window.location.href, '../pdfs/pr6531_1.pdf');
var loadingTask = PDFJS.getDocument(url);
@ -185,50 +175,62 @@ describe('api', function() {
passwordIncorrectCapability.promise,
loadingTask.promise
];
waitsForPromiseResolved(Promise.all(promises), function (data) {
Promise.all(promises).then(function (data) {
expect(data[2] instanceof PDFDocumentProxy).toEqual(true);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('creates pdf doc from PDF file protected with only a user password',
function () {
function (done) {
var url = combineUrl(window.location.href, '../pdfs/pr6531_2.pdf');
var passwordNeededLoadingTask = PDFJS.getDocument({
url: url, password: '',
});
waitsForPromiseRejected(passwordNeededLoadingTask.promise,
function (data) {
var result1 = passwordNeededLoadingTask.promise.then(function () {
done.fail('shall fail with no password');
return passwordNeededLoadingTask.destroy();
}, function (data) {
expect(data instanceof PasswordException).toEqual(true);
expect(data.code).toEqual(PasswordResponses.NEED_PASSWORD);
passwordNeededLoadingTask.destroy();
return passwordNeededLoadingTask.destroy();
});
var passwordIncorrectLoadingTask = PDFJS.getDocument({
url: url, password: 'qwerty',
});
waitsForPromiseRejected(passwordIncorrectLoadingTask.promise,
function (data) {
var result2 = passwordIncorrectLoadingTask.promise.then(function () {
done.fail('shall fail with wrong password');
return passwordNeededLoadingTask.destroy();
}, function (data) {
expect(data instanceof PasswordException).toEqual(true);
expect(data.code).toEqual(PasswordResponses.INCORRECT_PASSWORD);
passwordIncorrectLoadingTask.destroy();
return passwordIncorrectLoadingTask.destroy();
});
var passwordAcceptedLoadingTask = PDFJS.getDocument({
url: url, password: 'asdfasdf',
});
waitsForPromiseResolved(passwordAcceptedLoadingTask.promise,
function (data) {
var result3 = passwordAcceptedLoadingTask.promise.then(function (data) {
expect(data instanceof PDFDocumentProxy).toEqual(true);
passwordAcceptedLoadingTask.destroy();
return passwordAcceptedLoadingTask.destroy();
});
Promise.all([result1, result2, result3]).then(function () {
done();
}).catch(function (reason) {
done.fail(reason);
});
});
});
});
describe('PDFWorker', function() {
it('worker created or destroyed', function () {
it('worker created or destroyed', function (done) {
var worker = new PDFJS.PDFWorker('test1');
waitsForPromiseResolved(worker.promise, function () {
worker.promise.then(function () {
expect(worker.name).toEqual('test1');
expect(!!worker.port).toEqual(true);
expect(worker.destroyed).toEqual(false);
@ -238,12 +240,15 @@ describe('api', function() {
worker.destroy();
expect(!!worker.port).toEqual(false);
expect(worker.destroyed).toEqual(true);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('worker created or destroyed by getDocument', function () {
it('worker created or destroyed by getDocument', function (done) {
var loadingTask = PDFJS.getDocument(basicApiUrl);
var worker;
waitsForPromiseResolved(loadingTask.promise, function () {
loadingTask.promise.then(function () {
worker = loadingTask._worker;
expect(!!worker).toEqual(true);
});
@ -251,16 +256,19 @@ describe('api', function() {
var destroyPromise = loadingTask.promise.then(function () {
return loadingTask.destroy();
});
waitsForPromiseResolved(destroyPromise, function () {
destroyPromise.then(function () {
var destroyedWorker = loadingTask._worker;
expect(!!destroyedWorker).toEqual(false);
expect(worker.destroyed).toEqual(true);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('worker created and can be used in getDocument', function () {
it('worker created and can be used in getDocument', function (done) {
var worker = new PDFJS.PDFWorker('test1');
var loadingTask = PDFJS.getDocument({url: basicApiUrl, worker: worker});
waitsForPromiseResolved(loadingTask.promise, function () {
loadingTask.promise.then(function () {
var docWorker = loadingTask._worker;
expect(!!docWorker).toEqual(false);
// checking is the same port is used in the MessageHandler
@ -271,24 +279,30 @@ describe('api', function() {
var destroyPromise = loadingTask.promise.then(function () {
return loadingTask.destroy();
});
waitsForPromiseResolved(destroyPromise, function () {
destroyPromise.then(function () {
expect(worker.destroyed).toEqual(false);
worker.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('creates more than one worker', function () {
it('creates more than one worker', function (done) {
var worker1 = new PDFJS.PDFWorker('test1');
var worker2 = new PDFJS.PDFWorker('test2');
var worker3 = new PDFJS.PDFWorker('test3');
var ready = Promise.all([worker1.promise, worker2.promise,
worker3.promise]);
waitsForPromiseResolved(ready, function () {
ready.then(function () {
expect(worker1.port !== worker2.port &&
worker1.port !== worker3.port &&
worker2.port !== worker3.port).toEqual(true);
worker1.destroy();
worker2.destroy();
worker3.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
});
@ -296,10 +310,11 @@ describe('api', function() {
var loadingTask;
var doc;
beforeEach(function() {
beforeEach(function(done) {
loadingTask = PDFJS.getDocument(basicApiUrl);
waitsForPromiseResolved(loadingTask.promise, function(data) {
loadingTask.promise.then(function(data) {
doc = data;
done();
});
});
@ -315,54 +330,75 @@ describe('api', function() {
expect(typeof fingerprint).toEqual('string');
expect(fingerprint.length > 0).toEqual(true);
});
it('gets page', function() {
it('gets page', function(done) {
var promise = doc.getPage(1);
waitsForPromiseResolved(promise, function(data) {
promise.then(function(data) {
expect(data instanceof PDFPageProxy).toEqual(true);
expect(data.pageIndex).toEqual(0);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets non-existent page', function() {
it('gets non-existent page', function(done) {
var promise = doc.getPage(100);
waitsForPromiseRejected(promise, function(data) {
promise.then(function () {
done.fail('shall fail for non-existent page');
}, function(data) {
expect(data instanceof Error).toEqual(true);
done();
});
});
it('gets page index', function() {
it('gets page index', function(done) {
// reference to second page
var ref = {num: 17, gen: 0};
var promise = doc.getPageIndex(ref);
waitsForPromiseResolved(promise, function(pageIndex) {
promise.then(function(pageIndex) {
expect(pageIndex).toEqual(1);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets destinations', function() {
it('gets destinations', function(done) {
var promise = doc.getDestinations();
waitsForPromiseResolved(promise, function(data) {
promise.then(function(data) {
expect(data).toEqual({ chapter1: [{ gen: 0, num: 17 }, { name: 'XYZ' },
0, 841.89, null] });
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets a destination', function() {
it('gets a destination', function(done) {
var promise = doc.getDestination('chapter1');
waitsForPromiseResolved(promise, function(data) {
promise.then(function(data) {
expect(data).toEqual([{ gen: 0, num: 17 }, { name: 'XYZ' },
0, 841.89, null]);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets a non-existent destination', function() {
it('gets a non-existent destination', function(done) {
var promise = doc.getDestination('non-existent-named-destination');
waitsForPromiseResolved(promise, function(data) {
promise.then(function(data) {
expect(data).toEqual(null);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets non-existent page labels', function () {
it('gets non-existent page labels', function (done) {
var promise = doc.getPageLabels();
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data).toEqual(null);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets page labels', function () {
it('gets page labels', function (done) {
// PageLabels with Roman/Arabic numerals.
var url0 = combineUrl(window.location.href, '../pdfs/bug793632.pdf');
var loadingTask0 = PDFJS.getDocument(url0);
@ -384,8 +420,7 @@ describe('api', function() {
return pdfDoc.getPageLabels();
});
waitsForPromiseResolved(Promise.all([promise0, promise1, promise2]),
function (pageLabels) {
Promise.all([promise0, promise1, promise2]).then(function (pageLabels) {
expect(pageLabels[0]).toEqual(['i', 'ii', 'iii', '1']);
expect(pageLabels[1]).toEqual(['Front Page1']);
expect(pageLabels[2]).toEqual(['1', '2']);
@ -393,66 +428,86 @@ describe('api', function() {
loadingTask0.destroy();
loadingTask1.destroy();
loadingTask2.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets attachments', function() {
it('gets attachments', function(done) {
var promise = doc.getAttachments();
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data).toEqual(null);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets javascript', function() {
it('gets javascript', function(done) {
var promise = doc.getJavaScript();
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data).toEqual([]);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
// Keep this in sync with the pattern in viewer.js. The pattern is used to
// detect whether or not to automatically start printing.
var viewerPrintRegExp = /\bprint\s*\(/;
it('gets javascript with printing instructions (Print action)', function() {
it('gets javascript with printing instructions (Print action)',
function(done) {
// PDF document with "Print" Named action in OpenAction
var pdfUrl = combineUrl(window.location.href, '../pdfs/bug1001080.pdf');
var loadingTask = PDFJS.getDocument(pdfUrl);
var promise = loadingTask.promise.then(function(doc) {
return doc.getJavaScript();
});
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data).toEqual(['print({});']);
expect(data[0]).toMatch(viewerPrintRegExp);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets javascript with printing instructions (JS action)', function() {
it('gets javascript with printing instructions (JS action)',
function(done) {
// PDF document with "JavaScript" action in OpenAction
var pdfUrl = combineUrl(window.location.href, '../pdfs/issue6106.pdf');
var loadingTask = PDFJS.getDocument(pdfUrl);
var promise = loadingTask.promise.then(function(doc) {
return doc.getJavaScript();
});
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data).toEqual(
['this.print({bUI:true,bSilent:false,bShrinkToFit:true});']);
expect(data[0]).toMatch(viewerPrintRegExp);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets non-existent outline', function() {
it('gets non-existent outline', function(done) {
var url = combineUrl(window.location.href, '../pdfs/tracemonkey.pdf');
var loadingTask = PDFJS.getDocument(url);
var promise = loadingTask.promise.then(function (pdfDocument) {
return pdfDocument.getOutline();
});
waitsForPromiseResolved(promise, function (outline) {
promise.then(function (outline) {
expect(outline).toEqual(null);
loadingTask.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets outline', function() {
it('gets outline', function(done) {
var promise = doc.getOutline();
waitsForPromiseResolved(promise, function(outline) {
promise.then(function(outline) {
// Two top level entries.
expect(outline instanceof Array).toEqual(true);
expect(outline.length).toEqual(2);
@ -468,9 +523,12 @@ describe('api', function() {
expect(outlineItem.items.length).toEqual(1);
expect(outlineItem.items[0].title).toEqual('Paragraph 1.1');
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets outline containing a url', function() {
it('gets outline containing a url', function(done) {
var pdfUrl = combineUrl(window.location.href, '../pdfs/issue3214.pdf');
var loadingTask = PDFJS.getDocument(pdfUrl);
@ -490,38 +548,53 @@ describe('api', function() {
expect(outlineItemOne.color).toEqual(new Uint8Array([0, 0, 0]));
loadingTask.destroy(); // Cleanup the worker.
done();
});
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets metadata', function() {
it('gets metadata', function(done) {
var promise = doc.getMetadata();
waitsForPromiseResolved(promise, function(metadata) {
promise.then(function(metadata) {
expect(metadata.info['Title']).toEqual('Basic API Test');
expect(metadata.info['PDFFormatVersion']).toEqual('1.7');
expect(metadata.metadata.get('dc:title')).toEqual('Basic API Test');
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets data', function() {
it('gets data', function(done) {
var promise = doc.getData();
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data instanceof Uint8Array).toEqual(true);
expect(data.length).toEqual(basicApiFileLength);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets download info', function() {
it('gets download info', function(done) {
var promise = doc.getDownloadInfo();
waitsForPromiseResolved(promise, function (data) {
promise.then(function (data) {
expect(data).toEqual({ length: basicApiFileLength });
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets stats', function() {
it('gets stats', function(done) {
var promise = doc.getStats();
waitsForPromiseResolved(promise, function (stats) {
promise.then(function (stats) {
expect(stats).toEqual({ streamTypes: [], fontTypes: [] });
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('checks that fingerprints are unique', function() {
it('checks that fingerprints are unique', function(done) {
var url1 = combineUrl(window.location.href, '../pdfs/issue4436r.pdf');
var loadingTask1 = PDFJS.getDocument(url1);
@ -530,7 +603,7 @@ describe('api', function() {
var promises = [loadingTask1.promise,
loadingTask2.promise];
waitsForPromiseResolved(Promise.all(promises), function (data) {
Promise.all(promises).then(function (data) {
var fingerprint1 = data[0].fingerprint;
expect(typeof fingerprint1).toEqual('string');
expect(fingerprint1.length > 0).toEqual(true);
@ -543,6 +616,9 @@ describe('api', function() {
loadingTask1.destroy();
loadingTask2.destroy();
done();
}).catch(function (reason) {
done.fail(reason);
});
});
});
@ -550,13 +626,16 @@ describe('api', function() {
var loadingTask;
var pdfDocument, page;
beforeEach(function() {
beforeEach(function(done) {
loadingTask = PDFJS.getDocument(basicApiUrl);
waitsForPromiseResolved(loadingTask.promise, function(doc) {
loadingTask.promise.then(function(doc) {
pdfDocument = doc;
waitsForPromiseResolved(pdfDocument.getPage(1), function(data) {
pdfDocument.getPage(1).then(function(data) {
page = data;
done();
});
}).catch(function (reason) {
done.fail(reason);
});
});
@ -585,23 +664,28 @@ describe('api', function() {
expect(viewport.width).toEqual(1262.835);
expect(viewport.height).toEqual(892.92);
});
it('gets annotations', function () {
var defaultPromise = page.getAnnotations();
waitsForPromiseResolved(defaultPromise, function (data) {
it('gets annotations', function (done) {
var defaultPromise = page.getAnnotations().then(function (data) {
expect(data.length).toEqual(4);
});
var displayPromise = page.getAnnotations({ intent: 'display' });
waitsForPromiseResolved(displayPromise, function (data) {
var displayPromise = page.getAnnotations({ intent: 'display' }).then(
function (data) {
expect(data.length).toEqual(4);
});
var printPromise = page.getAnnotations({ intent: 'print' });
waitsForPromiseResolved(printPromise, function (data) {
var printPromise = page.getAnnotations({ intent: 'print' }).then(
function (data) {
expect(data.length).toEqual(4);
});
Promise.all([defaultPromise, displayPromise, printPromise]).then(
function () {
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets text content', function () {
it('gets text content', function (done) {
var defaultPromise = page.getTextContent();
var normalizeWhitespacePromise = page.getTextContent({
normalizeWhitespace: true });
@ -610,24 +694,30 @@ describe('api', function() {
defaultPromise,
normalizeWhitespacePromise
];
waitsForPromiseResolved(Promise.all(promises), function (data) {
Promise.all(promises).then(function (data) {
expect(!!data[0].items).toEqual(true);
expect(data[0].items.length).toEqual(7);
expect(!!data[0].styles).toEqual(true);
// A simple check that ensures the two `textContent` object match.
expect(JSON.stringify(data[0])).toEqual(JSON.stringify(data[1]));
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets operator list', function() {
it('gets operator list', function(done) {
var promise = page.getOperatorList();
waitsForPromiseResolved(promise, function (oplist) {
promise.then(function (oplist) {
expect(!!oplist.fnArray).toEqual(true);
expect(!!oplist.argsArray).toEqual(true);
expect(oplist.lastChunk).toEqual(true);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('gets stats after parsing page', function () {
it('gets stats after parsing page', function (done) {
var promise = page.getOperatorList().then(function () {
return pdfDocument.getStats();
});
@ -637,9 +727,12 @@ describe('api', function() {
expectedFontTypes[FontType.TYPE1] = true;
expectedFontTypes[FontType.CIDFONTTYPE2] = true;
waitsForPromiseResolved(promise, function (stats) {
promise.then(function (stats) {
expect(stats).toEqual({ streamTypes: expectedStreamTypes,
fontTypes: expectedFontTypes });
done();
}).catch(function (reason) {
done.fail(reason);
});
});
});
@ -677,23 +770,25 @@ describe('api', function() {
});
}
afterEach(function() {
afterEach(function(done) {
// Issue 6205 reported an issue with font rendering, so clear the loaded
// fonts so that we can see whether loading PDFs in parallel does not
// cause any issues with the rendered fonts.
var destroyPromises = pdfDocuments.map(function(pdfDocument) {
return pdfDocument.destroy();
});
waitsForPromiseResolved(Promise.all(destroyPromises), function() {});
// Destroy the workers.
destroyPromises = loadingTasks.map(function(loadingTask) {
var destroyPromises2 = loadingTasks.map(function(loadingTask) {
return loadingTask.destroy();
});
waitsForPromiseResolved(Promise.all(destroyPromises), function() {});
Promise.all(destroyPromises.concat(destroyPromises2)).then(function() {
done();
});
});
it('should correctly render PDFs in parallel', function() {
it('should correctly render PDFs in parallel', function(done) {
var baseline1, baseline2, baseline3;
var promiseDone = renderPDF(pdf1).then(function(data1) {
baseline1 = data1;
@ -714,7 +809,11 @@ describe('api', function() {
expect(dataUrls[2]).toEqual(baseline3);
return true;
});
waitsForPromiseResolved(promiseDone, function() {});
promiseDone.then(function() {
done();
}).catch(function (reason) {
done.fail(reason);
});
});
});
describe('PDFDataRangeTransport', function () {
@ -734,7 +833,7 @@ describe('api', function() {
});
return loadPromise;
}
it('should fetch document info and page using ranges', function () {
it('should fetch document info and page using ranges', function (done) {
var transport;
var initialDataLength = 4000;
var fetches = 0;
@ -758,14 +857,17 @@ describe('api', function() {
return pagePromise;
});
waitsForPromiseResolved(getPagePromise, function (page) {
getPagePromise.then(function (page) {
expect(pdfDocument.numPages).toEqual(14);
expect(page.rotate).toEqual(0);
expect(fetches).toBeGreaterThan(2);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
it('should fetch document info and page using range and streaming',
function () {
function (done) {
var transport;
var initialDataLength = 4000;
var fetches = 0;
@ -792,10 +894,13 @@ describe('api', function() {
return pagePromise;
});
waitsForPromiseResolved(getPagePromise, function (page) {
getPagePromise.then(function (page) {
expect(pdfDocument.numPages).toEqual(14);
expect(page.rotate).toEqual(0);
expect(fetches).toEqual(1);
done();
}).catch(function (reason) {
done.fail(reason);
});
});
});