Skip to content

Commit 91175dc

Browse files
authored
Merge pull request #19854 from calixteman/fix_find_in_tests
Fix errors when running the integration tests
2 parents de2a44a + 8630822 commit 91175dc

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

web/pdf_find_controller.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,9 @@ class PDFFindController {
771771
}
772772

773773
#calculateMatch(pageIndex) {
774+
if (!this.#state) {
775+
return;
776+
}
774777
const query = this.#query;
775778
if (query.length === 0) {
776779
return; // Do nothing: the matches should be wiped out already.
@@ -882,12 +885,17 @@ class PDFFindController {
882885

883886
let deferred = Promise.resolve();
884887
const textOptions = { disableNormalization: true };
888+
const pdfDoc = this._pdfDocument;
885889
for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
886890
const { promise, resolve } = Promise.withResolvers();
887891
this._extractTextPromises[i] = promise;
888892

889-
deferred = deferred.then(() =>
890-
this._pdfDocument
893+
deferred = deferred.then(async () => {
894+
if (pdfDoc !== this._pdfDocument) {
895+
resolve();
896+
return;
897+
}
898+
await pdfDoc
891899
.getPage(i + 1)
892900
.then(pdfPage => pdfPage.getTextContent(textOptions))
893901
.then(
@@ -920,8 +928,8 @@ class PDFFindController {
920928
this._hasDiacritics[i] = false;
921929
resolve();
922930
}
923-
)
924-
);
931+
);
932+
});
925933
}
926934
}
927935

0 commit comments

Comments
 (0)