|
|
@ -259,10 +259,10 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('PDFWorker', function () { |
|
|
|
describe('PDFWorker', function () { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
it('worker created or destroyed', function (done) { |
|
|
|
it('worker created or destroyed', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var worker = new _api.PDFWorker({ name: 'test1' }); |
|
|
|
var worker = new _api.PDFWorker({ name: 'test1' }); |
|
|
|
worker.promise.then(function () { |
|
|
|
worker.promise.then(function () { |
|
|
|
expect(worker.name).toEqual('test1'); |
|
|
|
expect(worker.name).toEqual('test1'); |
|
|
@ -279,6 +279,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('worker created or destroyed by getDocument', function (done) { |
|
|
|
it('worker created or destroyed by getDocument', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
|
var loadingTask = (0, _api.getDocument)(basicApiGetDocumentParams); |
|
|
|
var worker; |
|
|
|
var worker; |
|
|
|
loadingTask.promise.then(function () { |
|
|
|
loadingTask.promise.then(function () { |
|
|
@ -298,6 +301,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('worker created and can be used in getDocument', function (done) { |
|
|
|
it('worker created and can be used in getDocument', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var worker = new _api.PDFWorker({ name: 'test1' }); |
|
|
|
var worker = new _api.PDFWorker({ name: 'test1' }); |
|
|
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(basicApiFileName, { worker: worker })); |
|
|
|
var loadingTask = (0, _api.getDocument)((0, _test_utils.buildGetDocumentParams)(basicApiFileName, { worker: worker })); |
|
|
|
loadingTask.promise.then(function () { |
|
|
|
loadingTask.promise.then(function () { |
|
|
@ -318,6 +324,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('creates more than one worker', function (done) { |
|
|
|
it('creates more than one worker', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var worker1 = new _api.PDFWorker({ name: 'test1' }); |
|
|
|
var worker1 = new _api.PDFWorker({ name: 'test1' }); |
|
|
|
var worker2 = new _api.PDFWorker({ name: 'test2' }); |
|
|
|
var worker2 = new _api.PDFWorker({ name: 'test2' }); |
|
|
|
var worker3 = new _api.PDFWorker({ name: 'test3' }); |
|
|
|
var worker3 = new _api.PDFWorker({ name: 'test3' }); |
|
|
@ -333,6 +342,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('gets current workerSrc', function () { |
|
|
|
it('gets current workerSrc', function () { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('Worker is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var workerSrc = _api.PDFWorker.getWorkerSrc(); |
|
|
|
var workerSrc = _api.PDFWorker.getWorkerSrc(); |
|
|
|
expect(typeof workerSrc === 'undefined' ? 'undefined' : _typeof(workerSrc)).toEqual('string'); |
|
|
|
expect(typeof workerSrc === 'undefined' ? 'undefined' : _typeof(workerSrc)).toEqual('string'); |
|
|
|
expect(workerSrc).toEqual(_worker_options.GlobalWorkerOptions.workerSrc); |
|
|
|
expect(workerSrc).toEqual(_worker_options.GlobalWorkerOptions.workerSrc); |
|
|
@ -1019,10 +1031,7 @@ describe('api', function () { |
|
|
|
})]).then(done); |
|
|
|
})]).then(done); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('Multiple PDFJS instances', function () { |
|
|
|
describe('Multiple `getDocument` instances', function () { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var pdf1 = (0, _test_utils.buildGetDocumentParams)('tracemonkey.pdf'); |
|
|
|
var pdf1 = (0, _test_utils.buildGetDocumentParams)('tracemonkey.pdf'); |
|
|
|
var pdf2 = (0, _test_utils.buildGetDocumentParams)('TAMReview.pdf'); |
|
|
|
var pdf2 = (0, _test_utils.buildGetDocumentParams)('TAMReview.pdf'); |
|
|
|
var pdf3 = (0, _test_utils.buildGetDocumentParams)('issue6068.pdf'); |
|
|
|
var pdf3 = (0, _test_utils.buildGetDocumentParams)('issue6068.pdf'); |
|
|
@ -1059,6 +1068,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should correctly render PDFs in parallel', function (done) { |
|
|
|
it('should correctly render PDFs in parallel', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('TODO: Support Canvas testing in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var baseline1, baseline2, baseline3; |
|
|
|
var baseline1, baseline2, baseline3; |
|
|
|
var promiseDone = renderPDF(pdf1).then(function (data1) { |
|
|
|
var promiseDone = renderPDF(pdf1).then(function (data1) { |
|
|
|
baseline1 = data1; |
|
|
|
baseline1 = data1; |
|
|
@ -1083,12 +1095,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
describe('PDFDataRangeTransport', function () { |
|
|
|
describe('PDFDataRangeTransport', function () { |
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href; |
|
|
|
|
|
|
|
var loadPromise; |
|
|
|
var loadPromise; |
|
|
|
function getDocumentData() { |
|
|
|
function getDocumentData() { |
|
|
|
|
|
|
|
var pdfPath = new URL('../pdfs/tracemonkey.pdf', window.location).href; |
|
|
|
if (loadPromise) { |
|
|
|
if (loadPromise) { |
|
|
|
return loadPromise; |
|
|
|
return loadPromise; |
|
|
|
} |
|
|
|
} |
|
|
@ -1107,6 +1116,9 @@ describe('api', function () { |
|
|
|
return loadPromise; |
|
|
|
return loadPromise; |
|
|
|
} |
|
|
|
} |
|
|
|
it('should fetch document info and page using ranges', function (done) { |
|
|
|
it('should fetch document info and page using ranges', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var transport; |
|
|
|
var transport; |
|
|
|
var initialDataLength = 4000; |
|
|
|
var initialDataLength = 4000; |
|
|
|
var fetches = 0; |
|
|
|
var fetches = 0; |
|
|
@ -1139,6 +1151,9 @@ describe('api', function () { |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
it('should fetch document info and page using range and streaming', function (done) { |
|
|
|
it('should fetch document info and page using range and streaming', function (done) { |
|
|
|
|
|
|
|
if ((0, _is_node2.default)()) { |
|
|
|
|
|
|
|
pending('XMLHttpRequest is not supported in Node.js.'); |
|
|
|
|
|
|
|
} |
|
|
|
var transport; |
|
|
|
var transport; |
|
|
|
var initialDataLength = 4000; |
|
|
|
var initialDataLength = 4000; |
|
|
|
var fetches = 0; |
|
|
|
var fetches = 0; |
|
|
|