From 949497a3c4291a2be031f7df69ade0e33d1e6a30 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 14 May 2026 15:34:38 +0200 Subject: [PATCH] Add a simple API unit-test for /BrotliDecode This is a new feature in PDF documents, hence it shouldn't hurt to complement the existing ref-test with a simple unit-test as well. This should also improve test coverage for the `external/` folder, which can't hurt since the other external decoders are already fairly well covered. --- test/unit/api_spec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unit/api_spec.js b/test/unit/api_spec.js index bc1471260..9ca24d216 100644 --- a/test/unit/api_spec.js +++ b/test/unit/api_spec.js @@ -4590,6 +4590,27 @@ have written that much by now. So, here’s to squashing bugs.`); await loadingTask.destroy(); }); + it("gets operatorList, from PDF with /BrotliDecode", async function () { + const loadingTask = getDocument( + buildGetDocumentParams("Brotli-Prototype-FileA.pdf") + ); + expect(loadingTask).toBeInstanceOf(PDFDocumentLoadingTask); + + const pdfDoc = await loadingTask.promise; + expect(pdfDoc.numPages).toEqual(25); + + const pdfPage = await pdfDoc.getPage(1); + expect(pdfPage).toBeInstanceOf(PDFPageProxy); + + const opList = await pdfPage.getOperatorList(); + expect(opList.fnArray.length).toBeGreaterThan(9800); + expect(opList.argsArray.length).toBeGreaterThan(9800); + expect(opList.lastChunk).toBeTrue(); + expect(opList.separateAnnots).toBeNull(); + + await loadingTask.destroy(); + }); + it("gets page stats after parsing page, without `pdfBug` set", async function () { await page.getOperatorList(); expect(page.stats).toEqual(null);