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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/trBackground.p ng")); 144 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/trBackground.p ng"));
145 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/tdBackground.p ng")); 145 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/tdBackground.p ng"));
146 EXPECT_TRUE(webVectorContains(resources, "http://www.evene.fr/citations/aute ur.php?ida=46")); 146 EXPECT_TRUE(webVectorContains(resources, "http://www.evene.fr/citations/aute ur.php?ida=46"));
147 EXPECT_TRUE(webVectorContains(resources, "http://www.brainyquote.com/quotes/ authors/c/charles_darwin.html")); 147 EXPECT_TRUE(webVectorContains(resources, "http://www.brainyquote.com/quotes/ authors/c/charles_darwin.html"));
148 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/why_deleted.ht ml")); 148 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/why_deleted.ht ml"));
149 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/why_inserted.h tml")); 149 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/why_inserted.h tml"));
150 EXPECT_TRUE(webVectorContains(resources, "https://www.secure.com/https.gif") ); 150 EXPECT_TRUE(webVectorContains(resources, "https://www.secure.com/https.gif") );
151 EXPECT_TRUE(webVectorContains(resources, "file://c/my_folder/file.gif")); 151 EXPECT_TRUE(webVectorContains(resources, "file://c/my_folder/file.gif"));
152 } 152 }
153 153
154 TEST_F(WebPageSerializerTest, URLAttributeValues)
155 {
156 WebURL topFrameURL = toKURL("http://www.test.com");
157 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("url_attribute _values.html"));
158 loadURLInTopFrame(topFrameURL);
159
160 SimpleWebPageSerializerClient serializerClient;
161 WebVector<WebURL> links(&topFrameURL, 1);
162 WebVector<WebString> localPaths(&"local", 1);
163 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient, links, localPaths, "");
164
165 const char* expectedHTML =
166 "\n<!-- saved from url=(0020)http://www.test.com/ -->\n"
167 "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; char set=UTF-8\"><meta charset=\"utf8\">\n"
168 "</head><body><img src=\"javascript:&quot;\">\n"
169 "<a href=\"http://www.test.com/local#&quot;\">local</a>\n"
170 "<a href=\"http://www.example.com/#&quot;&gt;&lt;script&gt;alert(0)&lt;/ script&gt;\">external</a>\n"
171 "</body></html>";
172 EXPECT_EQ(expectedHTML, serializerClient.toString());
173 }
174
154 TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus) 175 TEST_F(WebPageSerializerTest, fromUrlWithMinusMinus)
155 { 176 {
156 WebURL topFrameURL = toKURL("http://www.test.com?--x--"); 177 WebURL topFrameURL = toKURL("http://www.test.com?--x--");
157 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_pag e.html")); 178 registerMockedURLLoad(topFrameURL.spec(), WebString::fromUTF8("text_only_pag e.html"));
158 loadURLInTopFrame(topFrameURL); 179 loadURLInTopFrame(topFrameURL);
159 180
160 SimpleWebPageSerializerClient serializerClient; 181 SimpleWebPageSerializerClient serializerClient;
161 WebVector<WebURL> links(&topFrameURL, 1); 182 WebVector<WebURL> links(&topFrameURL, 1);
162 WebVector<WebString> localPaths(&"local", 1); 183 WebVector<WebString> localPaths(&"local", 1);
163 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient, links, localPaths, ""); 184 WebPageSerializer::serialize(webView()->mainFrame()->toWebLocalFrame(), &ser ializerClient, links, localPaths, "");
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png ")); 223 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/innerFrame.png "));
203 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf")); 224 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/flash.swf"));
204 // FIXME: for some reason the following resources is missing on one of the b ot 225 // FIXME: for some reason the following resources is missing on one of the b ot
205 // causing the test to fail. Probably a plugin issue. 226 // causing the test to fail. Probably a plugin issue.
206 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") ); 227 // EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/music.mid") );
207 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png")); 228 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/object.png"));
208 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png")); 229 EXPECT_TRUE(webVectorContains(resources, "http://www.test.com/embed.png"));
209 } 230 }
210 231
211 } // namespace blink 232 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698