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

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

Issue 22926011: Add doctype declarations when using PageSerializer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Review fixes Created 7 years, 4 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/dtd/dtd.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/tests/PageSerializerTest.cpp
diff --git a/Source/web/tests/PageSerializerTest.cpp b/Source/web/tests/PageSerializerTest.cpp
index 44536240ed9b291bfe7088d47567b8dfcaa62650..8c647849cc638f3cf12a72541f18b52e750530df 100644
--- a/Source/web/tests/PageSerializerTest.cpp
+++ b/Source/web/tests/PageSerializerTest.cpp
@@ -143,16 +143,31 @@ protected:
return m_resources;
}
- bool isSerialized(const char* url, const char* mimeType)
+
+ const SerializedResource* getResource(const char* url, const char* mimeType)
{
KURL kURL = KURL(m_baseUrl, url);
- WTF::String mime(mimeType);
+ String mime(mimeType);
for (size_t i = 0; i < m_resources.size(); ++i) {
const SerializedResource& resource = m_resources[i];
- if (resource.url == kURL && !resource.data->isEmpty() && equalIgnoringCase(resource.mimeType, mime))
- return true;
+ if (resource.url == kURL && !resource.data->isEmpty()
+ && (mime.isNull() || equalIgnoringCase(resource.mimeType, mime)))
+ return &resource;
}
- return false;
+ return 0;
+ }
+
+ bool isSerialized(const char* url, const char* mimeType = 0)
+ {
+ return getResource(url, mimeType);
+ }
+
+ String getSerializedData(const char* url, const char* mimeType = 0)
+ {
+ const SerializedResource* resource = getResource(url, mimeType);
+ if (resource)
+ return String(resource->data->data());
+ return String();
}
WebViewImpl* m_webViewImpl;
@@ -179,4 +194,26 @@ TEST_F(PageSerializerTest, InputImage)
EXPECT_FALSE(isSerialized("non-existing-button.png", "image/png"));
}
+TEST_F(PageSerializerTest, XMLDeclaration)
+{
+ setBaseFolder("pageserializer/xmldecl/");
+
+ registerURL("xmldecl.xml", "text/xml");
+ serialize("xmldecl.xml");
+
+ String expectedStart("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ EXPECT_TRUE(getSerializedData("xmldecl.xml").startsWith(expectedStart));
+}
+
+TEST_F(PageSerializerTest, DTD)
+{
+ setBaseFolder("pageserializer/dtd/");
+
+ registerURL("dtd.html", "text/html");
+ serialize("dtd.html");
+
+ String expectedStart("<!DOCTYPE html>");
+ EXPECT_TRUE(getSerializedData("dtd.html").startsWith(expectedStart));
+}
+
}
« no previous file with comments | « Source/core/page/PageSerializer.cpp ('k') | Source/web/tests/data/pageserializer/dtd/dtd.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698