mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #17811 from calixteman/simplify_copy_paste_test
Simplify the copy & paste integration test
This commit is contained in:
commit
9673a6d344
2 changed files with 8 additions and 27 deletions
|
@ -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");
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue