diff --git a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php index 439d888..ff7482c 100644 --- a/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php +++ b/core/tests/Drupal/Tests/Core/Asset/CssOptimizerUnitTest.php @@ -201,6 +201,36 @@ function testOptimize($css_asset, $expected) { } /** + * Tests optimizing a CSS asset containing charset declaration. + */ + function testOptimizeRemoveCharset() { + $cases = array( + array( + 'asset' => array( + 'data' => '@charset "UTF-8";html{font-family:"sans-serif";}', + 'preprocess' => FALSE, + ), + 'expected' => 'html{font-family:"sans-serif";}', + ), + array( + 'asset' => array( + // This asset contains extra \n character. + 'data' => "@charset 'UTF-8';\nhtml{font-family:'sans-serif';}", + 'preprocess' => FALSE, + ), + 'expected' => "\nhtml{font-family:'sans-serif';}", + ), + ); + foreach ($cases as $case) { + $this->assertEquals( + $case['expected'], + $this->optimizer->optimize($case['asset']), + 'CSS optimizing correctly removes the charset declaration.' + ); + } + } + + /** * Tests a file CSS asset with preprocessing disabled. */ function testTypeFilePreprocessingDisabled() {