Merge pull request #10969 from Snuffleupagus/api-test-stopAtErrors
Add an API unit-test for the `stopAtErrors` option (PRs 8240 and 8922 follow-up)
This commit is contained in:
commit
13ebfec903
@ -2101,6 +2101,8 @@ class WorkerTransport {
|
|||||||
|
|
||||||
if (intentState.displayReadyCapability) {
|
if (intentState.displayReadyCapability) {
|
||||||
intentState.displayReadyCapability.reject(new Error(data.error));
|
intentState.displayReadyCapability.reject(new Error(data.error));
|
||||||
|
} else if (intentState.opListReadCapability) {
|
||||||
|
intentState.opListReadCapability.reject(new Error(data.error));
|
||||||
} else {
|
} else {
|
||||||
throw new Error(data.error);
|
throw new Error(data.error);
|
||||||
}
|
}
|
||||||
|
@ -1236,6 +1236,7 @@ describe('api', function() {
|
|||||||
done();
|
done();
|
||||||
}).catch(done.fail);
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets operatorList with JPEG image (issue 4888)', function(done) {
|
it('gets operatorList with JPEG image (issue 4888)', function(done) {
|
||||||
let loadingTask = getDocument(buildGetDocumentParams('cmykjpeg.pdf'));
|
let loadingTask = getDocument(buildGetDocumentParams('cmykjpeg.pdf'));
|
||||||
|
|
||||||
@ -1254,6 +1255,43 @@ describe('api', function() {
|
|||||||
});
|
});
|
||||||
}).catch(done.fail);
|
}).catch(done.fail);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('gets operatorList, from corrupt PDF file (issue 8702), ' +
|
||||||
|
'with/without `stopAtErrors` set', function(done) {
|
||||||
|
const loadingTask1 = getDocument(buildGetDocumentParams('issue8702.pdf', {
|
||||||
|
stopAtErrors: false, // The default value.
|
||||||
|
}));
|
||||||
|
const loadingTask2 = getDocument(buildGetDocumentParams('issue8702.pdf', {
|
||||||
|
stopAtErrors: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const result1 = loadingTask1.promise.then((pdfDoc) => {
|
||||||
|
return pdfDoc.getPage(1).then((pdfPage) => {
|
||||||
|
return pdfPage.getOperatorList().then((opList) => {
|
||||||
|
expect(opList.fnArray.length).toEqual(722);
|
||||||
|
expect(opList.argsArray.length).toEqual(722);
|
||||||
|
expect(opList.lastChunk).toEqual(true);
|
||||||
|
|
||||||
|
return loadingTask1.destroy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const result2 = loadingTask2.promise.then((pdfDoc) => {
|
||||||
|
return pdfDoc.getPage(1).then((pdfPage) => {
|
||||||
|
return pdfPage.getOperatorList().then((opList) => {
|
||||||
|
expect(opList.fnArray.length).toEqual(0);
|
||||||
|
expect(opList.argsArray.length).toEqual(0);
|
||||||
|
expect(opList.lastChunk).toEqual(true);
|
||||||
|
|
||||||
|
return loadingTask2.destroy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Promise.all([result1, result2]).then(done, done.fail);
|
||||||
|
});
|
||||||
|
|
||||||
it('gets document stats after parsing page', function(done) {
|
it('gets document stats after parsing page', function(done) {
|
||||||
var promise = page.getOperatorList().then(function () {
|
var promise = page.getOperatorList().then(function () {
|
||||||
return pdfDocument.getStats();
|
return pdfDocument.getStats();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user