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
3 // found in the LICENSE file.
5 #include "chrome/browser/browsing_data/cookies_tree_model.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browsing_data/mock_browsing_data_appcache_helper.h"
13 #include "chrome/browser/browsing_data/mock_browsing_data_channel_id_helper.h"
14 #include "chrome/browser/browsing_data/mock_browsing_data_cookie_helper.h"
15 #include "chrome/browser/browsing_data/mock_browsing_data_database_helper.h"
16 #include "chrome/browser/browsing_data/mock_browsing_data_file_system_helper.h"
17 #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_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_service_worker_helper.h"
22 #include "chrome/browser/content_settings/cookie_settings_factory.h"
23 #include "chrome/browser/content_settings/mock_settings_observer.h"
24 #include "chrome/test/base/testing_profile.h"
25 #include "components/content_settings/core/browser/cookie_settings.h"
26 #include "components/content_settings/core/browser/host_content_settings_map.h"
27 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_types.h"
30 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "net/url_request/url_request_context.h"
32 #include "net/url_request/url_request_context_getter.h"
33 #include "testing/gtest/include/gtest/gtest.h"
35 #if defined(ENABLE_EXTENSIONS)
36 #include "chrome/browser/extensions/extension_special_storage_policy.h"
40 using content::BrowserThread
;
44 class CookiesTreeModelTest
: public testing::Test
{
46 ~CookiesTreeModelTest() override
{
47 // Avoid memory leaks.
48 #if defined(ENABLE_EXTENSIONS)
49 special_storage_policy_
= nullptr;
52 base::MessageLoop::current()->RunUntilIdle();
55 void SetUp() override
{
56 profile_
.reset(new TestingProfile());
57 mock_browsing_data_cookie_helper_
=
58 new MockBrowsingDataCookieHelper(profile_
->GetRequestContext());
59 mock_browsing_data_database_helper_
=
60 new MockBrowsingDataDatabaseHelper(profile_
.get());
61 mock_browsing_data_local_storage_helper_
=
62 new MockBrowsingDataLocalStorageHelper(profile_
.get());
63 mock_browsing_data_session_storage_helper_
=
64 new MockBrowsingDataLocalStorageHelper(profile_
.get());
65 mock_browsing_data_appcache_helper_
=
66 new MockBrowsingDataAppCacheHelper(profile_
.get());
67 mock_browsing_data_indexed_db_helper_
=
68 new MockBrowsingDataIndexedDBHelper(profile_
.get());
69 mock_browsing_data_file_system_helper_
=
70 new MockBrowsingDataFileSystemHelper(profile_
.get());
71 mock_browsing_data_quota_helper_
=
72 new MockBrowsingDataQuotaHelper(profile_
.get());
73 mock_browsing_data_channel_id_helper_
=
74 new MockBrowsingDataChannelIDHelper();
75 mock_browsing_data_service_worker_helper_
=
76 new MockBrowsingDataServiceWorkerHelper(profile_
.get());
77 mock_browsing_data_flash_lso_helper_
=
78 new MockBrowsingDataFlashLSOHelper(profile_
.get());
80 const char kExtensionScheme
[] = "extensionscheme";
81 scoped_refptr
<content_settings::CookieSettings
> cookie_settings
=
82 new content_settings::CookieSettings(
83 profile_
->GetHostContentSettingsMap(), profile_
->GetPrefs(),
85 #if defined(ENABLE_EXTENSIONS)
86 special_storage_policy_
=
87 new ExtensionSpecialStoragePolicy(cookie_settings
.get());
91 void TearDown() override
{
92 mock_browsing_data_service_worker_helper_
= nullptr;
93 mock_browsing_data_channel_id_helper_
= nullptr;
94 mock_browsing_data_quota_helper_
= nullptr;
95 mock_browsing_data_file_system_helper_
= nullptr;
96 mock_browsing_data_indexed_db_helper_
= nullptr;
97 mock_browsing_data_appcache_helper_
= nullptr;
98 mock_browsing_data_session_storage_helper_
= nullptr;
99 mock_browsing_data_local_storage_helper_
= nullptr;
100 mock_browsing_data_database_helper_
= nullptr;
101 mock_browsing_data_flash_lso_helper_
= nullptr;
102 base::MessageLoop::current()->RunUntilIdle();
105 scoped_ptr
<CookiesTreeModel
> CreateCookiesTreeModelWithInitialSample() {
106 LocalDataContainer
* container
= new LocalDataContainer(
107 mock_browsing_data_cookie_helper_
.get(),
108 mock_browsing_data_database_helper_
.get(),
109 mock_browsing_data_local_storage_helper_
.get(),
110 mock_browsing_data_session_storage_helper_
.get(),
111 mock_browsing_data_appcache_helper_
.get(),
112 mock_browsing_data_indexed_db_helper_
.get(),
113 mock_browsing_data_file_system_helper_
.get(),
114 mock_browsing_data_quota_helper_
.get(),
115 mock_browsing_data_channel_id_helper_
.get(),
116 mock_browsing_data_service_worker_helper_
.get(),
117 mock_browsing_data_flash_lso_helper_
.get());
119 CookiesTreeModel
* cookies_model
=
120 new CookiesTreeModel(container
, special_storage_policy(), false);
121 mock_browsing_data_cookie_helper_
->
122 AddCookieSamples(GURL("http://foo1"), "A=1");
123 mock_browsing_data_cookie_helper_
->
124 AddCookieSamples(GURL("http://foo2"), "B=1");
125 mock_browsing_data_cookie_helper_
->
126 AddCookieSamples(GURL("http://foo3"), "C=1");
127 mock_browsing_data_cookie_helper_
->Notify();
128 mock_browsing_data_database_helper_
->AddDatabaseSamples();
129 mock_browsing_data_database_helper_
->Notify();
130 mock_browsing_data_local_storage_helper_
->AddLocalStorageSamples();
131 mock_browsing_data_local_storage_helper_
->Notify();
132 mock_browsing_data_session_storage_helper_
->AddLocalStorageSamples();
133 mock_browsing_data_session_storage_helper_
->Notify();
134 mock_browsing_data_indexed_db_helper_
->AddIndexedDBSamples();
135 mock_browsing_data_indexed_db_helper_
->Notify();
136 mock_browsing_data_file_system_helper_
->AddFileSystemSamples();
137 mock_browsing_data_file_system_helper_
->Notify();
138 mock_browsing_data_quota_helper_
->AddQuotaSamples();
139 mock_browsing_data_quota_helper_
->Notify();
140 mock_browsing_data_channel_id_helper_
->AddChannelIDSample(
142 mock_browsing_data_channel_id_helper_
->AddChannelIDSample(
144 mock_browsing_data_channel_id_helper_
->Notify();
145 mock_browsing_data_service_worker_helper_
->AddServiceWorkerSamples();
146 mock_browsing_data_service_worker_helper_
->Notify();
147 mock_browsing_data_flash_lso_helper_
->AddFlashLSODomain("xyz.com");
148 mock_browsing_data_flash_lso_helper_
->Notify();
151 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, "
152 "2 session storages, 2 indexed DBs, 3 filesystems, "
153 "2 quotas, 2 server bound certs, 2 service workers, "
155 // 59 because there's the root, then
156 // foo1 -> cookies -> a,
157 // foo2 -> cookies -> b,
158 // foo3 -> cookies -> c,
159 // dbhost1 -> database -> db1,
160 // dbhost2 -> database -> db2,
161 // host1 -> localstorage -> http://host1:1/,
162 // -> sessionstorage -> http://host1:1/,
163 // host2 -> localstorage -> http://host2:2/.
164 // -> sessionstorage -> http://host2:2/,
165 // idbhost1 -> indexeddb -> http://idbhost1:1/,
166 // idbhost2 -> indexeddb -> http://idbhost2:2/,
167 // fshost1 -> filesystem -> http://fshost1:1/,
168 // fshost2 -> filesystem -> http://fshost2:1/,
169 // fshost3 -> filesystem -> http://fshost3:1/,
170 // quotahost1 -> quotahost1,
171 // quotahost2 -> quotahost2,
172 // sbc1 -> sbcerts -> sbc1,
173 // sbc2 -> sbcerts -> sbc2.
174 // swhost1 -> service worker -> https://swhost1:1
175 // swhost2 -> service worker -> https://swhost1:2
176 // xyz.com -> flash_lsos
177 EXPECT_EQ(59, cookies_model
->GetRoot()->GetTotalNodeCount());
178 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model
));
179 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
));
180 EXPECT_EQ("http://host1:1/,http://host2:2/",
181 GetDisplayedLocalStorages(cookies_model
));
182 EXPECT_EQ("http://host1:1/,http://host2:2/",
183 GetDisplayedSessionStorages(cookies_model
));
184 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
185 GetDisplayedIndexedDBs(cookies_model
));
186 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
187 GetDisplayedFileSystems(cookies_model
));
188 EXPECT_EQ("quotahost1,quotahost2",
189 GetDisplayedQuotas(cookies_model
));
190 EXPECT_EQ("sbc1,sbc2",
191 GetDisplayedChannelIDs(cookies_model
));
192 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
193 GetDisplayedServiceWorkers(cookies_model
));
195 GetDisplayedFlashLSOs(cookies_model
));
197 return make_scoped_ptr(cookies_model
);
200 std::string
GetNodesOfChildren(
201 const CookieTreeNode
* node
,
202 CookieTreeNode::DetailedInfo::NodeType node_type
) {
203 if (!node
->empty()) {
205 for (int i
= 0; i
< node
->child_count(); ++i
) {
206 retval
+= GetNodesOfChildren(node
->GetChild(i
), node_type
);
211 if (node
->GetDetailedInfo().node_type
!= node_type
)
212 return std::string();
215 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE
:
216 return node
->GetDetailedInfo().session_storage_info
->origin_url
.spec() +
218 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE
:
219 return node
->GetDetailedInfo().local_storage_info
->origin_url
.spec() +
221 case CookieTreeNode::DetailedInfo::TYPE_DATABASE
:
222 return node
->GetDetailedInfo().database_info
->database_name
+ ",";
223 case CookieTreeNode::DetailedInfo::TYPE_COOKIE
:
224 return node
->GetDetailedInfo().cookie
->Name() + ",";
225 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE
:
226 return node
->GetDetailedInfo().appcache_info
->manifest_url
.spec() +
228 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB
:
229 return node
->GetDetailedInfo().indexed_db_info
->origin_
.spec() +
231 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM
:
232 return node
->GetDetailedInfo().file_system_info
->origin
.spec() +
234 case CookieTreeNode::DetailedInfo::TYPE_QUOTA
:
235 return node
->GetDetailedInfo().quota_info
->host
+ ",";
236 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID
:
237 return node
->GetDetailedInfo().channel_id
->server_identifier() + ",";
238 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER
:
239 return node
->GetDetailedInfo().service_worker_info
->origin
.spec() + ",";
240 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO
:
241 return node
->GetDetailedInfo().flash_lso_domain
+ ",";
243 return std::string();
247 std::string
GetCookiesOfChildren(const CookieTreeNode
* node
) {
248 return GetNodesOfChildren(node
, CookieTreeNode::DetailedInfo::TYPE_COOKIE
);
251 std::string
GetDatabasesOfChildren(const CookieTreeNode
* node
) {
252 return GetNodesOfChildren(node
,
253 CookieTreeNode::DetailedInfo::TYPE_DATABASE
);
256 std::string
GetLocalStoragesOfChildren(const CookieTreeNode
* node
) {
257 return GetNodesOfChildren(node
,
258 CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE
);
261 std::string
GetSessionStoragesOfChildren(const CookieTreeNode
* node
) {
262 return GetNodesOfChildren(
263 node
, CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE
);
266 std::string
GetIndexedDBsOfChildren(const CookieTreeNode
* node
) {
267 return GetNodesOfChildren(
268 node
, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB
);
271 std::string
GetFileSystemsOfChildren(const CookieTreeNode
* node
) {
272 return GetNodesOfChildren(
273 node
, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM
);
276 std::string
GetFileQuotaOfChildren(const CookieTreeNode
* node
) {
277 return GetNodesOfChildren(
278 node
, CookieTreeNode::DetailedInfo::TYPE_QUOTA
);
281 std::string
GetServiceWorkersOfChildren(const CookieTreeNode
* node
) {
282 return GetNodesOfChildren(
283 node
, CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER
);
286 std::string
GetFlashLSOsOfChildren(const CookieTreeNode
* node
) {
287 return GetNodesOfChildren(
288 node
, CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO
);
291 // Get the nodes names displayed in the view (if we had one) in the order
292 // they are displayed, as a comma seperated string.
293 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str());
294 std::string
GetDisplayedNodes(CookiesTreeModel
* cookies_model
,
295 CookieTreeNode::DetailedInfo::NodeType type
) {
296 CookieTreeRootNode
* root
= static_cast<CookieTreeRootNode
*>(
297 cookies_model
->GetRoot());
298 std::string retval
= GetNodesOfChildren(root
, type
);
299 if (retval
.length() && retval
[retval
.length() - 1] == ',')
300 retval
.erase(retval
.length() - 1);
304 std::string
GetDisplayedCookies(CookiesTreeModel
* cookies_model
) {
305 return GetDisplayedNodes(cookies_model
,
306 CookieTreeNode::DetailedInfo::TYPE_COOKIE
);
309 std::string
GetDisplayedDatabases(CookiesTreeModel
* cookies_model
) {
310 return GetDisplayedNodes(cookies_model
,
311 CookieTreeNode::DetailedInfo::TYPE_DATABASE
);
314 std::string
GetDisplayedLocalStorages(CookiesTreeModel
* cookies_model
) {
315 return GetDisplayedNodes(cookies_model
,
316 CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE
);
319 std::string
GetDisplayedSessionStorages(CookiesTreeModel
* cookies_model
) {
320 return GetDisplayedNodes(
321 cookies_model
, CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE
);
324 std::string
GetDisplayedAppCaches(CookiesTreeModel
* cookies_model
) {
325 return GetDisplayedNodes(cookies_model
,
326 CookieTreeNode::DetailedInfo::TYPE_APPCACHE
);
329 std::string
GetDisplayedIndexedDBs(CookiesTreeModel
* cookies_model
) {
330 return GetDisplayedNodes(cookies_model
,
331 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB
);
334 std::string
GetDisplayedFileSystems(CookiesTreeModel
* cookies_model
) {
335 return GetDisplayedNodes(cookies_model
,
336 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM
);
339 std::string
GetDisplayedQuotas(CookiesTreeModel
* cookies_model
) {
340 return GetDisplayedNodes(cookies_model
,
341 CookieTreeNode::DetailedInfo::TYPE_QUOTA
);
344 std::string
GetDisplayedChannelIDs(CookiesTreeModel
* cookies_model
) {
345 return GetDisplayedNodes(
346 cookies_model
, CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID
);
349 std::string
GetDisplayedServiceWorkers(CookiesTreeModel
* cookies_model
) {
350 return GetDisplayedNodes(cookies_model
,
351 CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER
);
354 std::string
GetDisplayedFlashLSOs(CookiesTreeModel
* cookies_model
) {
355 return GetDisplayedNodes(
356 cookies_model
, CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO
);
359 // Do not call on the root.
360 void DeleteStoredObjects(CookieTreeNode
* node
) {
361 node
->DeleteStoredObjects();
362 CookieTreeNode
* parent_node
= node
->parent();
364 delete parent_node
->GetModel()->Remove(parent_node
, node
);
368 ExtensionSpecialStoragePolicy
* special_storage_policy() {
369 #if defined(ENABLE_EXTENSIONS)
370 return special_storage_policy_
.get();
376 content::TestBrowserThreadBundle thread_bundle_
;
377 scoped_ptr
<TestingProfile
> profile_
;
378 scoped_refptr
<MockBrowsingDataCookieHelper
>
379 mock_browsing_data_cookie_helper_
;
380 scoped_refptr
<MockBrowsingDataDatabaseHelper
>
381 mock_browsing_data_database_helper_
;
382 scoped_refptr
<MockBrowsingDataLocalStorageHelper
>
383 mock_browsing_data_local_storage_helper_
;
384 scoped_refptr
<MockBrowsingDataLocalStorageHelper
>
385 mock_browsing_data_session_storage_helper_
;
386 scoped_refptr
<MockBrowsingDataAppCacheHelper
>
387 mock_browsing_data_appcache_helper_
;
388 scoped_refptr
<MockBrowsingDataIndexedDBHelper
>
389 mock_browsing_data_indexed_db_helper_
;
390 scoped_refptr
<MockBrowsingDataFileSystemHelper
>
391 mock_browsing_data_file_system_helper_
;
392 scoped_refptr
<MockBrowsingDataQuotaHelper
>
393 mock_browsing_data_quota_helper_
;
394 scoped_refptr
<MockBrowsingDataChannelIDHelper
>
395 mock_browsing_data_channel_id_helper_
;
396 scoped_refptr
<MockBrowsingDataServiceWorkerHelper
>
397 mock_browsing_data_service_worker_helper_
;
398 scoped_refptr
<MockBrowsingDataFlashLSOHelper
>
399 mock_browsing_data_flash_lso_helper_
;
401 #if defined(ENABLE_EXTENSIONS)
402 scoped_refptr
<ExtensionSpecialStoragePolicy
> special_storage_policy_
;
406 TEST_F(CookiesTreeModelTest
, RemoveAll
) {
407 scoped_ptr
<CookiesTreeModel
> cookies_model(
408 CreateCookiesTreeModelWithInitialSample());
410 // Reset the selection of the first row.
412 SCOPED_TRACE("Before removing");
414 GetDisplayedCookies(cookies_model
.get()));
416 GetDisplayedDatabases(cookies_model
.get()));
417 EXPECT_EQ("http://host1:1/,http://host2:2/",
418 GetDisplayedLocalStorages(cookies_model
.get()));
419 EXPECT_EQ("http://host1:1/,http://host2:2/",
420 GetDisplayedSessionStorages(cookies_model
.get()));
421 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
422 GetDisplayedIndexedDBs(cookies_model
.get()));
423 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
424 GetDisplayedFileSystems(cookies_model
.get()));
425 EXPECT_EQ("quotahost1,quotahost2",
426 GetDisplayedQuotas(cookies_model
.get()));
427 EXPECT_EQ("sbc1,sbc2",
428 GetDisplayedChannelIDs(cookies_model
.get()));
429 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
430 GetDisplayedServiceWorkers(cookies_model
.get()));
432 GetDisplayedFlashLSOs(cookies_model
.get()));
435 mock_browsing_data_cookie_helper_
->Reset();
436 mock_browsing_data_database_helper_
->Reset();
437 mock_browsing_data_local_storage_helper_
->Reset();
438 mock_browsing_data_session_storage_helper_
->Reset();
439 mock_browsing_data_indexed_db_helper_
->Reset();
440 mock_browsing_data_service_worker_helper_
->Reset();
441 mock_browsing_data_file_system_helper_
->Reset();
443 cookies_model
->DeleteAllStoredObjects();
445 // Make sure the nodes are also deleted from the model's cache.
446 // http://crbug.com/43249
447 cookies_model
->UpdateSearchResults(base::string16());
450 // 2 nodes - root and app
451 SCOPED_TRACE("After removing");
452 EXPECT_EQ(1, cookies_model
->GetRoot()->GetTotalNodeCount());
453 EXPECT_EQ(0, cookies_model
->GetRoot()->child_count());
454 EXPECT_EQ(std::string(), GetDisplayedCookies(cookies_model
.get()));
455 EXPECT_TRUE(mock_browsing_data_cookie_helper_
->AllDeleted());
456 EXPECT_TRUE(mock_browsing_data_database_helper_
->AllDeleted());
457 EXPECT_TRUE(mock_browsing_data_local_storage_helper_
->AllDeleted());
458 EXPECT_FALSE(mock_browsing_data_session_storage_helper_
->AllDeleted());
459 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_
->AllDeleted());
460 EXPECT_TRUE(mock_browsing_data_file_system_helper_
->AllDeleted());
461 EXPECT_TRUE(mock_browsing_data_channel_id_helper_
->AllDeleted());
462 EXPECT_TRUE(mock_browsing_data_service_worker_helper_
->AllDeleted());
463 EXPECT_TRUE(mock_browsing_data_flash_lso_helper_
->AllDeleted());
467 TEST_F(CookiesTreeModelTest
, Remove
) {
468 scoped_ptr
<CookiesTreeModel
> cookies_model(
469 CreateCookiesTreeModelWithInitialSample());
471 // Children start out arranged as follows:
493 // Here, we'll remove them one by one, starting from the end, and
494 // check that the state makes sense.
496 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(18));
498 SCOPED_TRACE("`xyz.com` removed.");
499 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
500 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
501 EXPECT_EQ("http://host1:1/,http://host2:2/",
502 GetDisplayedLocalStorages(cookies_model
.get()));
503 EXPECT_EQ("http://host1:1/,http://host2:2/",
504 GetDisplayedSessionStorages(cookies_model
.get()));
505 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
506 GetDisplayedFileSystems(cookies_model
.get()));
507 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
508 GetDisplayedIndexedDBs(cookies_model
.get()));
509 EXPECT_EQ("quotahost1,quotahost2",
510 GetDisplayedQuotas(cookies_model
.get()));
511 EXPECT_EQ("sbc1,sbc2",
512 GetDisplayedChannelIDs(cookies_model
.get()));
513 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
514 GetDisplayedServiceWorkers(cookies_model
.get()));
515 EXPECT_EQ(57, cookies_model
->GetRoot()->GetTotalNodeCount());
517 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(17));
519 SCOPED_TRACE("`swhost2` removed.");
520 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
521 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
522 EXPECT_EQ("http://host1:1/,http://host2:2/",
523 GetDisplayedLocalStorages(cookies_model
.get()));
524 EXPECT_EQ("http://host1:1/,http://host2:2/",
525 GetDisplayedSessionStorages(cookies_model
.get()));
526 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
527 GetDisplayedFileSystems(cookies_model
.get()));
528 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
529 GetDisplayedIndexedDBs(cookies_model
.get()));
530 EXPECT_EQ("quotahost1,quotahost2",
531 GetDisplayedQuotas(cookies_model
.get()));
532 EXPECT_EQ("sbc1,sbc2",
533 GetDisplayedChannelIDs(cookies_model
.get()));
534 EXPECT_EQ("https://swhost1:1/",
535 GetDisplayedServiceWorkers(cookies_model
.get()));
536 EXPECT_EQ(54, cookies_model
->GetRoot()->GetTotalNodeCount());
538 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(16));
540 SCOPED_TRACE("`swhost1` removed.");
541 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
542 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
543 EXPECT_EQ("http://host1:1/,http://host2:2/",
544 GetDisplayedLocalStorages(cookies_model
.get()));
545 EXPECT_EQ("http://host1:1/,http://host2:2/",
546 GetDisplayedSessionStorages(cookies_model
.get()));
547 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
548 GetDisplayedFileSystems(cookies_model
.get()));
549 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
550 GetDisplayedIndexedDBs(cookies_model
.get()));
551 EXPECT_EQ("quotahost1,quotahost2",
552 GetDisplayedQuotas(cookies_model
.get()));
553 EXPECT_EQ("sbc1,sbc2",
554 GetDisplayedChannelIDs(cookies_model
.get()));
555 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
556 EXPECT_EQ(51, cookies_model
->GetRoot()->GetTotalNodeCount());
558 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(15));
560 SCOPED_TRACE("`sbc2` removed.");
561 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
562 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
563 EXPECT_EQ("http://host1:1/,http://host2:2/",
564 GetDisplayedLocalStorages(cookies_model
.get()));
565 EXPECT_EQ("http://host1:1/,http://host2:2/",
566 GetDisplayedSessionStorages(cookies_model
.get()));
567 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
568 GetDisplayedFileSystems(cookies_model
.get()));
569 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
570 GetDisplayedIndexedDBs(cookies_model
.get()));
571 EXPECT_EQ("quotahost1,quotahost2",
572 GetDisplayedQuotas(cookies_model
.get()));
574 GetDisplayedChannelIDs(cookies_model
.get()));
575 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
576 EXPECT_EQ(48, cookies_model
->GetRoot()->GetTotalNodeCount());
578 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(14));
580 SCOPED_TRACE("`sbc1` removed.");
581 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
582 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
583 EXPECT_EQ("http://host1:1/,http://host2:2/",
584 GetDisplayedLocalStorages(cookies_model
.get()));
585 EXPECT_EQ("http://host1:1/,http://host2:2/",
586 GetDisplayedSessionStorages(cookies_model
.get()));
587 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
588 GetDisplayedFileSystems(cookies_model
.get()));
589 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
590 GetDisplayedIndexedDBs(cookies_model
.get()));
591 EXPECT_EQ("quotahost1,quotahost2",
592 GetDisplayedQuotas(cookies_model
.get()));
593 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
594 EXPECT_EQ(45, cookies_model
->GetRoot()->GetTotalNodeCount());
596 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(13));
598 SCOPED_TRACE("`quotahost2` removed.");
599 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
600 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
601 EXPECT_EQ("http://host1:1/,http://host2:2/",
602 GetDisplayedLocalStorages(cookies_model
.get()));
603 EXPECT_EQ("http://host1:1/,http://host2:2/",
604 GetDisplayedSessionStorages(cookies_model
.get()));
605 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
606 GetDisplayedFileSystems(cookies_model
.get()));
607 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
608 GetDisplayedIndexedDBs(cookies_model
.get()));
609 EXPECT_EQ("quotahost1",
610 GetDisplayedQuotas(cookies_model
.get()));
611 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
612 EXPECT_EQ(43, cookies_model
->GetRoot()->GetTotalNodeCount());
614 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(12));
616 SCOPED_TRACE("`quotahost1` removed.");
617 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
618 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
619 EXPECT_EQ("http://host1:1/,http://host2:2/",
620 GetDisplayedLocalStorages(cookies_model
.get()));
621 EXPECT_EQ("http://host1:1/,http://host2:2/",
622 GetDisplayedSessionStorages(cookies_model
.get()));
623 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
624 GetDisplayedFileSystems(cookies_model
.get()));
625 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
626 GetDisplayedIndexedDBs(cookies_model
.get()));
627 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
628 EXPECT_EQ(41, cookies_model
->GetRoot()->GetTotalNodeCount());
630 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(11));
632 SCOPED_TRACE("`idbhost2` removed.");
633 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
634 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
635 EXPECT_EQ("http://host1:1/,http://host2:2/",
636 GetDisplayedLocalStorages(cookies_model
.get()));
637 EXPECT_EQ("http://host1:1/,http://host2:2/",
638 GetDisplayedSessionStorages(cookies_model
.get()));
639 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
640 GetDisplayedFileSystems(cookies_model
.get()));
641 EXPECT_EQ("http://idbhost1:1/",
642 GetDisplayedIndexedDBs(cookies_model
.get()));
643 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
644 EXPECT_EQ(38, cookies_model
->GetRoot()->GetTotalNodeCount());
646 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(10));
648 SCOPED_TRACE("`idbhost1` removed.");
649 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
650 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
651 EXPECT_EQ("http://host1:1/,http://host2:2/",
652 GetDisplayedLocalStorages(cookies_model
.get()));
653 EXPECT_EQ("http://host1:1/,http://host2:2/",
654 GetDisplayedSessionStorages(cookies_model
.get()));
655 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
656 GetDisplayedFileSystems(cookies_model
.get()));
657 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
658 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
659 EXPECT_EQ(35, cookies_model
->GetRoot()->GetTotalNodeCount());
661 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(9));
663 SCOPED_TRACE("`host2` removed.");
664 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
665 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
666 EXPECT_EQ("http://host1:1/",
667 GetDisplayedLocalStorages(cookies_model
.get()));
668 EXPECT_EQ("http://host1:1/",
669 GetDisplayedSessionStorages(cookies_model
.get()));
670 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
671 GetDisplayedFileSystems(cookies_model
.get()));
672 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
673 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
674 EXPECT_EQ(30, cookies_model
->GetRoot()->GetTotalNodeCount());
676 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(8));
678 SCOPED_TRACE("`host1` removed.");
679 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
680 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
681 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
682 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
683 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
684 GetDisplayedFileSystems(cookies_model
.get()));
685 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
686 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
687 EXPECT_EQ(25, cookies_model
->GetRoot()->GetTotalNodeCount());
689 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(7));
691 SCOPED_TRACE("`gdbhost2` removed.");
692 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
693 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model
.get()));
694 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
695 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
696 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
697 GetDisplayedFileSystems(cookies_model
.get()));
698 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
699 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
700 EXPECT_EQ(22, cookies_model
->GetRoot()->GetTotalNodeCount());
702 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(6));
704 SCOPED_TRACE("`gdbhost1` removed.");
705 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
706 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
707 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
708 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
709 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
710 GetDisplayedFileSystems(cookies_model
.get()));
711 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
712 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
713 EXPECT_EQ(19, cookies_model
->GetRoot()->GetTotalNodeCount());
715 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(5));
717 SCOPED_TRACE("`fshost3` removed.");
718 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
719 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
720 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
721 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
722 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/",
723 GetDisplayedFileSystems(cookies_model
.get()));
724 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
725 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
726 EXPECT_EQ(16, cookies_model
->GetRoot()->GetTotalNodeCount());
728 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(4));
730 SCOPED_TRACE("`fshost2` removed.");
731 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
732 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
733 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
734 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
735 EXPECT_EQ("http://fshost1:1/",
736 GetDisplayedFileSystems(cookies_model
.get()));
737 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
738 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
739 EXPECT_EQ(13, cookies_model
->GetRoot()->GetTotalNodeCount());
741 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(3));
743 SCOPED_TRACE("`fshost1` removed.");
744 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
745 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
746 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
747 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
748 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
749 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
750 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
751 EXPECT_EQ(10, cookies_model
->GetRoot()->GetTotalNodeCount());
753 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(2));
755 SCOPED_TRACE("`foo3` removed.");
756 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model
.get()).c_str());
757 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
758 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
759 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
760 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
761 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
762 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
763 EXPECT_EQ(7, cookies_model
->GetRoot()->GetTotalNodeCount());
765 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(1));
767 SCOPED_TRACE("`foo2` removed.");
768 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model
.get()).c_str());
769 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
770 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
771 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
772 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
773 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
774 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
775 EXPECT_EQ(4, cookies_model
->GetRoot()->GetTotalNodeCount());
777 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(0));
779 SCOPED_TRACE("`foo1` removed.");
780 EXPECT_STREQ("", GetDisplayedCookies(cookies_model
.get()).c_str());
781 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
782 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
783 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
784 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
785 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
786 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
787 EXPECT_EQ(1, cookies_model
->GetRoot()->GetTotalNodeCount());
791 TEST_F(CookiesTreeModelTest
, RemoveCookiesNode
) {
792 scoped_ptr
<CookiesTreeModel
> cookies_model(
793 CreateCookiesTreeModelWithInitialSample());
796 cookies_model
->GetRoot()->GetChild(0)->GetChild(0));
798 SCOPED_TRACE("First origin removed");
799 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
800 // 57 because in this case, the origin remains, although the COOKIES
801 // node beneath it has been deleted.
802 EXPECT_EQ(57, cookies_model
->GetRoot()->GetTotalNodeCount());
803 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
804 EXPECT_EQ("http://host1:1/,http://host2:2/",
805 GetDisplayedLocalStorages(cookies_model
.get()));
806 EXPECT_EQ("http://host1:1/,http://host2:2/",
807 GetDisplayedSessionStorages(cookies_model
.get()));
808 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
809 GetDisplayedIndexedDBs(cookies_model
.get()));
810 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
811 GetDisplayedFileSystems(cookies_model
.get()));
812 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
813 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
814 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
815 GetDisplayedServiceWorkers(cookies_model
.get()));
819 cookies_model
->GetRoot()->GetChild(6)->GetChild(0));
821 SCOPED_TRACE("First database removed");
822 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
823 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
824 EXPECT_EQ("http://host1:1/,http://host2:2/",
825 GetDisplayedLocalStorages(cookies_model
.get()));
826 EXPECT_EQ("http://host1:1/,http://host2:2/",
827 GetDisplayedSessionStorages(cookies_model
.get()));
828 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
829 GetDisplayedIndexedDBs(cookies_model
.get()));
830 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
831 GetDisplayedFileSystems(cookies_model
.get()));
832 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
833 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
834 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
835 GetDisplayedServiceWorkers(cookies_model
.get()));
836 EXPECT_EQ(55, cookies_model
->GetRoot()->GetTotalNodeCount());
840 cookies_model
->GetRoot()->GetChild(8)->GetChild(0));
842 SCOPED_TRACE("First origin removed");
843 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
844 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
845 EXPECT_EQ("http://host2:2/",
846 GetDisplayedLocalStorages(cookies_model
.get()));
847 EXPECT_EQ("http://host1:1/,http://host2:2/",
848 GetDisplayedSessionStorages(cookies_model
.get()));
849 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
850 GetDisplayedIndexedDBs(cookies_model
.get()));
851 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
852 GetDisplayedFileSystems(cookies_model
.get()));
853 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
854 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
855 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
856 GetDisplayedServiceWorkers(cookies_model
.get()));
857 EXPECT_EQ(53, cookies_model
->GetRoot()->GetTotalNodeCount());
861 TEST_F(CookiesTreeModelTest
, RemoveCookieNode
) {
862 scoped_ptr
<CookiesTreeModel
> cookies_model(
863 CreateCookiesTreeModelWithInitialSample());
866 cookies_model
->GetRoot()->GetChild(1)->GetChild(0));
868 SCOPED_TRACE("Second origin COOKIES node removed");
869 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model
.get()).c_str());
870 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
871 EXPECT_EQ("http://host1:1/,http://host2:2/",
872 GetDisplayedLocalStorages(cookies_model
.get()));
873 EXPECT_EQ("http://host1:1/,http://host2:2/",
874 GetDisplayedSessionStorages(cookies_model
.get()));
875 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
876 GetDisplayedIndexedDBs(cookies_model
.get()));
877 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
878 GetDisplayedFileSystems(cookies_model
.get()));
879 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
880 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
881 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
882 GetDisplayedServiceWorkers(cookies_model
.get()));
883 // 57 because in this case, the origin remains, although the COOKIES
884 // node beneath it has been deleted.
885 EXPECT_EQ(57, cookies_model
->GetRoot()->GetTotalNodeCount());
889 cookies_model
->GetRoot()->GetChild(6)->GetChild(0));
891 SCOPED_TRACE("First database removed");
892 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model
.get()).c_str());
893 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
894 EXPECT_EQ("http://host1:1/,http://host2:2/",
895 GetDisplayedLocalStorages(cookies_model
.get()));
896 EXPECT_EQ("http://host1:1/,http://host2:2/",
897 GetDisplayedSessionStorages(cookies_model
.get()));
898 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
899 GetDisplayedIndexedDBs(cookies_model
.get()));
900 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
901 GetDisplayedFileSystems(cookies_model
.get()));
902 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
903 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
904 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
905 GetDisplayedServiceWorkers(cookies_model
.get()));
906 EXPECT_EQ(55, cookies_model
->GetRoot()->GetTotalNodeCount());
910 cookies_model
->GetRoot()->GetChild(8)->GetChild(0));
912 SCOPED_TRACE("First origin removed");
913 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model
.get()).c_str());
914 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
915 EXPECT_EQ("http://host2:2/",
916 GetDisplayedLocalStorages(cookies_model
.get()));
917 EXPECT_EQ("http://host1:1/,http://host2:2/",
918 GetDisplayedSessionStorages(cookies_model
.get()));
919 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
920 GetDisplayedIndexedDBs(cookies_model
.get()));
921 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
922 GetDisplayedFileSystems(cookies_model
.get()));
923 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
924 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
925 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
926 GetDisplayedServiceWorkers(cookies_model
.get()));
927 EXPECT_EQ(53, cookies_model
->GetRoot()->GetTotalNodeCount());
931 TEST_F(CookiesTreeModelTest
, RemoveSingleCookieNode
) {
932 LocalDataContainer
* container
=
933 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
934 mock_browsing_data_database_helper_
.get(),
935 mock_browsing_data_local_storage_helper_
.get(),
936 mock_browsing_data_session_storage_helper_
.get(),
937 mock_browsing_data_appcache_helper_
.get(),
938 mock_browsing_data_indexed_db_helper_
.get(),
939 mock_browsing_data_file_system_helper_
.get(),
940 mock_browsing_data_quota_helper_
.get(),
941 mock_browsing_data_channel_id_helper_
.get(),
942 mock_browsing_data_service_worker_helper_
.get(),
943 mock_browsing_data_flash_lso_helper_
.get());
944 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
946 mock_browsing_data_cookie_helper_
->
947 AddCookieSamples(GURL("http://foo1"), "A=1");
948 mock_browsing_data_cookie_helper_
->
949 AddCookieSamples(GURL("http://foo2"), "B=1");
950 mock_browsing_data_cookie_helper_
->
951 AddCookieSamples(GURL("http://foo3"), "C=1");
952 mock_browsing_data_cookie_helper_
->
953 AddCookieSamples(GURL("http://foo3"), "D=1");
954 mock_browsing_data_cookie_helper_
->Notify();
955 mock_browsing_data_database_helper_
->AddDatabaseSamples();
956 mock_browsing_data_database_helper_
->Notify();
957 mock_browsing_data_local_storage_helper_
->AddLocalStorageSamples();
958 mock_browsing_data_local_storage_helper_
->Notify();
959 mock_browsing_data_session_storage_helper_
->AddLocalStorageSamples();
960 mock_browsing_data_session_storage_helper_
->Notify();
961 mock_browsing_data_indexed_db_helper_
->AddIndexedDBSamples();
962 mock_browsing_data_indexed_db_helper_
->Notify();
963 mock_browsing_data_file_system_helper_
->AddFileSystemSamples();
964 mock_browsing_data_file_system_helper_
->Notify();
965 mock_browsing_data_quota_helper_
->AddQuotaSamples();
966 mock_browsing_data_quota_helper_
->Notify();
967 mock_browsing_data_service_worker_helper_
->AddServiceWorkerSamples();
968 mock_browsing_data_service_worker_helper_
->Notify();
971 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, "
972 "2 session storages, 2 indexed DBs, 3 file systems, "
973 "2 quotas, 2 service workers.");
974 // 52 because there's the root, then
975 // foo1 -> cookies -> a,
976 // foo2 -> cookies -> b,
977 // foo3 -> cookies -> c,d
978 // dbhost1 -> database -> db1,
979 // dbhost2 -> database -> db2,
980 // host1 -> localstorage -> http://host1:1/,
981 // -> sessionstorage -> http://host1:1/,
982 // host2 -> localstorage -> http://host2:2/,
983 // -> sessionstorage -> http://host2:2/,
984 // idbhost1 -> sessionstorage -> http://idbhost1:1/,
985 // idbhost2 -> sessionstorage -> http://idbhost2:2/,
986 // fshost1 -> filesystem -> http://fshost1:1/,
987 // fshost2 -> filesystem -> http://fshost2:1/,
988 // fshost3 -> filesystem -> http://fshost3:1/,
989 // quotahost1 -> quotahost1,
990 // quotahost2 -> quotahost2.
991 // swhost1 -> service worker -> https://swhost1:1
992 // swhost2 -> service worker -> https://swhost1:2
993 EXPECT_EQ(52, cookies_model
.GetRoot()->GetTotalNodeCount());
994 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model
).c_str());
995 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
996 EXPECT_EQ("http://host1:1/,http://host2:2/",
997 GetDisplayedLocalStorages(&cookies_model
));
998 EXPECT_EQ("http://host1:1/,http://host2:2/",
999 GetDisplayedSessionStorages(&cookies_model
));
1000 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1001 GetDisplayedIndexedDBs(&cookies_model
));
1002 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1003 GetDisplayedFileSystems(&cookies_model
));
1004 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1005 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1006 GetDisplayedServiceWorkers(&cookies_model
));
1008 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(2));
1010 SCOPED_TRACE("Third origin removed");
1011 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model
).c_str());
1012 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
1013 EXPECT_EQ("http://host1:1/,http://host2:2/",
1014 GetDisplayedLocalStorages(&cookies_model
));
1015 EXPECT_EQ("http://host1:1/,http://host2:2/",
1016 GetDisplayedSessionStorages(&cookies_model
));
1017 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1018 GetDisplayedIndexedDBs(&cookies_model
));
1019 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1020 GetDisplayedFileSystems(&cookies_model
));
1021 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1022 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1023 GetDisplayedServiceWorkers(&cookies_model
));
1024 EXPECT_EQ(48, cookies_model
.GetRoot()->GetTotalNodeCount());
1028 TEST_F(CookiesTreeModelTest
, RemoveSingleCookieNodeOf3
) {
1029 LocalDataContainer
* container
=
1030 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1031 mock_browsing_data_database_helper_
.get(),
1032 mock_browsing_data_local_storage_helper_
.get(),
1033 mock_browsing_data_session_storage_helper_
.get(),
1034 mock_browsing_data_appcache_helper_
.get(),
1035 mock_browsing_data_indexed_db_helper_
.get(),
1036 mock_browsing_data_file_system_helper_
.get(),
1037 mock_browsing_data_quota_helper_
.get(),
1038 mock_browsing_data_channel_id_helper_
.get(),
1039 mock_browsing_data_service_worker_helper_
.get(),
1040 mock_browsing_data_flash_lso_helper_
.get());
1041 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1043 mock_browsing_data_cookie_helper_
->
1044 AddCookieSamples(GURL("http://foo1"), "A=1");
1045 mock_browsing_data_cookie_helper_
->
1046 AddCookieSamples(GURL("http://foo2"), "B=1");
1047 mock_browsing_data_cookie_helper_
->
1048 AddCookieSamples(GURL("http://foo3"), "C=1");
1049 mock_browsing_data_cookie_helper_
->
1050 AddCookieSamples(GURL("http://foo3"), "D=1");
1051 mock_browsing_data_cookie_helper_
->
1052 AddCookieSamples(GURL("http://foo3"), "E=1");
1053 mock_browsing_data_cookie_helper_
->Notify();
1054 mock_browsing_data_database_helper_
->AddDatabaseSamples();
1055 mock_browsing_data_database_helper_
->Notify();
1056 mock_browsing_data_local_storage_helper_
->AddLocalStorageSamples();
1057 mock_browsing_data_local_storage_helper_
->Notify();
1058 mock_browsing_data_session_storage_helper_
->AddLocalStorageSamples();
1059 mock_browsing_data_session_storage_helper_
->Notify();
1060 mock_browsing_data_indexed_db_helper_
->AddIndexedDBSamples();
1061 mock_browsing_data_indexed_db_helper_
->Notify();
1062 mock_browsing_data_file_system_helper_
->AddFileSystemSamples();
1063 mock_browsing_data_file_system_helper_
->Notify();
1064 mock_browsing_data_quota_helper_
->AddQuotaSamples();
1065 mock_browsing_data_quota_helper_
->Notify();
1066 mock_browsing_data_service_worker_helper_
->AddServiceWorkerSamples();
1067 mock_browsing_data_service_worker_helper_
->Notify();
1070 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, "
1071 "2 session storages, 2 indexed DBs, 3 filesystems, "
1072 "2 quotas, 2 service workers.");
1073 // 53 because there's the root, then
1074 // foo1 -> cookies -> a,
1075 // foo2 -> cookies -> b,
1076 // foo3 -> cookies -> c,d,e
1077 // dbhost1 -> database -> db1,
1078 // dbhost2 -> database -> db2,
1079 // host1 -> localstorage -> http://host1:1/,
1080 // -> sessionstorage -> http://host1:1/,
1081 // host2 -> localstorage -> http://host2:2/,
1082 // -> sessionstorage -> http://host2:2/,
1083 // idbhost1 -> sessionstorage -> http://idbhost1:1/,
1084 // idbhost2 -> sessionstorage -> http://idbhost2:2/,
1085 // fshost1 -> filesystem -> http://fshost1:1/,
1086 // fshost2 -> filesystem -> http://fshost2:1/,
1087 // fshost3 -> filesystem -> http://fshost3:1/,
1088 // quotahost1 -> quotahost1,
1089 // quotahost2 -> quotahost2.
1090 // swhost1 -> service worker -> https://swhost1:1
1091 // swhost2 -> service worker -> https://swhost1:2
1092 EXPECT_EQ(53, cookies_model
.GetRoot()->GetTotalNodeCount());
1093 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model
).c_str());
1094 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
1095 EXPECT_EQ("http://host1:1/,http://host2:2/",
1096 GetDisplayedLocalStorages(&cookies_model
));
1097 EXPECT_EQ("http://host1:1/,http://host2:2/",
1098 GetDisplayedSessionStorages(&cookies_model
));
1099 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1100 GetDisplayedIndexedDBs(&cookies_model
));
1101 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1102 GetDisplayedFileSystems(&cookies_model
));
1103 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1104 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1105 GetDisplayedServiceWorkers(&cookies_model
));
1107 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(2)->GetChild(0)->
1110 SCOPED_TRACE("Middle cookie in third origin removed");
1111 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model
).c_str());
1112 EXPECT_EQ(52, cookies_model
.GetRoot()->GetTotalNodeCount());
1113 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
1114 EXPECT_EQ("http://host1:1/,http://host2:2/",
1115 GetDisplayedLocalStorages(&cookies_model
));
1116 EXPECT_EQ("http://host1:1/,http://host2:2/",
1117 GetDisplayedSessionStorages(&cookies_model
));
1118 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1119 GetDisplayedIndexedDBs(&cookies_model
));
1120 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1121 GetDisplayedFileSystems(&cookies_model
));
1122 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1123 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1124 GetDisplayedServiceWorkers(&cookies_model
));
1128 TEST_F(CookiesTreeModelTest
, RemoveSecondOrigin
) {
1129 LocalDataContainer
* container
=
1130 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1131 mock_browsing_data_database_helper_
.get(),
1132 mock_browsing_data_local_storage_helper_
.get(),
1133 mock_browsing_data_session_storage_helper_
.get(),
1134 mock_browsing_data_appcache_helper_
.get(),
1135 mock_browsing_data_indexed_db_helper_
.get(),
1136 mock_browsing_data_file_system_helper_
.get(),
1137 mock_browsing_data_quota_helper_
.get(),
1138 mock_browsing_data_channel_id_helper_
.get(),
1139 mock_browsing_data_service_worker_helper_
.get(),
1140 mock_browsing_data_flash_lso_helper_
.get());
1141 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1143 mock_browsing_data_cookie_helper_
->
1144 AddCookieSamples(GURL("http://foo1"), "A=1");
1145 mock_browsing_data_cookie_helper_
->
1146 AddCookieSamples(GURL("http://foo2"), "B=1");
1147 mock_browsing_data_cookie_helper_
->
1148 AddCookieSamples(GURL("http://foo3"), "C=1");
1149 mock_browsing_data_cookie_helper_
->
1150 AddCookieSamples(GURL("http://foo3"), "D=1");
1151 mock_browsing_data_cookie_helper_
->
1152 AddCookieSamples(GURL("http://foo3"), "E=1");
1153 mock_browsing_data_cookie_helper_
->Notify();
1156 SCOPED_TRACE("Initial State 5 cookies");
1157 // 12 because there's the root, then foo1 -> cookies -> a,
1158 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e
1159 EXPECT_EQ(12, cookies_model
.GetRoot()->GetTotalNodeCount());
1160 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model
).c_str());
1162 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(1));
1164 SCOPED_TRACE("Second origin removed");
1165 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model
).c_str());
1166 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e
1167 EXPECT_EQ(9, cookies_model
.GetRoot()->GetTotalNodeCount());
1171 TEST_F(CookiesTreeModelTest
, OriginOrdering
) {
1172 LocalDataContainer
* container
=
1173 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1174 mock_browsing_data_database_helper_
.get(),
1175 mock_browsing_data_local_storage_helper_
.get(),
1176 mock_browsing_data_session_storage_helper_
.get(),
1177 mock_browsing_data_appcache_helper_
.get(),
1178 mock_browsing_data_indexed_db_helper_
.get(),
1179 mock_browsing_data_file_system_helper_
.get(),
1180 mock_browsing_data_quota_helper_
.get(),
1181 mock_browsing_data_channel_id_helper_
.get(),
1182 mock_browsing_data_service_worker_helper_
.get(),
1183 mock_browsing_data_flash_lso_helper_
.get());
1184 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1186 mock_browsing_data_cookie_helper_
->
1187 AddCookieSamples(GURL("http://a.foo2.com"), "A=1");
1188 mock_browsing_data_cookie_helper_
->
1189 AddCookieSamples(GURL("http://foo2.com"), "B=1");
1190 mock_browsing_data_cookie_helper_
->
1191 AddCookieSamples(GURL("http://b.foo1.com"), "C=1");
1192 // Leading dot on the foo4
1193 mock_browsing_data_cookie_helper_
->AddCookieSamples(
1194 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;");
1195 mock_browsing_data_cookie_helper_
->
1196 AddCookieSamples(GURL("http://a.foo1.com"), "E=1");
1197 mock_browsing_data_cookie_helper_
->
1198 AddCookieSamples(GURL("http://foo1.com"), "F=1");
1199 mock_browsing_data_cookie_helper_
->
1200 AddCookieSamples(GURL("http://foo3.com"), "G=1");
1201 mock_browsing_data_cookie_helper_
->
1202 AddCookieSamples(GURL("http://foo4.com"), "H=1");
1203 mock_browsing_data_cookie_helper_
->Notify();
1206 SCOPED_TRACE("Initial State 8 cookies");
1207 EXPECT_EQ(23, cookies_model
.GetRoot()->GetTotalNodeCount());
1208 EXPECT_STREQ("F,E,C,B,A,G,D,H",
1209 GetDisplayedCookies(&cookies_model
).c_str());
1212 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(1));
1214 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model
).c_str());
1218 TEST_F(CookiesTreeModelTest
, ContentSettings
) {
1219 GURL
host("http://xyz.com/");
1220 LocalDataContainer
* container
=
1221 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1222 mock_browsing_data_database_helper_
.get(),
1223 mock_browsing_data_local_storage_helper_
.get(),
1224 mock_browsing_data_session_storage_helper_
.get(),
1225 mock_browsing_data_appcache_helper_
.get(),
1226 mock_browsing_data_indexed_db_helper_
.get(),
1227 mock_browsing_data_file_system_helper_
.get(),
1228 mock_browsing_data_quota_helper_
.get(),
1229 mock_browsing_data_channel_id_helper_
.get(),
1230 mock_browsing_data_service_worker_helper_
.get(),
1231 mock_browsing_data_flash_lso_helper_
.get());
1232 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1234 mock_browsing_data_cookie_helper_
->AddCookieSamples(host
, "A=1");
1235 mock_browsing_data_cookie_helper_
->Notify();
1237 TestingProfile profile
;
1238 HostContentSettingsMap
* content_settings
=
1239 profile
.GetHostContentSettingsMap();
1240 content_settings::CookieSettings
* cookie_settings
=
1241 CookieSettingsFactory::GetForProfile(&profile
).get();
1242 MockSettingsObserver
observer(content_settings
);
1244 CookieTreeRootNode
* root
=
1245 static_cast<CookieTreeRootNode
*>(cookies_model
.GetRoot());
1246 CookieTreeHostNode
* origin
=
1247 root
->GetOrCreateHostNode(host
);
1249 EXPECT_EQ(1, origin
->child_count());
1250 EXPECT_TRUE(origin
->CanCreateContentException());
1251 EXPECT_CALL(observer
,
1252 OnContentSettingsChanged(
1254 CONTENT_SETTINGS_TYPE_COOKIES
,
1256 ContentSettingsPattern::FromURLNoWildcard(host
),
1257 ContentSettingsPattern::Wildcard(),
1259 EXPECT_CALL(observer
,
1260 OnContentSettingsChanged(content_settings
,
1261 CONTENT_SETTINGS_TYPE_COOKIES
,
1263 ContentSettingsPattern::FromURL(host
),
1264 ContentSettingsPattern::Wildcard(),
1266 origin
->CreateContentException(
1267 cookie_settings
, CONTENT_SETTING_SESSION_ONLY
);
1268 EXPECT_TRUE(cookie_settings
->IsReadingCookieAllowed(host
, host
));
1269 EXPECT_TRUE(cookie_settings
->IsCookieSessionOnly(host
));
1272 TEST_F(CookiesTreeModelTest
, FileSystemFilter
) {
1273 scoped_ptr
<CookiesTreeModel
> cookies_model(
1274 CreateCookiesTreeModelWithInitialSample());
1276 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("fshost1"));
1277 EXPECT_EQ("http://fshost1:1/",
1278 GetDisplayedFileSystems(cookies_model
.get()));
1280 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("fshost2"));
1281 EXPECT_EQ("http://fshost2:2/",
1282 GetDisplayedFileSystems(cookies_model
.get()));
1284 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("fshost3"));
1285 EXPECT_EQ("http://fshost3:3/",
1286 GetDisplayedFileSystems(cookies_model
.get()));
1288 cookies_model
->UpdateSearchResults(base::string16());
1289 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1290 GetDisplayedFileSystems(cookies_model
.get()));
1293 TEST_F(CookiesTreeModelTest
, ServiceWorkerFilter
) {
1294 scoped_ptr
<CookiesTreeModel
> cookies_model(
1295 CreateCookiesTreeModelWithInitialSample());
1297 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("swhost1"));
1298 EXPECT_EQ("https://swhost1:1/",
1299 GetDisplayedServiceWorkers(cookies_model
.get()));
1301 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("swhost2"));
1302 EXPECT_EQ("https://swhost2:2/",
1303 GetDisplayedServiceWorkers(cookies_model
.get()));
1305 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("swhost3"));
1306 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
1308 cookies_model
->UpdateSearchResults(base::string16());
1309 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1310 GetDisplayedServiceWorkers(cookies_model
.get()));
1313 TEST_F(CookiesTreeModelTest
, CookiesFilter
) {
1314 LocalDataContainer
* container
=
1315 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1316 mock_browsing_data_database_helper_
.get(),
1317 mock_browsing_data_local_storage_helper_
.get(),
1318 mock_browsing_data_session_storage_helper_
.get(),
1319 mock_browsing_data_appcache_helper_
.get(),
1320 mock_browsing_data_indexed_db_helper_
.get(),
1321 mock_browsing_data_file_system_helper_
.get(),
1322 mock_browsing_data_quota_helper_
.get(),
1323 mock_browsing_data_channel_id_helper_
.get(),
1324 mock_browsing_data_service_worker_helper_
.get(),
1325 mock_browsing_data_flash_lso_helper_
.get());
1326 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1328 mock_browsing_data_cookie_helper_
->
1329 AddCookieSamples(GURL("http://123.com"), "A=1");
1330 mock_browsing_data_cookie_helper_
->
1331 AddCookieSamples(GURL("http://foo1.com"), "B=1");
1332 mock_browsing_data_cookie_helper_
->
1333 AddCookieSamples(GURL("http://foo2.com"), "C=1");
1334 mock_browsing_data_cookie_helper_
->
1335 AddCookieSamples(GURL("http://foo3.com"), "D=1");
1336 mock_browsing_data_cookie_helper_
->Notify();
1337 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model
));
1339 cookies_model
.UpdateSearchResults(base::string16(base::ASCIIToUTF16("foo")));
1340 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model
));
1342 cookies_model
.UpdateSearchResults(base::string16(base::ASCIIToUTF16("2")));
1343 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model
));
1345 cookies_model
.UpdateSearchResults(base::string16(base::ASCIIToUTF16("foo3")));
1346 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model
));
1348 cookies_model
.UpdateSearchResults(base::string16());
1349 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model
));