diff --git a/core/lib/Drupal/Core/ContentNegotiation.php b/core/lib/Drupal/Core/ContentNegotiation.php
index 8aa7e48..10237ab 100644
--- a/core/lib/Drupal/Core/ContentNegotiation.php
+++ b/core/lib/Drupal/Core/ContentNegotiation.php
@@ -37,10 +37,6 @@ public function getContentType(Request $request) {
       return $request->query->get('_format');
     }
 
-    if ($request->isXmlHttpRequest()) {
-      return 'ajax';
-    }
-
     // Do HTML last so that it always wins.
     return 'html';
   }
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 2ac0d4b..663d845 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -1555,7 +1555,15 @@ protected function drupalGetAjax($path, array $options = array(), array $headers
     if (!isset($options['query'][MainContentViewSubscriber::WRAPPER_FORMAT])) {
       $options['query'][MainContentViewSubscriber::WRAPPER_FORMAT] = 'drupal_ajax';
     }
-    return Json::decode($this->drupalGet($path, $options, $headers));
+    return Json::decode($this->drupalGetXHR($path, $options, $headers));
+  }
+
+  /**
+   * Requests a Drupal path in as if it is a XMLHttpRequest.
+   */
+  protected function drupalGetXHR($path, array $options = array(), array $headers = array()) {
+    $headers[] = 'X-Requested-With: XMLHttpRequest';
+    return $this->drupalGet($path, $options, $headers);
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php
index 83a102b..333cc6a 100644
--- a/core/modules/system/src/Tests/Ajax/DialogTest.php
+++ b/core/modules/system/src/Tests/Ajax/DialogTest.php
@@ -94,6 +94,10 @@ public function testDialog() {
     $this->drupalGet('ajax-test/dialog-contents');
     $this->assertRaw($dialog_contents, 'Non-JS modal dialog page present.');
 
+    // Check that requesting a modal dialog with XMLHttpRequest goes to a page.
+    $this->drupalGetXHR('ajax-test/dialog-contents');
+    $this->assertRaw($dialog_contents, 'Modal dialog page on XMLHttpRequest present.');
+
     // Emulate going to the JS version of the page and check the JSON response.
     $ajax_result = $this->drupalGetAjax('ajax-test/dialog-contents', array('query' => array(MainContentViewSubscriber::WRAPPER_FORMAT => 'drupal_modal')));
     $this->assertEqual($modal_expected_response, $ajax_result[3], 'Modal dialog JSON response matches.');
diff --git a/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php b/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php
index 9c54eae..b5f9d3f 100644
--- a/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php
+++ b/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php
@@ -73,7 +73,7 @@ public function testUnknowContentTypeButAjaxRequest() {
     $request = new Request();
     $request->headers->set('X-Requested-With', 'XMLHttpRequest');
 
-    $this->assertSame('ajax', $this->contentNegotiation->getContentType($request));
+    $this->assertSame('html', $this->contentNegotiation->getContentType($request));
   }
 
 }
