Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.92
diff -u -r1.92 common.test
--- modules/simpletest/tests/common.test	21 Nov 2009 14:35:05 -0000	1.92
+++ modules/simpletest/tests/common.test	25 Nov 2009 02:04:21 -0000
@@ -587,7 +587,7 @@
    */
   function testRenderInlineFullPage() {
     $css = 'body { font-size: 254px; }';
-    $expected = 'font-size:254px;';
+    $expected = 'font-size:254px';
 
     // Create a node, using the PHP filter that tests drupal_add_css().
     $settings = array(
@@ -762,22 +762,40 @@
    * is treated with adequate respect (not arbitrarily removing linefeeds).
    */
   function testLoadCssBasic() {
+    // Force base URL path to be '/'.
+    $GLOBALS['base_path'] = '/';
+
     // Array of files to test living in 'simpletest/files/css_test_files/'.
     // - Original: name.css
-    // - Unoptimized expected content: name.css.unoptimized.css
-    // - Optimized expected content: name.css.optimized.css
+    // - Unoptimized expected content: name.unoptimized.css
+    // - Optimized expected content: name.optimized.css
     $testfiles = array(
-      'css_input_without_import.css',
+      'basic',
+      'import',
+      'nested_import',
+      //'hacks', Does not pass yet
+      'selectors',
+      'paths'
     );
     $path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
     foreach ($testfiles as $file) {
-      $expected = file_get_contents("$path/$file.unoptimized.css");
-      $unoptimized_output = drupal_load_stylesheet("$path/$file.unoptimized.css", FALSE);
-      $this->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file has expected contents (@file)', array('@file' => $file)));
-
-      $expected = file_get_contents("$path/$file.optimized.css");
-      $optimized_output = drupal_load_stylesheet("$path/$file", TRUE);
-      $this->assertEqual($optimized_output, $expected, t('Optimized CSS file has expected contents (@file)', array('@file' => $file)));
+      if (file_exists("$path/$file.unoptimized.css")) {
+        $expected = file_get_contents("$path/$file.unoptimized.css");
+        $unoptimized_output = drupal_load_stylesheet("$path/$file.css", FALSE);
+        $this->assertEqual($unoptimized_output, $expected, t('Unoptimized CSS file has expected contents (@file)', array('@file' => "$file.css")));
+
+        // For developers: uncomment next line to store actual output of drupal_load_stylesheet()
+        //file_put_contents("sites/default/private/temp/$file.unoptimized.css", $unoptimized_output);
+      }
+
+      if (file_exists("$path/$file.optimized.css")) {
+        $expected = file_get_contents("$path/$file.optimized.css");
+        $optimized_output = drupal_load_stylesheet("$path/$file.css", TRUE);
+        $this->assertEqual($optimized_output, $expected, t('Optimized CSS file has expected contents (@file)', array('@file' => "$file.css")));
+
+        // For developers: uncomment next line to store actual output of drupal_load_stylesheet()
+        //file_put_contents("sites/default/private/temp/$file.optimized.css", $optimized_output);
+      }
     }
   }
 }
Index: modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized.css
diff -N modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized.css
--- modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized.css	10 Nov 2009 17:27:53 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-/* $Id: css_input_without_import.css.unoptimized.css,v 1.2 2009/11/10 17:27:53 webchick Exp $ */
-
-/**
- * @file Basic css that does not use import
- */
-
-
-body {
-  margin: 0;
-  padding: 0;
-  background: #edf5fa;
-  font: 76%/170% Verdana, sans-serif;
-  color: #494949;
-}
-
-.this .is .a .test {
-  font: 1em/100% Verdana, sans-serif;
-  color: #494949;
-}
-
-/**
- * CSS spec says that all whitespace is valid whitespace, so this selector should be just as
- * good as the one above.
- */
-
-.this
-.is
-.a
-.test {
-font: 1em/100% Verdana, sans-serif;
-color: #494949;
-}
-
-textarea, select {
-  font: 1em/160% Verdana, sans-serif;
-  color: #494949;
-}
-
Index: modules/simpletest/files/css_test_files/css_input_without_import.css.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/css_input_without_import.css.optimized.css
diff -N modules/simpletest/files/css_test_files/css_input_without_import.css.optimized.css
--- modules/simpletest/files/css_test_files/css_input_without_import.css.optimized.css	10 Nov 2009 17:27:53 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
-
-
-
-
-
-body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}
-
-.this
-.is
-.a
-.test{font:1em/100% Verdana,sans-serif;color:#494949;}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949;}
\ No newline at end of file
Index: modules/simpletest/files/css_test_files/css_input_without_import.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/css_input_without_import.css
diff -N modules/simpletest/files/css_test_files/css_input_without_import.css
--- modules/simpletest/files/css_test_files/css_input_without_import.css	10 Nov 2009 17:27:53 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,38 +0,0 @@
-/* $Id: css_input_without_import.css,v 1.2 2009/11/10 17:27:53 webchick Exp $ */
-
-/**
- * @file Basic css that does not use import
- */
-
-
-body {
-  margin: 0;
-  padding: 0;
-  background: #edf5fa;
-  font: 76%/170% Verdana, sans-serif;
-  color: #494949;
-}
-
-.this .is .a .test {
-  font: 1em/100% Verdana, sans-serif;
-  color: #494949;
-}
-
-/**
- * CSS spec says that all whitespace is valid whitespace, so this selector should be just as
- * good as the one above.
- */
-
-.this
-.is
-.a
-.test {
-font: 1em/100% Verdana, sans-serif;
-color: #494949;
-}
-
-textarea, select {
-  font: 1em/160% Verdana, sans-serif;
-  color: #494949;
-}
-
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1051
diff -u -r1.1051 common.inc
--- includes/common.inc	21 Nov 2009 00:43:42 -0000	1.1051
+++ includes/common.inc	25 Nov 2009 02:04:21 -0000
@@ -3069,7 +3069,7 @@
  * which on normal pages is up through the preprocess step of theme('html').
  * Adding a link will overwrite a prior link with the exact same 'rel' and
  * 'href' attributes.
- * 
+ *
  * @param $attributes
  *   Associative array of element attributes including 'href' and 'rel'.
  * @param $header
@@ -3309,7 +3309,7 @@
         break;
       case 'inline':
         // Include inline stylesheets.
-        $inline_css .= drupal_load_stylesheet_content($item['data'], $item['preprocess']);
+        $inline_css .= drupal_load_stylesheet_content($item['data'], $item['preprocess'], FALSE);
         break;
       case 'external':
         // Preprocessing for external CSS files is ignored.
@@ -3334,6 +3334,13 @@
   }
   // Enclose the inline CSS with the style tag if required.
   if (!empty($inline_css)) {
+    // Per the W3C specification at http://www.w3.org/TR/REC-CSS2/cascade.html#at-import,
+    // @import rules must proceed any other style, so we move those to the top.
+    $regexp = '/@import[^;]+;/i';
+    preg_match_all($regexp, $inline_css, $matches);
+    $inline_css = preg_replace($regexp, '', $inline_css);
+    $inline_css = implode('', $matches[0]) . $inline_css;
+
     $element = $css_element;
     $element['#tag'] = 'style';
     $element['#value'] = $inline_css;
@@ -3366,12 +3373,7 @@
     foreach ($css as $stylesheet) {
       // Only 'file' stylesheets can be aggregated.
       if ($stylesheet['type'] == 'file') {
-        $contents = drupal_load_stylesheet($stylesheet['data'], TRUE);
-        // Return the path to where this CSS file originated from.
-        $base = base_path() . dirname($stylesheet['data']) . '/';
-        _drupal_build_css_path(NULL, $base);
-        // Prefix all paths within this CSS file, ignoring external and absolute paths.
-        $data .= preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', '_drupal_build_css_path', $contents);
+        $data .= drupal_load_stylesheet($stylesheet['data'], TRUE, TRUE);
       }
     }
 
@@ -3389,25 +3391,45 @@
 }
 
 /**
- * Helper function for drupal_build_css_cache().
+ * Helper function for drupal_load_stylesheet().
  *
  * This function will prefix all paths within a CSS file.
+ *
+ * @see drupal_load_stylesheet()
+ * @see drupal_load_stylesheet_contents()
  */
 function _drupal_build_css_path($matches, $base = NULL) {
-  $_base = &drupal_static(__FUNCTION__);
+  // $_base does not use drupal_static as it is set by $base.
+  static $_base;
   // Store base path for preg_replace_callback.
   if (isset($base)) {
     $_base = $base;
   }
 
-  // Prefix with base and remove '../' segments where possible.
-  $path = $_base . $matches[1];
-  $last = '';
-  while ($path != $last) {
-    $last = $path;
-    $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
+  if (is_array($matches)) {
+    // Prefix with base.
+    if (!empty($_base)) {
+      $path = base_path() . $_base . '/' . $matches[1];
+    }
+    else {
+      $path = base_path() . $matches[1];
+    }
+
+    // Replace '/./' segments for '/'.
+    $path = str_replace('/./', '/', $path);
+
+    // Remove '../' segments where possible.
+    $last = '';
+    while ($path != $last) {
+      $last = $path;
+      $path = preg_replace('`(^|/)(?!\.\./)([^/]+)/\.\./`', '$1', $path);
+    }
+
+    return 'url(' . $path . ')';
+  }
+  else {
+    return $_base;
   }
-  return 'url(' . $path . ')';
 }
 
 /**
@@ -3425,10 +3447,12 @@
  *   Name of the stylesheet to be processed.
  * @param $optimize
  *   Defines if CSS contents should be compressed or not.
+ * @param $flatten
+ *   Defines if @import commands should be replaced with the actual stylesheet content.
  * @return
  *   Contents of the stylesheet, including any resolved @import commands.
  */
-function drupal_load_stylesheet($file, $optimize = NULL) {
+function drupal_load_stylesheet($file, $optimize = NULL, $flatten = TRUE) {
   // $_optimize does not use drupal_static as it is set by $optimize.
   static $_optimize;
   // Store optimization parameter for preg_replace_callback with nested @import loops.
@@ -3441,15 +3465,19 @@
     // Load the local CSS stylesheet.
     $contents = file_get_contents($file);
 
-    // Change to the current stylesheet's directory.
-    $cwd = getcwd();
-    chdir(dirname($file));
+    $temp = _drupal_build_css_path(NULL);
+    // Inform _drupal_build_css_path() where this CSS file originated from.
+    _drupal_build_css_path(NULL, dirname($file));
 
     // Process the stylesheet.
-    $contents = drupal_load_stylesheet_content($contents, $_optimize);
+    $contents = drupal_load_stylesheet_content($contents, $_optimize, $flatten);
 
-    // Change back directory.
-    chdir($cwd);
+    // Restore _drupal_build_css_path().
+    _drupal_build_css_path(NULL, $temp);
+  }
+  else {
+    // Return an @import command when file doesn't seem to exist.
+    $contents = '@import url(' . base_path() . $file . ');';
   }
 
   return $contents;
@@ -3463,10 +3491,13 @@
  * @param $optimize
  *   (optional) Boolean whether CSS contents should be minified. Defaults to
  *   FALSE.
+ * @param $flatten
+ *   (optional) Boolean whether @import commands should be replaced with the
+ *   actual stylesheet content.
  * @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,31 +3506,50 @@
     $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);
+
+    // Remove whitespace around { } and last semicolon in declaration block.
+    $contents = preg_replace('/\s*{\s*/', '{', $contents);
+    $contents = preg_replace('/;?\s*}\s*/', '}', $contents);
+
+    // Remove whitespace surrounding semicolons.
+    $contents = preg_replace('/\s*;\s*/', ';', $contents);
+
+    // Replace whitespace from the beginning and end with a single newline.
+    $contents = "\n" . trim($contents) . "\n";
+  }
+
+  // Normalize @import commands so they all contain the url() function.
+  $contents = preg_replace('/@import\s*(?:url\(\s*)?[\'"]?([^\'"\()]+)[\'"]?\s*\)?;/', '@import url(\1);', $contents);
+
+  // Normalize all paths within this CSS file, ignoring external and absolute paths.
+  // Paths always needs to be normalized as relative URLs may break when aggregating this CSS file.
+  $contents = preg_replace_callback('/url\(\s*[\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\s*\)/i', '_drupal_build_css_path', $contents);
+
+  if ($flatten) {
+    // Replaces @import commands with the actual stylesheet content.
+    // This happens recursively but omits external files.
+    $contents = preg_replace_callback('/@import url\((\/[^\)]+\.css)\)?;/', '_drupal_load_stylesheet', $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);
   return $contents;
 }
 
 /**
- * Loads stylesheets recursively and returns contents with corrected paths.
+ * Helper function for drupal_load_stylesheet_content().
+ *
+ * This function is used for recursive loading of stylesheets.
  *
- * This function is used for recursive loading of stylesheets and
- * returns the stylesheet content with all url() paths corrected.
+ * @see drupal_load_stylesheet_content()
  */
 function _drupal_load_stylesheet($matches) {
-  $filename = $matches[1];
-  // Load the imported stylesheet and replace @import commands in there as well.
-  $file = drupal_load_stylesheet($filename);
-  // Alter all url() paths, but not external.
-  return preg_replace('/url\(([\'"]?)(?![a-z]+:)([^\'")]+)[\'"]?\)?;/i', 'url(\1' . dirname($filename) . '/', $file);
+  // Strip base URL path to get a correct internal file path.
+  $filename = substr($matches[1], strlen(base_path()));
+  return drupal_load_stylesheet($filename);
 }
 
 /**
Index: modules/simpletest/files/css_test_files/paths.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/paths.optimized.css
diff -N modules/simpletest/files/css_test_files/paths.optimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/paths.optimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,2 @@
+
+foo{background:url(/modules/simpletest/files/css_test_files/bar/foo.png);background:url(/modules/simpletest/files/css_test_files/bar/foo.png);background:url(/modules/simpletest/files/css_test_files/bar/foo.png);background:url(/modules/simpletest/files/bar/foo.png);background:url(/modules/simpletest/files/foo.png);background:url(/modules/simpletest/files/css_test_files/bar/foo.png);background:url(/modules/simpletest/files/css_test_files/foo.png);background:url('/bar/foo.png');background:url('/bar/../../foo.png');background:url('http://foo.com/css/foo.css');background:url('http://foo.com/css/../foo.css');background:url('http://foo.com/css/../css/foo.css');background:url("//foo.com/css/foo.css");background:url(data:image/gif;base64,AAAA)}
Index: modules/simpletest/files/css_test_files/paths.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/paths.css
diff -N modules/simpletest/files/css_test_files/paths.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/paths.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,24 @@
+foo {
+  background: url('bar/foo.png');
+  background: url('./bar/foo.png');
+  background: url('bar/./foo.png');
+  background: url('../bar/foo.png');
+  background: url('bar/../../foo.png');
+  background: url('bar/../bar/foo.png');
+  background: url('bar/../bar/../foo.png');
+
+  /* absolute, should not alter */
+  background: url('/bar/foo.png');
+  background: url('/bar/../../foo.png');
+
+  /* external, should not alter */
+  background: url('http://foo.com/css/foo.css');
+  background: url('http://foo.com/css/../foo.css');
+  background: url('http://foo.com/css/../css/foo.css');
+
+  /* protocol relative, should not alter */
+  background: url("//foo.com/css/foo.css");
+
+  /* data, should not alter */
+  background: url(data:image/gif;base64,AAAA);
+}
Index: modules/simpletest/files/css_test_files/selectors.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/selectors.optimized.css
diff -N modules/simpletest/files/css_test_files/selectors.optimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/selectors.optimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,41 @@
+
+*
+E[foo]
+E[foo="bar"]
+E[foo~="bar"]
+E[foo^="bar"]
+E[foo$="bar"]
+E[foo*="bar"]
+E[hreflang|="en"]
+E:root
+E:nth-child(n)
+E:nth-last-child(n)
+E:nth-of-type(n)
+E:nth-last-of-type(n)
+E:first-child
+E:last-child
+E:first-of-type
+E:last-of-type
+E:only-child
+E:only-of-type
+E:empty
+E:link
+E:visited
+E:active
+E:hover
+E:focus
+E:target
+E:lang(fr)
+E:enabled
+E:disabled
+E:checked
+E::first-line
+E::first-letter
+E::selection
+E::before
+E::after
+E.warning#myid
+E:not(s)
+> F
+ + F
+ ~ F{color:red}
Index: modules/simpletest/files/css_test_files/nested_import.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/nested_import.optimized.css
diff -N modules/simpletest/files/css_test_files/nested_import.optimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/nested_import.optimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,9 @@
+
+
+
+body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949}.this
+.is
+.a
+.test{font:1em/100% Verdana,sans-serif;color:#494949}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949}
+body{margin:0;background-image:url(/modules/simpletest/files/image-1.png);font:76%/170% Verdana,sans-serif;color:#494949}
+body{margin:0;background-image:url(/modules/simpletest/files/image-1.png);font:76%/170% Verdana,sans-serif;color:#494949}
Index: modules/simpletest/files/css_test_files/hacks.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/hacks.css
diff -N modules/simpletest/files/css_test_files/hacks.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/hacks.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,66 @@
+/* hide from ie5/mac \*/ a{}
+.foo {color:red}
+/* necessary comment */
+
+/* comment to attempt to confuse parser */
+
+/* feed to ie5/mac \*//*/
+@import "ie5mac.css";
+/* necessary comment */
+
+/* comment to attempt to confuse parser */
+
+/*/ hide from nav4 */
+.foo {display:block;}
+/* necessary comment */
+
+/* comment to attempt to confuse parser */
+
+/*/ feed to nav *//*/
+.foo {display:crazy;}
+/* necessary comment */
+
+/* hide props from various IE/win */
+div {
+    width: 140px; 
+    width/* */:/**/100px; 
+    width: /**/100px;
+}
+
+html>/**/body {}
+
+/* Tantek's box model hack */
+div { 
+  width:400px; 
+  voice-family: "\"}\""; 
+  voice-family:inherit;
+  width:300px;
+}
+
+/* don't minimize hex colors in filters */
+div {
+  filter:chroma(color=#aabbcc);
+  filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000);
+}
+
+@media screen {
+    /* for IE 5.x-6, hidden from IE 5 Mac */ /*\*/
+    * html div#page {
+        height: 1%;
+    }
+    /**/ /* end hidden from IE 5 Mac */
+}
+
+foo { /* filters for IE */
+    _height : 20px;
+    *height : 15px;
+}
+
+/* http://tantek.com/CSS/Examples/midpass.html */
+@media tty {
+ i{content:"\";/*" "*/}} @import 'midpassafter.css'; /*";}
+}/* */
+
+/* leave at least 1 space between these pseudo elements and "{" for IE6: http://www.crankygeek.com/ie6pebug/ */
+p:first-letter  {color:red;}
+p:first-line   {color:red;}
Index: modules/simpletest/files/css_test_files/nested_import.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/nested_import.unoptimized.css
diff -N modules/simpletest/files/css_test_files/nested_import.unoptimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/nested_import.unoptimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,63 @@
+
+/**
+ * @file Basic css that does not use import
+ */
+
+
+body {
+  margin: 0;
+  padding: 0;
+  background: #edf5fa;
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
+
+.this .is .a .test {
+  font: 1em/100% Verdana, sans-serif;
+  color: #494949;
+}
+
+/**
+ * CSS spec says that all whitespace is valid whitespace, so this selector should be just as
+ * good as the one above.
+ */
+
+.this
+.is
+.a
+.test {
+font: 1em/100% Verdana, sans-serif;
+color: #494949;
+}
+
+textarea, select {
+  font: 1em/160% Verdana, sans-serif;
+  color: #494949;
+}
+
+
+
+/**
+ * @file Basic css that use import
+ */
+
+
+body {
+  margin: 0;
+  background-image: url(/modules/simpletest/files/image-1.png);
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
+
+
+/**
+ * @file css that use nested import commands
+ */
+
+
+body {
+  margin: 0;
+  background-image: url(/modules/simpletest/files/image-1.png);
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
Index: modules/simpletest/files/css_test_files/selectors.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/selectors.unoptimized.css
diff -N modules/simpletest/files/css_test_files/selectors.unoptimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/selectors.unoptimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,42 @@
+/* http://www.w3.org/TR/css3-selectors/ */
+
+*
+E[foo]
+E[foo="bar"]
+E[foo~="bar"]
+E[foo^="bar"]
+E[foo$="bar"]
+E[foo*="bar"]
+E[hreflang|="en"]
+E:root
+E:nth-child(n)
+E:nth-last-child(n)
+E:nth-of-type(n)
+E:nth-last-of-type(n)
+E:first-child
+E:last-child
+E:first-of-type
+E:last-of-type
+E:only-child
+E:only-of-type
+E:empty
+E:link
+E:visited
+E:active
+E:hover
+E:focus
+E:target
+E:lang(fr)
+E:enabled
+E:disabled
+E:checked
+E::first-line
+E::first-letter
+E::selection
+E::before
+E::after
+E.warning#myid
+E:not(s)
+ > F
+ + F
+ ~ F {color: red;}
Index: modules/simpletest/files/css_test_files/hacks.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/hacks.unoptimized.css
diff -N modules/simpletest/files/css_test_files/hacks.unoptimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/hacks.unoptimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,66 @@
+/* hide from ie5/mac \*/ a{}
+.foo {color:red}
+/* necessary comment */
+
+/* comment to attempt to confuse parser */
+
+/* feed to ie5/mac \*//*/
+@import url(/modules/simpletest/files/css_test_files/ie5mac.css);
+/* necessary comment */
+
+/* comment to attempt to confuse parser */
+
+/*/ hide from nav4 */
+.foo {display:block;}
+/* necessary comment */
+
+/* comment to attempt to confuse parser */
+
+/*/ feed to nav *//*/
+.foo {display:crazy;}
+/* necessary comment */
+
+/* hide props from various IE/win */
+div {
+    width: 140px; 
+    width/* */:/**/100px; 
+    width: /**/100px;
+}
+
+html>/**/body {}
+
+/* Tantek's box model hack */
+div { 
+  width:400px; 
+  voice-family: "\"}\""; 
+  voice-family:inherit;
+  width:300px;
+}
+
+/* don't minimize hex colors in filters */
+div {
+  filter:chroma(color=#aabbcc);
+  filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000);
+}
+
+@media screen {
+    /* for IE 5.x-6, hidden from IE 5 Mac */ /*\*/
+    * html div#page {
+        height: 1%;
+    }
+    /**/ /* end hidden from IE 5 Mac */
+}
+
+foo { /* filters for IE */
+    _height : 20px;
+    *height : 15px;
+}
+
+/* http://tantek.com/CSS/Examples/midpass.html */
+@media tty {
+ i{content:"\";/*" "*/}} @import 'midpassafter.css'; /*";}
+}/* */
+
+/* leave at least 1 space between these pseudo elements and "{" for IE6: http://www.crankygeek.com/ie6pebug/ */
+p:first-letter  {color:red;}
+p:first-line   {color:red;}
Index: modules/simpletest/files/css_test_files/import.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/import.optimized.css
diff -N modules/simpletest/files/css_test_files/import.optimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/import.optimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,7 @@
+
+
+body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949}.this
+.is
+.a
+.test{font:1em/100% Verdana,sans-serif;color:#494949}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949}
+body{margin:0;background-image:url(/modules/simpletest/files/image-1.png);font:76%/170% Verdana,sans-serif;color:#494949}
Index: modules/simpletest/files/css_test_files/basic.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/basic.unoptimized.css
diff -N modules/simpletest/files/css_test_files/basic.unoptimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/basic.unoptimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+
+/**
+ * @file Basic css that does not use import
+ */
+
+
+body {
+  margin: 0;
+  padding: 0;
+  background: #edf5fa;
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
+
+.this .is .a .test {
+  font: 1em/100% Verdana, sans-serif;
+  color: #494949;
+}
+
+/**
+ * CSS spec says that all whitespace is valid whitespace, so this selector should be just as
+ * good as the one above.
+ */
+
+.this
+.is
+.a
+.test {
+font: 1em/100% Verdana, sans-serif;
+color: #494949;
+}
+
+textarea, select {
+  font: 1em/160% Verdana, sans-serif;
+  color: #494949;
+}
+
Index: modules/simpletest/files/css_test_files/hacks.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/hacks.optimized.css
diff -N modules/simpletest/files/css_test_files/hacks.optimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/hacks.optimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,4 @@
+/*\*/a{}.foo{color:red}/**/ /*\*//*/@import "ie5mac.css";/**/ /*/*/.foo{display:block}/**/ /*/*//*/.foo{display:crazy}/**/ div{width:140px;width/**/:/**/100px;width:/**/100px}html>/**/body{}div{width:400px;voice-family:"\"}\"";voice-family:inherit;width:300px}div{filter:chroma(color=#aabbcc);filter:mask(color=#000000) shadow(color=#9BAD71, direction=135) chroma(color=#000000)}@media
+screen{/*\*/* html
+div#page{height:1%}/**/}foo{_height:20px;*height:15px}@media
+tty{i{content:"\";/*" "*/}}@import 'midpassafter.css';/*"}}/* */ p:first-letter {color:red}p:first-line {color:red}
Index: modules/simpletest/files/css_test_files/basic.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/basic.css
diff -N modules/simpletest/files/css_test_files/basic.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/basic.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,37 @@
+
+/**
+ * @file Basic css that does not use import
+ */
+
+
+body {
+  margin: 0;
+  padding: 0;
+  background: #edf5fa;
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
+
+.this .is .a .test {
+  font: 1em/100% Verdana, sans-serif;
+  color: #494949;
+}
+
+/**
+ * CSS spec says that all whitespace is valid whitespace, so this selector should be just as
+ * good as the one above.
+ */
+
+.this
+.is
+.a
+.test {
+font: 1em/100% Verdana, sans-serif;
+color: #494949;
+}
+
+textarea, select {
+  font: 1em/160% Verdana, sans-serif;
+  color: #494949;
+}
+
Index: modules/simpletest/files/css_test_files/basic.optimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/basic.optimized.css
diff -N modules/simpletest/files/css_test_files/basic.optimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/basic.optimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,5 @@
+
+body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949}.this
+.is
+.a
+.test{font:1em/100% Verdana,sans-serif;color:#494949}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949}
Index: modules/simpletest/files/css_test_files/import.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/import.unoptimized.css
diff -N modules/simpletest/files/css_test_files/import.unoptimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/import.unoptimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,50 @@
+
+/**
+ * @file Basic css that does not use import
+ */
+
+
+body {
+  margin: 0;
+  padding: 0;
+  background: #edf5fa;
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
+
+.this .is .a .test {
+  font: 1em/100% Verdana, sans-serif;
+  color: #494949;
+}
+
+/**
+ * CSS spec says that all whitespace is valid whitespace, so this selector should be just as
+ * good as the one above.
+ */
+
+.this
+.is
+.a
+.test {
+font: 1em/100% Verdana, sans-serif;
+color: #494949;
+}
+
+textarea, select {
+  font: 1em/160% Verdana, sans-serif;
+  color: #494949;
+}
+
+
+
+/**
+ * @file Basic css that use import
+ */
+
+
+body {
+  margin: 0;
+  background-image: url(/modules/simpletest/files/image-1.png);
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
Index: modules/simpletest/files/css_test_files/selectors.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/selectors.css
diff -N modules/simpletest/files/css_test_files/selectors.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/selectors.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,42 @@
+/* http://www.w3.org/TR/css3-selectors/ */
+
+*
+E[foo]
+E[foo="bar"]
+E[foo~="bar"]
+E[foo^="bar"]
+E[foo$="bar"]
+E[foo*="bar"]
+E[hreflang|="en"]
+E:root
+E:nth-child(n)
+E:nth-last-child(n)
+E:nth-of-type(n)
+E:nth-last-of-type(n)
+E:first-child
+E:last-child
+E:first-of-type
+E:last-of-type
+E:only-child
+E:only-of-type
+E:empty
+E:link
+E:visited
+E:active
+E:hover
+E:focus
+E:target
+E:lang(fr)
+E:enabled
+E:disabled
+E:checked
+E::first-line
+E::first-letter
+E::selection
+E::before
+E::after
+E.warning#myid
+E:not(s)
+ > F
+ + F
+ ~ F {color: red;}
Index: modules/simpletest/files/css_test_files/nested_import.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/nested_import.css
diff -N modules/simpletest/files/css_test_files/nested_import.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/nested_import.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+@import "import.css";
+
+/**
+ * @file css that use nested import commands
+ */
+
+
+body {
+  margin: 0;
+  background-image: url(../../files/image-1.png);
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
Index: modules/simpletest/files/css_test_files/paths.unoptimized.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/paths.unoptimized.css
diff -N modules/simpletest/files/css_test_files/paths.unoptimized.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/paths.unoptimized.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,24 @@
+foo {
+  background: url(/modules/simpletest/files/css_test_files/bar/foo.png);
+  background: url(/modules/simpletest/files/css_test_files/bar/foo.png);
+  background: url(/modules/simpletest/files/css_test_files/bar/foo.png);
+  background: url(/modules/simpletest/files/bar/foo.png);
+  background: url(/modules/simpletest/files/foo.png);
+  background: url(/modules/simpletest/files/css_test_files/bar/foo.png);
+  background: url(/modules/simpletest/files/css_test_files/foo.png);
+
+  /* absolute, should not alter */
+  background: url('/bar/foo.png');
+  background: url('/bar/../../foo.png');
+
+  /* external, should not alter */
+  background: url('http://foo.com/css/foo.css');
+  background: url('http://foo.com/css/../foo.css');
+  background: url('http://foo.com/css/../css/foo.css');
+
+  /* protocol relative, should not alter */
+  background: url("//foo.com/css/foo.css");
+
+  /* data, should not alter */
+  background: url(data:image/gif;base64,AAAA);
+}
Index: modules/simpletest/files/css_test_files/import.css
===================================================================
RCS file: modules/simpletest/files/css_test_files/import.css
diff -N modules/simpletest/files/css_test_files/import.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ modules/simpletest/files/css_test_files/import.css	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,13 @@
+@import "basic.css";
+
+/**
+ * @file Basic css that use import
+ */
+
+
+body {
+  margin: 0;
+  background-image: url(../image-1.png);
+  font: 76%/170% Verdana, sans-serif;
+  color: #494949;
+}
