Skip to content

Commit 801236f

Browse files
committed
Fix the gets text content, with correct properties (issue 8276) unit test
This unit test failed consistently in Firefox both locally and on GitHub Actions (but not in Chrome or on the bots), which suggests a timing issue. Since all other unit tests that rely on `commonObjs` actually render the page, most likely to make sure that `commonObjs` is fully populated at the time of the check, this commit mirrors that approach to this test, which indeed fixes the issue.
1 parent 92f862b commit 801236f

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)