diff --git a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml
index ccca279b69..6271408417 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml
+++ b/core/modules/system/tests/modules/ajax_forms_test/ajax_forms_test.routing.yml
@@ -30,3 +30,11 @@ ajax_forms_test.lazy_load_form:
requirements:
_access: 'TRUE'
+ajax_forms_test.image_button_form:
+ path: '/ajax_forms_image_button_form'
+ defaults:
+ _title: 'AJAX forms image button test'
+ _form: '\Drupal\ajax_forms_test\Form\AjaxFormsTestImageButtonForm'
+ requirements:
+ _access: 'TRUE'
+
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php
index 0ad80c9250..06c4b0bb0d 100644
--- a/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Callbacks.php
@@ -33,6 +33,15 @@ public function checkboxCallback($form, FormStateInterface $form_state) {
}
/**
+ * Ajax callback to confirm image button was submitted.
+ */
+ public function imageButtonCallback($form, FormStateInterface $form_state) {
+ $response = new AjaxResponse();
+ $response->addCommand(new HtmlCommand('#ajax_image_button_result', "
Something witty!
"));
+ return $response;
+ }
+
+ /**
* Ajax callback triggered by the checkbox in a #group.
*/
public function checkboxGroupCallback($form, FormStateInterface $form_state) {
diff --git a/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestImageButtonForm.php b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestImageButtonForm.php
new file mode 100644
index 0000000000..20754ffd99
--- /dev/null
+++ b/core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestImageButtonForm.php
@@ -0,0 +1,48 @@
+ 'image_button',
+ '#name' => 'image_button',
+ '#src' => 'core/misc/icons/787878/cog.svg',
+ '#attributes' => ['alt' => $this->t('Edit')],
+ '#op' => 'edit',
+ '#ajax' => [
+ 'callback' => [$object, 'imageButtonCallback'],
+ ],
+ '#suffix' => 'Image button not pressed yet.
',
+ ];
+
+ return $form;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state) {
+ // No submit code needed.
+ }
+
+}
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php
new file mode 100644
index 0000000000..943eb06a4a
--- /dev/null
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxFormImageButtonTest.php
@@ -0,0 +1,43 @@
+drupalGet('ajax_forms_image_button_form');
+ $assertSession = $this->assertSession();
+ $session = $this->getSession();
+
+ $enter_key_event = <<executeScript($enter_key_event);
+
+ // We expect a checkbox for the string formatter's link-to-entity setting.
+ $this->assertNotEmpty($assertSession->waitForElementVisible('css', '#ajax-1-more-div'), 'Page updated after image button pressed');
+ }
+
+}