1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[api-minor] Fix completely broken getStats method by returning stats in Objects, rather than in Arrays (PR 11029 follow-up)

With the changes to the `StreamType`/`FontType` "enums" in PR 11029, one unfortunate result is that `getStats` now *always* returns empty Arrays. Something that everyone, myself included, apparently missed is that you obviously cannot index an Array with Strings :-)

I wrongly assumed that the unit-tests would catch any bugs, but they apparently suffered from the same issue as the code in `src/core/`.

Another possible option could perhaps be to use `Set`s, rather than objects, but that will require larger changes since `LoopbackPort` (in `src/display/api.js`) doesn't support them.
This commit is contained in:
Jonas Jenwald 2019-08-02 13:55:37 +02:00
parent 9c8fe3142a
commit 0276385e6e
3 changed files with 8 additions and 8 deletions

View file

@ -926,7 +926,7 @@ describe('api', function() {
it('gets document stats', function(done) {
var promise = doc.getStats();
promise.then(function (stats) {
expect(stats).toEqual({ streamTypes: [], fontTypes: [], });
expect(stats).toEqual({ streamTypes: {}, fontTypes: {}, });
done();
}).catch(done.fail);
});
@ -1293,9 +1293,9 @@ describe('api', function() {
var promise = page.getOperatorList().then(function () {
return pdfDocument.getStats();
});
var expectedStreamTypes = [];
var expectedStreamTypes = {};
expectedStreamTypes[StreamType.FLATE] = true;
var expectedFontTypes = [];
var expectedFontTypes = {};
expectedFontTypes[FontType.TYPE1] = true;
expectedFontTypes[FontType.CIDFONTTYPE2] = true;