1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Simplify the copy & paste integration test

This commit is contained in:
Calixte Denizet 2024-03-19 22:29:59 +01:00
parent e892f3b18f
commit f6b215144d
2 changed files with 8 additions and 27 deletions

View file

@ -20,7 +20,6 @@ import {
loadAndWait,
mockClipboard,
waitForEvent,
waitForTextLayer,
} from "./test_utils.mjs";
const selectAll = async page => {
@ -40,17 +39,7 @@ describe("Copy and paste", () => {
let pages;
beforeAll(async () => {
pages = await loadAndWait(
"tracemonkey.pdf",
"#hiddenCopyElement",
100,
async page => {
await page.waitForFunction(
() => !!window.PDFViewerApplication.eventBus
);
await waitForTextLayer(page);
}
);
pages = await loadAndWait("tracemonkey.pdf", "#hiddenCopyElement", 100);
await mockClipboard(pages);
});
@ -61,6 +50,9 @@ describe("Copy and paste", () => {
it("must check that we've all the contents on copy/paste", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForSelector(
".page[data-page-number='1'] .textLayer .endOfContent"
);
await selectAll(page);
const promise = waitForEvent(page, "copy");
@ -150,13 +142,7 @@ describe("Copy and paste", () => {
pages = await loadAndWait(
"copy_paste_ligatures.pdf",
"#hiddenCopyElement",
100,
async page => {
await page.waitForFunction(
() => !!window.PDFViewerApplication.eventBus
);
await waitForTextLayer(page);
}
100
);
await mockClipboard(pages);
});
@ -168,6 +154,9 @@ describe("Copy and paste", () => {
it("must check that the ligatures have been removed when the text has been copied", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForSelector(
".page[data-page-number='1'] .textLayer .endOfContent"
);
await selectAll(page);
const promise = waitForEvent(page, "copy");

View file

@ -307,13 +307,6 @@ function waitForAnnotationEditorLayer(page) {
});
}
async function waitForTextLayer(page) {
const handle = await createPromise(page, resolve => {
window.PDFViewerApplication.eventBus.on("textlayerrendered", resolve);
});
return awaitPromise(handle);
}
async function scrollIntoView(page, selector) {
const handle = await page.evaluateHandle(
sel => [
@ -541,7 +534,6 @@ export {
waitForSelectedEditor,
waitForSerialized,
waitForStorageEntries,
waitForTextLayer,
waitForTimeout,
waitForUnselectedEditor,
};