diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 76988fa..431e84e 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -1043,6 +1043,18 @@ protected function curlExec($curl_options, $redirect = FALSE) {
       // not overwritten by Curl.
       $curl_options[CURLOPT_HTTPHEADER][] = 'Expect:';
     }
+
+    // Forward xdebug session.
+    if (isset($_COOKIE['XDEBUG_SESSION'])) {
+      if (!isset($curl_options[CURLOPT_COOKIE])) {
+        $curl_options[CURLOPT_COOKIE] = '';
+      }
+      if (!empty($curl_options[CURLOPT_COOKIE]) && substr(trim($curl_options[CURLOPT_COOKIE]), -1, 1) != ';') {
+        $curl_options[CURLOPT_COOKIE] .= '; ';
+      }
+      $curl_options[CURLOPT_COOKIE] .= 'XDEBUG_SESSION=' . $_COOKIE['XDEBUG_SESSION'] . '; ';
+    }
+
     curl_setopt_array($this->curlHandle, $this->additionalCurlOptions + $curl_options);
 
     if (!$redirect) {
