diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index ef4f49151bae4d98eb29ad74d2fafa77de1e1a99..323781b31520f7aecc73161c716f1b697f009be1 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -1581,6 +1581,7 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
         switch ($type) {
           case 'text':
           case 'textarea':
+          case 'hidden':
           case 'password':
             $post[$name] = $edit[$name];
             unset($edit[$name]);
diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc
index 7a12fbdc41a60581016ae05404a666b0937d4f31..e605c8e81347b782df2d758eb5121dcf10a4d3f3 100644
--- a/modules/taxonomy/taxonomy.admin.inc
+++ b/modules/taxonomy/taxonomy.admin.inc
@@ -240,7 +240,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) {
 
   // Check for confirmation forms.
   if (isset($form_state['confirm_reset_alphabetical'])) {
-    return taxonomy_vocabulary_confirm_reset_alphabetical($form_state, $vocabulary->vid);
+    return taxonomy_vocabulary_confirm_reset_alphabetical($form, $form_state, $vocabulary->vid);
   }
 
   $form['#vocabulary'] = $vocabulary;
diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test
index 6b64bf8ccad956ad25269f4468627f93ea267802..27508f572c9f1df2843c7622daec9f253b94bd69 100644
--- a/modules/taxonomy/taxonomy.test
+++ b/modules/taxonomy/taxonomy.test
@@ -478,6 +478,69 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
     $this->assertResponse(404, t('The taxonomy term page was not found'));
   }
 
+  /**
+   * Save, edit and delete a term using the user interface.
+   */
+  function testTermReorder() {
+    $this->createTerm($this->vocabulary);
+    $this->createTerm($this->vocabulary);
+    $this->createTerm($this->vocabulary);
+
+    // Fetch the created terms in the default alphabetical order, i.e. term1
+    // precedes term2 alphabetically, and term2 precedes term3.
+    drupal_static_reset('taxonomy_get_tree');
+    drupal_static_reset('taxonomy_get_treeparent');
+    drupal_static_reset('taxonomy_get_treeterms');
+    list($term1, $term2, $term3) = taxonomy_get_tree($this->vocabulary->vid);
+
+    // Change the order to term2, term3, term1. Emulate the reordering done by
+    // tabledrag.js by changing the page HTML source. Each term has three hidden
+    // fields, "tid:1:0[tid]", "tid:1:0[parent]", and "tid:1:0[depth]". The
+    // order of the input fields in the page is used when the form is processed.
+    $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->vid . '/list');
+    $reorder = array(
+      'tid:' . $term1->tid . ':0' => 'tid:' . $term2->tid . ':0',
+      'tid:' . $term2->tid . ':0' => 'tid:' . $term3->tid . ':0',
+      'tid:' . $term3->tid . ':0' => 'tid:' . $term1->tid . ':0',
+      );
+    $this->drupalSetContent(strtr($this->drupalGetContent(), $reorder));
+
+    // Make term3 a child of term2, and update all hidden fields.
+    $edit = array(
+      'tid:' . $term2->tid . ':0[tid]' => $term2->tid,
+      'tid:' . $term2->tid . ':0[parent]' => 0,
+      'tid:' . $term2->tid . ':0[depth]' => 0,
+      'tid:' . $term3->tid . ':0[tid]' => $term3->tid,
+      'tid:' . $term3->tid . ':0[parent]' => $term2->tid,
+      'tid:' . $term3->tid . ':0[depth]' => 1,
+      'tid:' . $term1->tid . ':0[tid]' => $term1->tid,
+      'tid:' . $term1->tid . ':0[parent]' => 0,
+      'tid:' . $term1->tid . ':0[depth]' => 0,
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+
+    drupal_static_reset('taxonomy_get_tree');
+    drupal_static_reset('taxonomy_get_treeparent');
+    drupal_static_reset('taxonomy_get_treeterms');
+    $terms = taxonomy_get_tree($this->vocabulary->vid);
+    $this->assertEqual($terms[0]->tid, $term2->tid, t('Term 2 was moved above term 1.'));
+    $this->assertEqual($terms[1]->parents, array($term2->tid), t('Term 3 was made a child of term 2.'));
+    $this->assertEqual($terms[2]->tid, $term1->tid, t('Term 1 was moved below term 2.'));
+
+    $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->vid . '/list', array(), t('Reset to alphabetical'));
+    // Submit confirmation form.
+    $this->drupalPost(NULL, array(), t('Reset to alphabetical'));
+
+    drupal_static_reset('taxonomy_get_tree');
+    drupal_static_reset('taxonomy_get_treeparent');
+    drupal_static_reset('taxonomy_get_treeterms');
+    $terms = taxonomy_get_tree($this->vocabulary->vid);
+    $this->assertEqual($terms[0]->tid, $term1->tid, t('Term 1 was moved to back above term 2.'));
+    $this->assertEqual($terms[1]->tid, $term2->tid, t('Term 2 was moved to back below term 1.'));
+    $this->assertEqual($terms[2]->tid, $term3->tid, t('Term 3 is still below term 2.'));
+    $this->assertEqual($terms[2]->parents, array($term2->tid), t('Term 3 is still a child of term 2.').var_export($terms[1]->tid,1));
+  }
+
   /**
    * Test taxonomy_get_term_by_name().
    */