diff --git a/src/core/annotation.js b/src/core/annotation.js index bfa9caabe..3b57c146c 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -1852,6 +1852,10 @@ class WidgetAnnotation extends Annotation { return { opList, separateForm: false, separateCanvas: false }; } + const isUsingOwnCanvas = !!( + this.data.hasOwnCanvas && intent & RenderingIntentFlag.DISPLAY + ); + const matrix = [1, 0, 0, 1, 0, 0]; const bbox = [ 0, @@ -1877,7 +1881,7 @@ class WidgetAnnotation extends Annotation { this.data.rect, transform, this.getRotationMatrix(annotationStorage), - /* isUsingOwnCanvas = */ false, + isUsingOwnCanvas, ]); const stream = new StringStream(content); @@ -1892,7 +1896,7 @@ class WidgetAnnotation extends Annotation { if (optionalContent !== undefined) { opList.addOp(OPS.endMarkedContent, []); } - return { opList, separateForm: false, separateCanvas: false }; + return { opList, separateForm: false, separateCanvas: isUsingOwnCanvas }; } _getMKDict(rotation) { diff --git a/test/integration/scripting_spec.js b/test/integration/scripting_spec.js index 5efbdb9d4..f92ebe917 100644 --- a/test/integration/scripting_spec.js +++ b/test/integration/scripting_spec.js @@ -1963,4 +1963,65 @@ describe("Interaction", () => { ); }); }); + + describe("in bug1844576.pdf", () => { + let pages; + + beforeAll(async () => { + pages = await loadAndWait("bug1844576.pdf", getSelector("9R")); + }); + + afterAll(async () => { + await closePages(pages); + }); + + it("must check that a field has the correct formatted value", async () => { + await Promise.all( + pages.map(async ([browserName, page]) => { + const hasVisibleCanvas = await page.evaluate(_ => { + const elem = document.querySelector( + `[data-annotation-id="9R"] > canvas` + ); + return elem && !elem.hasAttribute("hidden"); + }); + expect(hasVisibleCanvas) + .withContext(`In ${browserName}`) + .toEqual(true); + + const hasHiddenInput = await page.evaluate(_ => { + const elem = document.querySelector( + `[data-annotation-id="9R"] > input` + ); + return elem?.hasAttribute("hidden"); + }); + + expect(hasHiddenInput).withContext(`In ${browserName}`).toEqual(true); + + await page.click(getSelector("12R")); + await page.waitForTimeout(10); + + const hasHiddenCanvas = await page.evaluate(_ => { + const elem = document.querySelector( + `[data-annotation-id="9R"] > canvas` + ); + return elem?.hasAttribute("hidden"); + }); + expect(hasHiddenCanvas) + .withContext(`In ${browserName}`) + .toEqual(true); + + const hasVisibleInput = await page.evaluate(_ => { + const elem = document.querySelector( + `[data-annotation-id="9R"] > input` + ); + return elem && !elem.hasAttribute("hidden"); + }); + + expect(hasVisibleInput) + .withContext(`In ${browserName}`) + .toEqual(true); + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index a57c8ef4b..6f736fb1d 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -604,3 +604,4 @@ !empty.pdf !rotated_freetexts.pdf !issue16633.pdf +!bug1844576.pdf diff --git a/test/pdfs/bug1844576.pdf b/test/pdfs/bug1844576.pdf new file mode 100755 index 000000000..e65ff138e Binary files /dev/null and b/test/pdfs/bug1844576.pdf differ