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

Side by Side Diff: chrome/browser/cookies_tree_model_unittest.cc

Issue 10790150: Show Flash LSOs for Pepper Flash in cookie dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/cookies_tree_model.h" 5 #include "chrome/browser/cookies_tree_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/content_settings/cookie_settings.h" 10 #include "chrome/browser/content_settings/cookie_settings.h"
11 #include "chrome/browser/content_settings/host_content_settings_map.h" 11 #include "chrome/browser/content_settings/host_content_settings_map.h"
12 #include "chrome/browser/content_settings/mock_settings_observer.h" 12 #include "chrome/browser/content_settings/mock_settings_observer.h"
13 #include "chrome/browser/extensions/extension_special_storage_policy.h" 13 #include "chrome/browser/extensions/extension_special_storage_policy.h"
14 #include "chrome/browser/browsing_data/mock_browsing_data_appcache_helper.h" 14 #include "chrome/browser/browsing_data/mock_browsing_data_appcache_helper.h"
15 #include "chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h" 15 #include "chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h"
16 #include "chrome/browser/browsing_data/mock_browsing_data_database_helper.h" 16 #include "chrome/browser/browsing_data/mock_browsing_data_database_helper.h"
17 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h" 17 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h"
18 #include "chrome/browser/browsing_data/mock_browsing_data_flash_lso_helper.h"
18 #include "chrome/browser/browsing_data/mock_browsing_data_indexed_db_helper.h" 19 #include "chrome/browser/browsing_data/mock_browsing_data_indexed_db_helper.h"
19 #include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h " 20 #include "chrome/browser/browsing_data/mock_browsing_data_local_storage_helper.h "
20 #include "chrome/browser/browsing_data/mock_browsing_data_quota_helper.h" 21 #include "chrome/browser/browsing_data/mock_browsing_data_quota_helper.h"
21 #include "chrome/browser/browsing_data/mock_browsing_data_server_bound_cert_help er.h" 22 #include "chrome/browser/browsing_data/mock_browsing_data_server_bound_cert_help er.h"
22 #include "chrome/test/base/testing_profile.h" 23 #include "chrome/test/base/testing_profile.h"
23 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
24 #include "content/public/browser/notification_types.h" 25 #include "content/public/browser/notification_types.h"
25 #include "content/public/test/test_browser_thread.h" 26 #include "content/public/test/test_browser_thread.h"
26 #include "net/url_request/url_request_context.h" 27 #include "net/url_request/url_request_context.h"
27 #include "net/url_request/url_request_context_getter.h" 28 #include "net/url_request/url_request_context_getter.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 mock_browsing_data_appcache_helper_ = 64 mock_browsing_data_appcache_helper_ =
64 new MockBrowsingDataAppCacheHelper(profile_.get()); 65 new MockBrowsingDataAppCacheHelper(profile_.get());
65 mock_browsing_data_indexed_db_helper_ = 66 mock_browsing_data_indexed_db_helper_ =
66 new MockBrowsingDataIndexedDBHelper(); 67 new MockBrowsingDataIndexedDBHelper();
67 mock_browsing_data_file_system_helper_ = 68 mock_browsing_data_file_system_helper_ =
68 new MockBrowsingDataFileSystemHelper(profile_.get()); 69 new MockBrowsingDataFileSystemHelper(profile_.get());
69 mock_browsing_data_quota_helper_ = 70 mock_browsing_data_quota_helper_ =
70 new MockBrowsingDataQuotaHelper(profile_.get()); 71 new MockBrowsingDataQuotaHelper(profile_.get());
71 mock_browsing_data_server_bound_cert_helper_ = 72 mock_browsing_data_server_bound_cert_helper_ =
72 new MockBrowsingDataServerBoundCertHelper(); 73 new MockBrowsingDataServerBoundCertHelper();
74 mock_browsing_data_flash_lso_helper_ =
75 new MockBrowsingDataFlashLSOHelper(profile_.get());
73 76
74 // It is fine to reuse the profile request context for the app, since 77 // It is fine to reuse the profile request context for the app, since
75 // the mock cookie helper maintains its own list internally and doesn't 78 // the mock cookie helper maintains its own list internally and doesn't
76 // really use the request context. Same is true for the rest. 79 // really use the request context. Same is true for the rest.
77 mock_browsing_data_cookie_helper_app_ = 80 mock_browsing_data_cookie_helper_app_ =
78 new MockBrowsingDataCookieHelper(profile_->GetRequestContext()); 81 new MockBrowsingDataCookieHelper(profile_->GetRequestContext());
79 82
80 scoped_refptr<CookieSettings> cookie_settings = 83 scoped_refptr<CookieSettings> cookie_settings =
81 new CookieSettings(profile_->GetHostContentSettingsMap(), 84 new CookieSettings(profile_->GetHostContentSettingsMap(),
82 profile_->GetPrefs()); 85 profile_->GetPrefs());
83 special_storage_policy_ = 86 special_storage_policy_ =
84 new ExtensionSpecialStoragePolicy(cookie_settings); 87 new ExtensionSpecialStoragePolicy(cookie_settings);
85 } 88 }
86 89
87 virtual void TearDown() OVERRIDE { 90 virtual void TearDown() OVERRIDE {
88 mock_browsing_data_server_bound_cert_helper_ = NULL; 91 mock_browsing_data_server_bound_cert_helper_ = NULL;
89 mock_browsing_data_quota_helper_ = NULL; 92 mock_browsing_data_quota_helper_ = NULL;
90 mock_browsing_data_file_system_helper_ = NULL; 93 mock_browsing_data_file_system_helper_ = NULL;
91 mock_browsing_data_indexed_db_helper_ = NULL; 94 mock_browsing_data_indexed_db_helper_ = NULL;
92 mock_browsing_data_appcache_helper_ = NULL; 95 mock_browsing_data_appcache_helper_ = NULL;
93 mock_browsing_data_session_storage_helper_ = NULL; 96 mock_browsing_data_session_storage_helper_ = NULL;
94 mock_browsing_data_local_storage_helper_ = NULL; 97 mock_browsing_data_local_storage_helper_ = NULL;
95 mock_browsing_data_database_helper_ = NULL; 98 mock_browsing_data_database_helper_ = NULL;
99 mock_browsing_data_flash_lso_helper_ = NULL;
96 message_loop_.RunAllPending(); 100 message_loop_.RunAllPending();
97 } 101 }
98 102
99 scoped_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample( 103 scoped_ptr<CookiesTreeModel> CreateCookiesTreeModelWithInitialSample(
100 bool add_app) { 104 bool add_app) {
101 ContainerMap containers_map; 105 ContainerMap containers_map;
102 106
103 containers_map[std::string()] = new LocalDataContainer( 107 containers_map[std::string()] = new LocalDataContainer(
104 "Drive-By-Web", std::string(), 108 "Drive-By-Web", std::string(),
105 mock_browsing_data_cookie_helper_, 109 mock_browsing_data_cookie_helper_,
106 mock_browsing_data_database_helper_, 110 mock_browsing_data_database_helper_,
107 mock_browsing_data_local_storage_helper_, 111 mock_browsing_data_local_storage_helper_,
108 mock_browsing_data_session_storage_helper_, 112 mock_browsing_data_session_storage_helper_,
109 mock_browsing_data_appcache_helper_, 113 mock_browsing_data_appcache_helper_,
110 mock_browsing_data_indexed_db_helper_, 114 mock_browsing_data_indexed_db_helper_,
111 mock_browsing_data_file_system_helper_, 115 mock_browsing_data_file_system_helper_,
112 mock_browsing_data_quota_helper_, 116 mock_browsing_data_quota_helper_,
113 mock_browsing_data_server_bound_cert_helper_); 117 mock_browsing_data_server_bound_cert_helper_,
118 mock_browsing_data_flash_lso_helper_);
114 119
115 if (add_app) { 120 if (add_app) {
116 std::string app_id = "some-random-id"; 121 std::string app_id = "some-random-id";
117 // The cookie helper is mandatory, the rest can be NULL. 122 // The cookie helper is mandatory, the rest can be NULL.
118 containers_map[app_id] = new LocalDataContainer( 123 containers_map[app_id] = new LocalDataContainer(
119 "Isolated App", app_id, 124 "Isolated App", app_id,
120 mock_browsing_data_cookie_helper_app_, 125 mock_browsing_data_cookie_helper_app_,
121 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); 126 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
122 } 127 }
123 128
124 CookiesTreeModel* cookies_model = 129 CookiesTreeModel* cookies_model =
125 new CookiesTreeModel(containers_map, 130 new CookiesTreeModel(containers_map,
126 special_storage_policy_, 131 special_storage_policy_,
127 false); 132 false);
128 mock_browsing_data_cookie_helper_-> 133 mock_browsing_data_cookie_helper_->
129 AddCookieSamples(GURL("http://foo1"), "A=1"); 134 AddCookieSamples(GURL("http://foo1"), "A=1");
130 mock_browsing_data_cookie_helper_-> 135 mock_browsing_data_cookie_helper_->
131 AddCookieSamples(GURL("http://foo2"), "B=1"); 136 AddCookieSamples(GURL("http://foo2"), "B=1");
(...skipping 10 matching lines...) Expand all
142 mock_browsing_data_indexed_db_helper_->Notify(); 147 mock_browsing_data_indexed_db_helper_->Notify();
143 mock_browsing_data_file_system_helper_->AddFileSystemSamples(); 148 mock_browsing_data_file_system_helper_->AddFileSystemSamples();
144 mock_browsing_data_file_system_helper_->Notify(); 149 mock_browsing_data_file_system_helper_->Notify();
145 mock_browsing_data_quota_helper_->AddQuotaSamples(); 150 mock_browsing_data_quota_helper_->AddQuotaSamples();
146 mock_browsing_data_quota_helper_->Notify(); 151 mock_browsing_data_quota_helper_->Notify();
147 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( 152 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample(
148 "sbc1"); 153 "sbc1");
149 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample( 154 mock_browsing_data_server_bound_cert_helper_->AddServerBoundCertSample(
150 "sbc2"); 155 "sbc2");
151 mock_browsing_data_server_bound_cert_helper_->Notify(); 156 mock_browsing_data_server_bound_cert_helper_->Notify();
157 mock_browsing_data_flash_lso_helper_->AddFlashLSODomain("xyz.com");
158 mock_browsing_data_flash_lso_helper_->Notify();
152 159
153 if (add_app) { 160 if (add_app) {
154 mock_browsing_data_cookie_helper_app_-> 161 mock_browsing_data_cookie_helper_app_->
155 AddCookieSamples(GURL("http://app-origin1"), "Z=1"); 162 AddCookieSamples(GURL("http://app-origin1"), "Z=1");
156 mock_browsing_data_cookie_helper_app_-> 163 mock_browsing_data_cookie_helper_app_->
157 AddCookieSamples(GURL("http://app-origin2"), "Y=1"); 164 AddCookieSamples(GURL("http://app-origin2"), "Y=1");
158 mock_browsing_data_cookie_helper_app_-> 165 mock_browsing_data_cookie_helper_app_->
159 AddCookieSamples(GURL("http://app-origin3"), "X=1"); 166 AddCookieSamples(GURL("http://app-origin3"), "X=1");
160 mock_browsing_data_cookie_helper_app_->Notify(); 167 mock_browsing_data_cookie_helper_app_->Notify();
161 } 168 }
162 169
163 { 170 {
164 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, " 171 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, "
165 "2 session storages, 2 indexed DBs, 3 filesystems, " 172 "2 session storages, 2 indexed DBs, 3 filesystems, "
166 "2 quotas, 2 server bound certs"); 173 "2 quotas, 2 server bound certs, 1 Flash LSO");
167 // 51 because there's the root, then 174 // 51 because there's the root, then
168 // foo1 -> cookies -> a, 175 // foo1 -> cookies -> a,
169 // foo2 -> cookies -> b, 176 // foo2 -> cookies -> b,
170 // foo3 -> cookies -> c, 177 // foo3 -> cookies -> c,
171 // dbhost1 -> database -> db1, 178 // dbhost1 -> database -> db1,
172 // dbhost2 -> database -> db2, 179 // dbhost2 -> database -> db2,
173 // host1 -> localstorage -> http://host1:1/, 180 // host1 -> localstorage -> http://host1:1/,
174 // -> sessionstorage -> http://host1:1/, 181 // -> sessionstorage -> http://host1:1/,
175 // host2 -> localstorage -> http://host2:2/. 182 // host2 -> localstorage -> http://host2:2/.
176 // -> sessionstorage -> http://host2:2/, 183 // -> sessionstorage -> http://host2:2/,
177 // idbhost1 -> indexeddb -> http://idbhost1:1/, 184 // idbhost1 -> indexeddb -> http://idbhost1:1/,
178 // idbhost2 -> indexeddb -> http://idbhost2:2/, 185 // idbhost2 -> indexeddb -> http://idbhost2:2/,
179 // fshost1 -> filesystem -> http://fshost1:1/, 186 // fshost1 -> filesystem -> http://fshost1:1/,
180 // fshost2 -> filesystem -> http://fshost2:1/, 187 // fshost2 -> filesystem -> http://fshost2:1/,
181 // fshost3 -> filesystem -> http://fshost3:1/, 188 // fshost3 -> filesystem -> http://fshost3:1/,
182 // quotahost1 -> quotahost1, 189 // quotahost1 -> quotahost1,
183 // quotahost2 -> quotahost2, 190 // quotahost2 -> quotahost2,
184 // sbc1 -> sbcerts -> sbc1, 191 // sbc1 -> sbcerts -> sbc1,
185 // sbc2 -> sbcerts -> sbc2. 192 // sbc2 -> sbcerts -> sbc2.
193 // xyz.com -> flash_lsos
186 if (!add_app) { 194 if (!add_app) {
187 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount()); 195 EXPECT_EQ(53, cookies_model->GetRoot()->GetTotalNodeCount());
188 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model)); 196 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model));
189 } else { 197 } else {
190 // Once we add the app, we have 9 more nodes: 198 // Once we add the app, we have 9 more nodes:
191 // app-origin1 -> cookies -> z, 199 // app-origin1 -> cookies -> z,
192 // app-origin2 -> cookies -> y, 200 // app-origin2 -> cookies -> y,
193 // app-origin3 -> cookies -> x, 201 // app-origin3 -> cookies -> x,
194 EXPECT_EQ(60, cookies_model->GetRoot()->GetTotalNodeCount()); 202 EXPECT_EQ(62, cookies_model->GetRoot()->GetTotalNodeCount());
195 EXPECT_EQ("A,B,C,Z,Y,X", GetDisplayedCookies(cookies_model)); 203 EXPECT_EQ("A,B,C,Z,Y,X", GetDisplayedCookies(cookies_model));
196 } 204 }
197 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model)); 205 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model));
198 EXPECT_EQ("http://host1:1/,http://host2:2/", 206 EXPECT_EQ("http://host1:1/,http://host2:2/",
199 GetDisplayedLocalStorages(cookies_model)); 207 GetDisplayedLocalStorages(cookies_model));
200 EXPECT_EQ("http://host1:1/,http://host2:2/", 208 EXPECT_EQ("http://host1:1/,http://host2:2/",
201 GetDisplayedSessionStorages(cookies_model)); 209 GetDisplayedSessionStorages(cookies_model));
202 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 210 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
203 GetDisplayedIndexedDBs(cookies_model)); 211 GetDisplayedIndexedDBs(cookies_model));
204 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 212 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
205 GetDisplayedFileSystems(cookies_model)); 213 GetDisplayedFileSystems(cookies_model));
206 EXPECT_EQ("quotahost1,quotahost2", 214 EXPECT_EQ("quotahost1,quotahost2",
207 GetDisplayedQuotas(cookies_model)); 215 GetDisplayedQuotas(cookies_model));
208 EXPECT_EQ("sbc1,sbc2", 216 EXPECT_EQ("sbc1,sbc2",
209 GetDisplayedServerBoundCerts(cookies_model)); 217 GetDisplayedServerBoundCerts(cookies_model));
218 EXPECT_EQ("xyz.com",
219 GetDisplayedFlashLSOs(cookies_model));
210 } 220 }
211 return make_scoped_ptr(cookies_model); 221 return make_scoped_ptr(cookies_model);
212 } 222 }
213 223
214 std::string GetNodesOfChildren( 224 std::string GetNodesOfChildren(
215 const CookieTreeNode* node, 225 const CookieTreeNode* node,
216 CookieTreeNode::DetailedInfo::NodeType node_type) { 226 CookieTreeNode::DetailedInfo::NodeType node_type) {
217 if (!node->empty()) { 227 if (!node->empty()) {
218 std::string retval; 228 std::string retval;
219 for (int i = 0; i < node->child_count(); ++i) { 229 for (int i = 0; i < node->child_count(); ++i) {
(...skipping 23 matching lines...) Expand all
243 return node->GetDetailedInfo().indexed_db_info->origin.spec() + 253 return node->GetDetailedInfo().indexed_db_info->origin.spec() +
244 ","; 254 ",";
245 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM: 255 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM:
246 return node->GetDetailedInfo().file_system_info->origin.spec() + 256 return node->GetDetailedInfo().file_system_info->origin.spec() +
247 ","; 257 ",";
248 case CookieTreeNode::DetailedInfo::TYPE_QUOTA: 258 case CookieTreeNode::DetailedInfo::TYPE_QUOTA:
249 return node->GetDetailedInfo().quota_info->host + ","; 259 return node->GetDetailedInfo().quota_info->host + ",";
250 case CookieTreeNode::DetailedInfo::TYPE_SERVER_BOUND_CERT: 260 case CookieTreeNode::DetailedInfo::TYPE_SERVER_BOUND_CERT:
251 return node->GetDetailedInfo( 261 return node->GetDetailedInfo(
252 ).server_bound_cert->server_identifier() + ","; 262 ).server_bound_cert->server_identifier() + ",";
263 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO:
264 return node->GetDetailedInfo().flash_lso_domain + ",";
253 default: 265 default:
254 return std::string(); 266 return std::string();
255 } 267 }
256 } 268 }
257 269
258 std::string GetCookiesOfChildren(const CookieTreeNode* node) { 270 std::string GetCookiesOfChildren(const CookieTreeNode* node) {
259 return GetNodesOfChildren(node, CookieTreeNode::DetailedInfo::TYPE_COOKIE); 271 return GetNodesOfChildren(node, CookieTreeNode::DetailedInfo::TYPE_COOKIE);
260 } 272 }
261 273
262 std::string GetDatabasesOfChildren(const CookieTreeNode* node) { 274 std::string GetDatabasesOfChildren(const CookieTreeNode* node) {
(...skipping 19 matching lines...) Expand all
282 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) { 294 std::string GetFileSystemsOfChildren(const CookieTreeNode* node) {
283 return GetNodesOfChildren( 295 return GetNodesOfChildren(
284 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM); 296 node, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM);
285 } 297 }
286 298
287 std::string GetFileQuotaOfChildren(const CookieTreeNode* node) { 299 std::string GetFileQuotaOfChildren(const CookieTreeNode* node) {
288 return GetNodesOfChildren( 300 return GetNodesOfChildren(
289 node, CookieTreeNode::DetailedInfo::TYPE_QUOTA); 301 node, CookieTreeNode::DetailedInfo::TYPE_QUOTA);
290 } 302 }
291 303
304 std::string GetFlashLSOsOfChildren(const CookieTreeNode* node) {
305 return GetNodesOfChildren(
306 node, CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO);
307 }
308
292 // Get the nodes names displayed in the view (if we had one) in the order 309 // Get the nodes names displayed in the view (if we had one) in the order
293 // they are displayed, as a comma seperated string. 310 // they are displayed, as a comma seperated string.
294 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str()); 311 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str());
295 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model, 312 std::string GetDisplayedNodes(CookiesTreeModel* cookies_model,
296 CookieTreeNode::DetailedInfo::NodeType type) { 313 CookieTreeNode::DetailedInfo::NodeType type) {
297 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>( 314 CookieTreeRootNode* root = static_cast<CookieTreeRootNode*>(
298 cookies_model->GetRoot()); 315 cookies_model->GetRoot());
299 std::string retval = GetNodesOfChildren(root, type); 316 std::string retval = GetNodesOfChildren(root, type);
300 if (retval.length() && retval[retval.length() - 1] == ',') 317 if (retval.length() && retval[retval.length() - 1] == ',')
301 retval.erase(retval.length() - 1); 318 retval.erase(retval.length() - 1);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 std::string GetDisplayedQuotas(CookiesTreeModel* cookies_model) { 357 std::string GetDisplayedQuotas(CookiesTreeModel* cookies_model) {
341 return GetDisplayedNodes(cookies_model, 358 return GetDisplayedNodes(cookies_model,
342 CookieTreeNode::DetailedInfo::TYPE_QUOTA); 359 CookieTreeNode::DetailedInfo::TYPE_QUOTA);
343 } 360 }
344 361
345 std::string GetDisplayedServerBoundCerts(CookiesTreeModel* cookies_model) { 362 std::string GetDisplayedServerBoundCerts(CookiesTreeModel* cookies_model) {
346 return GetDisplayedNodes( 363 return GetDisplayedNodes(
347 cookies_model, CookieTreeNode::DetailedInfo::TYPE_SERVER_BOUND_CERT); 364 cookies_model, CookieTreeNode::DetailedInfo::TYPE_SERVER_BOUND_CERT);
348 } 365 }
349 366
367 std::string GetDisplayedFlashLSOs(CookiesTreeModel* cookies_model) {
368 return GetDisplayedNodes(
369 cookies_model, CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO);
370 }
371
350 // Do not call on the root. 372 // Do not call on the root.
351 void DeleteStoredObjects(CookieTreeNode* node) { 373 void DeleteStoredObjects(CookieTreeNode* node) {
352 node->DeleteStoredObjects(); 374 node->DeleteStoredObjects();
353 CookieTreeNode* parent_node = node->parent(); 375 CookieTreeNode* parent_node = node->parent();
354 DCHECK(parent_node); 376 DCHECK(parent_node);
355 delete parent_node->GetModel()->Remove(parent_node, node); 377 delete parent_node->GetModel()->Remove(parent_node, node);
356 } 378 }
357 379
358 protected: 380 protected:
359 MessageLoop message_loop_; 381 MessageLoop message_loop_;
(...skipping 13 matching lines...) Expand all
373 scoped_refptr<MockBrowsingDataAppCacheHelper> 395 scoped_refptr<MockBrowsingDataAppCacheHelper>
374 mock_browsing_data_appcache_helper_; 396 mock_browsing_data_appcache_helper_;
375 scoped_refptr<MockBrowsingDataIndexedDBHelper> 397 scoped_refptr<MockBrowsingDataIndexedDBHelper>
376 mock_browsing_data_indexed_db_helper_; 398 mock_browsing_data_indexed_db_helper_;
377 scoped_refptr<MockBrowsingDataFileSystemHelper> 399 scoped_refptr<MockBrowsingDataFileSystemHelper>
378 mock_browsing_data_file_system_helper_; 400 mock_browsing_data_file_system_helper_;
379 scoped_refptr<MockBrowsingDataQuotaHelper> 401 scoped_refptr<MockBrowsingDataQuotaHelper>
380 mock_browsing_data_quota_helper_; 402 mock_browsing_data_quota_helper_;
381 scoped_refptr<MockBrowsingDataServerBoundCertHelper> 403 scoped_refptr<MockBrowsingDataServerBoundCertHelper>
382 mock_browsing_data_server_bound_cert_helper_; 404 mock_browsing_data_server_bound_cert_helper_;
405 scoped_refptr<MockBrowsingDataFlashLSOHelper>
406 mock_browsing_data_flash_lso_helper_;
383 407
384 // App helpers. 408 // App helpers.
385 scoped_refptr<MockBrowsingDataCookieHelper> 409 scoped_refptr<MockBrowsingDataCookieHelper>
386 mock_browsing_data_cookie_helper_app_; 410 mock_browsing_data_cookie_helper_app_;
387 411
388 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_; 412 scoped_refptr<ExtensionSpecialStoragePolicy> special_storage_policy_;
389 }; 413 };
390 414
391 TEST_F(CookiesTreeModelTest, RemoveAll) { 415 TEST_F(CookiesTreeModelTest, RemoveAll) {
392 scoped_ptr<CookiesTreeModel> cookies_model( 416 scoped_ptr<CookiesTreeModel> cookies_model(
(...skipping 11 matching lines...) Expand all
404 EXPECT_EQ("http://host1:1/,http://host2:2/", 428 EXPECT_EQ("http://host1:1/,http://host2:2/",
405 GetDisplayedSessionStorages(cookies_model.get())); 429 GetDisplayedSessionStorages(cookies_model.get()));
406 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 430 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
407 GetDisplayedIndexedDBs(cookies_model.get())); 431 GetDisplayedIndexedDBs(cookies_model.get()));
408 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 432 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
409 GetDisplayedFileSystems(cookies_model.get())); 433 GetDisplayedFileSystems(cookies_model.get()));
410 EXPECT_EQ("quotahost1,quotahost2", 434 EXPECT_EQ("quotahost1,quotahost2",
411 GetDisplayedQuotas(cookies_model.get())); 435 GetDisplayedQuotas(cookies_model.get()));
412 EXPECT_EQ("sbc1,sbc2", 436 EXPECT_EQ("sbc1,sbc2",
413 GetDisplayedServerBoundCerts(cookies_model.get())); 437 GetDisplayedServerBoundCerts(cookies_model.get()));
438 EXPECT_EQ("xyz.com",
439 GetDisplayedFlashLSOs(cookies_model.get()));
414 } 440 }
415 441
416 mock_browsing_data_cookie_helper_->Reset(); 442 mock_browsing_data_cookie_helper_->Reset();
417 mock_browsing_data_database_helper_->Reset(); 443 mock_browsing_data_database_helper_->Reset();
418 mock_browsing_data_local_storage_helper_->Reset(); 444 mock_browsing_data_local_storage_helper_->Reset();
419 mock_browsing_data_session_storage_helper_->Reset(); 445 mock_browsing_data_session_storage_helper_->Reset();
420 mock_browsing_data_indexed_db_helper_->Reset(); 446 mock_browsing_data_indexed_db_helper_->Reset();
421 mock_browsing_data_file_system_helper_->Reset(); 447 mock_browsing_data_file_system_helper_->Reset();
422 448
423 cookies_model->DeleteAllStoredObjects(); 449 cookies_model->DeleteAllStoredObjects();
424 450
425 // Make sure the nodes are also deleted from the model's cache. 451 // Make sure the nodes are also deleted from the model's cache.
426 // http://crbug.com/43249 452 // http://crbug.com/43249
427 cookies_model->UpdateSearchResults(string16()); 453 cookies_model->UpdateSearchResults(string16());
428 454
429 { 455 {
430 // 2 nodes - root and app 456 // 2 nodes - root and app
431 SCOPED_TRACE("After removing"); 457 SCOPED_TRACE("After removing");
432 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount()); 458 EXPECT_EQ(1, cookies_model->GetRoot()->GetTotalNodeCount());
433 EXPECT_EQ(0, cookies_model->GetRoot()->child_count()); 459 EXPECT_EQ(0, cookies_model->GetRoot()->child_count());
434 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get())); 460 EXPECT_EQ(std::string(""), GetDisplayedCookies(cookies_model.get()));
435 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted()); 461 EXPECT_TRUE(mock_browsing_data_cookie_helper_->AllDeleted());
436 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted()); 462 EXPECT_TRUE(mock_browsing_data_database_helper_->AllDeleted());
437 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted()); 463 EXPECT_TRUE(mock_browsing_data_local_storage_helper_->AllDeleted());
438 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted()); 464 EXPECT_FALSE(mock_browsing_data_session_storage_helper_->AllDeleted());
439 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted()); 465 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_->AllDeleted());
440 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted()); 466 EXPECT_TRUE(mock_browsing_data_file_system_helper_->AllDeleted());
441 EXPECT_TRUE(mock_browsing_data_server_bound_cert_helper_->AllDeleted()); 467 EXPECT_TRUE(mock_browsing_data_server_bound_cert_helper_->AllDeleted());
468 EXPECT_TRUE(mock_browsing_data_flash_lso_helper_->AllDeleted());
442 } 469 }
443 } 470 }
444 471
445 TEST_F(CookiesTreeModelTest, Remove) { 472 TEST_F(CookiesTreeModelTest, Remove) {
446 scoped_ptr<CookiesTreeModel> cookies_model( 473 scoped_ptr<CookiesTreeModel> cookies_model(
447 CreateCookiesTreeModelWithInitialSample(false)); 474 CreateCookiesTreeModelWithInitialSample(false));
448 475
449 // Children start out arranged as follows: 476 // Children start out arranged as follows:
450 // 477 //
451 // 0. `foo1` 478 // 0. `foo1`
452 // 1. `foo2` 479 // 1. `foo2`
453 // 2. `foo3` 480 // 2. `foo3`
454 // 3. `fshost1` 481 // 3. `fshost1`
455 // 4. `fshost2` 482 // 4. `fshost2`
456 // 5. `fshost3` 483 // 5. `fshost3`
457 // 6. `gdbhost1` 484 // 6. `gdbhost1`
458 // 7. `gdbhost2` 485 // 7. `gdbhost2`
459 // 8. `host1` 486 // 8. `host1`
460 // 9. `host2` 487 // 9. `host2`
461 // 10. `idbhost1` 488 // 10. `idbhost1`
462 // 11. `idbhost2` 489 // 11. `idbhost2`
463 // 12. `quotahost1` 490 // 12. `quotahost1`
464 // 13. `quotahost2` 491 // 13. `quotahost2`
465 // 14. `sbc1` 492 // 14. `sbc1`
466 // 15. `sbc2` 493 // 15. `sbc2`
494 // 16. `xyz.com`
467 // 495 //
468 // Here, we'll remove them one by one, starting from the end, and 496 // Here, we'll remove them one by one, starting from the end, and
469 // check that the state makes sense. 497 // check that the state makes sense.
470 498
499 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(16));
500 {
501 SCOPED_TRACE("`xyz.com` removed.");
502 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
503 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
504 EXPECT_EQ("http://host1:1/,http://host2:2/",
505 GetDisplayedLocalStorages(cookies_model.get()));
506 EXPECT_EQ("http://host1:1/,http://host2:2/",
507 GetDisplayedSessionStorages(cookies_model.get()));
508 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
509 GetDisplayedFileSystems(cookies_model.get()));
510 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
511 GetDisplayedIndexedDBs(cookies_model.get()));
512 EXPECT_EQ("quotahost1,quotahost2",
513 GetDisplayedQuotas(cookies_model.get()));
514 EXPECT_EQ("sbc1,sbc2",
515 GetDisplayedServerBoundCerts(cookies_model.get()));
516 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount());
517 }
471 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(15)); 518 DeleteStoredObjects(cookies_model->GetRoot()->GetChild(15));
472 { 519 {
473 SCOPED_TRACE("`sbc2` removed."); 520 SCOPED_TRACE("`sbc2` removed.");
474 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str()); 521 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model.get()).c_str());
475 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); 522 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
476 EXPECT_EQ("http://host1:1/,http://host2:2/", 523 EXPECT_EQ("http://host1:1/,http://host2:2/",
477 GetDisplayedLocalStorages(cookies_model.get())); 524 GetDisplayedLocalStorages(cookies_model.get()));
478 EXPECT_EQ("http://host1:1/,http://host2:2/", 525 EXPECT_EQ("http://host1:1/,http://host2:2/",
479 GetDisplayedSessionStorages(cookies_model.get())); 526 GetDisplayedSessionStorages(cookies_model.get()));
480 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 527 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 734
688 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) { 735 TEST_F(CookiesTreeModelTest, RemoveCookiesNode) {
689 scoped_ptr<CookiesTreeModel> cookies_model( 736 scoped_ptr<CookiesTreeModel> cookies_model(
690 CreateCookiesTreeModelWithInitialSample(false)); 737 CreateCookiesTreeModelWithInitialSample(false));
691 738
692 DeleteStoredObjects( 739 DeleteStoredObjects(
693 cookies_model->GetRoot()->GetChild(0)->GetChild(0)); 740 cookies_model->GetRoot()->GetChild(0)->GetChild(0));
694 { 741 {
695 SCOPED_TRACE("First origin removed"); 742 SCOPED_TRACE("First origin removed");
696 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); 743 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
697 // 49 because in this case, the origin remains, although the COOKIES 744 // 51 because in this case, the origin remains, although the COOKIES
698 // node beneath it has been deleted. 745 // node beneath it has been deleted.
699 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); 746 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount());
700 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); 747 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
701 EXPECT_EQ("http://host1:1/,http://host2:2/", 748 EXPECT_EQ("http://host1:1/,http://host2:2/",
702 GetDisplayedLocalStorages(cookies_model.get())); 749 GetDisplayedLocalStorages(cookies_model.get()));
703 EXPECT_EQ("http://host1:1/,http://host2:2/", 750 EXPECT_EQ("http://host1:1/,http://host2:2/",
704 GetDisplayedSessionStorages(cookies_model.get())); 751 GetDisplayedSessionStorages(cookies_model.get()));
705 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 752 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
706 GetDisplayedIndexedDBs(cookies_model.get())); 753 GetDisplayedIndexedDBs(cookies_model.get()));
707 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 754 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
708 GetDisplayedFileSystems(cookies_model.get())); 755 GetDisplayedFileSystems(cookies_model.get()));
709 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); 756 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
710 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); 757 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
711 } 758 }
712 759
713 DeleteStoredObjects( 760 DeleteStoredObjects(
714 cookies_model->GetRoot()->GetChild(6)->GetChild(0)); 761 cookies_model->GetRoot()->GetChild(6)->GetChild(0));
715 { 762 {
716 SCOPED_TRACE("First database removed"); 763 SCOPED_TRACE("First database removed");
717 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); 764 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
718 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); 765 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
719 EXPECT_EQ("http://host1:1/,http://host2:2/", 766 EXPECT_EQ("http://host1:1/,http://host2:2/",
720 GetDisplayedLocalStorages(cookies_model.get())); 767 GetDisplayedLocalStorages(cookies_model.get()));
721 EXPECT_EQ("http://host1:1/,http://host2:2/", 768 EXPECT_EQ("http://host1:1/,http://host2:2/",
722 GetDisplayedSessionStorages(cookies_model.get())); 769 GetDisplayedSessionStorages(cookies_model.get()));
723 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 770 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
724 GetDisplayedIndexedDBs(cookies_model.get())); 771 GetDisplayedIndexedDBs(cookies_model.get()));
725 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 772 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
726 GetDisplayedFileSystems(cookies_model.get())); 773 GetDisplayedFileSystems(cookies_model.get()));
727 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); 774 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
728 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); 775 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
729 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); 776 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount());
730 } 777 }
731 778
732 DeleteStoredObjects( 779 DeleteStoredObjects(
733 cookies_model->GetRoot()->GetChild(8)->GetChild(0)); 780 cookies_model->GetRoot()->GetChild(8)->GetChild(0));
734 { 781 {
735 SCOPED_TRACE("First origin removed"); 782 SCOPED_TRACE("First origin removed");
736 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str()); 783 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model.get()).c_str());
737 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); 784 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
738 EXPECT_EQ("http://host2:2/", 785 EXPECT_EQ("http://host2:2/",
739 GetDisplayedLocalStorages(cookies_model.get())); 786 GetDisplayedLocalStorages(cookies_model.get()));
740 EXPECT_EQ("http://host1:1/,http://host2:2/", 787 EXPECT_EQ("http://host1:1/,http://host2:2/",
741 GetDisplayedSessionStorages(cookies_model.get())); 788 GetDisplayedSessionStorages(cookies_model.get()));
742 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 789 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
743 GetDisplayedIndexedDBs(cookies_model.get())); 790 GetDisplayedIndexedDBs(cookies_model.get()));
744 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 791 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
745 GetDisplayedFileSystems(cookies_model.get())); 792 GetDisplayedFileSystems(cookies_model.get()));
746 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); 793 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
747 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); 794 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
748 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); 795 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount());
749 } 796 }
750 } 797 }
751 798
752 TEST_F(CookiesTreeModelTest, RemoveCookieNode) { 799 TEST_F(CookiesTreeModelTest, RemoveCookieNode) {
753 scoped_ptr<CookiesTreeModel> cookies_model( 800 scoped_ptr<CookiesTreeModel> cookies_model(
754 CreateCookiesTreeModelWithInitialSample(false)); 801 CreateCookiesTreeModelWithInitialSample(false));
755 802
756 DeleteStoredObjects( 803 DeleteStoredObjects(
757 cookies_model->GetRoot()->GetChild(1)->GetChild(0)); 804 cookies_model->GetRoot()->GetChild(1)->GetChild(0));
758 { 805 {
759 SCOPED_TRACE("Second origin COOKIES node removed"); 806 SCOPED_TRACE("Second origin COOKIES node removed");
760 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); 807 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
761 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get())); 808 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model.get()));
762 EXPECT_EQ("http://host1:1/,http://host2:2/", 809 EXPECT_EQ("http://host1:1/,http://host2:2/",
763 GetDisplayedLocalStorages(cookies_model.get())); 810 GetDisplayedLocalStorages(cookies_model.get()));
764 EXPECT_EQ("http://host1:1/,http://host2:2/", 811 EXPECT_EQ("http://host1:1/,http://host2:2/",
765 GetDisplayedSessionStorages(cookies_model.get())); 812 GetDisplayedSessionStorages(cookies_model.get()));
766 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 813 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
767 GetDisplayedIndexedDBs(cookies_model.get())); 814 GetDisplayedIndexedDBs(cookies_model.get()));
768 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 815 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
769 GetDisplayedFileSystems(cookies_model.get())); 816 GetDisplayedFileSystems(cookies_model.get()));
770 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); 817 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
771 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); 818 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
772 // 49 because in this case, the origin remains, although the COOKIES 819 // 51 because in this case, the origin remains, although the COOKIES
773 // node beneath it has been deleted. 820 // node beneath it has been deleted.
774 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount()); 821 EXPECT_EQ(51, cookies_model->GetRoot()->GetTotalNodeCount());
775 } 822 }
776 823
777 DeleteStoredObjects( 824 DeleteStoredObjects(
778 cookies_model->GetRoot()->GetChild(6)->GetChild(0)); 825 cookies_model->GetRoot()->GetChild(6)->GetChild(0));
779 { 826 {
780 SCOPED_TRACE("First database removed"); 827 SCOPED_TRACE("First database removed");
781 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); 828 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
782 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); 829 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
783 EXPECT_EQ("http://host1:1/,http://host2:2/", 830 EXPECT_EQ("http://host1:1/,http://host2:2/",
784 GetDisplayedLocalStorages(cookies_model.get())); 831 GetDisplayedLocalStorages(cookies_model.get()));
785 EXPECT_EQ("http://host1:1/,http://host2:2/", 832 EXPECT_EQ("http://host1:1/,http://host2:2/",
786 GetDisplayedSessionStorages(cookies_model.get())); 833 GetDisplayedSessionStorages(cookies_model.get()));
787 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 834 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
788 GetDisplayedIndexedDBs(cookies_model.get())); 835 GetDisplayedIndexedDBs(cookies_model.get()));
789 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 836 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
790 GetDisplayedFileSystems(cookies_model.get())); 837 GetDisplayedFileSystems(cookies_model.get()));
791 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); 838 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
792 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); 839 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
793 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount()); 840 EXPECT_EQ(49, cookies_model->GetRoot()->GetTotalNodeCount());
794 } 841 }
795 842
796 DeleteStoredObjects( 843 DeleteStoredObjects(
797 cookies_model->GetRoot()->GetChild(8)->GetChild(0)); 844 cookies_model->GetRoot()->GetChild(8)->GetChild(0));
798 { 845 {
799 SCOPED_TRACE("First origin removed"); 846 SCOPED_TRACE("First origin removed");
800 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str()); 847 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model.get()).c_str());
801 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get())); 848 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model.get()));
802 EXPECT_EQ("http://host2:2/", 849 EXPECT_EQ("http://host2:2/",
803 GetDisplayedLocalStorages(cookies_model.get())); 850 GetDisplayedLocalStorages(cookies_model.get()));
804 EXPECT_EQ("http://host1:1/,http://host2:2/", 851 EXPECT_EQ("http://host1:1/,http://host2:2/",
805 GetDisplayedSessionStorages(cookies_model.get())); 852 GetDisplayedSessionStorages(cookies_model.get()));
806 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/", 853 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
807 GetDisplayedIndexedDBs(cookies_model.get())); 854 GetDisplayedIndexedDBs(cookies_model.get()));
808 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/", 855 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
809 GetDisplayedFileSystems(cookies_model.get())); 856 GetDisplayedFileSystems(cookies_model.get()));
810 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get())); 857 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model.get()));
811 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get())); 858 EXPECT_EQ("sbc1,sbc2", GetDisplayedServerBoundCerts(cookies_model.get()));
812 EXPECT_EQ(45, cookies_model->GetRoot()->GetTotalNodeCount()); 859 EXPECT_EQ(47, cookies_model->GetRoot()->GetTotalNodeCount());
813 } 860 }
814 } 861 }
815 862
816 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) { 863 TEST_F(CookiesTreeModelTest, RemoveSingleCookieNode) {
817 ContainerMap container_map; 864 ContainerMap container_map;
818 865
819 container_map[std::string()] = new LocalDataContainer( 866 container_map[std::string()] = new LocalDataContainer(
820 "Drive-By-Web", std::string(), 867 "Drive-By-Web", std::string(),
821 mock_browsing_data_cookie_helper_, 868 mock_browsing_data_cookie_helper_,
822 mock_browsing_data_database_helper_, 869 mock_browsing_data_database_helper_,
823 mock_browsing_data_local_storage_helper_, 870 mock_browsing_data_local_storage_helper_,
824 mock_browsing_data_session_storage_helper_, 871 mock_browsing_data_session_storage_helper_,
825 mock_browsing_data_appcache_helper_, 872 mock_browsing_data_appcache_helper_,
826 mock_browsing_data_indexed_db_helper_, 873 mock_browsing_data_indexed_db_helper_,
827 mock_browsing_data_file_system_helper_, 874 mock_browsing_data_file_system_helper_,
828 mock_browsing_data_quota_helper_, 875 mock_browsing_data_quota_helper_,
829 mock_browsing_data_server_bound_cert_helper_); 876 mock_browsing_data_server_bound_cert_helper_,
877 mock_browsing_data_flash_lso_helper_);
830 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); 878 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false);
831 879
832 mock_browsing_data_cookie_helper_-> 880 mock_browsing_data_cookie_helper_->
833 AddCookieSamples(GURL("http://foo1"), "A=1"); 881 AddCookieSamples(GURL("http://foo1"), "A=1");
834 mock_browsing_data_cookie_helper_-> 882 mock_browsing_data_cookie_helper_->
835 AddCookieSamples(GURL("http://foo2"), "B=1"); 883 AddCookieSamples(GURL("http://foo2"), "B=1");
836 mock_browsing_data_cookie_helper_-> 884 mock_browsing_data_cookie_helper_->
837 AddCookieSamples(GURL("http://foo3"), "C=1"); 885 AddCookieSamples(GURL("http://foo3"), "C=1");
838 mock_browsing_data_cookie_helper_-> 886 mock_browsing_data_cookie_helper_->
839 AddCookieSamples(GURL("http://foo3"), "D=1"); 887 AddCookieSamples(GURL("http://foo3"), "D=1");
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 container_map[std::string()] = new LocalDataContainer( 957 container_map[std::string()] = new LocalDataContainer(
910 "Drive-By-Web", std::string(), 958 "Drive-By-Web", std::string(),
911 mock_browsing_data_cookie_helper_, 959 mock_browsing_data_cookie_helper_,
912 mock_browsing_data_database_helper_, 960 mock_browsing_data_database_helper_,
913 mock_browsing_data_local_storage_helper_, 961 mock_browsing_data_local_storage_helper_,
914 mock_browsing_data_session_storage_helper_, 962 mock_browsing_data_session_storage_helper_,
915 mock_browsing_data_appcache_helper_, 963 mock_browsing_data_appcache_helper_,
916 mock_browsing_data_indexed_db_helper_, 964 mock_browsing_data_indexed_db_helper_,
917 mock_browsing_data_file_system_helper_, 965 mock_browsing_data_file_system_helper_,
918 mock_browsing_data_quota_helper_, 966 mock_browsing_data_quota_helper_,
919 mock_browsing_data_server_bound_cert_helper_); 967 mock_browsing_data_server_bound_cert_helper_,
968 mock_browsing_data_flash_lso_helper_);
920 CookiesTreeModel cookies_model(container_map, special_storage_policy_,false); 969 CookiesTreeModel cookies_model(container_map, special_storage_policy_,false);
921 970
922 mock_browsing_data_cookie_helper_-> 971 mock_browsing_data_cookie_helper_->
923 AddCookieSamples(GURL("http://foo1"), "A=1"); 972 AddCookieSamples(GURL("http://foo1"), "A=1");
924 mock_browsing_data_cookie_helper_-> 973 mock_browsing_data_cookie_helper_->
925 AddCookieSamples(GURL("http://foo2"), "B=1"); 974 AddCookieSamples(GURL("http://foo2"), "B=1");
926 mock_browsing_data_cookie_helper_-> 975 mock_browsing_data_cookie_helper_->
927 AddCookieSamples(GURL("http://foo3"), "C=1"); 976 AddCookieSamples(GURL("http://foo3"), "C=1");
928 mock_browsing_data_cookie_helper_-> 977 mock_browsing_data_cookie_helper_->
929 AddCookieSamples(GURL("http://foo3"), "D=1"); 978 AddCookieSamples(GURL("http://foo3"), "D=1");
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1002 container_map[std::string()] = new LocalDataContainer( 1051 container_map[std::string()] = new LocalDataContainer(
1003 "Drive-By-Web", std::string(), 1052 "Drive-By-Web", std::string(),
1004 mock_browsing_data_cookie_helper_, 1053 mock_browsing_data_cookie_helper_,
1005 mock_browsing_data_database_helper_, 1054 mock_browsing_data_database_helper_,
1006 mock_browsing_data_local_storage_helper_, 1055 mock_browsing_data_local_storage_helper_,
1007 mock_browsing_data_session_storage_helper_, 1056 mock_browsing_data_session_storage_helper_,
1008 mock_browsing_data_appcache_helper_, 1057 mock_browsing_data_appcache_helper_,
1009 mock_browsing_data_indexed_db_helper_, 1058 mock_browsing_data_indexed_db_helper_,
1010 mock_browsing_data_file_system_helper_, 1059 mock_browsing_data_file_system_helper_,
1011 mock_browsing_data_quota_helper_, 1060 mock_browsing_data_quota_helper_,
1012 mock_browsing_data_server_bound_cert_helper_); 1061 mock_browsing_data_server_bound_cert_helper_,
1062 mock_browsing_data_flash_lso_helper_);
1013 CookiesTreeModel cookies_model(container_map, special_storage_policy_,false); 1063 CookiesTreeModel cookies_model(container_map, special_storage_policy_,false);
1014 1064
1015 mock_browsing_data_cookie_helper_-> 1065 mock_browsing_data_cookie_helper_->
1016 AddCookieSamples(GURL("http://foo1"), "A=1"); 1066 AddCookieSamples(GURL("http://foo1"), "A=1");
1017 mock_browsing_data_cookie_helper_-> 1067 mock_browsing_data_cookie_helper_->
1018 AddCookieSamples(GURL("http://foo2"), "B=1"); 1068 AddCookieSamples(GURL("http://foo2"), "B=1");
1019 mock_browsing_data_cookie_helper_-> 1069 mock_browsing_data_cookie_helper_->
1020 AddCookieSamples(GURL("http://foo3"), "C=1"); 1070 AddCookieSamples(GURL("http://foo3"), "C=1");
1021 mock_browsing_data_cookie_helper_-> 1071 mock_browsing_data_cookie_helper_->
1022 AddCookieSamples(GURL("http://foo3"), "D=1"); 1072 AddCookieSamples(GURL("http://foo3"), "D=1");
(...skipping 23 matching lines...) Expand all
1046 container_map[std::string()] = new LocalDataContainer( 1096 container_map[std::string()] = new LocalDataContainer(
1047 "Drive-By-Web", std::string(), 1097 "Drive-By-Web", std::string(),
1048 mock_browsing_data_cookie_helper_, 1098 mock_browsing_data_cookie_helper_,
1049 mock_browsing_data_database_helper_, 1099 mock_browsing_data_database_helper_,
1050 mock_browsing_data_local_storage_helper_, 1100 mock_browsing_data_local_storage_helper_,
1051 mock_browsing_data_session_storage_helper_, 1101 mock_browsing_data_session_storage_helper_,
1052 mock_browsing_data_appcache_helper_, 1102 mock_browsing_data_appcache_helper_,
1053 mock_browsing_data_indexed_db_helper_, 1103 mock_browsing_data_indexed_db_helper_,
1054 mock_browsing_data_file_system_helper_, 1104 mock_browsing_data_file_system_helper_,
1055 mock_browsing_data_quota_helper_, 1105 mock_browsing_data_quota_helper_,
1056 mock_browsing_data_server_bound_cert_helper_); 1106 mock_browsing_data_server_bound_cert_helper_,
1107 mock_browsing_data_flash_lso_helper_);
1057 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); 1108 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false);
1058 1109
1059 mock_browsing_data_cookie_helper_-> 1110 mock_browsing_data_cookie_helper_->
1060 AddCookieSamples(GURL("http://a.foo2.com"), "A=1"); 1111 AddCookieSamples(GURL("http://a.foo2.com"), "A=1");
1061 mock_browsing_data_cookie_helper_-> 1112 mock_browsing_data_cookie_helper_->
1062 AddCookieSamples(GURL("http://foo2.com"), "B=1"); 1113 AddCookieSamples(GURL("http://foo2.com"), "B=1");
1063 mock_browsing_data_cookie_helper_-> 1114 mock_browsing_data_cookie_helper_->
1064 AddCookieSamples(GURL("http://b.foo1.com"), "C=1"); 1115 AddCookieSamples(GURL("http://b.foo1.com"), "C=1");
1065 // Leading dot on the foo4 1116 // Leading dot on the foo4
1066 mock_browsing_data_cookie_helper_->AddCookieSamples( 1117 mock_browsing_data_cookie_helper_->AddCookieSamples(
(...skipping 15 matching lines...) Expand all
1082 GetDisplayedCookies(&cookies_model).c_str()); 1133 GetDisplayedCookies(&cookies_model).c_str());
1083 } 1134 }
1084 // Delete "E" 1135 // Delete "E"
1085 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1)); 1136 DeleteStoredObjects(cookies_model.GetRoot()->GetChild(1));
1086 { 1137 {
1087 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str()); 1138 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model).c_str());
1088 } 1139 }
1089 } 1140 }
1090 1141
1091 TEST_F(CookiesTreeModelTest, ContentSettings) { 1142 TEST_F(CookiesTreeModelTest, ContentSettings) {
1092 GURL host("http://example.com/"); 1143 GURL host("http://xyz.com/");
1093 std::string name = "Drive-By-Web"; 1144 std::string name = "Drive-By-Web";
1094 std::string browser_id; 1145 std::string browser_id;
1095 ContainerMap container_map; 1146 ContainerMap container_map;
1096 1147
1097 container_map[browser_id] = new LocalDataContainer( 1148 container_map[browser_id] = new LocalDataContainer(
1098 name, browser_id, 1149 name, browser_id,
1099 mock_browsing_data_cookie_helper_, 1150 mock_browsing_data_cookie_helper_,
1100 mock_browsing_data_database_helper_, 1151 mock_browsing_data_database_helper_,
1101 mock_browsing_data_local_storage_helper_, 1152 mock_browsing_data_local_storage_helper_,
1102 mock_browsing_data_session_storage_helper_, 1153 mock_browsing_data_session_storage_helper_,
1103 mock_browsing_data_appcache_helper_, 1154 mock_browsing_data_appcache_helper_,
1104 mock_browsing_data_indexed_db_helper_, 1155 mock_browsing_data_indexed_db_helper_,
1105 mock_browsing_data_file_system_helper_, 1156 mock_browsing_data_file_system_helper_,
1106 mock_browsing_data_quota_helper_, 1157 mock_browsing_data_quota_helper_,
1107 mock_browsing_data_server_bound_cert_helper_); 1158 mock_browsing_data_server_bound_cert_helper_,
1159 mock_browsing_data_flash_lso_helper_);
1108 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); 1160 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false);
1109 1161
1110 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1"); 1162 mock_browsing_data_cookie_helper_->AddCookieSamples(host, "A=1");
1111 mock_browsing_data_cookie_helper_->Notify(); 1163 mock_browsing_data_cookie_helper_->Notify();
1112 1164
1113 TestingProfile profile; 1165 TestingProfile profile;
1114 HostContentSettingsMap* content_settings = 1166 HostContentSettingsMap* content_settings =
1115 profile.GetHostContentSettingsMap(); 1167 profile.GetHostContentSettingsMap();
1116 CookieSettings* cookie_settings = 1168 CookieSettings* cookie_settings =
1117 CookieSettings::Factory::GetForProfile(&profile); 1169 CookieSettings::Factory::GetForProfile(&profile);
(...skipping 25 matching lines...) Expand all
1143 cookie_settings, CONTENT_SETTING_SESSION_ONLY); 1195 cookie_settings, CONTENT_SETTING_SESSION_ONLY);
1144 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(host, host)); 1196 EXPECT_TRUE(cookie_settings->IsReadingCookieAllowed(host, host));
1145 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host)); 1197 EXPECT_TRUE(cookie_settings->IsCookieSessionOnly(host));
1146 } 1198 }
1147 1199
1148 TEST_F(CookiesTreeModelTest, AppOriginTitle) { 1200 TEST_F(CookiesTreeModelTest, AppOriginTitle) {
1149 scoped_ptr<CookiesTreeModel> cookies_model( 1201 scoped_ptr<CookiesTreeModel> cookies_model(
1150 CreateCookiesTreeModelWithInitialSample(true)); 1202 CreateCookiesTreeModelWithInitialSample(true));
1151 1203
1152 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin1"), 1204 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin1"),
1153 cookies_model->GetRoot()->GetChild(16)->GetTitle()); 1205 cookies_model->GetRoot()->GetChild(17)->GetTitle());
1154 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin2"), 1206 EXPECT_EQ(ASCIIToUTF16("Isolated App, app-origin2"),
1155 cookies_model->GetRoot()->GetChild(17)->GetTitle()); 1207 cookies_model->GetRoot()->GetChild(18)->GetTitle());
1156 } 1208 }
1157 1209
1158 TEST_F(CookiesTreeModelTest, FileSystemFilter) { 1210 TEST_F(CookiesTreeModelTest, FileSystemFilter) {
1159 scoped_ptr<CookiesTreeModel> cookies_model( 1211 scoped_ptr<CookiesTreeModel> cookies_model(
1160 CreateCookiesTreeModelWithInitialSample(false)); 1212 CreateCookiesTreeModelWithInitialSample(false));
1161 1213
1162 cookies_model->UpdateSearchResults(ASCIIToUTF16("fshost1")); 1214 cookies_model->UpdateSearchResults(ASCIIToUTF16("fshost1"));
1163 EXPECT_EQ("http://fshost1:1/", 1215 EXPECT_EQ("http://fshost1:1/",
1164 GetDisplayedFileSystems(cookies_model.get())); 1216 GetDisplayedFileSystems(cookies_model.get()));
1165 1217
(...skipping 16 matching lines...) Expand all
1182 container_map[std::string()] = new LocalDataContainer( 1234 container_map[std::string()] = new LocalDataContainer(
1183 "Drive-By-Web", std::string(), 1235 "Drive-By-Web", std::string(),
1184 mock_browsing_data_cookie_helper_, 1236 mock_browsing_data_cookie_helper_,
1185 mock_browsing_data_database_helper_, 1237 mock_browsing_data_database_helper_,
1186 mock_browsing_data_local_storage_helper_, 1238 mock_browsing_data_local_storage_helper_,
1187 mock_browsing_data_session_storage_helper_, 1239 mock_browsing_data_session_storage_helper_,
1188 mock_browsing_data_appcache_helper_, 1240 mock_browsing_data_appcache_helper_,
1189 mock_browsing_data_indexed_db_helper_, 1241 mock_browsing_data_indexed_db_helper_,
1190 mock_browsing_data_file_system_helper_, 1242 mock_browsing_data_file_system_helper_,
1191 mock_browsing_data_quota_helper_, 1243 mock_browsing_data_quota_helper_,
1192 mock_browsing_data_server_bound_cert_helper_); 1244 mock_browsing_data_server_bound_cert_helper_,
1245 mock_browsing_data_flash_lso_helper_);
1193 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false); 1246 CookiesTreeModel cookies_model(container_map, special_storage_policy_, false);
1194 1247
1195 mock_browsing_data_cookie_helper_-> 1248 mock_browsing_data_cookie_helper_->
1196 AddCookieSamples(GURL("http://123.com"), "A=1"); 1249 AddCookieSamples(GURL("http://123.com"), "A=1");
1197 mock_browsing_data_cookie_helper_-> 1250 mock_browsing_data_cookie_helper_->
1198 AddCookieSamples(GURL("http://foo1.com"), "B=1"); 1251 AddCookieSamples(GURL("http://foo1.com"), "B=1");
1199 mock_browsing_data_cookie_helper_-> 1252 mock_browsing_data_cookie_helper_->
1200 AddCookieSamples(GURL("http://foo2.com"), "C=1"); 1253 AddCookieSamples(GURL("http://foo2.com"), "C=1");
1201 mock_browsing_data_cookie_helper_-> 1254 mock_browsing_data_cookie_helper_->
1202 AddCookieSamples(GURL("http://foo3.com"), "D=1"); 1255 AddCookieSamples(GURL("http://foo3.com"), "D=1");
1203 mock_browsing_data_cookie_helper_->Notify(); 1256 mock_browsing_data_cookie_helper_->Notify();
1204 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); 1257 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model));
1205 1258
1206 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo"))); 1259 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo")));
1207 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model)); 1260 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model));
1208 1261
1209 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2"))); 1262 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("2")));
1210 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model)); 1263 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model));
1211 1264
1212 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3"))); 1265 cookies_model.UpdateSearchResults(string16(ASCIIToUTF16("foo3")));
1213 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model)); 1266 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model));
1214 1267
1215 cookies_model.UpdateSearchResults(string16()); 1268 cookies_model.UpdateSearchResults(string16());
1216 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model)); 1269 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model));
1217 } 1270 }
1218 1271
1219 } // namespace 1272 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698