diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module
index 802b34e..e74c83d 100644
--- a/core/modules/system/tests/modules/ajax_test/ajax_test.module
+++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module
@@ -20,6 +20,22 @@ function ajax_test_menu() {
     'title' => 'AJAX commands order',
     'route_name' => 'ajax_test.order',
     'theme callback' => 'ajax_base_page_theme',
+<<<<<<< HEAD
+=======
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+  $items['ajax-test/render-error'] = array(
+    'title' => 'ajax_render_error',
+    'page callback' => 'ajax_test_error',
+    'access callback' => TRUE,
+    'type' => MENU_CALLBACK,
+  );
+  $items['ajax-test/dialog-close'] = array(
+    'title' => 'AJAX Dialog close',
+    'page callback' => 'ajax_test_dialog_close',
+    'access callback' => TRUE,
+>>>>>>> patch
     'type' => MENU_CALLBACK,
   );
   return $items;
@@ -87,6 +103,7 @@ function ajax_test_error() {
 }
 
 /**
+<<<<<<< HEAD
  * Menu callback: Renders a form elements and links with #ajax['dialog'].
  *
  * @deprecated \Drupal\ajax_test\Controller\AjaxTestController::dialog()
@@ -181,6 +198,8 @@ function ajax_test_dialog() {
 }
 
 /**
+=======
+>>>>>>> patch
  * Form builder: Renders buttons with #ajax['dialog'].
  */
 function ajax_test_dialog_form($form, &$form_state) {
diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml b/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
index 9453bef..e847a4c 100644
--- a/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
+++ b/core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
@@ -46,3 +46,11 @@ ajax_test.render_error:
     _controller: '\Drupal\ajax_test\Controller\AjaxTestController::renderError'
   requirements:
     _access: 'TRUE'
+
+ajax_test_dialog:
+  pattern: 'ajax-test/dialog'
+  defaults:
+    _title: 'AJAX Dialog'
+    _content: '\Drupal\ajax_test\AjaxTestController::dialog'
+  requirements:
+    _access: 'TRUE'
diff --git a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
index d0387ef..e472afc 100644
--- a/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
+++ b/core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
@@ -46,7 +46,92 @@ public function renderError() {
    * @todo Remove ajax_test_dialog().
    */
   public function dialog() {
-    return ajax_test_dialog();
+    // Add two wrapper elements for testing non-modal dialogs. Modal dialogs use
+    // the global drupal-modal wrapper by default.
+    $build['dialog_wrappers'] = array('#markup' => '<div id="ajax-test-dialog-wrapper-1"></div><div id="ajax-test-dialog-wrapper-2"></div>');
+
+    // Dialog behavior applied to a button.
+    $build['form'] = drupal_get_form('ajax_test_dialog_form');
+
+    // Dialog behavior applied to a #type => 'link'.
+    $build['link'] = array(
+      '#type' => 'link',
+      '#title' => 'Link 1 (modal)',
+      '#href' => 'ajax-test/dialog-contents',
+      '#attributes' => array(
+        'class' => array('use-ajax'),
+        'data-accepts' => 'application/vnd.drupal-modal',
+      ),
+    );
+
+    // Dialog behavior applied to links rendered by theme_links().
+    $build['links'] = array(
+      '#theme' => 'links',
+      '#links' => array(
+        'link2' => array(
+          'title' => 'Link 2 (modal)',
+          'href' => 'ajax-test/dialog-contents',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-modal',
+            'data-dialog-options' => json_encode(array(
+              'width' => 400,
+            ))
+          ),
+        ),
+        'link3' => array(
+          'title' => 'Link 3 (non-modal)',
+          'href' => 'ajax-test/dialog-contents',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-dialog',
+            'data-dialog-options' => json_encode(array(
+              'target' => 'ajax-test-dialog-wrapper-1',
+              'width' => 800,
+            ))
+          ),
+        ),
+        'link4' => array(
+          'title' => 'Link 4 (close non-modal if open)',
+          'href' => 'ajax-test/dialog-close',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+          ),
+        ),
+        'link5' => array(
+          'title' => 'Link 5 (form)',
+          'href' => 'ajax-test/dialog-form',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-modal',
+          ),
+        ),
+        'link6' => array(
+          'title' => 'Link 6 (entity form)',
+          'href' => 'admin/structure/contact/add',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-modal',
+            'data-dialog-options' => json_encode(array(
+              'width' => 800,
+              'height' => 500,
+            ))
+          ),
+        ),
+        'link7' => array(
+          'title' => 'Link 7 (non-modal, no target)',
+          'href' => 'ajax-test/dialog-contents',
+          'attributes' => array(
+            'class' => array('use-ajax'),
+            'data-accepts' => 'application/vnd.drupal-dialog',
+            'data-dialog-options' => json_encode(array(
+              'width' => 800,
+            ))
+          ),
+        ),
+      ),
+    );
+    return $build;
   }
 
   /**
