Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.256
diff -u -p -r1.256 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	22 Dec 2010 21:34:13 -0000	1.256
+++ modules/simpletest/drupal_web_test_case.php	2 Jan 2011 11:01:09 -0000
@@ -1665,13 +1665,19 @@ class DrupalWebTestCase extends DrupalTe
     $out = $this->curlExec(array(CURLOPT_HTTPGET => TRUE, CURLOPT_URL => url($path, $options), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => $headers));
     $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
 
-    // Replace original page output with new output from redirected page(s).
-    if ($new = $this->checkForMetaRefresh()) {
-      $out = $new;
-    }
     $this->verbose('GET request to: ' . $path .
                    '<hr />Ending URL: ' . $this->getUrl() .
                    '<hr />' . $out);
+
+    // 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($newURL, array()), CURLOPT_NOBODY => FALSE, CURLOPT_HTTPHEADER => array()));
+      $this->refreshVariables(); // Ensure that any changes to variables in the other thread are picked up.
+
+      $this->verbose('GET request to: ' . $path .
+                     '<hr />Ending URL: ' . $this->getUrl() .
+                     '<hr />' . $out);
+    }
     return $out;
   }
 
@@ -1992,17 +1998,31 @@ class DrupalWebTestCase extends DrupalTe
    * 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->drupalGetContent(), '<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=(?P<url>.*)/i', $refresh[0]['content'], $match)) {
-          return $this->drupalGet($this->getAbsoluteUrl(decode_entities($match['url'])));
+          $newURL = $this->getAbsoluteUrl(decode_entities($match['url']));
+          if ($return_url) {
+            return $newURL;
+          }
+          else {
+            return $this->drupalGet($newURL);
+          }
         }
       }
     }
