1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-29 07:37:57 +02:00

Fix errors when running the integration tests

JavaScript error: http://127.0.0.1:42301/build/generic/web/viewer.mjs, line 5822: TypeError: this[#state] is null
JavaScript error: http://127.0.0.1:42301/build/generic/web/viewer.mjs, line 6001: TypeError: can't access property "getPage", this._pdfDocument is null
This commit is contained in:
Calixte Denizet 2025-04-23 15:59:50 +02:00
parent de2a44a558
commit 8630822a63

View file

@ -771,6 +771,9 @@ class PDFFindController {
} }
#calculateMatch(pageIndex) { #calculateMatch(pageIndex) {
if (!this.#state) {
return;
}
const query = this.#query; const query = this.#query;
if (query.length === 0) { if (query.length === 0) {
return; // Do nothing: the matches should be wiped out already. return; // Do nothing: the matches should be wiped out already.
@ -882,12 +885,17 @@ class PDFFindController {
let deferred = Promise.resolve(); let deferred = Promise.resolve();
const textOptions = { disableNormalization: true }; const textOptions = { disableNormalization: true };
const pdfDoc = this._pdfDocument;
for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) { for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
const { promise, resolve } = Promise.withResolvers(); const { promise, resolve } = Promise.withResolvers();
this._extractTextPromises[i] = promise; this._extractTextPromises[i] = promise;
deferred = deferred.then(() => deferred = deferred.then(async () => {
this._pdfDocument if (pdfDoc !== this._pdfDocument) {
resolve();
return;
}
await pdfDoc
.getPage(i + 1) .getPage(i + 1)
.then(pdfPage => pdfPage.getTextContent(textOptions)) .then(pdfPage => pdfPage.getTextContent(textOptions))
.then( .then(
@ -920,8 +928,8 @@ class PDFFindController {
this._hasDiacritics[i] = false; this._hasDiacritics[i] = false;
resolve(); resolve();
} }
) );
); });
} }
} }