diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 44af34c..240f9f2 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -27,6 +27,7 @@
 use Drupal\Core\StreamWrapper\PublicStream;
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\block\Entity\Block;
+use Drupal\Core\Url;
 use Symfony\Component\HttpFoundation\Request;
 use Drupal\user\Entity\Role;
 
@@ -1471,11 +1472,6 @@ protected function drupalGet($path, array $options = array(), array $headers = a
     // Ensure that any changes to variables in the other thread are picked up.
     $this->refreshVariables();
 
-    // Replace original page output with new output from redirected page(s).
-    if ($new = $this->checkForMetaRefresh()) {
-      $out = $new;
-    }
-
     $verbose = 'GET request to: ' . $path .
                '<hr />Ending URL: ' . $this->getUrl();
     if ($this->dumpHeaders) {
@@ -1484,6 +1480,21 @@ protected function drupalGet($path, array $options = array(), array $headers = a
     $verbose .= '<hr />' . $out;
 
     $this->verbose($verbose);
+
+    // Replace original page output with new output from redirected page(s).
+    while ($newURL = $this->checkForMetaRefresh(TRUE)) {
+      $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => Url::fromUri($newURL, array()), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array()));
+      $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
+
+      $verbose = 'GET request to: ' . $path . '<hr />Ending URL: ' . $this->getUrl();
+      if ($this->dumpHeaders) {
+        $verbose .= '<hr />Headers: <pre>' . check_plain(var_export(array_map('trim', $this->headers), TRUE)) . '</pre>';
+      }
+	  $verbose .= '<hr />' . $out;
+
+      $this->verbose($verbose);
+    }
+
     return $out;
   }
 
@@ -2039,17 +2050,31 @@ protected function cronRun() {
    * This function looks for the http-equiv attribute to be set to "Refresh" and
    * is case-sensitive.
    *
+   * @param $return_url
+   * Boolean to indicate that the URL instead of the page content should be
+   * returned.
+   *
    * @return
-   *   Either the new page content or FALSE.
+   *   FALSE when there is no meta refresh tag. Otherwise the URL or the content
+   *   of the new page is returned, depending on $return_url. When
+   *   $return_url is set to TRUE, the URL of the meta refresh tag is returned.
+   *   If set to FALSE, this returns the result of drupalGet() on the URL of the
+   *   meta refresh tag.
    */
-  protected function checkForMetaRefresh() {
+  protected function checkForMetaRefresh($return_url = FALSE) {
     if (strpos($this->getRawContent(), '<meta ') && $this->parse()) {
       $refresh = $this->xpath('//meta[@http-equiv="Refresh"]');
       if (!empty($refresh)) {
         // Parse the content attribute of the meta tag for the format:
         // "[delay]: URL=[page_to_redirect_to]".
         if (preg_match('/\d+;\s*URL=(?<url>.*)/i', $refresh[0]['content'], $match)) {
-          return $this->drupalGet($this->getAbsoluteUrl(String::decodeEntities($match['url'])));
+          $newURL = $this->getAbsoluteUrl(String::decodeEntities($match['url']));
+          if ($return_url) {
+            return $newURL;
+		  }
+		  else {
+            return $this->drupalGet($newURL);
+		  }
         }
       }
     }
