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

Unified Diff: chrome/renderer/chrome_content_renderer_client_unittest.cc

Issue 13375003: Fixing iframe jank in the local omnibox popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressing comments. Created 7 years, 8 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: chrome/renderer/chrome_content_renderer_client_unittest.cc
diff --git a/chrome/renderer/chrome_content_renderer_client_unittest.cc b/chrome/renderer/chrome_content_renderer_client_unittest.cc
index b099eea5a6f62b857835b5b26ae3dbcf6e51cbd3..029f18671d0de7566ab05726f47450d5553639bf 100644
--- a/chrome/renderer/chrome_content_renderer_client_unittest.cc
+++ b/chrome/renderer/chrome_content_renderer_client_unittest.cc
@@ -342,4 +342,34 @@ TEST_F(ChromeContentRendererClientTest, IsRequestOSFileHandleAllowedForURL) {
GURL("filesystem:http://192.168.0.1/foo")));
}
+TEST_F(ChromeContentRendererClientTest, SetOriginForSuggestionRequest) {
+ ChromeContentRendererClient client;
+ // The origin parameter should be set from top_url.
+ EXPECT_EQ(GURL("chrome-search://suggestion/result.js?"
+ "origin=http://sanity.example.com"),
+ client.SetOriginForSuggestionRequest(
+ GURL("chrome-search://suggestion/result.js"),
+ GURL("http://sanity.example.com")));
+ // Any existing &origin parameter should be replaced by origin=top_url.
+ EXPECT_EQ(GURL("chrome-search://suggestion/result.js?"
+ "origin=http://evil.example.com"),
+ client.SetOriginForSuggestionRequest(
+ GURL("chrome-search://suggestion/result.js?"
+ "origin=http://good.example.com/"),
+ GURL("http://evil.example.com")));
+ // Multiple &origin parameters should also be replaced by origin=top_url.
+ EXPECT_EQ(GURL("chrome-search://suggestion/result.js?"
+ "origin=http://evil.example.com"),
+ client.SetOriginForSuggestionRequest(
+ GURL("chrome-search://suggestion/result.js?"
+ "origin=http://good.example.com/&"
+ "origin=http://better.example.com"),
+ GURL("http://evil.example.com")));
+ // A malformed top_url should result in an empty origin.
+ EXPECT_EQ(GURL("chrome-search://suggestion/result.js?origin="),
+ client.SetOriginForSuggestionRequest(
+ GURL("chrome-search://suggestion/result.js"),
+ GURL("\"<script>alert('evil')</script>")));
+}
+
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698