mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
[Editor] Fix undoing an editor deletion (bug 1886959)
The original bug was because the parent was null when trying to show an highlight annotation which led to an exception. That led me to think about having some null/non-null parent when removing an editor: it's a mess especially if a destroyed parent is still attached to an editor. Consequently, this patch always sets the parent to null when deleting the editor.
This commit is contained in:
parent
b0f54b2235
commit
d5a0e557c2
10 changed files with 574 additions and 11 deletions
|
@ -24,10 +24,13 @@ import {
|
|||
kbCopy,
|
||||
kbPaste,
|
||||
kbSelectAll,
|
||||
kbUndo,
|
||||
loadAndWait,
|
||||
scrollIntoView,
|
||||
serializeBitmapDimensions,
|
||||
waitForAnnotationEditorLayer,
|
||||
waitForSelectedEditor,
|
||||
waitForSerialized,
|
||||
waitForStorageEntries,
|
||||
} from "./test_utils.mjs";
|
||||
import { fileURLToPath } from "url";
|
||||
|
@ -605,4 +608,124 @@ describe("Stamp Editor", () => {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("Undo a stamp", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that a stamp can be undone", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.click("#editorStamp");
|
||||
await page.waitForSelector(".annotationEditorLayer.stampEditing");
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
await waitForSerialized(page, 1);
|
||||
|
||||
await page.waitForSelector(`${getEditorSelector(0)} button.delete`);
|
||||
await page.click(`${getEditorSelector(0)} button.delete`);
|
||||
await waitForSerialized(page, 0);
|
||||
|
||||
await kbUndo(page);
|
||||
await waitForSerialized(page, 1);
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Delete a stamp and undo it on another page", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that a stamp can be undone", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.click("#editorStamp");
|
||||
await page.waitForSelector(".annotationEditorLayer.stampEditing");
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
await waitForSerialized(page, 1);
|
||||
|
||||
await page.waitForSelector(`${getEditorSelector(0)} button.delete`);
|
||||
await page.click(`${getEditorSelector(0)} button.delete`);
|
||||
await waitForSerialized(page, 0);
|
||||
|
||||
const twoToFourteen = Array.from(new Array(13).keys(), n => n + 2);
|
||||
for (const pageNumber of twoToFourteen) {
|
||||
const pageSelector = `.page[data-page-number = "${pageNumber}"]`;
|
||||
await scrollIntoView(page, pageSelector);
|
||||
}
|
||||
|
||||
await kbUndo(page);
|
||||
await waitForSerialized(page, 1);
|
||||
|
||||
const thirteenToOne = Array.from(new Array(13).keys(), n => 13 - n);
|
||||
for (const pageNumber of thirteenToOne) {
|
||||
const pageSelector = `.page[data-page-number = "${pageNumber}"]`;
|
||||
await scrollIntoView(page, pageSelector);
|
||||
}
|
||||
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Delete a stamp, scroll and undo it", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that a stamp can be undone", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.click("#editorStamp");
|
||||
await page.waitForSelector(".annotationEditorLayer.stampEditing");
|
||||
|
||||
await copyImage(page, "../images/firefox_logo.png", 0);
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
await waitForSerialized(page, 1);
|
||||
|
||||
await page.waitForSelector(`${getEditorSelector(0)} button.delete`);
|
||||
await page.click(`${getEditorSelector(0)} button.delete`);
|
||||
await waitForSerialized(page, 0);
|
||||
|
||||
const twoToOne = Array.from(new Array(13).keys(), n => n + 2).concat(
|
||||
Array.from(new Array(13).keys(), n => 13 - n)
|
||||
);
|
||||
for (const pageNumber of twoToOne) {
|
||||
const pageSelector = `.page[data-page-number = "${pageNumber}"]`;
|
||||
await scrollIntoView(page, pageSelector);
|
||||
}
|
||||
|
||||
await kbUndo(page);
|
||||
await waitForSerialized(page, 1);
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue