mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
[Editor] Fix the quadpoints value when serializing an highlight annotation
The coordinates of each point in a box are in the page coordinates system.
This commit is contained in:
parent
8f75e34b6f
commit
30101cbb31
2 changed files with 41 additions and 5 deletions
|
@ -18,6 +18,7 @@ import {
|
|||
closePages,
|
||||
createPromise,
|
||||
getEditorSelector,
|
||||
getFirstSerialized,
|
||||
getSerialized,
|
||||
kbBigMoveLeft,
|
||||
kbBigMoveUp,
|
||||
|
@ -1329,4 +1330,40 @@ describe("Highlight Editor", () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Quadpoints must be correct", () => {
|
||||
let pages;
|
||||
|
||||
beforeAll(async () => {
|
||||
pages = await loadAndWait("tracemonkey.pdf", ".annotationEditorLayer");
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that the quadpoints for an highlight are almost correct", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
await page.click("#editorHighlight");
|
||||
await page.waitForSelector(".annotationEditorLayer.highlightEditing");
|
||||
|
||||
const rect = await getSpanRectFromText(page, 1, "Languages");
|
||||
await page.mouse.click(
|
||||
rect.x + rect.width / 2,
|
||||
rect.y + rect.height / 2,
|
||||
{ count: 2, delay: 100 }
|
||||
);
|
||||
|
||||
await page.waitForSelector(getEditorSelector(0));
|
||||
await waitForSerialized(page, 1);
|
||||
const quadPoints = await getFirstSerialized(page, e => e.quadPoints);
|
||||
const expected = [263, 674, 346, 674, 263, 696, 346, 696];
|
||||
expect(quadPoints.every((x, i) => Math.abs(x - expected[i]) <= 5))
|
||||
.withContext(`In ${browserName}`)
|
||||
.toBeTrue();
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue