diff --git a/tests/views_cache.test b/tests/views_cache.test
index e2f834a..b71d2c9 100644
--- a/tests/views_cache.test
+++ b/tests/views_cache.test
@@ -148,4 +148,66 @@ class ViewsCacheTest extends ViewsSqlTest {
     // Verify the result.
     $this->assertEqual(6, count($view->result), t('The number of returned rows match.'));
   }
+
+  /**
+   * Tests css/js storage and restoring mechanism.
+   */
+  function testHeaderStorage() {
+    // Create a view with output caching enabled.
+    // Some hook_views_pre_render in views_test.module adds the test css/js file
+    // so they should be added to the css/js storage.
+    $view = $this->getBasicView();
+    $view->init_display();
+    $view->name = 'test_cache_header_storage';
+    $view->display_handler->override_option('cache', array(
+      'type' => 'time',
+      'output_lifespan' => '3600',
+    ));
+    // @FIXME: The cache plugin expects settings['data'] to be set
+    drupal_add_js('setting', array('example' => ''));
+
+    $view->preview();
+    $view->destroy();
+    unset($view->pre_render_called);
+    drupal_static_reset('drupal_add_css');
+    drupal_static_reset('drupal_add_js');
+
+    $view->init_display();
+    $view->preview();
+    $css = drupal_add_css();
+    $css_path = drupal_get_path('module', 'views_test') . '/views_cache.test.css';
+    $js_path = drupal_get_path('module', 'views_test') . '/views_cache.test.js';
+    $js = drupal_add_js();
+
+    $this->assertTrue(isset($css[$css_path]), 'Take sure the css is added for cached views.');
+    $this->assertTrue(isset($js[$js_path]), 'Take sure the js is added for cached views.');
+    $this->assertFalse(!empty($view->pre_render_called), 'Take sure hook_views_pre_render is not called for the cached view.');
+    $view->destroy();
+
+    // Now add some css/jss before running the view.
+    // Take sure that this css is not added when running the cached view.
+    $view->name = 'test_cache_header_storage_2';
+
+    $system_css_path = drupal_get_path('module', 'system') . '/system.maintenance.css';
+    drupal_add_css($system_css_path);
+    $system_js_path = drupal_get_path('module', 'system') . '/system.cron.js';
+    drupal_add_js($system_js_path);
+
+    $view->init_display();
+    $view->preview();
+    $view->destroy();
+    drupal_static_reset('drupal_add_css');
+    drupal_static_reset('drupal_add_js');
+
+    $view->init_display();
+    $view->preview();
+
+    $css = drupal_add_css();
+    $js = drupal_add_js();
+
+    $this->assertFalse(isset($css[$system_css_path]), 'Take sure that unrelated css is not added.');
+    $this->assertFalse(isset($js[$system_js_path]), 'Take sure that unrelated js is not added.');
+
+  }
+
 }
diff --git a/tests/views_test.module b/tests/views_test.module
index 8f8afbe..f6026b8 100644
--- a/tests/views_test.module
+++ b/tests/views_test.module
@@ -48,3 +48,14 @@ function views_test_test_static_access_callback($access) {
 function views_test_test_dynamic_access_callback($access, $argument1, $argument2) {
   return $access && $argument1 == variable_get('test_dynamic_access_argument1', NULL) && $argument2 == variable_get('test_dynamic_access_argument2', NULL);
 }
+
+/**
+ * Implements hook_views_pre_render().
+ */
+function views_test_views_pre_render(&$view) {
+  if ($view->name == 'test_cache_header_storage') {
+    drupal_add_js(drupal_get_path('module', 'views_test') . '/views_cache.test.js');
+    drupal_add_css(drupal_get_path('module', 'views_test') . '/views_cache.test.css');
+    $view->pre_render_called = TRUE;
+  }
+}
