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

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

Issue 1398453005: Make WebPageSerializerImpl to escape URL attribute values in result. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2015-10-13T17:56:56 Rebase Created 5 years, 2 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
Index: third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp b/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
index 0c2821a8cfcdc0d54a4725388dc3fdaef386d99d..afc35c70e12af2d68fb2a723defbb3db9176c244 100644
--- a/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
+++ b/third_party/WebKit/Source/web/tests/WebPageSerializerTest.cpp
@@ -151,6 +151,27 @@ TEST_F(WebPageSerializerTest, HTMLNodes)
EXPECT_TRUE(webVectorContains(resources, "file://c/my_folder/file.gif"));
}
+TEST_F(WebPageSerializerTest, URLAttributeValues)
+{
+ WebURL topFrameURL = toKURL("http://www.test.com");
+ registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("url_attribute_values.html"));
+ loadURLInTopFrame(topFrameURL);
+
+ SimpleWebPageSerializerClient serializerClient;
+ WebVector<WebURL> links(&topFrameURL, 1);
+ WebVector<WebString> localPaths(&"local", 1);
+ WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &serializerClient, links, localPaths, "");
+
+ const char* expectedHTML =
+ "\n<!-- saved from url=(0020)http://www.test.com/ -->\n"
+ "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><meta charset=\"utf8\">\n"
+ "</head><body><img src=\"javascript:&quot;\">\n"
+ "<a href=\"http://www.test.com/local#&quot;\">local</a>\n"
+ "<a href=\"http://www.example.com/#&quot;&gt;&lt;script&gt;alert(0)&lt;/script&gt;\">external</a>\n"
+ "</body></html>";
+ EXPECT_EQ(expectedHTML, serializerClient.toString());
+}
+
TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus)
{
WebURL topFrameURL = toKURL("http://www.test.com?--x--");

Powered by Google App Engine
This is Rietveld 408576698