Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.93
diff -u -r1.93 common.test
--- modules/simpletest/tests/common.test	2 Dec 2009 19:26:22 -0000	1.93
+++ modules/simpletest/tests/common.test	3 Dec 2009 14:18:23 -0000
@@ -583,6 +583,21 @@
   }
 
   /**
+   * Tests rendering an inline stylesheet containing an @import command.
+   *
+   * @import command inside inline stylesheets should not be replaced with the
+   * contents of the actual stylesheet.
+   */
+  function testRenderInlineAtImport() {
+    $css = '@import url(modules/system/defaults.css);';
+    drupal_add_css($css, array('type' => 'inline', 'preprocess' => FALSE));
+
+    $expected = "\n" . '<style type="text/css">@import url(modules/system/defaults.css);</style>' . "\n";
+    $styles = drupal_get_css();
+    $this->assertEqual($styles, $expected, t('Rendering inline CSS with @import command adds it to the page.'));
+  }
+
+  /**
    * Tests rendering inline stylesheets through a full page request.
    */
   function testRenderInlineFullPage() {
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1056
diff -u -r1.1056 common.inc
--- includes/common.inc	3 Dec 2009 02:20:28 -0000	1.1056
+++ includes/common.inc	3 Dec 2009 14:18:23 -0000
@@ -3308,8 +3308,8 @@
         }
         break;
       case 'inline':
-        // Include inline stylesheets.
-        $inline_css .= drupal_load_stylesheet_content($item['data'], $item['preprocess']);
+        // Include inline stylesheets, but don't resolve @import rules.
+        $inline_css .= drupal_load_stylesheet_content($item['data'], $item['preprocess'], FALSE);
         break;
       case 'external':
         // Preprocessing for external CSS files is ignored.
@@ -3463,10 +3463,13 @@
  * @param $optimize
  *   (optional) Boolean whether CSS contents should be minified. Defaults to
  *   FALSE.
+ * @param $flatten
+ *   (internal) Boolean whether @import rules should be replaced with the actual
+ *   stylesheet content. Defaults to TRUE.
  * @return
  *   Contents of the stylesheet including the imported stylesheets.
  */
-function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
+function drupal_load_stylesheet_content($contents, $optimize = FALSE, $flatten = TRUE) {
   // Remove multiple charset declarations for standards compliance (and fixing Safari problems).
   $contents = preg_replace('/^@charset\s+[\'"](\S*)\b[\'"];/i', '', $contents);
 
@@ -3475,16 +3478,18 @@
     $contents = preg_replace('{
       (?<=\\\\\*/)([^/\*]+/\*)([^\*/]+\*/)  # Add a backslash also at the end ie-mac hack comment, so the next pass will not touch it.
                                             # The added backshlash does not affect the effectiveness of the hack.
-      }x', '\1\\\\\2', $contents);    
+      }x', '\1\\\\\2', $contents);
     $contents = preg_replace('<
       \s*([@{}:;,]|\)\s|\s\()\s* |          # Remove whitespace around separators, but keep space around parentheses.
       /\*[^*\\\\]*\*+([^/*][^*]*\*+)*/ |    # Remove comments that are not CSS hacks.
       >x', '\1', $contents);
   }
 
-  // Replaces @import commands with the actual stylesheet content.
-  // This happens recursively but omits external files.
-  $contents = preg_replace_callback('/@import\s*(?:url\()?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\)?;/', '_drupal_load_stylesheet', $contents);
+  if ($flatten) {
+    // Replaces @import commands with the actual stylesheet content.
+    // This happens recursively but omits external files.
+    $contents = preg_replace_callback('/@import\s*(?:url\()?[\'"]?(?![a-z]+:)([^\'"\()]+)[\'"]?\)?;/', '_drupal_load_stylesheet', $contents);
+  }
   return $contents;
 }
 
