Merge pull request #17380 from calixteman/issue17379
[Editor] Don't remove elements from the draw layer after it has been destroyed
This commit is contained in:
commit
c0436013a0
@ -185,6 +185,9 @@ class DrawLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
remove(id) {
|
remove(id) {
|
||||||
|
if (this.#parent === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.#mapping.get(id).remove();
|
this.#mapping.get(id).remove();
|
||||||
this.#mapping.delete(id);
|
this.#mapping.delete(id);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ async function runTests(results) {
|
|||||||
"copy_paste_spec.mjs",
|
"copy_paste_spec.mjs",
|
||||||
"find_spec.mjs",
|
"find_spec.mjs",
|
||||||
"freetext_editor_spec.mjs",
|
"freetext_editor_spec.mjs",
|
||||||
|
"highlight_editor_spec.mjs",
|
||||||
"ink_editor_spec.mjs",
|
"ink_editor_spec.mjs",
|
||||||
"scripting_spec.mjs",
|
"scripting_spec.mjs",
|
||||||
"stamp_editor_spec.mjs",
|
"stamp_editor_spec.mjs",
|
||||||
|
79
test/integration/highlight_editor_spec.mjs
Normal file
79
test/integration/highlight_editor_spec.mjs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
/* Copyright 2022 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {
|
||||||
|
closePages,
|
||||||
|
getEditorSelector,
|
||||||
|
loadAndWait,
|
||||||
|
scrollIntoView,
|
||||||
|
} from "./test_utils.mjs";
|
||||||
|
|
||||||
|
describe("Highlight Editor", () => {
|
||||||
|
describe("Editor must be removed without exception", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must scroll and check that the draw layer is there", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await page.click("#editorHighlight");
|
||||||
|
await page.waitForSelector(".annotationEditorLayer.highlightEditing");
|
||||||
|
|
||||||
|
const rect = await page.evaluate(() => {
|
||||||
|
for (const el of document.querySelectorAll(
|
||||||
|
`.page[data-page-number="1"] > .textLayer > span`
|
||||||
|
)) {
|
||||||
|
if (el.textContent === "Abstract") {
|
||||||
|
const { x, y, width, height } = el.getBoundingClientRect();
|
||||||
|
return { x, y, width, height };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const x = rect.x + rect.width / 2;
|
||||||
|
const y = rect.y + rect.height / 2;
|
||||||
|
await page.mouse.click(x, y, { count: 2 });
|
||||||
|
|
||||||
|
await page.waitForSelector(`${getEditorSelector(0)}`);
|
||||||
|
|
||||||
|
const oneToOne = Array.from(new Array(13).keys(), n => n + 2).concat(
|
||||||
|
Array.from(new Array(13).keys(), n => 13 - n)
|
||||||
|
);
|
||||||
|
for (const pageNumber of oneToOne) {
|
||||||
|
await scrollIntoView(
|
||||||
|
page,
|
||||||
|
`.page[data-page-number = "${pageNumber}"]`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
await page.waitForSelector(
|
||||||
|
`.page[data-page-number = "1"] svg.highlight`,
|
||||||
|
{
|
||||||
|
visible: true,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -130,7 +130,7 @@ const defaultOptions = {
|
|||||||
// in Firefox release, but it has to be temporary.
|
// in Firefox release, but it has to be temporary.
|
||||||
// TODO: remove it when unnecessary.
|
// TODO: remove it when unnecessary.
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: typeof PDFJSDev === "undefined",
|
value: typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING"),
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
enablePermissions: {
|
enablePermissions: {
|
||||||
|
Loading…
Reference in New Issue
Block a user