diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index 220974bf1000c..70d25a974402c 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -1637,6 +1637,21 @@ class RadioButtonWidgetAnnotationElement extends WidgetAnnotationElement { storage.setValue(id, { value }); } + if (value) { + // It's possible that multiple radio buttons are checked. + // So if this one is checked we just reset the other ones. + // (see bug 1864136). Then when the other ones will be rendered they will + // unchecked (because of their value in the storage). + // Consequently, the first checked radio button will be the only checked + // one. + for (const radio of this._getElementsByName( + data.fieldName, + /* skipId = */ id + )) { + storage.setValue(radio.id, { value: false }); + } + } + const element = document.createElement("input"); GetElementsByNameSet.add(element); element.setAttribute("data-element-id", id); diff --git a/test/driver.js b/test/driver.js index 45a48560d6529..6a0fa4513f2f7 100644 --- a/test/driver.js +++ b/test/driver.js @@ -219,6 +219,8 @@ class Rasterize { outputScale, annotations, annotationCanvasMap, + annotationStorage, + fieldObjects, page, imageResourcesPath, renderForms = false @@ -244,6 +246,8 @@ class Rasterize { linkService: new SimpleLinkService(), imageResourcesPath, renderForms, + annotationStorage, + fieldObjects, }; // Ensure that the annotationLayer gets translated. @@ -682,6 +686,10 @@ class Driver { } } + if (task.forms) { + task.fieldObjects = await doc.getFieldObjects(); + } + this._nextPage(task, failure); }, err => { @@ -928,9 +936,7 @@ class Driver { transform, }; if (renderForms) { - renderContext.annotationMode = task.annotationStorage - ? AnnotationMode.ENABLE_STORAGE - : AnnotationMode.ENABLE_FORMS; + renderContext.annotationMode = AnnotationMode.ENABLE_FORMS; } else if (renderPrint) { if (task.annotationStorage) { renderContext.annotationMode = AnnotationMode.ENABLE_STORAGE; @@ -984,6 +990,8 @@ class Driver { outputScale, data, annotationCanvasMap, + task.pdfDoc.annotationStorage, + task.fieldObjects, page, IMAGE_RESOURCES_PATH, renderForms diff --git a/test/integration/scripting_spec.mjs b/test/integration/scripting_spec.mjs index 1154c0869c9aa..eea36a7f0f293 100644 --- a/test/integration/scripting_spec.mjs +++ b/test/integration/scripting_spec.mjs @@ -2261,9 +2261,15 @@ describe("Interaction", () => { expect(storage) .withContext(`In ${browserName}`) .toEqual({ - "22R": { value: false }, "25R": { value: true }, "28R": { value: false }, + "35R": { value: false }, + "38R": { value: false }, + "41R": { value: false }, + "44R": { value: false }, + "47R": { value: false }, + "50R": { value: false }, + "22R": { value: false }, }); await page.click(getSelector("22R")); @@ -2273,9 +2279,15 @@ describe("Interaction", () => { expect(storage) .withContext(`In ${browserName}`) .toEqual({ - "22R": { value: true }, "25R": { value: false }, "28R": { value: false }, + "35R": { value: false }, + "38R": { value: false }, + "41R": { value: false }, + "44R": { value: false }, + "47R": { value: false }, + "50R": { value: false }, + "22R": { value: true }, }); }) ); diff --git a/test/pdfs/bug1864136.pdf.link b/test/pdfs/bug1864136.pdf.link new file mode 100644 index 0000000000000..0cf28d442f717 --- /dev/null +++ b/test/pdfs/bug1864136.pdf.link @@ -0,0 +1,2 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=9363183 + diff --git a/test/test_manifest.json b/test/test_manifest.json index d3799e7b4a0d8..372298a514d57 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -8361,5 +8361,16 @@ "rotation": 0 } } + }, + { + "id": "bug1864136-forms", + "file": "pdfs/bug1864136.pdf", + "md5": "97357ad5b0fde2c4e79c07819e4d9710", + "rounds": 1, + "link": true, + "firstPage": 2, + "lastPage": 2, + "type": "eq", + "forms": true } ]