Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the "write a new annotation, save the pdf and check that the text content is correct" unit-test (PR 16559 follow-up) #16835

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion test/unit/api_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2203,8 +2203,14 @@ describe("api", function () {
We have learned that we should more explicitly set out our aspirations for the human experience of the internet.
We do so now.
`.repeat(100);
expect(manifesto.length).toEqual(80500);

let loadingTask = getDocument(buildGetDocumentParams("empty.pdf"));
let pdfDoc = await loadingTask.promise;
// The initial document size (indirectly) affects the length check below.
let typedArray = await pdfDoc.getData();
expect(typedArray.length).toBeLessThan(5000);

pdfDoc.annotationStorage.setValue("pdfjs_internal_editor_0", {
annotationType: AnnotationEditorType.FREETEXT,
rect: [10, 10, 500, 500],
Expand All @@ -2214,12 +2220,15 @@ describe("api", function () {
value: manifesto,
pageIndex: 0,
});

const data = await pdfDoc.saveDocument();
await loadingTask.destroy();

loadingTask = getDocument(data);
pdfDoc = await loadingTask.promise;
// Ensure that the Annotation text-content was actually compressed.
typedArray = await pdfDoc.getData();
expect(typedArray.length).toBeLessThan(90000);

const page = await pdfDoc.getPage(1);
const annotations = await page.getAnnotations();

Expand Down