mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Simplify the copy & paste integration test
This commit is contained in:
parent
e892f3b18f
commit
f6b215144d
2 changed files with 8 additions and 27 deletions
|
@ -20,7 +20,6 @@ import {
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
mockClipboard,
|
mockClipboard,
|
||||||
waitForEvent,
|
waitForEvent,
|
||||||
waitForTextLayer,
|
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
|
|
||||||
const selectAll = async page => {
|
const selectAll = async page => {
|
||||||
|
@ -40,17 +39,7 @@ describe("Copy and paste", () => {
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
pages = await loadAndWait(
|
pages = await loadAndWait("tracemonkey.pdf", "#hiddenCopyElement", 100);
|
||||||
"tracemonkey.pdf",
|
|
||||||
"#hiddenCopyElement",
|
|
||||||
100,
|
|
||||||
async page => {
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !!window.PDFViewerApplication.eventBus
|
|
||||||
);
|
|
||||||
await waitForTextLayer(page);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
await mockClipboard(pages);
|
await mockClipboard(pages);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,6 +50,9 @@ describe("Copy and paste", () => {
|
||||||
it("must check that we've all the contents on copy/paste", async () => {
|
it("must check that we've all the contents on copy/paste", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await page.waitForSelector(
|
||||||
|
".page[data-page-number='1'] .textLayer .endOfContent"
|
||||||
|
);
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|
||||||
const promise = waitForEvent(page, "copy");
|
const promise = waitForEvent(page, "copy");
|
||||||
|
@ -150,13 +142,7 @@ describe("Copy and paste", () => {
|
||||||
pages = await loadAndWait(
|
pages = await loadAndWait(
|
||||||
"copy_paste_ligatures.pdf",
|
"copy_paste_ligatures.pdf",
|
||||||
"#hiddenCopyElement",
|
"#hiddenCopyElement",
|
||||||
100,
|
100
|
||||||
async page => {
|
|
||||||
await page.waitForFunction(
|
|
||||||
() => !!window.PDFViewerApplication.eventBus
|
|
||||||
);
|
|
||||||
await waitForTextLayer(page);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
await mockClipboard(pages);
|
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 () => {
|
it("must check that the ligatures have been removed when the text has been copied", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await page.waitForSelector(
|
||||||
|
".page[data-page-number='1'] .textLayer .endOfContent"
|
||||||
|
);
|
||||||
await selectAll(page);
|
await selectAll(page);
|
||||||
|
|
||||||
const promise = waitForEvent(page, "copy");
|
const promise = waitForEvent(page, "copy");
|
||||||
|
|
|
@ -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) {
|
async function scrollIntoView(page, selector) {
|
||||||
const handle = await page.evaluateHandle(
|
const handle = await page.evaluateHandle(
|
||||||
sel => [
|
sel => [
|
||||||
|
@ -541,7 +534,6 @@ export {
|
||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForStorageEntries,
|
waitForStorageEntries,
|
||||||
waitForTextLayer,
|
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
waitForUnselectedEditor,
|
waitForUnselectedEditor,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue