Skip to content

Instantly share code, notes, and snippets.

@oschaaf
Created December 15, 2015 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oschaaf/15a9a429867ee18ea622 to your computer and use it in GitHub Desktop.
Save oschaaf/15a9a429867ee18ea622 to your computer and use it in GitHub Desktop.
diff --git a/net/instaweb/rewriter/css_combine_filter_test.cc b/net/instaweb/rewriter/css_combine_filter_test.cc
index da0623e..8e16d54 100644
--- a/net/instaweb/rewriter/css_combine_filter_test.cc
+++ b/net/instaweb/rewriter/css_combine_filter_test.cc
@@ -2005,6 +2005,46 @@ TEST_F(CollapseWhitespaceGeneralTest, CollapseAfterCombine) {
ValidateExpected("collapse_after_combine", before, after);
}
+// Issue 1215:
+TEST_F(CollapseWhitespaceGeneralTest, CollapseAfterCombineOptimizeForBandwidth) {
+ // Note: Even though we enable collapse_whitespace first, it should run
+ // after combine_css.
+ options()->EnableFilter(RewriteOptions::kCollapseWhitespace);
+ options()->EnableFilter(RewriteOptions::kCombineCss);
+ options()->SetRewriteLevel(RewriteOptions::kOptimizeForBandwidth);
+ rewrite_driver()->AddFilters();
+
+ // Setup resources for combine_css.
+ ResponseHeaders default_css_header;
+ SetDefaultLongCacheHeaders(&kContentTypeCss, &default_css_header);
+ SetFetchResponse(AbsolutifyUrl("a.css"),
+ default_css_header, ".a { color: red; }");
+ SetFetchResponse(AbsolutifyUrl("b.css"),
+ default_css_header, ".b { color: green; }");
+ SetFetchResponse(AbsolutifyUrl("c.css"),
+ default_css_header, ".c { color: blue; }");
+
+ // Before and expected after text.
+ const char before[] =
+ "<html>\n"
+ " <head>\n"
+ " <link rel=stylesheet type=text/css href=a.css>\n"
+ " <link rel=stylesheet type=text/css href=b.css>\n"
+ " <link rel=stylesheet type=text/css href=c.css>\n"
+ " </head>\n"
+ "</html>\n";
+ const char after_template[] =
+ "<html>\n"
+ "<head>\n"
+ "<link rel=stylesheet type=text/css href=%s />\n"
+ "</head>\n"
+ "</html>\n";
+ GoogleString after = StringPrintf(after_template, Encode(
+ "", "cc", "0", MultiUrl("a.css", "b.css", "c.css"), "css").c_str());
+
+ ValidateExpected("collapse_after_combine", before, after);
+}
+
/*
TODO(jmarantz): cover intervening FLUSH
TODO(jmarantz): consider converting some of the existing tests to this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment