Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.320
diff -u -p -r1.320 form.inc
--- includes/form.inc	3 Feb 2009 18:55:29 -0000	1.320
+++ includes/form.inc	5 Feb 2009 21:04:32 -0000
@@ -633,6 +633,9 @@ function drupal_redirect_form($form, $re
         call_user_func_array('drupal_goto', $goto);
       }
       else {
+        if (isset($_REQUEST['destination']) && $_REQUEST['destination'] == $_GET['q']) {
+          unset($_REQUEST['destination']);
+        }
         drupal_goto($goto);
       }
     }
Index: modules/search/search.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.module,v
retrieving revision 1.283
diff -u -p -r1.283 search.module
--- modules/search/search.module	4 Jan 2009 16:10:48 -0000	1.283
+++ modules/search/search.module	5 Feb 2009 21:04:33 -0000
@@ -1105,7 +1105,7 @@ function search_box(&$form_state, $form_
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
   $form['#submit'][] = 'search_box_form_submit';
-
+  
   return $form;
 }
 
Index: modules/search/search.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/search/search.test,v
retrieving revision 1.15
diff -u -p -r1.15 search.test
--- modules/search/search.test	22 Jan 2009 04:49:58 -0000	1.15
+++ modules/search/search.test	5 Feb 2009 21:04:33 -0000
@@ -373,8 +373,8 @@ class SearchRankingTestCase extends Drup
 class SearchBlockTestCase extends DrupalWebTestCase {
   function getInfo() {
     return array(
-      'name' => t('Block availability'),
-      'description' => t('Check if the search form block is available.'),
+      'name' => t('Search block'),
+      'description' => t('Test the search block form.'),
       'group' => t('Search'),
     );
   }
@@ -383,19 +383,37 @@ class SearchBlockTestCase extends Drupal
     parent::setUp('search');
 
     // Create and login user
-    $admin_user = $this->drupalCreateUser(array('administer blocks'));
+    $admin_user = $this->drupalCreateUser(array('administer blocks', 'search content'));
     $this->drupalLogin($admin_user);
   }
 
-  function testSearchFormBlock() {
-    // Set block title to confirm that the interface is availble.
-    $this->drupalPost('admin/build/block/configure/search/form', array('title' => $this->randomName(8)), t('Save block'));
-    $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
-
-    // Set the block to a region to confirm block is availble.
-    $edit = array();
-    $edit['search_form[region]'] = 'footer';
+  /**
+   * Test that the search block form works correctly.
+   */
+  function testBlock() {
+    // Disable the theme form to avoid confusion.
+    $settings = theme_get_settings();
+    $settings['toggle_search'] = FALSE;
+    variable_set('theme_settings', $settings);
+
+    // Enable the block, and place it in the 'content' region so that it isn't
+    // hidden on 404 pages.
+    $edit = array('search_form[region]' => 'content');
     $this->drupalPost('admin/build/block', $edit, t('Save blocks'));
-    $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));
+
+    // Test a normal search via the block form, from the front page.
+    $terms = array('search_block_form' => 'test');
+    $this->drupalPost('node', $terms, t('Search'));
+    $this->assertText('Your search yielded no results');
+
+    // Test a search from the block on a 404 page.
+    $this->drupalPost('foo', $terms, t('Search'));
+    $this->assertText('Your search yielded no results');
+
+    // Test a search from the block when it doesn't appear on the search page.
+    $edit = array('pages' => 'search');
+    $this->drupalPost('admin/build/block/configure/search/form', $edit, t('Save block'));
+    $this->drupalPost('node', $terms, t('Search'));
+    $this->assertText('Your search yielded no results');
   }
 }
