diff --git a/core/modules/system/tests/modules/submit_form_test/src/Controller/LinksController.php b/core/modules/system/tests/modules/submit_form_test/src/Controller/LinksController.php
new file mode 100644
index 0000000..e4f085f
--- /dev/null
+++ b/core/modules/system/tests/modules/submit_form_test/src/Controller/LinksController.php
@@ -0,0 +1,36 @@
+<?php
+
+
+namespace Drupal\submit_form_test\Controller;
+
+
+use Drupal\Core\Url;
+
+class LinksController {
+
+  /**
+   * Displays test links that will open in ajax modal dialog tray.
+   *
+   * @return array
+   *   Render array with links.
+   */
+  public function linksDisplay() {
+    return [
+      'offcanvas_link_1' => [
+        '#title' => 'Click Me 1!',
+        '#type' => 'link',
+        '#url' => Url::fromRoute('submitter_form'),
+        '#attributes' => array(
+          'class' => array('use-ajax'),
+          'data-dialog-type' => 'modal',
+        ),
+        '#attached' => [
+          'library' => [
+            'core/drupal.ajax',
+          ],
+        ],
+      ],
+    ];
+  }
+
+}
diff --git a/core/modules/system/tests/modules/submit_form_test/src/Form/SubmitterForm.php b/core/modules/system/tests/modules/submit_form_test/src/Form/SubmitterForm.php
new file mode 100644
index 0000000..8a3b503
--- /dev/null
+++ b/core/modules/system/tests/modules/submit_form_test/src/Form/SubmitterForm.php
@@ -0,0 +1,32 @@
+<?php
+
+
+namespace Drupal\submit_form_test\Form;
+
+
+use Drupal\Core\Form\FormBase;
+use Drupal\Core\Form\FormStateInterface;
+
+class SubmitterForm extends FormBase {
+
+  public function getFormId() {
+    return 'submitter_form';
+  }
+
+  public function buildForm(array $form, FormStateInterface $form_state) {
+    $form['msg'] = [
+      '#type' => 'textfield',
+      '#title' => $this->t('Message'),
+    ];
+    $form['submit'] = [
+      '#type' => 'submit',
+      '#value' => $this->t('Submit'),
+    ];
+    return $form;
+  }
+
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    drupal_set_message($this->t('This is ') . $form_state->getValue('msg'));
+  }
+
+}
diff --git a/core/modules/system/tests/modules/submit_form_test/submit_form_test.info.yml b/core/modules/system/tests/modules/submit_form_test/submit_form_test.info.yml
new file mode 100644
index 0000000..74171a4
--- /dev/null
+++ b/core/modules/system/tests/modules/submit_form_test/submit_form_test.info.yml
@@ -0,0 +1,6 @@
+name: 'Submit form test'
+type: module
+description: 'Support module for submiting form testing.'
+package: Testing
+version: VERSION
+core: 8.x
diff --git a/core/modules/system/tests/modules/submit_form_test/submit_form_test.routing.yml b/core/modules/system/tests/modules/submit_form_test/submit_form_test.routing.yml
new file mode 100644
index 0000000..22065e3
--- /dev/null
+++ b/core/modules/system/tests/modules/submit_form_test/submit_form_test.routing.yml
@@ -0,0 +1,14 @@
+submitter_form:
+  path: '/submitter-form-test'
+  defaults:
+    _title: 'Session value'
+    _form: '\Drupal\submit_form_test\Form\SubmitterForm'
+  requirements:
+    _access: 'TRUE'
+submit_form_test.links:
+  path: '/submitter-form-test-link'
+  defaults:
+    _controller: '\Drupal\submit_form_test\Controller\LinksController::linksDisplay'
+    _title: 'Links'
+  requirements:
+    _access: 'TRUE'
diff --git a/core/modules/system/tests/src/FunctionalJavascript/DialogSubmitFormTest.php b/core/modules/system/tests/src/FunctionalJavascript/DialogSubmitFormTest.php
new file mode 100644
index 0000000..f599f11
--- /dev/null
+++ b/core/modules/system/tests/src/FunctionalJavascript/DialogSubmitFormTest.php
@@ -0,0 +1,57 @@
+<?php
+
+namespace Drupal\Tests\system\FunctionalJavascript;
+
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+
+/**
+ * Tests submitting a form in a Javascript test using a modal.
+ *
+ * @group system
+ */
+class DialogSubmitFormTest extends JavascriptTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['submit_form_test'];
+
+  /**
+   * Tests submitting a form in a modal.
+   */
+  public function testFormSubmit() {
+    $web_assert = $this->assertSession();
+    \Drupal::service('theme_installer')->install(['stable', 'seven']);
+    $theme_config = \Drupal::configFactory()->getEditable('system.theme');
+    $theme_config->set('default', 'stable');
+    $theme_config->save();
+
+    $this->drupalGet('submitter-form-test');
+    $page = $this->getSession()->getPage();
+    $web_assert->pageTextContains('Message');
+
+    // Confirm the form submits when not in a modal.
+    $page->fillField('msg', 'the end of the sentence.');
+    $page->pressButton('Submit');
+    $web_assert->pageTextContains('This is the end of the sentence.');
+
+    // Load the form in modal and then submit it.
+    $this->drupalGet('submitter-form-test-link');
+    $page->clickLink('Click Me 1!');
+    $web_assert->assertWaitOnAjaxRequest();
+    $web_assert->elementExists('css', '.ui-dialog');
+    $dialog = $page->find('css', '.ui-dialog');
+    $dialog->fillField('msg', 'the end of the other sentence.');
+
+    $dialog->pressButton('Submit');
+
+    $web_assert->pageTextContains('This is the end of the other sentence.');
+    /**
+     * Various other ways that also don't work for submitting the form
+     * $page->pressButton('Submit');
+     * $dialog->find('css', '.js-form-submit')->press();
+     * $dialog->find('css', '.js-form-submit')->click();
+     * $this->submitForm(['msg' => 'the end of the other sentence.'], 'Submit');
+     */
+  }
+}
