mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Avoid an infinite loop when searching for a single diacritic
This commit is contained in:
parent
1e3e2defe4
commit
69c88477a9
2 changed files with 55 additions and 9 deletions
|
@ -13,11 +13,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { FindState, PDFFindController } from "../../web/pdf_find_controller.js";
|
||||
import { buildGetDocumentParams } from "./test_utils.js";
|
||||
import { EventBus } from "../../web/event_utils.js";
|
||||
import { getDocument } from "../../src/display/api.js";
|
||||
import { isNodeJS } from "../../src/shared/is_node.js";
|
||||
import { PDFFindController } from "../../web/pdf_find_controller.js";
|
||||
import { SimpleLinkService } from "../../web/pdf_link_service.js";
|
||||
|
||||
const tracemonkeyFileName = "tracemonkey.pdf";
|
||||
|
@ -156,6 +156,38 @@ function testSearch({
|
|||
});
|
||||
}
|
||||
|
||||
function testEmptySearch({ eventBus, pdfFindController, state }) {
|
||||
return new Promise(function (resolve) {
|
||||
const eventState = Object.assign(
|
||||
Object.create(null),
|
||||
{
|
||||
source: this,
|
||||
type: "",
|
||||
query: null,
|
||||
caseSensitive: false,
|
||||
entireWord: false,
|
||||
phraseSearch: true,
|
||||
findPrevious: false,
|
||||
matchDiacritics: false,
|
||||
},
|
||||
state
|
||||
);
|
||||
eventBus.dispatch("find", eventState);
|
||||
|
||||
eventBus.on(
|
||||
"updatefindcontrolstate",
|
||||
function onUpdatefindcontrolstate(evt) {
|
||||
if (evt.state !== FindState.NOT_FOUND) {
|
||||
return;
|
||||
}
|
||||
eventBus.off("updatefindcontrolstate", onUpdatefindcontrolstate);
|
||||
expect(evt.matchesCount.total).toBe(0);
|
||||
resolve();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
describe("pdf_find_controller", function () {
|
||||
it("performs a normal search", async function () {
|
||||
const { eventBus, pdfFindController } = await initPdfFindController();
|
||||
|
@ -689,4 +721,16 @@ describe("pdf_find_controller", function () {
|
|||
pageMatchesLength: [[5]],
|
||||
});
|
||||
});
|
||||
|
||||
it("performs a search with a single diacritic", async function () {
|
||||
const { eventBus, pdfFindController } = await initPdfFindController();
|
||||
|
||||
await testEmptySearch({
|
||||
eventBus,
|
||||
pdfFindController,
|
||||
state: {
|
||||
query: "\u064E",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue