OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <set> | 5 #include <set> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 // Test the touch icon for this URL. | 1127 // Test the touch icon for this URL. |
1128 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); | 1128 ASSERT_TRUE(backend_->GetFaviconFromDB(url, TOUCH_ICON, &favicon)); |
1129 std::string touchicon_data( | 1129 std::string touchicon_data( |
1130 favicon.image_data->front(), | 1130 favicon.image_data->front(), |
1131 favicon.image_data->front() + favicon.image_data->size()); | 1131 favicon.image_data->front() + favicon.image_data->size()); |
1132 | 1132 |
1133 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); | 1133 EXPECT_EQ(TOUCH_ICON, favicon.icon_type); |
1134 EXPECT_EQ(icon_url, favicon.icon_url); | 1134 EXPECT_EQ(icon_url, favicon.icon_url); |
1135 EXPECT_EQ(blob_data, touchicon_data); | 1135 EXPECT_EQ(blob_data, touchicon_data); |
1136 } | 1136 } |
| 1137 |
| 1138 TEST_F(HistoryBackendTest, CloneFaviconIsRestrictedToSameDomain) { |
| 1139 const GURL url("http://www.google.com/"); |
| 1140 const GURL icon_url("http://www.google.com/icon"); |
| 1141 const GURL same_domain_url("http://www.google.com/subdir/index.html"); |
| 1142 const GURL foreign_domain_url("http://www.not-google.com/"); |
| 1143 |
| 1144 // Add a favicon |
| 1145 std::vector<unsigned char> data(blob1, blob1 + sizeof(blob1)); |
| 1146 scoped_refptr<RefCountedBytes> bytes(new RefCountedBytes(data)); |
| 1147 backend_->SetFavicon( |
| 1148 url, icon_url, bytes.get(), FAVICON); |
| 1149 EXPECT_TRUE(backend_->thumbnail_db_->GetIconMappingForPageURL( |
| 1150 url, FAVICON, NULL)); |
| 1151 |
| 1152 // Validate starting state. |
| 1153 FaviconData favicon; |
| 1154 EXPECT_TRUE(backend_->GetFaviconFromDB(url, FAVICON, &favicon)); |
| 1155 EXPECT_FALSE(backend_->GetFaviconFromDB(same_domain_url, FAVICON, &favicon)); |
| 1156 EXPECT_FALSE(backend_->GetFaviconFromDB(foreign_domain_url, |
| 1157 FAVICON, &favicon)); |
| 1158 |
| 1159 // Same-domain cloning should work. |
| 1160 backend_->CloneFavicon(url, same_domain_url); |
| 1161 EXPECT_TRUE(backend_->GetFaviconFromDB(same_domain_url, FAVICON, &favicon)); |
| 1162 |
| 1163 // Foreign-domain cloning is forbidden. |
| 1164 backend_->CloneFavicon(url, foreign_domain_url); |
| 1165 EXPECT_FALSE(backend_->GetFaviconFromDB(foreign_domain_url, |
| 1166 FAVICON, &favicon)); |
| 1167 } |
1137 } // namespace history | 1168 } // namespace history |
OLD | NEW |