1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[Editor] Avoid to add unexpected commands in the undo/redo queue when undoing/redoing (bug 1781790)

We can undo/redo a command which will at some point add a command in the queue: typically
it can happening when redoing an addition.
So the idea is to lock the queue when undoing/redoing.
This commit is contained in:
Calixte Denizet 2022-07-27 19:05:44 +02:00
parent 89d1892959
commit 759116f4c5
2 changed files with 43 additions and 6 deletions

View file

@ -197,6 +197,28 @@ describe("Editor", () => {
}, `${editorPrefix}4`);
expect(hasEditor).withContext(`In ${browserName}`).toEqual(false);
for (let i = 0; i < 2; i++) {
await page.keyboard.down("Control");
await page.keyboard.press("v");
await page.keyboard.up("Control");
}
let length = await page.evaluate(sel => {
return document.querySelectorAll(sel).length;
}, `${editorPrefix}5, ${editorPrefix}6`);
expect(length).withContext(`In ${browserName}`).toEqual(2);
for (let i = 0; i < 2; i++) {
await page.keyboard.down("Control");
await page.keyboard.press("z");
await page.keyboard.up("Control");
}
length = await page.evaluate(sel => {
return document.querySelectorAll(sel).length;
}, `${editorPrefix}5, ${editorPrefix}6`);
expect(length).withContext(`In ${browserName}`).toEqual(0);
})
);
});
@ -230,7 +252,7 @@ describe("Editor", () => {
stacksRect.x + stacksRect.width + 1,
stacksRect.y + stacksRect.height / 2
);
await page.type(`${editorPrefix}5 .internal`, data);
await page.type(`${editorPrefix}7 .internal`, data);
// Commit.
await page.keyboard.press("Escape");
@ -242,7 +264,7 @@ describe("Editor", () => {
expect(ariaOwns)
.withContext(`In ${browserName}`)
.toEqual(`${editorPrefix}5-editor`.slice(1));
.toEqual(`${editorPrefix}7-editor`.slice(1));
})
);
});
@ -265,9 +287,9 @@ describe("Editor", () => {
const data = "Hello PDF.js World !!";
await page.mouse.click(rect.x + 100, rect.y + 100);
await page.type(`${editorPrefix}6 .internal`, data);
await page.type(`${editorPrefix}8 .internal`, data);
const editorRect = await page.$eval(`${editorPrefix}6`, el => {
const editorRect = await page.$eval(`${editorPrefix}8`, el => {
const { x, y, width, height } = el.getBoundingClientRect();
return { x, y, width, height };
});
@ -277,7 +299,7 @@ describe("Editor", () => {
expect(await getSelectedEditors(page))
.withContext(`In ${browserName}`)
.toEqual([6]);
.toEqual([8]);
await page.keyboard.press("Escape");
expect(await getSelectedEditors(page))
@ -291,7 +313,7 @@ describe("Editor", () => {
expect(await getSelectedEditors(page))
.withContext(`In ${browserName}`)
.toEqual([6]);
.toEqual([8]);
// Escape.
await page.keyboard.press("Escape");