mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-07-11 17:45:49 +02:00
Merge pull request #21460 from Snuffleupagus/autolinking-check-every-LinkAnnotation
Check every LinkAnnotation when testing if inferred links overlap (issue 21458)
This commit is contained in:
commit
2ed018ec2d
@ -169,6 +169,43 @@ describe("autolinker", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("issue21458.pdf", function () {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
pages = await loadAndWait(
|
||||||
|
"issue21458.pdf",
|
||||||
|
".page[data-page-number='1'] .annotationLayer",
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
{ enableAutoLinking: true }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must not add links that overlap internal destinations", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await waitForLinkAnnotations(page);
|
||||||
|
const linkIds = await page.$$eval(
|
||||||
|
".page[data-page-number='1'] .annotationLayer > .linkAnnotation > a",
|
||||||
|
annotations =>
|
||||||
|
annotations.map(a => a.getAttribute("data-element-id"))
|
||||||
|
);
|
||||||
|
expect(linkIds.length).withContext(`In ${browserName}`).toEqual(42);
|
||||||
|
linkIds.forEach(id =>
|
||||||
|
expect(id)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.not.toContain("inferred_link_")
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe("PR 19470", function () {
|
describe("PR 19470", function () {
|
||||||
let pages;
|
let pages;
|
||||||
|
|
||||||
|
|||||||
1
test/pdfs/issue21458.pdf.link
Normal file
1
test/pdfs/issue21458.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/user-attachments/files/28985267/Gumbel.Distillation.pdf
|
||||||
@ -31,6 +31,14 @@
|
|||||||
"link": true,
|
"link": true,
|
||||||
"type": "other"
|
"type": "other"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "issue21458",
|
||||||
|
"file": "pdfs/issue21458.pdf",
|
||||||
|
"md5": "875754beca276ab63568e06fd49e8375",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"type": "other"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "filled-background-range",
|
"id": "filled-background-range",
|
||||||
"file": "pdfs/filled-background.pdf",
|
"file": "pdfs/filled-background.pdf",
|
||||||
|
|||||||
@ -332,10 +332,7 @@ class AnnotationLayerBuilder {
|
|||||||
let linkAreaRects;
|
let linkAreaRects;
|
||||||
|
|
||||||
for (const annotation of this.#annotations) {
|
for (const annotation of this.#annotations) {
|
||||||
if (
|
if (annotation.annotationType !== AnnotationType.LINK) {
|
||||||
annotation.annotationType !== AnnotationType.LINK ||
|
|
||||||
!annotation.url
|
|
||||||
) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// TODO: Add a test case to verify that we can find the intersection
|
// TODO: Add a test case to verify that we can find the intersection
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user