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

Side by Side Diff: third_party/WebKit/Source/web/tests/FrameSerializerTest.cpp

Issue 2410693002: Add a few more edge cases to CSS serialization test. (Closed)
Patch Set: Adds the case of a CSS already being included in another frame. Created 4 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) 2013, Opera Software ASA. All rights reserved. 2 * Copyright (c) 2013, Opera Software ASA. 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 response.setHTTPStatusCode(statusCode); 98 response.setHTTPStatusCode(statusCode);
99 99
100 Platform::current()->getURLLoaderMockFactory()->registerErrorURL( 100 Platform::current()->getURLLoaderMockFactory()->registerErrorURL(
101 KURL(m_baseUrl, file), response, error); 101 KURL(m_baseUrl, file), response, error);
102 } 102 }
103 103
104 void registerRewriteURL(const char* fromURL, const char* toURL) { 104 void registerRewriteURL(const char* fromURL, const char* toURL) {
105 m_rewriteURLs.add(fromURL, toURL); 105 m_rewriteURLs.add(fromURL, toURL);
106 } 106 }
107 107
108 void registerSkipURL(const char* url) {
109 m_skipURLs.append(KURL(m_baseUrl, url));
110 }
111
108 void serialize(const char* url) { 112 void serialize(const char* url) {
109 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(), 113 FrameTestHelpers::loadFrame(m_helper.webView()->mainFrame(),
110 KURL(m_baseUrl, url).getString().utf8().data()); 114 KURL(m_baseUrl, url).getString().utf8().data());
111 FrameSerializer serializer(m_resources, *this); 115 FrameSerializer serializer(m_resources, *this);
112 Frame* frame = m_helper.webView()->mainFrameImpl()->frame(); 116 Frame* frame = m_helper.webView()->mainFrameImpl()->frame();
113 for (; frame; frame = frame->tree().traverseNext()) { 117 for (; frame; frame = frame->tree().traverseNext()) {
114 // This is safe, because tests do not do cross-site navigation 118 // This is safe, because tests do not do cross-site navigation
115 // (and therefore don't have remote frames). 119 // (and therefore don't have remote frames).
116 serializer.serializeFrame(*toLocalFrame(frame)); 120 serializer.serializeFrame(*toLocalFrame(frame));
117 } 121 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return false; 168 return false;
165 169
166 StringBuilder uriBuilder; 170 StringBuilder uriBuilder;
167 uriBuilder.append(m_rewriteFolder); 171 uriBuilder.append(m_rewriteFolder);
168 uriBuilder.append('/'); 172 uriBuilder.append('/');
169 uriBuilder.append(m_rewriteURLs.get(completeURL)); 173 uriBuilder.append(m_rewriteURLs.get(completeURL));
170 rewrittenLink = uriBuilder.toString(); 174 rewrittenLink = uriBuilder.toString();
171 return true; 175 return true;
172 } 176 }
173 177
178 bool shouldSkipResourceWithURL(const KURL& url) {
179 return m_skipURLs.contains(url);
180 }
181
174 FrameTestHelpers::WebViewHelper m_helper; 182 FrameTestHelpers::WebViewHelper m_helper;
175 WebString m_folder; 183 WebString m_folder;
176 KURL m_baseUrl; 184 KURL m_baseUrl;
177 Vector<SerializedResource> m_resources; 185 Vector<SerializedResource> m_resources;
178 HashMap<String, String> m_rewriteURLs; 186 HashMap<String, String> m_rewriteURLs;
187 Vector<String> m_skipURLs;
179 String m_rewriteFolder; 188 String m_rewriteFolder;
180 }; 189 };
181 190
182 TEST_F(FrameSerializerTest, HTMLElements) { 191 TEST_F(FrameSerializerTest, HTMLElements) {
183 setBaseFolder("frameserializer/elements/"); 192 setBaseFolder("frameserializer/elements/");
184 193
185 registerURL("elements.html", "text/html"); 194 registerURL("elements.html", "text/html");
186 registerURL("style.css", "style.css", "text/css"); 195 registerURL("style.css", "style.css", "text/css");
187 registerURL("copyright.html", "empty.txt", "text/html"); 196 registerURL("copyright.html", "empty.txt", "text/html");
188 registerURL("script.js", "empty.txt", "text/javascript"); 197 registerURL("script.js", "empty.txt", "text/javascript");
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 registerURL("orange_background.png", "image.png", "image/png"); 338 registerURL("orange_background.png", "image.png", "image/png");
330 registerURL("yellow_background.png", "image.png", "image/png"); 339 registerURL("yellow_background.png", "image.png", "image/png");
331 registerURL("green_background.png", "image.png", "image/png"); 340 registerURL("green_background.png", "image.png", "image/png");
332 registerURL("blue_background.png", "image.png", "image/png"); 341 registerURL("blue_background.png", "image.png", "image/png");
333 registerURL("purple_background.png", "image.png", "image/png"); 342 registerURL("purple_background.png", "image.png", "image/png");
334 registerURL("pink_background.png", "image.png", "image/png"); 343 registerURL("pink_background.png", "image.png", "image/png");
335 registerURL("brown_background.png", "image.png", "image/png"); 344 registerURL("brown_background.png", "image.png", "image/png");
336 registerURL("ul-dot.png", "image.png", "image/png"); 345 registerURL("ul-dot.png", "image.png", "image/png");
337 registerURL("ol-dot.png", "image.png", "image/png"); 346 registerURL("ol-dot.png", "image.png", "image/png");
338 347
348 registerURL("included_in_another_frame.css", "text/css");
349 registerSkipURL("included_in_another_frame.css");
350
339 serialize("css_test_page.html"); 351 serialize("css_test_page.html");
340 352
341 EXPECT_EQ(15U, getResources().size()); 353 EXPECT_EQ(15U, getResources().size());
342 354
343 EXPECT_FALSE(isSerialized("do_not_serialize.png", "image/png")); 355 EXPECT_FALSE(isSerialized("do_not_serialize.png", "image/png"));
356 EXPECT_FALSE(isSerialized("included_in_another_frame.css", "text/css"));
344 357
345 EXPECT_TRUE(isSerialized("css_test_page.html", "text/html")); 358 EXPECT_TRUE(isSerialized("css_test_page.html", "text/html"));
346 EXPECT_TRUE(isSerialized("link_styles.css", "text/css")); 359 EXPECT_TRUE(isSerialized("link_styles.css", "text/css"));
347 EXPECT_TRUE(isSerialized("encoding.css", "text/css")); 360 EXPECT_TRUE(isSerialized("encoding.css", "text/css"));
348 EXPECT_TRUE(isSerialized("import_styles.css", "text/css")); 361 EXPECT_TRUE(isSerialized("import_styles.css", "text/css"));
349 EXPECT_TRUE(isSerialized("import_style_from_link.css", "text/css")); 362 EXPECT_TRUE(isSerialized("import_style_from_link.css", "text/css"));
350 EXPECT_TRUE(isSerialized("red_background.png", "image/png")); 363 EXPECT_TRUE(isSerialized("red_background.png", "image/png"));
351 EXPECT_TRUE(isSerialized("orange_background.png", "image/png")); 364 EXPECT_TRUE(isSerialized("orange_background.png", "image/png"));
352 EXPECT_TRUE(isSerialized("yellow_background.png", "image/png")); 365 EXPECT_TRUE(isSerialized("yellow_background.png", "image/png"));
353 EXPECT_TRUE(isSerialized("green_background.png", "image/png")); 366 EXPECT_TRUE(isSerialized("green_background.png", "image/png"));
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 KURL(ParsedURLString, "http://foo.com?--"))); 539 KURL(ParsedURLString, "http://foo.com?--")));
527 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D", 540 EXPECT_EQ("saved from url=(0020)http://foo.com/#-%2D",
528 FrameSerializer::markOfTheWebDeclaration( 541 FrameSerializer::markOfTheWebDeclaration(
529 KURL(ParsedURLString, "http://foo.com#--"))); 542 KURL(ParsedURLString, "http://foo.com#--")));
530 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz", 543 EXPECT_EQ("saved from url=(0026)http://foo.com/#bar-%2Dbaz",
531 FrameSerializer::markOfTheWebDeclaration( 544 FrameSerializer::markOfTheWebDeclaration(
532 KURL(ParsedURLString, "http://foo.com#bar--baz"))); 545 KURL(ParsedURLString, "http://foo.com#bar--baz")));
533 } 546 }
534 547
535 } // namespace blink 548 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698