mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-28 01:47:22 +02:00
Wait a little between each key press in the test 'must check that the comment sidebar is resizable with the keyboard'
This commit is contained in:
parent
1192e5e921
commit
2ac42392f0
@ -32,6 +32,7 @@ import {
|
|||||||
selectEditor,
|
selectEditor,
|
||||||
switchToEditor,
|
switchToEditor,
|
||||||
waitAndClick,
|
waitAndClick,
|
||||||
|
waitForBrowserTrip,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
} from "./test_utils.mjs";
|
} from "./test_utils.mjs";
|
||||||
@ -570,6 +571,7 @@ describe("Comment", () => {
|
|||||||
const rect = await getRect(page, sidebarSelector);
|
const rect = await getRect(page, sidebarSelector);
|
||||||
const arrowKey = extraWidth > 0 ? "ArrowLeft" : "ArrowRight";
|
const arrowKey = extraWidth > 0 ? "ArrowLeft" : "ArrowRight";
|
||||||
for (let i = 0; i < Math.abs(extraWidth); i++) {
|
for (let i = 0; i < Math.abs(extraWidth); i++) {
|
||||||
|
await waitForBrowserTrip(page);
|
||||||
await kbModifierDown(page);
|
await kbModifierDown(page);
|
||||||
await page.keyboard.press(arrowKey);
|
await page.keyboard.press(arrowKey);
|
||||||
await kbModifierUp(page);
|
await kbModifierUp(page);
|
||||||
|
|||||||
@ -43,6 +43,7 @@ import {
|
|||||||
unselectEditor,
|
unselectEditor,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
|
waitForBrowserTrip,
|
||||||
waitForEntryInStorage,
|
waitForEntryInStorage,
|
||||||
waitForPageRendered,
|
waitForPageRendered,
|
||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
@ -84,14 +85,6 @@ const copyImage = async (page, imagePath, selector) => {
|
|||||||
await waitForImage(page, selector);
|
await waitForImage(page, selector);
|
||||||
};
|
};
|
||||||
|
|
||||||
async function waitForTranslation(page) {
|
|
||||||
return page.evaluate(async () => {
|
|
||||||
await new Promise(resolve => {
|
|
||||||
window.requestAnimationFrame(resolve);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const switchToStamp = switchToEditor.bind(null, "Stamp");
|
const switchToStamp = switchToEditor.bind(null, "Stamp");
|
||||||
|
|
||||||
describe("Stamp Editor", () => {
|
describe("Stamp Editor", () => {
|
||||||
@ -1007,7 +1000,7 @@ describe("Stamp Editor", () => {
|
|||||||
const buttonSelector = `${editorSelector} button.altText.new`;
|
const buttonSelector = `${editorSelector} button.altText.new`;
|
||||||
await page.waitForSelector(buttonSelector, { visible: true });
|
await page.waitForSelector(buttonSelector, { visible: true });
|
||||||
|
|
||||||
await waitForTranslation(page);
|
await waitForBrowserTrip(page);
|
||||||
// Check the text in the button.
|
// Check the text in the button.
|
||||||
let text = await page.evaluate(
|
let text = await page.evaluate(
|
||||||
sel => document.querySelector(sel).textContent,
|
sel => document.querySelector(sel).textContent,
|
||||||
@ -1056,7 +1049,7 @@ describe("Stamp Editor", () => {
|
|||||||
await waitForSelectedEditor(page, editorSelector);
|
await waitForSelectedEditor(page, editorSelector);
|
||||||
await page.waitForSelector(buttonSelector, { visible: true });
|
await page.waitForSelector(buttonSelector, { visible: true });
|
||||||
|
|
||||||
await waitForTranslation(page);
|
await waitForBrowserTrip(page);
|
||||||
// Check the text in the button.
|
// Check the text in the button.
|
||||||
text = await page.evaluate(
|
text = await page.evaluate(
|
||||||
sel => document.querySelector(sel).textContent,
|
sel => document.querySelector(sel).textContent,
|
||||||
@ -1098,7 +1091,7 @@ describe("Stamp Editor", () => {
|
|||||||
await page.click("#newAltTextSave");
|
await page.click("#newAltTextSave");
|
||||||
await page.waitForSelector("#newAltTextDialog", { visible: false });
|
await page.waitForSelector("#newAltTextDialog", { visible: false });
|
||||||
|
|
||||||
await waitForTranslation(page);
|
await waitForBrowserTrip(page);
|
||||||
// Check the text in the button.
|
// Check the text in the button.
|
||||||
text = await page.evaluate(
|
text = await page.evaluate(
|
||||||
sel => document.querySelector(sel).firstChild.textContent,
|
sel => document.querySelector(sel).firstChild.textContent,
|
||||||
|
|||||||
@ -1006,6 +1006,15 @@ async function showViewsManager(page) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function waitForBrowserTrip(page) {
|
||||||
|
const handle = await page.evaluateHandle(() => [
|
||||||
|
new Promise(resolve => {
|
||||||
|
window.requestAnimationFrame(resolve);
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
await awaitPromise(handle);
|
||||||
|
}
|
||||||
|
|
||||||
// Unicode bidi isolation characters, Fluent adds these markers to the text.
|
// Unicode bidi isolation characters, Fluent adds these markers to the text.
|
||||||
const FSI = "\u2068";
|
const FSI = "\u2068";
|
||||||
const PDI = "\u2069";
|
const PDI = "\u2069";
|
||||||
@ -1078,6 +1087,7 @@ export {
|
|||||||
waitAndClick,
|
waitAndClick,
|
||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
|
waitForBrowserTrip,
|
||||||
waitForDOMMutation,
|
waitForDOMMutation,
|
||||||
waitForEntryInStorage,
|
waitForEntryInStorage,
|
||||||
waitForEvent,
|
waitForEvent,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user