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

Fix #serializeBoxes bug inconsistent with deserialize function for highlight editor.

Add test for quadPoints order while serializing.
This commit is contained in:
Jarklee 2024-11-17 18:29:01 +07:00
parent 9bf9bbda0b
commit 2200f0523c
2 changed files with 9 additions and 8 deletions

View file

@ -1272,7 +1272,8 @@ describe("Highlight Editor", () => {
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];
// Expected quadPoints tL, tR, bL, bR with bL coordinate.
const expected = [263, 696, 346, 696, 263, 674, 346, 674];
expect(quadPoints.every((x, i) => Math.abs(x - expected[i]) <= 5))
.withContext(`In ${browserName}`)
.toBeTrue();
@ -1307,7 +1308,8 @@ describe("Highlight Editor", () => {
await page.waitForSelector(getEditorSelector(0));
await waitForSerialized(page, 1);
const quadPoints = await getFirstSerialized(page, e => e.quadPoints);
const expected = [148, 624, 176, 624, 148, 637, 176, 637];
// Expected quadPoints tL, tR, bL, bR with bL coordinate.
const expected = [148, 637, 176, 637, 148, 624, 176, 624];
expect(quadPoints.every((x, i) => Math.abs(x - expected[i]) <= 5))
.withContext(`In ${browserName} (got ${quadPoints})`)
.toBeTrue();