Index: includes/common.inc =================================================================== --- includes/common.inc (revision 6) +++ includes/common.inc (working copy) @@ -2623,8 +2623,7 @@ // Perform some safe CSS optimizations. $contents = preg_replace('< \s*([@{}:;,]|\)\s|\s\()\s* | # Remove whitespace around separators, but keep space around parentheses. - /\*([^*\\\\]|\*(?!/))+\*/ | # Remove comments that are not CSS hacks. - [\n\r] # Remove line breaks. + /\*([^*\\\\]|\*(?!/))+\*/ # Remove comments that are not CSS hacks. >x', '\1', $contents); } return $contents; Index: modules/simpletest/files/css_test_files/css_input_with_import.css =================================================================== --- modules/simpletest/files/css_test_files/css_input_with_import.css (revision 0) +++ modules/simpletest/files/css_test_files/css_input_with_import.css (revision 0) @@ -0,0 +1,34 @@ +/* $Id: style.css,v 1.57 2009/05/31 00:51:41 webchick Exp $ */ + +/** + * @file Basic css that uses @import +*/ + +@import "import1.css"; +@import "import2.css"; + +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/css_input_with_import.css.optimized =================================================================== --- modules/simpletest/files/css_test_files/css_input_with_import.css.optimized (revision 0) +++ modules/simpletest/files/css_test_files/css_input_with_import.css.optimized (revision 0) @@ -0,0 +1,11 @@ + + + + + + + +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_with_import.css.unoptimized =================================================================== --- modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized (revision 0) +++ modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized (revision 0) @@ -0,0 +1,34 @@ +/* $Id: style.css,v 1.57 2009/05/31 00:51:41 webchick Exp $ */ + +/** + * @file Basic css that uses @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; +} +.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 =================================================================== --- modules/simpletest/files/css_test_files/css_input_without_import.css (revision 0) +++ modules/simpletest/files/css_test_files/css_input_without_import.css (revision 0) @@ -0,0 +1,33 @@ +/* $Id: style.css,v 1.57 2009/05/31 00:51:41 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; +} + +.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 =================================================================== --- modules/simpletest/files/css_test_files/css_input_without_import.css.optimized (revision 0) +++ modules/simpletest/files/css_test_files/css_input_without_import.css.optimized (revision 0) @@ -0,0 +1,4 @@ + + +/** + *@file Basic css that does not use} \ No newline at end of file Index: modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized =================================================================== --- modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized (revision 0) +++ modules/simpletest/files/css_test_files/css_input_without_import.css.unoptimized (revision 0) @@ -0,0 +1,6 @@ +/* $Id: style.css,v 1.57 2009/05/31 00:51:41 webchick Exp $ */ + +/** + * @file Basic css that does not use +} + Index: modules/simpletest/files/css_test_files/import1.css =================================================================== --- modules/simpletest/files/css_test_files/import1.css (revision 0) +++ modules/simpletest/files/css_test_files/import1.css (revision 0) @@ -0,0 +1,5 @@ + +ul, select { + font: 1em/160% Verdana, sans-serif; + color: #494949; +} Index: modules/simpletest/files/css_test_files/import2.css =================================================================== --- modules/simpletest/files/css_test_files/import2.css (revision 0) +++ modules/simpletest/files/css_test_files/import2.css (revision 0) @@ -0,0 +1,5 @@ + +p, select { + font: 1em/160% Verdana, sans-serif; + color: #494949; +} Index: modules/simpletest/tests/common.test =================================================================== --- modules/simpletest/tests/common.test (revision 5) +++ modules/simpletest/tests/common.test (working copy) @@ -270,6 +270,26 @@ $this->drupalGet('node/' . $node->nid); $this->assertRaw($compressed_css, t('Inline stylesheets appear in the full page rendering.')); } + + /** + * Tests basic CSS loading with and without optimization (drupal_load_stylesheet()) + */ + function testLoadCssBasic() { + // Array of files to test. Original = .css, unoptimized expected output = .css.unoptimized, + // optimized expected = .css.optimized + // They live in the simpletest/files/css_test_files directory + $testfiles = array('css_input_without_import.css', 'css_input_with_import.css'); + $path = drupal_get_path('module', 'simpletest') . '/files/css_test_files'; + foreach ($testfiles as $file) { + $content = file_get_contents("$path/$file"); + $unoptimized_output = drupal_load_stylesheet_content($content, FALSE); + $expected = file_get_contents("$path/{$file}.unoptimized"); + $this->assertEqual($unoptimized_output, $expected, t('Loaded CSS Stylesheet has expected contents (unoptimized) (%file)', array('%file' => $file))); + $expected = file_get_contents("$path/{$file}.optimized"); + $optimized_output = drupal_load_stylesheet_content($content, TRUE); + $this->assertEqual($optimized_output, $expected, t('Loaded CSS Stylesheet has expected contents (optimized) (%file)', array('%file' => $file))); + } + } } /**