mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Fix intermittent failures with freetext and stamp tests
They're potentially due to some concurrent access to the system clipboard. So this patch makes them sequential.
This commit is contained in:
parent
af16aa62ad
commit
0e94f2bd00
2 changed files with 470 additions and 485 deletions
|
@ -3369,8 +3369,8 @@ describe("FreeText Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that pasting html just keep the text", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [browserName, page] of pages) {
|
||||
await switchToFreeText(page);
|
||||
|
||||
const rect = await getRect(page, ".annotationEditorLayer");
|
||||
|
@ -3403,9 +3403,7 @@ describe("FreeText Editor", () => {
|
|||
editorRect.y + editorRect.height / 2,
|
||||
{ count: 2 }
|
||||
);
|
||||
await page.waitForSelector(
|
||||
`${editorSelector} .overlay:not(.enabled)`
|
||||
);
|
||||
await page.waitForSelector(`${editorSelector} .overlay:not(.enabled)`);
|
||||
|
||||
const select = position =>
|
||||
page.evaluate(
|
||||
|
@ -3493,8 +3491,7 @@ describe("FreeText Editor", () => {
|
|||
await waitForTextChange("", editorSelector);
|
||||
text = await getText(editorSelector);
|
||||
expect(text).withContext(`In ${browserName}`).toEqual(fooBar);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -258,8 +258,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that the alt-text flow is correctly implemented", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [browserName, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
|
@ -410,8 +410,7 @@ describe("Stamp Editor", () => {
|
|||
await (browserName === "chrome"
|
||||
? page.waitForSelector(`${buttonSelector}:focus`)
|
||||
: page.waitForSelector(`${buttonSelector}:focus-visible`));
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -427,8 +426,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that the dimensions change", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [browserName, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
|
@ -544,8 +543,7 @@ describe("Stamp Editor", () => {
|
|||
await page.waitForFunction(
|
||||
() => !document.activeElement?.classList.contains("resizer")
|
||||
);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -594,8 +592,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that a stamp can be undone", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
const selector = getEditorSelector(0);
|
||||
|
||||
|
@ -610,8 +608,7 @@ describe("Stamp Editor", () => {
|
|||
await kbUndo(page);
|
||||
await waitForSerialized(page, 1);
|
||||
await page.waitForSelector(`${selector} canvas`);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -627,8 +624,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that a stamp can be undone", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
const selector = getEditorSelector(0);
|
||||
|
||||
|
@ -656,8 +653,7 @@ describe("Stamp Editor", () => {
|
|||
}
|
||||
|
||||
await page.waitForSelector(`${selector} canvas`);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -673,8 +669,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that a stamp can be undone", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
const selector = getEditorSelector(0);
|
||||
|
||||
|
@ -697,8 +693,7 @@ describe("Stamp Editor", () => {
|
|||
await kbUndo(page);
|
||||
await waitForSerialized(page, 1);
|
||||
await page.waitForSelector(`${selector} canvas`);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -714,8 +709,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that a resized stamp has its canvas at the right position", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
|
@ -750,8 +745,7 @@ describe("Stamp Editor", () => {
|
|||
key => Math.abs(canvasRect[key] - stampRect[key]) <= 10
|
||||
)
|
||||
).toBeTrue();
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -775,8 +769,8 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that the stamp has its canvas at the right position", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
|
@ -794,8 +788,7 @@ describe("Stamp Editor", () => {
|
|||
key => Math.abs(canvasRect[key] - stampRect[key]) <= 10
|
||||
)
|
||||
).toBeTrue();
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -811,23 +804,19 @@ describe("Stamp Editor", () => {
|
|||
});
|
||||
|
||||
it("must check that the pasted image has an alt text", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
// Run sequentially to avoid clipboard issues.
|
||||
for (const [browserName, page] of pages) {
|
||||
await switchToStamp(page);
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
await waitForSerialized(page, 1);
|
||||
await applyFunctionToEditor(
|
||||
page,
|
||||
"pdfjs_internal_editor_0",
|
||||
editor => {
|
||||
await applyFunctionToEditor(page, "pdfjs_internal_editor_0", editor => {
|
||||
editor.altTextData = {
|
||||
altText: "Hello World",
|
||||
decorative: false,
|
||||
};
|
||||
}
|
||||
);
|
||||
});
|
||||
await page.waitForSelector(`${getEditorSelector(0)} .altText.done`);
|
||||
|
||||
await copy(page);
|
||||
|
@ -843,8 +832,7 @@ describe("Stamp Editor", () => {
|
|||
expect(serialized)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual(["Hello World", "Hello World"]);
|
||||
})
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue