Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Unified Diff: third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp

Issue 2538953002: Remove hidden elements from MHTML (Closed)
Patch Set: Address feedback Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
index 60d6fa6f9932a389d2fd92cf06b175414fda8fe9..70e9374e6bae9e15b9d91a74705545a3816880cb 100644
--- a/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebFrameSerializerTest.cpp
@@ -215,4 +215,22 @@ TEST_F(WebFrameSerializerSanitizationTest, RemoveInlineScriptInAttributes) {
EXPECT_NE(std::string::npos, mhtml.find("id="));
}
+TEST_F(WebFrameSerializerSanitizationTest, RemoveHiddenElements) {
+ String mhtml =
+ generateMHTMLParts("http://www.test.com", "hidden_elements.html");
+
+ // These hidden elements that do not affect layout should be removed.
+ EXPECT_EQ(std::string::npos, mhtml.find("<h1"));
+ EXPECT_EQ(std::string::npos, mhtml.find("<p id=3D\"hidden_id\""));
+ EXPECT_EQ(std::string::npos, mhtml.find("<input type=3D\"hidden\""));
+
+ // These hidden elements that affect layout should remain intact.
+ EXPECT_NE(std::string::npos, mhtml.find("<h2"));
+
+ // These visible elements should remain intact.
+ EXPECT_NE(std::string::npos, mhtml.find("<h2"));
+ EXPECT_NE(std::string::npos, mhtml.find("<p id=3D\"visible_id\""));
+ EXPECT_NE(std::string::npos, mhtml.find("<input type=3D\"text\""));
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698