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 () => {
|
it("must check that pasting html just keep the text", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
await switchToFreeText(page);
|
await switchToFreeText(page);
|
||||||
|
|
||||||
const rect = await getRect(page, ".annotationEditorLayer");
|
const rect = await getRect(page, ".annotationEditorLayer");
|
||||||
|
@ -3403,9 +3403,7 @@ describe("FreeText Editor", () => {
|
||||||
editorRect.y + editorRect.height / 2,
|
editorRect.y + editorRect.height / 2,
|
||||||
{ count: 2 }
|
{ count: 2 }
|
||||||
);
|
);
|
||||||
await page.waitForSelector(
|
await page.waitForSelector(`${editorSelector} .overlay:not(.enabled)`);
|
||||||
`${editorSelector} .overlay:not(.enabled)`
|
|
||||||
);
|
|
||||||
|
|
||||||
const select = position =>
|
const select = position =>
|
||||||
page.evaluate(
|
page.evaluate(
|
||||||
|
@ -3493,8 +3491,7 @@ describe("FreeText Editor", () => {
|
||||||
await waitForTextChange("", editorSelector);
|
await waitForTextChange("", editorSelector);
|
||||||
text = await getText(editorSelector);
|
text = await getText(editorSelector);
|
||||||
expect(text).withContext(`In ${browserName}`).toEqual(fooBar);
|
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 () => {
|
it("must check that the alt-text flow is correctly implemented", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
|
|
||||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||||
|
@ -410,8 +410,7 @@ describe("Stamp Editor", () => {
|
||||||
await (browserName === "chrome"
|
await (browserName === "chrome"
|
||||||
? page.waitForSelector(`${buttonSelector}:focus`)
|
? page.waitForSelector(`${buttonSelector}:focus`)
|
||||||
: page.waitForSelector(`${buttonSelector}:focus-visible`));
|
: page.waitForSelector(`${buttonSelector}:focus-visible`));
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -427,8 +426,8 @@ describe("Stamp Editor", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that the dimensions change", async () => {
|
it("must check that the dimensions change", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
|
|
||||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||||
|
@ -544,8 +543,7 @@ describe("Stamp Editor", () => {
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
() => !document.activeElement?.classList.contains("resizer")
|
() => !document.activeElement?.classList.contains("resizer")
|
||||||
);
|
);
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -594,8 +592,8 @@ describe("Stamp Editor", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that a stamp can be undone", async () => {
|
it("must check that a stamp can be undone", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
const selector = getEditorSelector(0);
|
const selector = getEditorSelector(0);
|
||||||
|
|
||||||
|
@ -610,8 +608,7 @@ describe("Stamp Editor", () => {
|
||||||
await kbUndo(page);
|
await kbUndo(page);
|
||||||
await waitForSerialized(page, 1);
|
await waitForSerialized(page, 1);
|
||||||
await page.waitForSelector(`${selector} canvas`);
|
await page.waitForSelector(`${selector} canvas`);
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -627,8 +624,8 @@ describe("Stamp Editor", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that a stamp can be undone", async () => {
|
it("must check that a stamp can be undone", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
const selector = getEditorSelector(0);
|
const selector = getEditorSelector(0);
|
||||||
|
|
||||||
|
@ -656,8 +653,7 @@ describe("Stamp Editor", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await page.waitForSelector(`${selector} canvas`);
|
await page.waitForSelector(`${selector} canvas`);
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -673,8 +669,8 @@ describe("Stamp Editor", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that a stamp can be undone", async () => {
|
it("must check that a stamp can be undone", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
const selector = getEditorSelector(0);
|
const selector = getEditorSelector(0);
|
||||||
|
|
||||||
|
@ -697,8 +693,7 @@ describe("Stamp Editor", () => {
|
||||||
await kbUndo(page);
|
await kbUndo(page);
|
||||||
await waitForSerialized(page, 1);
|
await waitForSerialized(page, 1);
|
||||||
await page.waitForSelector(`${selector} canvas`);
|
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 () => {
|
it("must check that a resized stamp has its canvas at the right position", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
|
|
||||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||||
|
@ -750,8 +745,7 @@ describe("Stamp Editor", () => {
|
||||||
key => Math.abs(canvasRect[key] - stampRect[key]) <= 10
|
key => Math.abs(canvasRect[key] - stampRect[key]) <= 10
|
||||||
)
|
)
|
||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -775,8 +769,8 @@ describe("Stamp Editor", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that the stamp has its canvas at the right position", async () => {
|
it("must check that the stamp has its canvas at the right position", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
|
|
||||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||||
|
@ -794,8 +788,7 @@ describe("Stamp Editor", () => {
|
||||||
key => Math.abs(canvasRect[key] - stampRect[key]) <= 10
|
key => Math.abs(canvasRect[key] - stampRect[key]) <= 10
|
||||||
)
|
)
|
||||||
).toBeTrue();
|
).toBeTrue();
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -811,23 +804,19 @@ describe("Stamp Editor", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("must check that the pasted image has an alt text", async () => {
|
it("must check that the pasted image has an alt text", async () => {
|
||||||
await Promise.all(
|
// Run sequentially to avoid clipboard issues.
|
||||||
pages.map(async ([browserName, page]) => {
|
for (const [browserName, page] of pages) {
|
||||||
await switchToStamp(page);
|
await switchToStamp(page);
|
||||||
|
|
||||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||||
await page.waitForSelector(getEditorSelector(0));
|
await page.waitForSelector(getEditorSelector(0));
|
||||||
await waitForSerialized(page, 1);
|
await waitForSerialized(page, 1);
|
||||||
await applyFunctionToEditor(
|
await applyFunctionToEditor(page, "pdfjs_internal_editor_0", editor => {
|
||||||
page,
|
|
||||||
"pdfjs_internal_editor_0",
|
|
||||||
editor => {
|
|
||||||
editor.altTextData = {
|
editor.altTextData = {
|
||||||
altText: "Hello World",
|
altText: "Hello World",
|
||||||
decorative: false,
|
decorative: false,
|
||||||
};
|
};
|
||||||
}
|
});
|
||||||
);
|
|
||||||
await page.waitForSelector(`${getEditorSelector(0)} .altText.done`);
|
await page.waitForSelector(`${getEditorSelector(0)} .altText.done`);
|
||||||
|
|
||||||
await copy(page);
|
await copy(page);
|
||||||
|
@ -843,8 +832,7 @@ describe("Stamp Editor", () => {
|
||||||
expect(serialized)
|
expect(serialized)
|
||||||
.withContext(`In ${browserName}`)
|
.withContext(`In ${browserName}`)
|
||||||
.toEqual(["Hello World", "Hello World"]);
|
.toEqual(["Hello World", "Hello World"]);
|
||||||
})
|
}
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue