Chromium Code Reviews| Index: chrome/browser/history/history_backend_unittest.cc |
| diff --git a/chrome/browser/history/history_backend_unittest.cc b/chrome/browser/history/history_backend_unittest.cc |
| index 9840e09f2ac30fa493dec43bdb2ae1c9a7272709..9e2e1e46953b0ba51dcefc5e6313e0144b6de673 100644 |
| --- a/chrome/browser/history/history_backend_unittest.cc |
| +++ b/chrome/browser/history/history_backend_unittest.cc |
| @@ -1134,4 +1134,36 @@ TEST_F(HistoryBackendTest, GetFaviconForURL) { |
| EXPECT_EQ(icon_url, favicon.icon_url); |
| EXPECT_EQ(blob_data, touchicon_data); |
| } |
| + |
| +TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { |
| + const GURL url("http://www.google.com/"); |
| + const GURL icon_url("http://www.google.com/icon"); |
| + const GURL same_domain_url("http://www.google.com/subdir/index.html"); |
| + const GURL foreign_domain_url("http://www.not-google.com/"); |
| + |
|
sky
2011/11/17 04:49:01
nit: remove one line.
groby-ooo-7-16
2011/11/18 01:11:19
Done.
|
| + |
| + // Add a favicon |
| + std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); |
| + scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(data)); |
| + backend_->SetFavicon( |
| + url, icon_url, bytes.get(), FAVICON); |
| + EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( |
| + url, FAVICON, NULL)); |
| + |
| + // Validate starting state. |
| + FaviconData favicon; |
| + EXPECT_TRUE(backend_->GetFaviconFromDB(url, FAVICON, &favicon)); |
| + EXPECT_FALSE(backend_->GetFaviconFromDB(same_domain_url, FAVICON, &favicon)); |
| + EXPECT_FALSE(backend_->GetFaviconFromDB(foreign_domain_url, |
| + FAVICON, &favicon)); |
| + |
| + // Same-domain cloning should work. |
| + backend_->CloneFavicon(url, same_domain_url); |
| + EXPECT_TRUE(backend_->GetFaviconFromDB(same_domain_url, FAVICON, &favicon)); |
| + |
| + // Foreign-domain cloning is forbidden. |
| + backend_->CloneFavicon(url, foreign_domain_url); |
| + EXPECT_FALSE(backend_->GetFaviconFromDB(foreign_domain_url, |
| + FAVICON, &favicon)); |
| +} |
| } // namespace history |