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

Unified Diff: Source/web/tests/WebPageNewSerializerTest.cpp

Issue 177243005: [SavePage] Do not save images with errors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed the unused variable. Created 6 years, 9 months 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
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | Source/web/tests/data/pageserializer/error_image.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/WebPageNewSerializerTest.cpp
diff --git a/Source/web/tests/WebPageNewSerializerTest.cpp b/Source/web/tests/WebPageNewSerializerTest.cpp
index fc8f3b43ed2f18dbac6a283cd50dd6135664ffc5..e42c8150a32d94f7df093734680cb2ffd2f56263 100644
--- a/Source/web/tests/WebPageNewSerializerTest.cpp
+++ b/Source/web/tests/WebPageNewSerializerTest.cpp
@@ -367,6 +367,30 @@ TEST_F(WebPageNewSerializeTest, SVGImageDontCrash)
EXPECT_GT(mhtml.length(), 50U);
}
+
+TEST_F(WebPageNewSerializeTest, DontIncludeErrorImage)
+{
+ WebURL pageUrl = toKURL("http://www.test.com");
+ WebURL imageUrl = toKURL("http://www.test.com/error_image.png");
+
+ registerMockedURLLoad(pageUrl, WebString::fromUTF8("page_with_img_error.html"), WebString::fromUTF8("pageserializer/"), htmlMimeType());
+ registerMockedURLLoad(imageUrl, WebString::fromUTF8("error_image.png"), WebString::fromUTF8("pageserializer/"), pngMimeType());
+
+ loadURLInTopFrame(pageUrl);
+
+ WebCString mhtmlData = WebPageSerializer::serializeToMHTML(webView());
+ ASSERT_FALSE(mhtmlData.isEmpty());
+
+ // Sniff the MHTML data to make sure image content is excluded.
+ LineReader lineReader(std::string(mhtmlData.data()));
+ std::string line;
+ while (lineReader.getNextLine(&line)) {
+ if (line.find("image/") != std::string::npos)
+ FAIL() << "Error Image was not excluded " << line;
+ }
+}
+
+
TEST_F(WebPageNewSerializeTest, NamespaceElementsDontCrash)
{
WebURL pageUrl = toKURL("http://www.test.com");
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | Source/web/tests/data/pageserializer/error_image.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698