Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.400
diff -u -p -r1.400 form.inc
--- includes/form.inc	16 Nov 2009 05:11:01 -0000	1.400
+++ includes/form.inc	17 Nov 2009 18:17:55 -0000
@@ -224,7 +224,7 @@ function drupal_build_form($form_id, &$f
   // complete. We need to construct a fresh copy of the form, passing
   // in the latest $form_state in addition to any other variables passed
   // into drupal_get_form().
-  if ((!empty($form_state['storage']) || $form_state['rebuild']) && $form_state['submitted'] && !form_get_errors()) {
+  if ((!empty($form_state['storage']) || $form_state['rebuild']) && !form_get_errors()) {
     $form = drupal_rebuild_form($form_id, $form_state);
   }
 
Index: modules/simpletest/tests/form.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form.test,v
retrieving revision 1.24
diff -u -p -r1.24 form.test
--- modules/simpletest/tests/form.test	15 Nov 2009 21:36:06 -0000	1.24
+++ modules/simpletest/tests/form.test	17 Nov 2009 18:19:13 -0000
@@ -419,15 +419,24 @@ class FormsFormStorageTestCase extends D
    * Tests using the form in a usual way.
    */
   function testForm() {
-
     $user = $this->drupalCreateUser(array('access content'));
     $this->drupalLogin($user);
 
-    $this->drupalPost('form_test/form-storage', array('title' => 'new', 'value' => 'value_is_set'), 'Continue');
-    $this->assertText('Form constructions: 2', t('The form has been constructed two times till now.'));
+    $this->drupalGet('form_test/form-storage');
+    $this->assertText('Form constructions: 1');
+
+    $edit = array(
+      'title' => 'new',
+      'value' => 'value_is_set',
+    );
+    $this->drupalPost(NULL, $edit, 'Continue button');
+    $this->assertText('Form constructions: 2');
+
+    $this->drupalPost(NULL, $edit, 'Continue submit');
+    $this->assertText('Form constructions: 3');
 
     $this->drupalPost(NULL, array(), 'Save');
-    $this->assertText('Form constructions: 3', t('The form has been constructed three times till now.'));
+    $this->assertText('Form constructions: 4');
     $this->assertText('Title: new', t('The form storage has stored the values.'));
   }
 
@@ -438,11 +447,21 @@ class FormsFormStorageTestCase extends D
     $user = $this->drupalCreateUser(array('access content'));
     $this->drupalLogin($user);
 
-    $this->drupalPost('form_test/form-storage', array('title' => 'new', 'value' => 'value_is_set'), 'Continue', array('query' => array('cache' => 1)));
-    $this->assertText('Form constructions: 1', t('The form has been constructed one time till now.'));
+    $this->drupalGet('form_test/form-storage');
+    $this->assertText('Form constructions: 1');
+
+    $edit = array(
+      'title' => 'new',
+      'value' => 'value_is_set',
+    );
+    $this->drupalPost(NULL, $edit, 'Continue button', array('query' => array('cache' => 1)));
+    $this->assertText('Form constructions: 2');
+
+    $this->drupalPost(NULL, $edit, 'Continue submit', array('query' => array('cache' => 1)));
+    $this->assertText('Form constructions: 3');
 
     $this->drupalPost(NULL, array(), 'Save', array('query' => array('cache' => 1)));
-    $this->assertText('Form constructions: 2', t('The form has been constructed two times till now.'));
+    $this->assertText('Form constructions: 4');
     $this->assertText('Title: new', t('The form storage has stored the values.'));
   }
 
@@ -453,8 +472,8 @@ class FormsFormStorageTestCase extends D
     $user = $this->drupalCreateUser(array('access content'));
     $this->drupalLogin($user);
 
-    $this->drupalPost('form_test/form-storage', array('title' => '', 'value' => 'value_is_set'), 'Continue');
-    $this->assertPattern('/value_is_set/', t("The input values have been kept."));
+    $this->drupalPost('form_test/form-storage', array('title' => '', 'value' => 'value_is_set'), 'Continue submit');
+    $this->assertPattern('/value_is_set/', t('The input values have been kept.'));
   }
 }
 
Index: modules/simpletest/tests/form_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/form_test.module,v
retrieving revision 1.14
diff -u -p -r1.14 form_test.module
--- modules/simpletest/tests/form_test.module	15 Nov 2009 21:36:06 -0000	1.14
+++ modules/simpletest/tests/form_test.module	17 Nov 2009 18:17:55 -0000
@@ -297,8 +297,10 @@ function form_storage_test_form($form, &
     );
     $form_state['storage'] += array('step' => 1);
   }
+  // Output how often this form has been constructed.
+  drupal_set_message('Form constructions: ' . $_SESSION['constructions']);
 
-  // Count how often the form is constructed
+  // Count how often the form is constructed.
   $_SESSION['constructions']++;
 
   if ($form_state['storage']['step'] == 1) {
@@ -313,9 +315,15 @@ function form_storage_test_form($form, &
       '#title' => 'value',
       '#default_value' => $form_state['storage']['thing']['value'],
     );
+    $form['button'] = array(
+      '#type' => 'button',
+      '#value' => 'Continue button',
+      '#submit' => array('form_storage_test_form_continue_submit'),
+    );
     $form['submit'] = array(
       '#type' => 'submit',
-      '#value' => 'Continue',
+      '#value' => 'Continue submit',
+      '#submit' => array('form_storage_test_form_continue_submit'),
     );
   }
   else {
@@ -336,18 +344,20 @@ function form_storage_test_form($form, &
 }
 
 /**
- * Multistep form submit callback.
+ * Form submit handler to continue multi-step form.
  */
-function form_storage_test_form_submit($form, &$form_state) {
-  if ($form_state['storage']['step'] == 1) {
-    $form_state['storage']['thing']['title'] = $form_state['values']['title'];
-    $form_state['storage']['thing']['value'] = $form_state['values']['value'];
-  }
-  else {
-    drupal_set_message("Title: ". check_plain($form_state['storage']['thing']['title']));
-  }
+function form_storage_test_form_continue_submit($form, &$form_state) {
+  $form_state['storage']['thing']['title'] = $form_state['values']['title'];
+  $form_state['storage']['thing']['value'] = $form_state['values']['value'];
+
   $form_state['storage']['step']++;
-  drupal_set_message("Form constructions: ". $_SESSION['constructions']);
+}
+
+/**
+ * Form submit handler to finish multi-step form.
+ */
+function form_storage_test_form_submit($form, &$form_state) {
+  drupal_set_message('Title: ' . check_plain($form_state['storage']['thing']['title']));
 }
 
 /**
