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.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/host_content_settings_map.h"
26 #include "content/public/browser/browser_thread.h"
27 #include "content/public/browser/notification_details.h"
28 #include "content/public/browser/notification_types.h"
29 #include "content/public/test/test_browser_thread_bundle.h"
30 #include "net/url_request/url_request_context.h"
31 #include "net/url_request/url_request_context_getter.h"
32 #include "testing/gtest/include/gtest/gtest.h"
34 #if defined(ENABLE_EXTENSIONS)
35 #include "chrome/browser/extensions/extension_special_storage_policy.h"
39 using content::BrowserThread
;
43 class CookiesTreeModelTest
: public testing::Test
{
45 ~CookiesTreeModelTest() override
{
46 // Avoid memory leaks.
47 #if defined(ENABLE_EXTENSIONS)
48 special_storage_policy_
= NULL
;
51 base::MessageLoop::current()->RunUntilIdle();
54 void SetUp() override
{
55 profile_
.reset(new TestingProfile());
56 mock_browsing_data_cookie_helper_
=
57 new MockBrowsingDataCookieHelper(profile_
->GetRequestContext());
58 mock_browsing_data_database_helper_
=
59 new MockBrowsingDataDatabaseHelper(profile_
.get());
60 mock_browsing_data_local_storage_helper_
=
61 new MockBrowsingDataLocalStorageHelper(profile_
.get());
62 mock_browsing_data_session_storage_helper_
=
63 new MockBrowsingDataLocalStorageHelper(profile_
.get());
64 mock_browsing_data_appcache_helper_
=
65 new MockBrowsingDataAppCacheHelper(profile_
.get());
66 mock_browsing_data_indexed_db_helper_
=
67 new MockBrowsingDataIndexedDBHelper(profile_
.get());
68 mock_browsing_data_file_system_helper_
=
69 new MockBrowsingDataFileSystemHelper(profile_
.get());
70 mock_browsing_data_quota_helper_
=
71 new MockBrowsingDataQuotaHelper(profile_
.get());
72 mock_browsing_data_channel_id_helper_
=
73 new MockBrowsingDataChannelIDHelper();
74 mock_browsing_data_service_worker_helper_
=
75 new MockBrowsingDataServiceWorkerHelper(profile_
.get());
76 mock_browsing_data_flash_lso_helper_
=
77 new MockBrowsingDataFlashLSOHelper(profile_
.get());
79 scoped_refptr
<CookieSettings
> cookie_settings
=
80 new CookieSettings(profile_
->GetHostContentSettingsMap(),
81 profile_
->GetPrefs());
82 #if defined(ENABLE_EXTENSIONS)
83 special_storage_policy_
=
84 new ExtensionSpecialStoragePolicy(cookie_settings
.get());
88 void TearDown() override
{
89 mock_browsing_data_service_worker_helper_
= NULL
;
90 mock_browsing_data_channel_id_helper_
= NULL
;
91 mock_browsing_data_quota_helper_
= NULL
;
92 mock_browsing_data_file_system_helper_
= NULL
;
93 mock_browsing_data_indexed_db_helper_
= NULL
;
94 mock_browsing_data_appcache_helper_
= NULL
;
95 mock_browsing_data_session_storage_helper_
= NULL
;
96 mock_browsing_data_local_storage_helper_
= NULL
;
97 mock_browsing_data_database_helper_
= NULL
;
98 mock_browsing_data_flash_lso_helper_
= NULL
;
99 base::MessageLoop::current()->RunUntilIdle();
102 scoped_ptr
<CookiesTreeModel
> CreateCookiesTreeModelWithInitialSample() {
103 LocalDataContainer
* container
= new LocalDataContainer(
104 mock_browsing_data_cookie_helper_
.get(),
105 mock_browsing_data_database_helper_
.get(),
106 mock_browsing_data_local_storage_helper_
.get(),
107 mock_browsing_data_session_storage_helper_
.get(),
108 mock_browsing_data_appcache_helper_
.get(),
109 mock_browsing_data_indexed_db_helper_
.get(),
110 mock_browsing_data_file_system_helper_
.get(),
111 mock_browsing_data_quota_helper_
.get(),
112 mock_browsing_data_channel_id_helper_
.get(),
113 mock_browsing_data_service_worker_helper_
.get(),
114 mock_browsing_data_flash_lso_helper_
.get());
116 CookiesTreeModel
* cookies_model
=
117 new CookiesTreeModel(container
, special_storage_policy(), false);
118 mock_browsing_data_cookie_helper_
->
119 AddCookieSamples(GURL("http://foo1"), "A=1");
120 mock_browsing_data_cookie_helper_
->
121 AddCookieSamples(GURL("http://foo2"), "B=1");
122 mock_browsing_data_cookie_helper_
->
123 AddCookieSamples(GURL("http://foo3"), "C=1");
124 mock_browsing_data_cookie_helper_
->Notify();
125 mock_browsing_data_database_helper_
->AddDatabaseSamples();
126 mock_browsing_data_database_helper_
->Notify();
127 mock_browsing_data_local_storage_helper_
->AddLocalStorageSamples();
128 mock_browsing_data_local_storage_helper_
->Notify();
129 mock_browsing_data_session_storage_helper_
->AddLocalStorageSamples();
130 mock_browsing_data_session_storage_helper_
->Notify();
131 mock_browsing_data_indexed_db_helper_
->AddIndexedDBSamples();
132 mock_browsing_data_indexed_db_helper_
->Notify();
133 mock_browsing_data_file_system_helper_
->AddFileSystemSamples();
134 mock_browsing_data_file_system_helper_
->Notify();
135 mock_browsing_data_quota_helper_
->AddQuotaSamples();
136 mock_browsing_data_quota_helper_
->Notify();
137 mock_browsing_data_channel_id_helper_
->AddChannelIDSample(
139 mock_browsing_data_channel_id_helper_
->AddChannelIDSample(
141 mock_browsing_data_channel_id_helper_
->Notify();
142 mock_browsing_data_service_worker_helper_
->AddServiceWorkerSamples();
143 mock_browsing_data_service_worker_helper_
->Notify();
144 mock_browsing_data_flash_lso_helper_
->AddFlashLSODomain("xyz.com");
145 mock_browsing_data_flash_lso_helper_
->Notify();
148 SCOPED_TRACE("Initial State 3 cookies, 2 databases, 2 local storages, "
149 "2 session storages, 2 indexed DBs, 3 filesystems, "
150 "2 quotas, 2 server bound certs, 2 service workers, "
152 // 59 because there's the root, then
153 // foo1 -> cookies -> a,
154 // foo2 -> cookies -> b,
155 // foo3 -> cookies -> c,
156 // dbhost1 -> database -> db1,
157 // dbhost2 -> database -> db2,
158 // host1 -> localstorage -> http://host1:1/,
159 // -> sessionstorage -> http://host1:1/,
160 // host2 -> localstorage -> http://host2:2/.
161 // -> sessionstorage -> http://host2:2/,
162 // idbhost1 -> indexeddb -> http://idbhost1:1/,
163 // idbhost2 -> indexeddb -> http://idbhost2:2/,
164 // fshost1 -> filesystem -> http://fshost1:1/,
165 // fshost2 -> filesystem -> http://fshost2:1/,
166 // fshost3 -> filesystem -> http://fshost3:1/,
167 // quotahost1 -> quotahost1,
168 // quotahost2 -> quotahost2,
169 // sbc1 -> sbcerts -> sbc1,
170 // sbc2 -> sbcerts -> sbc2.
171 // swhost1 -> service worker -> https://swhost1:1
172 // swhost2 -> service worker -> https://swhost1:2
173 // xyz.com -> flash_lsos
174 EXPECT_EQ(59, cookies_model
->GetRoot()->GetTotalNodeCount());
175 EXPECT_EQ("A,B,C", GetDisplayedCookies(cookies_model
));
176 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
));
177 EXPECT_EQ("http://host1:1/,http://host2:2/",
178 GetDisplayedLocalStorages(cookies_model
));
179 EXPECT_EQ("http://host1:1/,http://host2:2/",
180 GetDisplayedSessionStorages(cookies_model
));
181 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
182 GetDisplayedIndexedDBs(cookies_model
));
183 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
184 GetDisplayedFileSystems(cookies_model
));
185 EXPECT_EQ("quotahost1,quotahost2",
186 GetDisplayedQuotas(cookies_model
));
187 EXPECT_EQ("sbc1,sbc2",
188 GetDisplayedChannelIDs(cookies_model
));
189 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
190 GetDisplayedServiceWorkers(cookies_model
));
192 GetDisplayedFlashLSOs(cookies_model
));
194 return make_scoped_ptr(cookies_model
);
197 std::string
GetNodesOfChildren(
198 const CookieTreeNode
* node
,
199 CookieTreeNode::DetailedInfo::NodeType node_type
) {
200 if (!node
->empty()) {
202 for (int i
= 0; i
< node
->child_count(); ++i
) {
203 retval
+= GetNodesOfChildren(node
->GetChild(i
), node_type
);
208 if (node
->GetDetailedInfo().node_type
!= node_type
)
209 return std::string();
212 case CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE
:
213 return node
->GetDetailedInfo().session_storage_info
->origin_url
.spec() +
215 case CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE
:
216 return node
->GetDetailedInfo().local_storage_info
->origin_url
.spec() +
218 case CookieTreeNode::DetailedInfo::TYPE_DATABASE
:
219 return node
->GetDetailedInfo().database_info
->database_name
+ ",";
220 case CookieTreeNode::DetailedInfo::TYPE_COOKIE
:
221 return node
->GetDetailedInfo().cookie
->Name() + ",";
222 case CookieTreeNode::DetailedInfo::TYPE_APPCACHE
:
223 return node
->GetDetailedInfo().appcache_info
->manifest_url
.spec() +
225 case CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB
:
226 return node
->GetDetailedInfo().indexed_db_info
->origin_
.spec() +
228 case CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM
:
229 return node
->GetDetailedInfo().file_system_info
->origin
.spec() +
231 case CookieTreeNode::DetailedInfo::TYPE_QUOTA
:
232 return node
->GetDetailedInfo().quota_info
->host
+ ",";
233 case CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID
:
234 return node
->GetDetailedInfo().channel_id
->server_identifier() + ",";
235 case CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER
:
236 return node
->GetDetailedInfo().service_worker_info
->origin
.spec() + ",";
237 case CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO
:
238 return node
->GetDetailedInfo().flash_lso_domain
+ ",";
240 return std::string();
244 std::string
GetCookiesOfChildren(const CookieTreeNode
* node
) {
245 return GetNodesOfChildren(node
, CookieTreeNode::DetailedInfo::TYPE_COOKIE
);
248 std::string
GetDatabasesOfChildren(const CookieTreeNode
* node
) {
249 return GetNodesOfChildren(node
,
250 CookieTreeNode::DetailedInfo::TYPE_DATABASE
);
253 std::string
GetLocalStoragesOfChildren(const CookieTreeNode
* node
) {
254 return GetNodesOfChildren(node
,
255 CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE
);
258 std::string
GetSessionStoragesOfChildren(const CookieTreeNode
* node
) {
259 return GetNodesOfChildren(
260 node
, CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE
);
263 std::string
GetIndexedDBsOfChildren(const CookieTreeNode
* node
) {
264 return GetNodesOfChildren(
265 node
, CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB
);
268 std::string
GetFileSystemsOfChildren(const CookieTreeNode
* node
) {
269 return GetNodesOfChildren(
270 node
, CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM
);
273 std::string
GetFileQuotaOfChildren(const CookieTreeNode
* node
) {
274 return GetNodesOfChildren(
275 node
, CookieTreeNode::DetailedInfo::TYPE_QUOTA
);
278 std::string
GetServiceWorkersOfChildren(const CookieTreeNode
* node
) {
279 return GetNodesOfChildren(
280 node
, CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER
);
283 std::string
GetFlashLSOsOfChildren(const CookieTreeNode
* node
) {
284 return GetNodesOfChildren(
285 node
, CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO
);
288 // Get the nodes names displayed in the view (if we had one) in the order
289 // they are displayed, as a comma seperated string.
290 // Ex: EXPECT_STREQ("X,Y", GetDisplayedNodes(cookies_view, type).c_str());
291 std::string
GetDisplayedNodes(CookiesTreeModel
* cookies_model
,
292 CookieTreeNode::DetailedInfo::NodeType type
) {
293 CookieTreeRootNode
* root
= static_cast<CookieTreeRootNode
*>(
294 cookies_model
->GetRoot());
295 std::string retval
= GetNodesOfChildren(root
, type
);
296 if (retval
.length() && retval
[retval
.length() - 1] == ',')
297 retval
.erase(retval
.length() - 1);
301 std::string
GetDisplayedCookies(CookiesTreeModel
* cookies_model
) {
302 return GetDisplayedNodes(cookies_model
,
303 CookieTreeNode::DetailedInfo::TYPE_COOKIE
);
306 std::string
GetDisplayedDatabases(CookiesTreeModel
* cookies_model
) {
307 return GetDisplayedNodes(cookies_model
,
308 CookieTreeNode::DetailedInfo::TYPE_DATABASE
);
311 std::string
GetDisplayedLocalStorages(CookiesTreeModel
* cookies_model
) {
312 return GetDisplayedNodes(cookies_model
,
313 CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE
);
316 std::string
GetDisplayedSessionStorages(CookiesTreeModel
* cookies_model
) {
317 return GetDisplayedNodes(
318 cookies_model
, CookieTreeNode::DetailedInfo::TYPE_SESSION_STORAGE
);
321 std::string
GetDisplayedAppCaches(CookiesTreeModel
* cookies_model
) {
322 return GetDisplayedNodes(cookies_model
,
323 CookieTreeNode::DetailedInfo::TYPE_APPCACHE
);
326 std::string
GetDisplayedIndexedDBs(CookiesTreeModel
* cookies_model
) {
327 return GetDisplayedNodes(cookies_model
,
328 CookieTreeNode::DetailedInfo::TYPE_INDEXED_DB
);
331 std::string
GetDisplayedFileSystems(CookiesTreeModel
* cookies_model
) {
332 return GetDisplayedNodes(cookies_model
,
333 CookieTreeNode::DetailedInfo::TYPE_FILE_SYSTEM
);
336 std::string
GetDisplayedQuotas(CookiesTreeModel
* cookies_model
) {
337 return GetDisplayedNodes(cookies_model
,
338 CookieTreeNode::DetailedInfo::TYPE_QUOTA
);
341 std::string
GetDisplayedChannelIDs(CookiesTreeModel
* cookies_model
) {
342 return GetDisplayedNodes(
343 cookies_model
, CookieTreeNode::DetailedInfo::TYPE_CHANNEL_ID
);
346 std::string
GetDisplayedServiceWorkers(CookiesTreeModel
* cookies_model
) {
347 return GetDisplayedNodes(cookies_model
,
348 CookieTreeNode::DetailedInfo::TYPE_SERVICE_WORKER
);
351 std::string
GetDisplayedFlashLSOs(CookiesTreeModel
* cookies_model
) {
352 return GetDisplayedNodes(
353 cookies_model
, CookieTreeNode::DetailedInfo::TYPE_FLASH_LSO
);
356 // Do not call on the root.
357 void DeleteStoredObjects(CookieTreeNode
* node
) {
358 node
->DeleteStoredObjects();
359 CookieTreeNode
* parent_node
= node
->parent();
361 delete parent_node
->GetModel()->Remove(parent_node
, node
);
365 ExtensionSpecialStoragePolicy
* special_storage_policy() {
366 #if defined(ENABLE_EXTENSIONS)
367 return special_storage_policy_
.get();
373 content::TestBrowserThreadBundle thread_bundle_
;
374 scoped_ptr
<TestingProfile
> profile_
;
375 scoped_refptr
<MockBrowsingDataCookieHelper
>
376 mock_browsing_data_cookie_helper_
;
377 scoped_refptr
<MockBrowsingDataDatabaseHelper
>
378 mock_browsing_data_database_helper_
;
379 scoped_refptr
<MockBrowsingDataLocalStorageHelper
>
380 mock_browsing_data_local_storage_helper_
;
381 scoped_refptr
<MockBrowsingDataLocalStorageHelper
>
382 mock_browsing_data_session_storage_helper_
;
383 scoped_refptr
<MockBrowsingDataAppCacheHelper
>
384 mock_browsing_data_appcache_helper_
;
385 scoped_refptr
<MockBrowsingDataIndexedDBHelper
>
386 mock_browsing_data_indexed_db_helper_
;
387 scoped_refptr
<MockBrowsingDataFileSystemHelper
>
388 mock_browsing_data_file_system_helper_
;
389 scoped_refptr
<MockBrowsingDataQuotaHelper
>
390 mock_browsing_data_quota_helper_
;
391 scoped_refptr
<MockBrowsingDataChannelIDHelper
>
392 mock_browsing_data_channel_id_helper_
;
393 scoped_refptr
<MockBrowsingDataServiceWorkerHelper
>
394 mock_browsing_data_service_worker_helper_
;
395 scoped_refptr
<MockBrowsingDataFlashLSOHelper
>
396 mock_browsing_data_flash_lso_helper_
;
398 #if defined(ENABLE_EXTENSIONS)
399 scoped_refptr
<ExtensionSpecialStoragePolicy
> special_storage_policy_
;
403 TEST_F(CookiesTreeModelTest
, RemoveAll
) {
404 scoped_ptr
<CookiesTreeModel
> cookies_model(
405 CreateCookiesTreeModelWithInitialSample());
407 // Reset the selection of the first row.
409 SCOPED_TRACE("Before removing");
411 GetDisplayedCookies(cookies_model
.get()));
413 GetDisplayedDatabases(cookies_model
.get()));
414 EXPECT_EQ("http://host1:1/,http://host2:2/",
415 GetDisplayedLocalStorages(cookies_model
.get()));
416 EXPECT_EQ("http://host1:1/,http://host2:2/",
417 GetDisplayedSessionStorages(cookies_model
.get()));
418 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
419 GetDisplayedIndexedDBs(cookies_model
.get()));
420 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
421 GetDisplayedFileSystems(cookies_model
.get()));
422 EXPECT_EQ("quotahost1,quotahost2",
423 GetDisplayedQuotas(cookies_model
.get()));
424 EXPECT_EQ("sbc1,sbc2",
425 GetDisplayedChannelIDs(cookies_model
.get()));
426 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
427 GetDisplayedServiceWorkers(cookies_model
.get()));
429 GetDisplayedFlashLSOs(cookies_model
.get()));
432 mock_browsing_data_cookie_helper_
->Reset();
433 mock_browsing_data_database_helper_
->Reset();
434 mock_browsing_data_local_storage_helper_
->Reset();
435 mock_browsing_data_session_storage_helper_
->Reset();
436 mock_browsing_data_indexed_db_helper_
->Reset();
437 mock_browsing_data_service_worker_helper_
->Reset();
438 mock_browsing_data_file_system_helper_
->Reset();
440 cookies_model
->DeleteAllStoredObjects();
442 // Make sure the nodes are also deleted from the model's cache.
443 // http://crbug.com/43249
444 cookies_model
->UpdateSearchResults(base::string16());
447 // 2 nodes - root and app
448 SCOPED_TRACE("After removing");
449 EXPECT_EQ(1, cookies_model
->GetRoot()->GetTotalNodeCount());
450 EXPECT_EQ(0, cookies_model
->GetRoot()->child_count());
451 EXPECT_EQ(std::string(), GetDisplayedCookies(cookies_model
.get()));
452 EXPECT_TRUE(mock_browsing_data_cookie_helper_
->AllDeleted());
453 EXPECT_TRUE(mock_browsing_data_database_helper_
->AllDeleted());
454 EXPECT_TRUE(mock_browsing_data_local_storage_helper_
->AllDeleted());
455 EXPECT_FALSE(mock_browsing_data_session_storage_helper_
->AllDeleted());
456 EXPECT_TRUE(mock_browsing_data_indexed_db_helper_
->AllDeleted());
457 EXPECT_TRUE(mock_browsing_data_file_system_helper_
->AllDeleted());
458 EXPECT_TRUE(mock_browsing_data_channel_id_helper_
->AllDeleted());
459 EXPECT_TRUE(mock_browsing_data_service_worker_helper_
->AllDeleted());
460 EXPECT_TRUE(mock_browsing_data_flash_lso_helper_
->AllDeleted());
464 TEST_F(CookiesTreeModelTest
, Remove
) {
465 scoped_ptr
<CookiesTreeModel
> cookies_model(
466 CreateCookiesTreeModelWithInitialSample());
468 // Children start out arranged as follows:
490 // Here, we'll remove them one by one, starting from the end, and
491 // check that the state makes sense.
493 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(18));
495 SCOPED_TRACE("`xyz.com` removed.");
496 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
497 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
498 EXPECT_EQ("http://host1:1/,http://host2:2/",
499 GetDisplayedLocalStorages(cookies_model
.get()));
500 EXPECT_EQ("http://host1:1/,http://host2:2/",
501 GetDisplayedSessionStorages(cookies_model
.get()));
502 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
503 GetDisplayedFileSystems(cookies_model
.get()));
504 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
505 GetDisplayedIndexedDBs(cookies_model
.get()));
506 EXPECT_EQ("quotahost1,quotahost2",
507 GetDisplayedQuotas(cookies_model
.get()));
508 EXPECT_EQ("sbc1,sbc2",
509 GetDisplayedChannelIDs(cookies_model
.get()));
510 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
511 GetDisplayedServiceWorkers(cookies_model
.get()));
512 EXPECT_EQ(57, cookies_model
->GetRoot()->GetTotalNodeCount());
514 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(17));
516 SCOPED_TRACE("`swhost2` removed.");
517 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
518 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
519 EXPECT_EQ("http://host1:1/,http://host2:2/",
520 GetDisplayedLocalStorages(cookies_model
.get()));
521 EXPECT_EQ("http://host1:1/,http://host2:2/",
522 GetDisplayedSessionStorages(cookies_model
.get()));
523 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
524 GetDisplayedFileSystems(cookies_model
.get()));
525 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
526 GetDisplayedIndexedDBs(cookies_model
.get()));
527 EXPECT_EQ("quotahost1,quotahost2",
528 GetDisplayedQuotas(cookies_model
.get()));
529 EXPECT_EQ("sbc1,sbc2",
530 GetDisplayedChannelIDs(cookies_model
.get()));
531 EXPECT_EQ("https://swhost1:1/",
532 GetDisplayedServiceWorkers(cookies_model
.get()));
533 EXPECT_EQ(54, cookies_model
->GetRoot()->GetTotalNodeCount());
535 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(16));
537 SCOPED_TRACE("`swhost1` removed.");
538 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
539 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
540 EXPECT_EQ("http://host1:1/,http://host2:2/",
541 GetDisplayedLocalStorages(cookies_model
.get()));
542 EXPECT_EQ("http://host1:1/,http://host2:2/",
543 GetDisplayedSessionStorages(cookies_model
.get()));
544 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
545 GetDisplayedFileSystems(cookies_model
.get()));
546 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
547 GetDisplayedIndexedDBs(cookies_model
.get()));
548 EXPECT_EQ("quotahost1,quotahost2",
549 GetDisplayedQuotas(cookies_model
.get()));
550 EXPECT_EQ("sbc1,sbc2",
551 GetDisplayedChannelIDs(cookies_model
.get()));
552 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
553 EXPECT_EQ(51, cookies_model
->GetRoot()->GetTotalNodeCount());
555 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(15));
557 SCOPED_TRACE("`sbc2` removed.");
558 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
559 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
560 EXPECT_EQ("http://host1:1/,http://host2:2/",
561 GetDisplayedLocalStorages(cookies_model
.get()));
562 EXPECT_EQ("http://host1:1/,http://host2:2/",
563 GetDisplayedSessionStorages(cookies_model
.get()));
564 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
565 GetDisplayedFileSystems(cookies_model
.get()));
566 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
567 GetDisplayedIndexedDBs(cookies_model
.get()));
568 EXPECT_EQ("quotahost1,quotahost2",
569 GetDisplayedQuotas(cookies_model
.get()));
571 GetDisplayedChannelIDs(cookies_model
.get()));
572 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
573 EXPECT_EQ(48, cookies_model
->GetRoot()->GetTotalNodeCount());
575 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(14));
577 SCOPED_TRACE("`sbc1` removed.");
578 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
579 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
580 EXPECT_EQ("http://host1:1/,http://host2:2/",
581 GetDisplayedLocalStorages(cookies_model
.get()));
582 EXPECT_EQ("http://host1:1/,http://host2:2/",
583 GetDisplayedSessionStorages(cookies_model
.get()));
584 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
585 GetDisplayedFileSystems(cookies_model
.get()));
586 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
587 GetDisplayedIndexedDBs(cookies_model
.get()));
588 EXPECT_EQ("quotahost1,quotahost2",
589 GetDisplayedQuotas(cookies_model
.get()));
590 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
591 EXPECT_EQ(45, cookies_model
->GetRoot()->GetTotalNodeCount());
593 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(13));
595 SCOPED_TRACE("`quotahost2` removed.");
596 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
597 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
598 EXPECT_EQ("http://host1:1/,http://host2:2/",
599 GetDisplayedLocalStorages(cookies_model
.get()));
600 EXPECT_EQ("http://host1:1/,http://host2:2/",
601 GetDisplayedSessionStorages(cookies_model
.get()));
602 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
603 GetDisplayedFileSystems(cookies_model
.get()));
604 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
605 GetDisplayedIndexedDBs(cookies_model
.get()));
606 EXPECT_EQ("quotahost1",
607 GetDisplayedQuotas(cookies_model
.get()));
608 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
609 EXPECT_EQ(43, cookies_model
->GetRoot()->GetTotalNodeCount());
611 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(12));
613 SCOPED_TRACE("`quotahost1` removed.");
614 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
615 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
616 EXPECT_EQ("http://host1:1/,http://host2:2/",
617 GetDisplayedLocalStorages(cookies_model
.get()));
618 EXPECT_EQ("http://host1:1/,http://host2:2/",
619 GetDisplayedSessionStorages(cookies_model
.get()));
620 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
621 GetDisplayedFileSystems(cookies_model
.get()));
622 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
623 GetDisplayedIndexedDBs(cookies_model
.get()));
624 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
625 EXPECT_EQ(41, cookies_model
->GetRoot()->GetTotalNodeCount());
627 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(11));
629 SCOPED_TRACE("`idbhost2` removed.");
630 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
631 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
632 EXPECT_EQ("http://host1:1/,http://host2:2/",
633 GetDisplayedLocalStorages(cookies_model
.get()));
634 EXPECT_EQ("http://host1:1/,http://host2:2/",
635 GetDisplayedSessionStorages(cookies_model
.get()));
636 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
637 GetDisplayedFileSystems(cookies_model
.get()));
638 EXPECT_EQ("http://idbhost1:1/",
639 GetDisplayedIndexedDBs(cookies_model
.get()));
640 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
641 EXPECT_EQ(38, cookies_model
->GetRoot()->GetTotalNodeCount());
643 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(10));
645 SCOPED_TRACE("`idbhost1` removed.");
646 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
647 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
648 EXPECT_EQ("http://host1:1/,http://host2:2/",
649 GetDisplayedLocalStorages(cookies_model
.get()));
650 EXPECT_EQ("http://host1:1/,http://host2:2/",
651 GetDisplayedSessionStorages(cookies_model
.get()));
652 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
653 GetDisplayedFileSystems(cookies_model
.get()));
654 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
655 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
656 EXPECT_EQ(35, cookies_model
->GetRoot()->GetTotalNodeCount());
658 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(9));
660 SCOPED_TRACE("`host2` removed.");
661 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
662 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
663 EXPECT_EQ("http://host1:1/",
664 GetDisplayedLocalStorages(cookies_model
.get()));
665 EXPECT_EQ("http://host1:1/",
666 GetDisplayedSessionStorages(cookies_model
.get()));
667 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
668 GetDisplayedFileSystems(cookies_model
.get()));
669 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
670 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
671 EXPECT_EQ(30, cookies_model
->GetRoot()->GetTotalNodeCount());
673 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(8));
675 SCOPED_TRACE("`host1` removed.");
676 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
677 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
678 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
679 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
680 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
681 GetDisplayedFileSystems(cookies_model
.get()));
682 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
683 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
684 EXPECT_EQ(25, cookies_model
->GetRoot()->GetTotalNodeCount());
686 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(7));
688 SCOPED_TRACE("`gdbhost2` removed.");
689 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
690 EXPECT_EQ("db1", GetDisplayedDatabases(cookies_model
.get()));
691 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
692 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
693 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
694 GetDisplayedFileSystems(cookies_model
.get()));
695 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
696 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
697 EXPECT_EQ(22, cookies_model
->GetRoot()->GetTotalNodeCount());
699 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(6));
701 SCOPED_TRACE("`gdbhost1` removed.");
702 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
703 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
704 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
705 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
706 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
707 GetDisplayedFileSystems(cookies_model
.get()));
708 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
709 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
710 EXPECT_EQ(19, cookies_model
->GetRoot()->GetTotalNodeCount());
712 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(5));
714 SCOPED_TRACE("`fshost3` removed.");
715 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
716 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
717 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
718 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
719 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/",
720 GetDisplayedFileSystems(cookies_model
.get()));
721 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
722 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
723 EXPECT_EQ(16, cookies_model
->GetRoot()->GetTotalNodeCount());
725 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(4));
727 SCOPED_TRACE("`fshost2` removed.");
728 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
729 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
730 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
731 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
732 EXPECT_EQ("http://fshost1:1/",
733 GetDisplayedFileSystems(cookies_model
.get()));
734 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
735 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
736 EXPECT_EQ(13, cookies_model
->GetRoot()->GetTotalNodeCount());
738 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(3));
740 SCOPED_TRACE("`fshost1` removed.");
741 EXPECT_STREQ("A,B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
742 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
743 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
744 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
745 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
746 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
747 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
748 EXPECT_EQ(10, cookies_model
->GetRoot()->GetTotalNodeCount());
750 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(2));
752 SCOPED_TRACE("`foo3` removed.");
753 EXPECT_STREQ("A,B", GetDisplayedCookies(cookies_model
.get()).c_str());
754 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
755 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
756 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
757 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
758 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
759 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
760 EXPECT_EQ(7, cookies_model
->GetRoot()->GetTotalNodeCount());
762 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(1));
764 SCOPED_TRACE("`foo2` removed.");
765 EXPECT_STREQ("A", GetDisplayedCookies(cookies_model
.get()).c_str());
766 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
767 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
768 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
769 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
770 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
771 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
772 EXPECT_EQ(4, cookies_model
->GetRoot()->GetTotalNodeCount());
774 DeleteStoredObjects(cookies_model
->GetRoot()->GetChild(0));
776 SCOPED_TRACE("`foo1` removed.");
777 EXPECT_STREQ("", GetDisplayedCookies(cookies_model
.get()).c_str());
778 EXPECT_EQ("", GetDisplayedDatabases(cookies_model
.get()));
779 EXPECT_EQ("", GetDisplayedLocalStorages(cookies_model
.get()));
780 EXPECT_EQ("", GetDisplayedSessionStorages(cookies_model
.get()));
781 EXPECT_EQ("", GetDisplayedFileSystems(cookies_model
.get()));
782 EXPECT_EQ("", GetDisplayedIndexedDBs(cookies_model
.get()));
783 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
784 EXPECT_EQ(1, cookies_model
->GetRoot()->GetTotalNodeCount());
788 TEST_F(CookiesTreeModelTest
, RemoveCookiesNode
) {
789 scoped_ptr
<CookiesTreeModel
> cookies_model(
790 CreateCookiesTreeModelWithInitialSample());
793 cookies_model
->GetRoot()->GetChild(0)->GetChild(0));
795 SCOPED_TRACE("First origin removed");
796 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
797 // 57 because in this case, the origin remains, although the COOKIES
798 // node beneath it has been deleted.
799 EXPECT_EQ(57, cookies_model
->GetRoot()->GetTotalNodeCount());
800 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
801 EXPECT_EQ("http://host1:1/,http://host2:2/",
802 GetDisplayedLocalStorages(cookies_model
.get()));
803 EXPECT_EQ("http://host1:1/,http://host2:2/",
804 GetDisplayedSessionStorages(cookies_model
.get()));
805 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
806 GetDisplayedIndexedDBs(cookies_model
.get()));
807 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
808 GetDisplayedFileSystems(cookies_model
.get()));
809 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
810 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
811 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
812 GetDisplayedServiceWorkers(cookies_model
.get()));
816 cookies_model
->GetRoot()->GetChild(6)->GetChild(0));
818 SCOPED_TRACE("First database removed");
819 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
820 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
821 EXPECT_EQ("http://host1:1/,http://host2:2/",
822 GetDisplayedLocalStorages(cookies_model
.get()));
823 EXPECT_EQ("http://host1:1/,http://host2:2/",
824 GetDisplayedSessionStorages(cookies_model
.get()));
825 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
826 GetDisplayedIndexedDBs(cookies_model
.get()));
827 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
828 GetDisplayedFileSystems(cookies_model
.get()));
829 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
830 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
831 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
832 GetDisplayedServiceWorkers(cookies_model
.get()));
833 EXPECT_EQ(55, cookies_model
->GetRoot()->GetTotalNodeCount());
837 cookies_model
->GetRoot()->GetChild(8)->GetChild(0));
839 SCOPED_TRACE("First origin removed");
840 EXPECT_STREQ("B,C", GetDisplayedCookies(cookies_model
.get()).c_str());
841 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
842 EXPECT_EQ("http://host2:2/",
843 GetDisplayedLocalStorages(cookies_model
.get()));
844 EXPECT_EQ("http://host1:1/,http://host2:2/",
845 GetDisplayedSessionStorages(cookies_model
.get()));
846 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
847 GetDisplayedIndexedDBs(cookies_model
.get()));
848 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
849 GetDisplayedFileSystems(cookies_model
.get()));
850 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
851 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
852 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
853 GetDisplayedServiceWorkers(cookies_model
.get()));
854 EXPECT_EQ(53, cookies_model
->GetRoot()->GetTotalNodeCount());
858 TEST_F(CookiesTreeModelTest
, RemoveCookieNode
) {
859 scoped_ptr
<CookiesTreeModel
> cookies_model(
860 CreateCookiesTreeModelWithInitialSample());
863 cookies_model
->GetRoot()->GetChild(1)->GetChild(0));
865 SCOPED_TRACE("Second origin COOKIES node removed");
866 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model
.get()).c_str());
867 EXPECT_EQ("db1,db2", GetDisplayedDatabases(cookies_model
.get()));
868 EXPECT_EQ("http://host1:1/,http://host2:2/",
869 GetDisplayedLocalStorages(cookies_model
.get()));
870 EXPECT_EQ("http://host1:1/,http://host2:2/",
871 GetDisplayedSessionStorages(cookies_model
.get()));
872 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
873 GetDisplayedIndexedDBs(cookies_model
.get()));
874 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
875 GetDisplayedFileSystems(cookies_model
.get()));
876 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
877 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
878 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
879 GetDisplayedServiceWorkers(cookies_model
.get()));
880 // 57 because in this case, the origin remains, although the COOKIES
881 // node beneath it has been deleted.
882 EXPECT_EQ(57, cookies_model
->GetRoot()->GetTotalNodeCount());
886 cookies_model
->GetRoot()->GetChild(6)->GetChild(0));
888 SCOPED_TRACE("First database removed");
889 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model
.get()).c_str());
890 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
891 EXPECT_EQ("http://host1:1/,http://host2:2/",
892 GetDisplayedLocalStorages(cookies_model
.get()));
893 EXPECT_EQ("http://host1:1/,http://host2:2/",
894 GetDisplayedSessionStorages(cookies_model
.get()));
895 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
896 GetDisplayedIndexedDBs(cookies_model
.get()));
897 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
898 GetDisplayedFileSystems(cookies_model
.get()));
899 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
900 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
901 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
902 GetDisplayedServiceWorkers(cookies_model
.get()));
903 EXPECT_EQ(55, cookies_model
->GetRoot()->GetTotalNodeCount());
907 cookies_model
->GetRoot()->GetChild(8)->GetChild(0));
909 SCOPED_TRACE("First origin removed");
910 EXPECT_STREQ("A,C", GetDisplayedCookies(cookies_model
.get()).c_str());
911 EXPECT_EQ("db2", GetDisplayedDatabases(cookies_model
.get()));
912 EXPECT_EQ("http://host2:2/",
913 GetDisplayedLocalStorages(cookies_model
.get()));
914 EXPECT_EQ("http://host1:1/,http://host2:2/",
915 GetDisplayedSessionStorages(cookies_model
.get()));
916 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
917 GetDisplayedIndexedDBs(cookies_model
.get()));
918 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
919 GetDisplayedFileSystems(cookies_model
.get()));
920 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(cookies_model
.get()));
921 EXPECT_EQ("sbc1,sbc2", GetDisplayedChannelIDs(cookies_model
.get()));
922 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
923 GetDisplayedServiceWorkers(cookies_model
.get()));
924 EXPECT_EQ(53, cookies_model
->GetRoot()->GetTotalNodeCount());
928 TEST_F(CookiesTreeModelTest
, RemoveSingleCookieNode
) {
929 LocalDataContainer
* container
=
930 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
931 mock_browsing_data_database_helper_
.get(),
932 mock_browsing_data_local_storage_helper_
.get(),
933 mock_browsing_data_session_storage_helper_
.get(),
934 mock_browsing_data_appcache_helper_
.get(),
935 mock_browsing_data_indexed_db_helper_
.get(),
936 mock_browsing_data_file_system_helper_
.get(),
937 mock_browsing_data_quota_helper_
.get(),
938 mock_browsing_data_channel_id_helper_
.get(),
939 mock_browsing_data_service_worker_helper_
.get(),
940 mock_browsing_data_flash_lso_helper_
.get());
941 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
943 mock_browsing_data_cookie_helper_
->
944 AddCookieSamples(GURL("http://foo1"), "A=1");
945 mock_browsing_data_cookie_helper_
->
946 AddCookieSamples(GURL("http://foo2"), "B=1");
947 mock_browsing_data_cookie_helper_
->
948 AddCookieSamples(GURL("http://foo3"), "C=1");
949 mock_browsing_data_cookie_helper_
->
950 AddCookieSamples(GURL("http://foo3"), "D=1");
951 mock_browsing_data_cookie_helper_
->Notify();
952 mock_browsing_data_database_helper_
->AddDatabaseSamples();
953 mock_browsing_data_database_helper_
->Notify();
954 mock_browsing_data_local_storage_helper_
->AddLocalStorageSamples();
955 mock_browsing_data_local_storage_helper_
->Notify();
956 mock_browsing_data_session_storage_helper_
->AddLocalStorageSamples();
957 mock_browsing_data_session_storage_helper_
->Notify();
958 mock_browsing_data_indexed_db_helper_
->AddIndexedDBSamples();
959 mock_browsing_data_indexed_db_helper_
->Notify();
960 mock_browsing_data_file_system_helper_
->AddFileSystemSamples();
961 mock_browsing_data_file_system_helper_
->Notify();
962 mock_browsing_data_quota_helper_
->AddQuotaSamples();
963 mock_browsing_data_quota_helper_
->Notify();
964 mock_browsing_data_service_worker_helper_
->AddServiceWorkerSamples();
965 mock_browsing_data_service_worker_helper_
->Notify();
968 SCOPED_TRACE("Initial State 4 cookies, 2 databases, 2 local storages, "
969 "2 session storages, 2 indexed DBs, 3 file systems, "
970 "2 quotas, 2 service workers.");
971 // 52 because there's the root, then
972 // foo1 -> cookies -> a,
973 // foo2 -> cookies -> b,
974 // foo3 -> cookies -> c,d
975 // dbhost1 -> database -> db1,
976 // dbhost2 -> database -> db2,
977 // host1 -> localstorage -> http://host1:1/,
978 // -> sessionstorage -> http://host1:1/,
979 // host2 -> localstorage -> http://host2:2/,
980 // -> sessionstorage -> http://host2:2/,
981 // idbhost1 -> sessionstorage -> http://idbhost1:1/,
982 // idbhost2 -> sessionstorage -> http://idbhost2:2/,
983 // fshost1 -> filesystem -> http://fshost1:1/,
984 // fshost2 -> filesystem -> http://fshost2:1/,
985 // fshost3 -> filesystem -> http://fshost3:1/,
986 // quotahost1 -> quotahost1,
987 // quotahost2 -> quotahost2.
988 // swhost1 -> service worker -> https://swhost1:1
989 // swhost2 -> service worker -> https://swhost1:2
990 EXPECT_EQ(52, cookies_model
.GetRoot()->GetTotalNodeCount());
991 EXPECT_STREQ("A,B,C,D", GetDisplayedCookies(&cookies_model
).c_str());
992 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
993 EXPECT_EQ("http://host1:1/,http://host2:2/",
994 GetDisplayedLocalStorages(&cookies_model
));
995 EXPECT_EQ("http://host1:1/,http://host2:2/",
996 GetDisplayedSessionStorages(&cookies_model
));
997 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
998 GetDisplayedIndexedDBs(&cookies_model
));
999 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1000 GetDisplayedFileSystems(&cookies_model
));
1001 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1002 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1003 GetDisplayedServiceWorkers(&cookies_model
));
1005 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(2));
1007 SCOPED_TRACE("Third origin removed");
1008 EXPECT_STREQ("A,B", GetDisplayedCookies(&cookies_model
).c_str());
1009 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
1010 EXPECT_EQ("http://host1:1/,http://host2:2/",
1011 GetDisplayedLocalStorages(&cookies_model
));
1012 EXPECT_EQ("http://host1:1/,http://host2:2/",
1013 GetDisplayedSessionStorages(&cookies_model
));
1014 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1015 GetDisplayedIndexedDBs(&cookies_model
));
1016 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1017 GetDisplayedFileSystems(&cookies_model
));
1018 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1019 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1020 GetDisplayedServiceWorkers(&cookies_model
));
1021 EXPECT_EQ(48, cookies_model
.GetRoot()->GetTotalNodeCount());
1025 TEST_F(CookiesTreeModelTest
, RemoveSingleCookieNodeOf3
) {
1026 LocalDataContainer
* container
=
1027 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1028 mock_browsing_data_database_helper_
.get(),
1029 mock_browsing_data_local_storage_helper_
.get(),
1030 mock_browsing_data_session_storage_helper_
.get(),
1031 mock_browsing_data_appcache_helper_
.get(),
1032 mock_browsing_data_indexed_db_helper_
.get(),
1033 mock_browsing_data_file_system_helper_
.get(),
1034 mock_browsing_data_quota_helper_
.get(),
1035 mock_browsing_data_channel_id_helper_
.get(),
1036 mock_browsing_data_service_worker_helper_
.get(),
1037 mock_browsing_data_flash_lso_helper_
.get());
1038 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1040 mock_browsing_data_cookie_helper_
->
1041 AddCookieSamples(GURL("http://foo1"), "A=1");
1042 mock_browsing_data_cookie_helper_
->
1043 AddCookieSamples(GURL("http://foo2"), "B=1");
1044 mock_browsing_data_cookie_helper_
->
1045 AddCookieSamples(GURL("http://foo3"), "C=1");
1046 mock_browsing_data_cookie_helper_
->
1047 AddCookieSamples(GURL("http://foo3"), "D=1");
1048 mock_browsing_data_cookie_helper_
->
1049 AddCookieSamples(GURL("http://foo3"), "E=1");
1050 mock_browsing_data_cookie_helper_
->Notify();
1051 mock_browsing_data_database_helper_
->AddDatabaseSamples();
1052 mock_browsing_data_database_helper_
->Notify();
1053 mock_browsing_data_local_storage_helper_
->AddLocalStorageSamples();
1054 mock_browsing_data_local_storage_helper_
->Notify();
1055 mock_browsing_data_session_storage_helper_
->AddLocalStorageSamples();
1056 mock_browsing_data_session_storage_helper_
->Notify();
1057 mock_browsing_data_indexed_db_helper_
->AddIndexedDBSamples();
1058 mock_browsing_data_indexed_db_helper_
->Notify();
1059 mock_browsing_data_file_system_helper_
->AddFileSystemSamples();
1060 mock_browsing_data_file_system_helper_
->Notify();
1061 mock_browsing_data_quota_helper_
->AddQuotaSamples();
1062 mock_browsing_data_quota_helper_
->Notify();
1063 mock_browsing_data_service_worker_helper_
->AddServiceWorkerSamples();
1064 mock_browsing_data_service_worker_helper_
->Notify();
1067 SCOPED_TRACE("Initial State 5 cookies, 2 databases, 2 local storages, "
1068 "2 session storages, 2 indexed DBs, 3 filesystems, "
1069 "2 quotas, 2 service workers.");
1070 // 53 because there's the root, then
1071 // foo1 -> cookies -> a,
1072 // foo2 -> cookies -> b,
1073 // foo3 -> cookies -> c,d,e
1074 // dbhost1 -> database -> db1,
1075 // dbhost2 -> database -> db2,
1076 // host1 -> localstorage -> http://host1:1/,
1077 // -> sessionstorage -> http://host1:1/,
1078 // host2 -> localstorage -> http://host2:2/,
1079 // -> sessionstorage -> http://host2:2/,
1080 // idbhost1 -> sessionstorage -> http://idbhost1:1/,
1081 // idbhost2 -> sessionstorage -> http://idbhost2:2/,
1082 // fshost1 -> filesystem -> http://fshost1:1/,
1083 // fshost2 -> filesystem -> http://fshost2:1/,
1084 // fshost3 -> filesystem -> http://fshost3:1/,
1085 // quotahost1 -> quotahost1,
1086 // quotahost2 -> quotahost2.
1087 // swhost1 -> service worker -> https://swhost1:1
1088 // swhost2 -> service worker -> https://swhost1:2
1089 EXPECT_EQ(53, cookies_model
.GetRoot()->GetTotalNodeCount());
1090 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model
).c_str());
1091 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
1092 EXPECT_EQ("http://host1:1/,http://host2:2/",
1093 GetDisplayedLocalStorages(&cookies_model
));
1094 EXPECT_EQ("http://host1:1/,http://host2:2/",
1095 GetDisplayedSessionStorages(&cookies_model
));
1096 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1097 GetDisplayedIndexedDBs(&cookies_model
));
1098 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1099 GetDisplayedFileSystems(&cookies_model
));
1100 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1101 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1102 GetDisplayedServiceWorkers(&cookies_model
));
1104 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(2)->GetChild(0)->
1107 SCOPED_TRACE("Middle cookie in third origin removed");
1108 EXPECT_STREQ("A,B,C,E", GetDisplayedCookies(&cookies_model
).c_str());
1109 EXPECT_EQ(52, cookies_model
.GetRoot()->GetTotalNodeCount());
1110 EXPECT_EQ("db1,db2", GetDisplayedDatabases(&cookies_model
));
1111 EXPECT_EQ("http://host1:1/,http://host2:2/",
1112 GetDisplayedLocalStorages(&cookies_model
));
1113 EXPECT_EQ("http://host1:1/,http://host2:2/",
1114 GetDisplayedSessionStorages(&cookies_model
));
1115 EXPECT_EQ("http://idbhost1:1/,http://idbhost2:2/",
1116 GetDisplayedIndexedDBs(&cookies_model
));
1117 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1118 GetDisplayedFileSystems(&cookies_model
));
1119 EXPECT_EQ("quotahost1,quotahost2", GetDisplayedQuotas(&cookies_model
));
1120 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1121 GetDisplayedServiceWorkers(&cookies_model
));
1125 TEST_F(CookiesTreeModelTest
, RemoveSecondOrigin
) {
1126 LocalDataContainer
* container
=
1127 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1128 mock_browsing_data_database_helper_
.get(),
1129 mock_browsing_data_local_storage_helper_
.get(),
1130 mock_browsing_data_session_storage_helper_
.get(),
1131 mock_browsing_data_appcache_helper_
.get(),
1132 mock_browsing_data_indexed_db_helper_
.get(),
1133 mock_browsing_data_file_system_helper_
.get(),
1134 mock_browsing_data_quota_helper_
.get(),
1135 mock_browsing_data_channel_id_helper_
.get(),
1136 mock_browsing_data_service_worker_helper_
.get(),
1137 mock_browsing_data_flash_lso_helper_
.get());
1138 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1140 mock_browsing_data_cookie_helper_
->
1141 AddCookieSamples(GURL("http://foo1"), "A=1");
1142 mock_browsing_data_cookie_helper_
->
1143 AddCookieSamples(GURL("http://foo2"), "B=1");
1144 mock_browsing_data_cookie_helper_
->
1145 AddCookieSamples(GURL("http://foo3"), "C=1");
1146 mock_browsing_data_cookie_helper_
->
1147 AddCookieSamples(GURL("http://foo3"), "D=1");
1148 mock_browsing_data_cookie_helper_
->
1149 AddCookieSamples(GURL("http://foo3"), "E=1");
1150 mock_browsing_data_cookie_helper_
->Notify();
1153 SCOPED_TRACE("Initial State 5 cookies");
1154 // 12 because there's the root, then foo1 -> cookies -> a,
1155 // foo2 -> cookies -> b, foo3 -> cookies -> c,d,e
1156 EXPECT_EQ(12, cookies_model
.GetRoot()->GetTotalNodeCount());
1157 EXPECT_STREQ("A,B,C,D,E", GetDisplayedCookies(&cookies_model
).c_str());
1159 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(1));
1161 SCOPED_TRACE("Second origin removed");
1162 EXPECT_STREQ("A,C,D,E", GetDisplayedCookies(&cookies_model
).c_str());
1163 // Left with root -> foo1 -> cookies -> a, foo3 -> cookies -> c,d,e
1164 EXPECT_EQ(9, cookies_model
.GetRoot()->GetTotalNodeCount());
1168 TEST_F(CookiesTreeModelTest
, OriginOrdering
) {
1169 LocalDataContainer
* container
=
1170 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1171 mock_browsing_data_database_helper_
.get(),
1172 mock_browsing_data_local_storage_helper_
.get(),
1173 mock_browsing_data_session_storage_helper_
.get(),
1174 mock_browsing_data_appcache_helper_
.get(),
1175 mock_browsing_data_indexed_db_helper_
.get(),
1176 mock_browsing_data_file_system_helper_
.get(),
1177 mock_browsing_data_quota_helper_
.get(),
1178 mock_browsing_data_channel_id_helper_
.get(),
1179 mock_browsing_data_service_worker_helper_
.get(),
1180 mock_browsing_data_flash_lso_helper_
.get());
1181 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1183 mock_browsing_data_cookie_helper_
->
1184 AddCookieSamples(GURL("http://a.foo2.com"), "A=1");
1185 mock_browsing_data_cookie_helper_
->
1186 AddCookieSamples(GURL("http://foo2.com"), "B=1");
1187 mock_browsing_data_cookie_helper_
->
1188 AddCookieSamples(GURL("http://b.foo1.com"), "C=1");
1189 // Leading dot on the foo4
1190 mock_browsing_data_cookie_helper_
->AddCookieSamples(
1191 GURL("http://foo4.com"), "D=1; domain=.foo4.com; path=/;");
1192 mock_browsing_data_cookie_helper_
->
1193 AddCookieSamples(GURL("http://a.foo1.com"), "E=1");
1194 mock_browsing_data_cookie_helper_
->
1195 AddCookieSamples(GURL("http://foo1.com"), "F=1");
1196 mock_browsing_data_cookie_helper_
->
1197 AddCookieSamples(GURL("http://foo3.com"), "G=1");
1198 mock_browsing_data_cookie_helper_
->
1199 AddCookieSamples(GURL("http://foo4.com"), "H=1");
1200 mock_browsing_data_cookie_helper_
->Notify();
1203 SCOPED_TRACE("Initial State 8 cookies");
1204 EXPECT_EQ(23, cookies_model
.GetRoot()->GetTotalNodeCount());
1205 EXPECT_STREQ("F,E,C,B,A,G,D,H",
1206 GetDisplayedCookies(&cookies_model
).c_str());
1209 DeleteStoredObjects(cookies_model
.GetRoot()->GetChild(1));
1211 EXPECT_STREQ("F,C,B,A,G,D,H", GetDisplayedCookies(&cookies_model
).c_str());
1215 TEST_F(CookiesTreeModelTest
, ContentSettings
) {
1216 GURL
host("http://xyz.com/");
1217 LocalDataContainer
* container
=
1218 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1219 mock_browsing_data_database_helper_
.get(),
1220 mock_browsing_data_local_storage_helper_
.get(),
1221 mock_browsing_data_session_storage_helper_
.get(),
1222 mock_browsing_data_appcache_helper_
.get(),
1223 mock_browsing_data_indexed_db_helper_
.get(),
1224 mock_browsing_data_file_system_helper_
.get(),
1225 mock_browsing_data_quota_helper_
.get(),
1226 mock_browsing_data_channel_id_helper_
.get(),
1227 mock_browsing_data_service_worker_helper_
.get(),
1228 mock_browsing_data_flash_lso_helper_
.get());
1229 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1231 mock_browsing_data_cookie_helper_
->AddCookieSamples(host
, "A=1");
1232 mock_browsing_data_cookie_helper_
->Notify();
1234 TestingProfile profile
;
1235 HostContentSettingsMap
* content_settings
=
1236 profile
.GetHostContentSettingsMap();
1237 CookieSettings
* cookie_settings
=
1238 CookieSettings::Factory::GetForProfile(&profile
).get();
1239 MockSettingsObserver
observer(content_settings
);
1241 CookieTreeRootNode
* root
=
1242 static_cast<CookieTreeRootNode
*>(cookies_model
.GetRoot());
1243 CookieTreeHostNode
* origin
=
1244 root
->GetOrCreateHostNode(host
);
1246 EXPECT_EQ(1, origin
->child_count());
1247 EXPECT_TRUE(origin
->CanCreateContentException());
1248 EXPECT_CALL(observer
,
1249 OnContentSettingsChanged(
1251 CONTENT_SETTINGS_TYPE_COOKIES
,
1253 ContentSettingsPattern::FromURLNoWildcard(host
),
1254 ContentSettingsPattern::Wildcard(),
1256 EXPECT_CALL(observer
,
1257 OnContentSettingsChanged(content_settings
,
1258 CONTENT_SETTINGS_TYPE_COOKIES
,
1260 ContentSettingsPattern::FromURL(host
),
1261 ContentSettingsPattern::Wildcard(),
1263 origin
->CreateContentException(
1264 cookie_settings
, CONTENT_SETTING_SESSION_ONLY
);
1265 EXPECT_TRUE(cookie_settings
->IsReadingCookieAllowed(host
, host
));
1266 EXPECT_TRUE(cookie_settings
->IsCookieSessionOnly(host
));
1269 TEST_F(CookiesTreeModelTest
, FileSystemFilter
) {
1270 scoped_ptr
<CookiesTreeModel
> cookies_model(
1271 CreateCookiesTreeModelWithInitialSample());
1273 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("fshost1"));
1274 EXPECT_EQ("http://fshost1:1/",
1275 GetDisplayedFileSystems(cookies_model
.get()));
1277 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("fshost2"));
1278 EXPECT_EQ("http://fshost2:2/",
1279 GetDisplayedFileSystems(cookies_model
.get()));
1281 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("fshost3"));
1282 EXPECT_EQ("http://fshost3:3/",
1283 GetDisplayedFileSystems(cookies_model
.get()));
1285 cookies_model
->UpdateSearchResults(base::string16());
1286 EXPECT_EQ("http://fshost1:1/,http://fshost2:2/,http://fshost3:3/",
1287 GetDisplayedFileSystems(cookies_model
.get()));
1290 TEST_F(CookiesTreeModelTest
, ServiceWorkerFilter
) {
1291 scoped_ptr
<CookiesTreeModel
> cookies_model(
1292 CreateCookiesTreeModelWithInitialSample());
1294 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("swhost1"));
1295 EXPECT_EQ("https://swhost1:1/",
1296 GetDisplayedServiceWorkers(cookies_model
.get()));
1298 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("swhost2"));
1299 EXPECT_EQ("https://swhost2:2/",
1300 GetDisplayedServiceWorkers(cookies_model
.get()));
1302 cookies_model
->UpdateSearchResults(base::ASCIIToUTF16("swhost3"));
1303 EXPECT_EQ("", GetDisplayedServiceWorkers(cookies_model
.get()));
1305 cookies_model
->UpdateSearchResults(base::string16());
1306 EXPECT_EQ("https://swhost1:1/,https://swhost2:2/",
1307 GetDisplayedServiceWorkers(cookies_model
.get()));
1310 TEST_F(CookiesTreeModelTest
, CookiesFilter
) {
1311 LocalDataContainer
* container
=
1312 new LocalDataContainer(mock_browsing_data_cookie_helper_
.get(),
1313 mock_browsing_data_database_helper_
.get(),
1314 mock_browsing_data_local_storage_helper_
.get(),
1315 mock_browsing_data_session_storage_helper_
.get(),
1316 mock_browsing_data_appcache_helper_
.get(),
1317 mock_browsing_data_indexed_db_helper_
.get(),
1318 mock_browsing_data_file_system_helper_
.get(),
1319 mock_browsing_data_quota_helper_
.get(),
1320 mock_browsing_data_channel_id_helper_
.get(),
1321 mock_browsing_data_service_worker_helper_
.get(),
1322 mock_browsing_data_flash_lso_helper_
.get());
1323 CookiesTreeModel
cookies_model(container
, special_storage_policy(), false);
1325 mock_browsing_data_cookie_helper_
->
1326 AddCookieSamples(GURL("http://123.com"), "A=1");
1327 mock_browsing_data_cookie_helper_
->
1328 AddCookieSamples(GURL("http://foo1.com"), "B=1");
1329 mock_browsing_data_cookie_helper_
->
1330 AddCookieSamples(GURL("http://foo2.com"), "C=1");
1331 mock_browsing_data_cookie_helper_
->
1332 AddCookieSamples(GURL("http://foo3.com"), "D=1");
1333 mock_browsing_data_cookie_helper_
->Notify();
1334 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model
));
1336 cookies_model
.UpdateSearchResults(base::string16(base::ASCIIToUTF16("foo")));
1337 EXPECT_EQ("B,C,D", GetDisplayedCookies(&cookies_model
));
1339 cookies_model
.UpdateSearchResults(base::string16(base::ASCIIToUTF16("2")));
1340 EXPECT_EQ("A,C", GetDisplayedCookies(&cookies_model
));
1342 cookies_model
.UpdateSearchResults(base::string16(base::ASCIIToUTF16("foo3")));
1343 EXPECT_EQ("D", GetDisplayedCookies(&cookies_model
));
1345 cookies_model
.UpdateSearchResults(base::string16());
1346 EXPECT_EQ("A,B,C,D", GetDisplayedCookies(&cookies_model
));