Skip to content

Commit 3ccb263

Browse files
Merge pull request #21123 from timvandermeij/fix-unit-test-commonobjs
Fix the `gets text content, with correct properties (issue 8276)` unit test
2 parents 92f862b + 801236f commit 3ccb263

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

test/unit/api_spec.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,9 +3723,25 @@ page 1 / 3`);
37233723
vertical: false,
37243724
});
37253725

3726-
// Wait for font data to be loaded so we can check that the font names
3727-
// match.
3728-
await pdfPage.getOperatorList();
3726+
// Render the page to make sure that the font data is loaded so we can
3727+
// check that the font name in `commonObjs` matches.
3728+
const { canvasFactory } = pdfDoc;
3729+
const viewport = pdfPage.getViewport({ scale: 1 });
3730+
3731+
const canvasAndCtx = canvasFactory.create(
3732+
viewport.width,
3733+
viewport.height
3734+
);
3735+
const renderTask = pdfPage.render({
3736+
canvas: canvasAndCtx.canvas,
3737+
viewport,
3738+
});
3739+
3740+
await renderTask.promise;
3741+
// The canvas is no longer necessary, since we only care about the
3742+
// `commonObjs` property being populated below.
3743+
canvasFactory.destroy(canvasAndCtx);
3744+
37293745
expect(pdfPage.commonObjs.has(fontName)).toEqual(true);
37303746

37313747
await loadingTask.destroy();

0 commit comments

Comments
 (0)