[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 1 | // Copyright 2013 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. |
| 4 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 5 | #include "base/file_util.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 6 | #include "base/message_loop/message_loop_proxy.h" |
| 7 | #include "base/run_loop.h" |
| 8 | #include "base/threading/thread.h" |
| 9 | #include "content/browser/browser_thread_impl.h" |
| 10 | #include "content/browser/gpu/shader_disk_cache.h" |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 11 | #include "content/browser/quota/mock_quota_manager.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 12 | #include "content/browser/storage_partition_impl.h" |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 13 | #include "content/public/browser/local_storage_usage_info.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 14 | #include "content/public/browser/storage_partition.h" |
[email protected] | 523e5c59 | 2014-04-30 21:46:25 | [diff] [blame] | 15 | #include "content/public/test/mock_special_storage_policy.h" |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 16 | #include "content/public/test/test_browser_context.h" |
| 17 | #include "content/public/test/test_browser_thread.h" |
[email protected] | ec04d3f | 2013-06-06 21:31:39 | [diff] [blame] | 18 | #include "content/public/test/test_browser_thread_bundle.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 19 | #include "net/base/test_completion_callback.h" |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 20 | #include "net/cookies/cookie_monster.h" |
| 21 | #include "net/url_request/url_request_context.h" |
| 22 | #include "net/url_request/url_request_context_getter.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 23 | #include "testing/gtest/include/gtest/gtest.h" |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 24 | #include "webkit/browser/quota/quota_manager.h" |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 25 | |
| 26 | namespace content { |
| 27 | namespace { |
| 28 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 29 | const int kDefaultClientId = 42; |
| 30 | const char kCacheKey[] = "key"; |
| 31 | const char kCacheValue[] = "cached value"; |
| 32 | |
| 33 | const char kTestOrigin1[] = "http://host1:1/"; |
| 34 | const char kTestOrigin2[] = "http://host2:1/"; |
| 35 | const char kTestOrigin3[] = "http://host3:1/"; |
| 36 | const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; |
| 37 | |
| 38 | const GURL kOrigin1(kTestOrigin1); |
| 39 | const GURL kOrigin2(kTestOrigin2); |
| 40 | const GURL kOrigin3(kTestOrigin3); |
| 41 | const GURL kOriginDevTools(kTestOriginDevTools); |
| 42 | |
| 43 | const base::FilePath::CharType kDomStorageOrigin1[] = |
| 44 | FILE_PATH_LITERAL("http_host1_1.localstorage"); |
| 45 | |
| 46 | const base::FilePath::CharType kDomStorageOrigin2[] = |
| 47 | FILE_PATH_LITERAL("http_host2_1.localstorage"); |
| 48 | |
| 49 | const base::FilePath::CharType kDomStorageOrigin3[] = |
| 50 | FILE_PATH_LITERAL("http_host3_1.localstorage"); |
| 51 | |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 52 | const storage::StorageType kTemporary = storage::kStorageTypeTemporary; |
| 53 | const storage::StorageType kPersistent = storage::kStorageTypePersistent; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 54 | |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 55 | const storage::QuotaClient::ID kClientFile = storage::QuotaClient::kFileSystem; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 56 | |
| 57 | const uint32 kAllQuotaRemoveMask = |
[email protected] | 93ea188 | 2014-07-10 20:30:12 | [diff] [blame] | 58 | StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 59 | StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
[email protected] | 93ea188 | 2014-07-10 20:30:12 | [diff] [blame] | 60 | StoragePartition::REMOVE_DATA_MASK_INDEXEDDB | |
| 61 | StoragePartition::REMOVE_DATA_MASK_WEBSQL; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 62 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 63 | class AwaitCompletionHelper { |
| 64 | public: |
| 65 | AwaitCompletionHelper() : start_(false), already_quit_(false) {} |
| 66 | virtual ~AwaitCompletionHelper() {} |
| 67 | |
| 68 | void BlockUntilNotified() { |
| 69 | if (!already_quit_) { |
| 70 | DCHECK(!start_); |
| 71 | start_ = true; |
| 72 | base::MessageLoop::current()->Run(); |
| 73 | } else { |
| 74 | DCHECK(!start_); |
| 75 | already_quit_ = false; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | void Notify() { |
| 80 | if (start_) { |
| 81 | DCHECK(!already_quit_); |
| 82 | base::MessageLoop::current()->Quit(); |
| 83 | start_ = false; |
| 84 | } else { |
| 85 | DCHECK(!already_quit_); |
| 86 | already_quit_ = true; |
| 87 | } |
| 88 | } |
| 89 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 90 | private: |
| 91 | // Helps prevent from running message_loop, if the callback invoked |
| 92 | // immediately. |
| 93 | bool start_; |
| 94 | bool already_quit_; |
| 95 | |
| 96 | DISALLOW_COPY_AND_ASSIGN(AwaitCompletionHelper); |
| 97 | }; |
| 98 | |
| 99 | class RemoveCookieTester { |
| 100 | public: |
| 101 | explicit RemoveCookieTester(TestBrowserContext* context) |
| 102 | : get_cookie_success_(false), monster_(NULL) { |
| 103 | SetMonster(context->GetRequestContext()->GetURLRequestContext()-> |
| 104 | cookie_store()->GetCookieMonster()); |
| 105 | } |
| 106 | |
| 107 | // Returns true, if the given cookie exists in the cookie store. |
| 108 | bool ContainsCookie() { |
| 109 | get_cookie_success_ = false; |
| 110 | monster_->GetCookiesWithOptionsAsync( |
| 111 | kOrigin1, net::CookieOptions(), |
| 112 | base::Bind(&RemoveCookieTester::GetCookieCallback, |
| 113 | base::Unretained(this))); |
| 114 | await_completion_.BlockUntilNotified(); |
| 115 | return get_cookie_success_; |
| 116 | } |
| 117 | |
| 118 | void AddCookie() { |
| 119 | monster_->SetCookieWithOptionsAsync( |
| 120 | kOrigin1, "A=1", net::CookieOptions(), |
| 121 | base::Bind(&RemoveCookieTester::SetCookieCallback, |
| 122 | base::Unretained(this))); |
| 123 | await_completion_.BlockUntilNotified(); |
| 124 | } |
| 125 | |
| 126 | protected: |
| 127 | void SetMonster(net::CookieStore* monster) { |
| 128 | monster_ = monster; |
| 129 | } |
| 130 | |
| 131 | private: |
| 132 | void GetCookieCallback(const std::string& cookies) { |
| 133 | if (cookies == "A=1") { |
| 134 | get_cookie_success_ = true; |
| 135 | } else { |
| 136 | EXPECT_EQ("", cookies); |
| 137 | get_cookie_success_ = false; |
| 138 | } |
| 139 | await_completion_.Notify(); |
| 140 | } |
| 141 | |
| 142 | void SetCookieCallback(bool result) { |
| 143 | ASSERT_TRUE(result); |
| 144 | await_completion_.Notify(); |
| 145 | } |
| 146 | |
| 147 | bool get_cookie_success_; |
| 148 | AwaitCompletionHelper await_completion_; |
| 149 | net::CookieStore* monster_; |
| 150 | |
| 151 | DISALLOW_COPY_AND_ASSIGN(RemoveCookieTester); |
| 152 | }; |
| 153 | |
| 154 | class RemoveLocalStorageTester { |
| 155 | public: |
| 156 | explicit RemoveLocalStorageTester(TestBrowserContext* profile) |
| 157 | : profile_(profile), dom_storage_context_(NULL) { |
| 158 | dom_storage_context_ = |
| 159 | content::BrowserContext::GetDefaultStoragePartition(profile)-> |
| 160 | GetDOMStorageContext(); |
| 161 | } |
| 162 | |
| 163 | // Returns true, if the given origin URL exists. |
| 164 | bool DOMStorageExistsForOrigin(const GURL& origin) { |
| 165 | GetLocalStorageUsage(); |
| 166 | await_completion_.BlockUntilNotified(); |
| 167 | for (size_t i = 0; i < infos_.size(); ++i) { |
| 168 | if (origin == infos_[i].origin) |
| 169 | return true; |
| 170 | } |
| 171 | return false; |
| 172 | } |
| 173 | |
| 174 | void AddDOMStorageTestData() { |
| 175 | // Note: This test depends on details of how the dom_storage library |
| 176 | // stores data in the host file system. |
| 177 | base::FilePath storage_path = |
| 178 | profile_->GetPath().AppendASCII("Local Storage"); |
[email protected] | 426d1c9 | 2013-12-03 20:08:54 | [diff] [blame] | 179 | base::CreateDirectory(storage_path); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 180 | |
| 181 | // Write some files. |
[email protected] | e5c2a22e | 2014-03-06 20:42:30 | [diff] [blame] | 182 | base::WriteFile(storage_path.Append(kDomStorageOrigin1), NULL, 0); |
| 183 | base::WriteFile(storage_path.Append(kDomStorageOrigin2), NULL, 0); |
| 184 | base::WriteFile(storage_path.Append(kDomStorageOrigin3), NULL, 0); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 185 | |
| 186 | // Tweak their dates. |
[email protected] | c0d50816 | 2013-12-04 22:49:00 | [diff] [blame] | 187 | base::Time now = base::Time::Now(); |
| 188 | base::TouchFile(storage_path.Append(kDomStorageOrigin1), now, now); |
| 189 | |
| 190 | base::Time one_day_ago = now - base::TimeDelta::FromDays(1); |
| 191 | base::TouchFile(storage_path.Append(kDomStorageOrigin2), |
| 192 | one_day_ago, one_day_ago); |
| 193 | |
| 194 | base::Time sixty_days_ago = now - base::TimeDelta::FromDays(60); |
| 195 | base::TouchFile(storage_path.Append(kDomStorageOrigin3), |
| 196 | sixty_days_ago, sixty_days_ago); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | private: |
| 200 | void GetLocalStorageUsage() { |
| 201 | dom_storage_context_->GetLocalStorageUsage( |
| 202 | base::Bind(&RemoveLocalStorageTester::OnGotLocalStorageUsage, |
| 203 | base::Unretained(this))); |
| 204 | } |
| 205 | void OnGotLocalStorageUsage( |
| 206 | const std::vector<content::LocalStorageUsageInfo>& infos) { |
| 207 | infos_ = infos; |
| 208 | await_completion_.Notify(); |
| 209 | } |
| 210 | |
| 211 | // We don't own these pointers. |
| 212 | TestBrowserContext* profile_; |
| 213 | content::DOMStorageContext* dom_storage_context_; |
| 214 | |
| 215 | std::vector<content::LocalStorageUsageInfo> infos_; |
| 216 | |
| 217 | AwaitCompletionHelper await_completion_; |
| 218 | |
| 219 | DISALLOW_COPY_AND_ASSIGN(RemoveLocalStorageTester); |
| 220 | }; |
| 221 | |
| 222 | bool IsWebSafeSchemeForTest(const std::string& scheme) { |
| 223 | return scheme == "http"; |
| 224 | } |
| 225 | |
| 226 | bool DoesOriginMatchForUnprotectedWeb( |
| 227 | const GURL& origin, |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 228 | storage::SpecialStoragePolicy* special_storage_policy) { |
[email protected] | 8c63cd2 | 2013-11-08 11:31:21 | [diff] [blame] | 229 | if (IsWebSafeSchemeForTest(origin.scheme())) |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 230 | return !special_storage_policy->IsStorageProtected(origin.GetOrigin()); |
| 231 | |
[email protected] | 8c63cd2 | 2013-11-08 11:31:21 | [diff] [blame] | 232 | return false; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | bool DoesOriginMatchForBothProtectedAndUnprotectedWeb( |
| 236 | const GURL& origin, |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 237 | storage::SpecialStoragePolicy* special_storage_policy) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 238 | return true; |
| 239 | } |
| 240 | |
| 241 | bool DoesOriginMatchUnprotected( |
| 242 | const GURL& origin, |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 243 | storage::SpecialStoragePolicy* special_storage_policy) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 244 | return origin.GetOrigin().scheme() != kOriginDevTools.scheme(); |
| 245 | } |
| 246 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 247 | void ClearQuotaData(content::StoragePartition* partition, |
| 248 | base::RunLoop* loop_to_quit) { |
[email protected] | 93ea188 | 2014-07-10 20:30:12 | [diff] [blame] | 249 | partition->ClearData(kAllQuotaRemoveMask, |
| 250 | StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, GURL(), |
| 251 | StoragePartition::OriginMatcherFunction(), base::Time(), |
| 252 | base::Time::Max(), loop_to_quit->QuitClosure()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | void ClearQuotaDataWithOriginMatcher( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 256 | content::StoragePartition* partition, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 257 | const GURL& remove_origin, |
| 258 | const StoragePartition::OriginMatcherFunction& origin_matcher, |
| 259 | const base::Time delete_begin, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 260 | base::RunLoop* loop_to_quit) { |
| 261 | partition->ClearData(kAllQuotaRemoveMask, |
| 262 | StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
| 263 | remove_origin, origin_matcher, delete_begin, |
| 264 | base::Time::Max(), loop_to_quit->QuitClosure()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | void ClearQuotaDataForOrigin( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 268 | content::StoragePartition* partition, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 269 | const GURL& remove_origin, |
| 270 | const base::Time delete_begin, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 271 | base::RunLoop* loop_to_quit) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 272 | ClearQuotaDataWithOriginMatcher( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 273 | partition, remove_origin, |
| 274 | StoragePartition::OriginMatcherFunction(), delete_begin, |
| 275 | loop_to_quit); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | void ClearQuotaDataForNonPersistent( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 279 | content::StoragePartition* partition, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 280 | const base::Time delete_begin, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 281 | base::RunLoop* loop_to_quit) { |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 282 | partition->ClearData( |
[email protected] | 93ea188 | 2014-07-10 20:30:12 | [diff] [blame] | 283 | kAllQuotaRemoveMask, |
| 284 | ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT, |
| 285 | GURL(), StoragePartition::OriginMatcherFunction(), delete_begin, |
| 286 | base::Time::Max(), loop_to_quit->QuitClosure()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 287 | } |
| 288 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 289 | void ClearCookies(content::StoragePartition* partition, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 290 | const base::Time delete_begin, |
| 291 | const base::Time delete_end, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 292 | base::RunLoop* run_loop) { |
| 293 | partition->ClearData( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 294 | StoragePartition::REMOVE_DATA_MASK_COOKIES, |
| 295 | StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 296 | GURL(), StoragePartition::OriginMatcherFunction(), |
| 297 | delete_begin, delete_end, run_loop->QuitClosure()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | void ClearStuff(uint32 remove_mask, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 301 | content::StoragePartition* partition, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 302 | const base::Time delete_begin, |
| 303 | const base::Time delete_end, |
| 304 | const StoragePartition::OriginMatcherFunction& origin_matcher, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 305 | base::RunLoop* run_loop) { |
| 306 | partition->ClearData( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 307 | remove_mask, StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 308 | GURL(), origin_matcher, delete_begin, delete_end, |
| 309 | run_loop->QuitClosure()); |
| 310 | } |
| 311 | |
| 312 | void ClearData(content::StoragePartition* partition, |
| 313 | base::RunLoop* run_loop) { |
| 314 | base::Time time; |
| 315 | partition->ClearData( |
| 316 | StoragePartition::REMOVE_DATA_MASK_SHADER_CACHE, |
| 317 | StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL, |
| 318 | GURL(), StoragePartition::OriginMatcherFunction(), |
| 319 | time, time, run_loop->QuitClosure()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 320 | } |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 321 | |
| 322 | } // namespace |
| 323 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 324 | class StoragePartitionImplTest : public testing::Test { |
| 325 | public: |
| 326 | StoragePartitionImplTest() |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 327 | : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 328 | browser_context_(new TestBrowserContext()) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 329 | } |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 330 | |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 331 | MockQuotaManager* GetMockManager() { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 332 | if (!quota_manager_.get()) { |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 333 | quota_manager_ = new MockQuotaManager( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 334 | browser_context_->IsOffTheRecord(), |
| 335 | browser_context_->GetPath(), |
| 336 | BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO).get(), |
| 337 | BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB).get(), |
| 338 | browser_context_->GetSpecialStoragePolicy()); |
| 339 | } |
| 340 | return quota_manager_.get(); |
| 341 | } |
| 342 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 343 | TestBrowserContext* browser_context() { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 344 | return browser_context_.get(); |
| 345 | } |
| 346 | |
| 347 | private: |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 348 | content::TestBrowserThreadBundle thread_bundle_; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 349 | scoped_ptr<TestBrowserContext> browser_context_; |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 350 | scoped_refptr<MockQuotaManager> quota_manager_; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 351 | |
| 352 | DISALLOW_COPY_AND_ASSIGN(StoragePartitionImplTest); |
| 353 | }; |
| 354 | |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 355 | class StoragePartitionShaderClearTest : public testing::Test { |
| 356 | public: |
[email protected] | ec04d3f | 2013-06-06 21:31:39 | [diff] [blame] | 357 | StoragePartitionShaderClearTest() |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 358 | : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP), |
| 359 | browser_context_(new TestBrowserContext()) { |
| 360 | ShaderCacheFactory::GetInstance()->SetCacheInfo( |
| 361 | kDefaultClientId, |
| 362 | BrowserContext::GetDefaultStoragePartition( |
| 363 | browser_context())->GetPath()); |
| 364 | cache_ = ShaderCacheFactory::GetInstance()->Get(kDefaultClientId); |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 365 | } |
| 366 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 367 | virtual ~StoragePartitionShaderClearTest() { |
| 368 | cache_ = NULL; |
| 369 | ShaderCacheFactory::GetInstance()->RemoveCacheInfo(kDefaultClientId); |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 370 | } |
| 371 | |
| 372 | void InitCache() { |
| 373 | net::TestCompletionCallback available_cb; |
| 374 | int rv = cache_->SetAvailableCallback(available_cb.callback()); |
| 375 | ASSERT_EQ(net::OK, available_cb.GetResult(rv)); |
| 376 | EXPECT_EQ(0, cache_->Size()); |
| 377 | |
| 378 | cache_->Cache(kCacheKey, kCacheValue); |
| 379 | |
| 380 | net::TestCompletionCallback complete_cb; |
| 381 | |
| 382 | rv = cache_->SetCacheCompleteCallback(complete_cb.callback()); |
| 383 | ASSERT_EQ(net::OK, complete_cb.GetResult(rv)); |
| 384 | } |
| 385 | |
| 386 | size_t Size() { return cache_->Size(); } |
| 387 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 388 | TestBrowserContext* browser_context() { |
| 389 | return browser_context_.get(); |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 390 | } |
| 391 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 392 | private: |
[email protected] | ec04d3f | 2013-06-06 21:31:39 | [diff] [blame] | 393 | content::TestBrowserThreadBundle thread_bundle_; |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 394 | scoped_ptr<TestBrowserContext> browser_context_; |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 395 | |
| 396 | scoped_refptr<ShaderDiskCache> cache_; |
| 397 | }; |
| 398 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 399 | // Tests --------------------------------------------------------------------- |
| 400 | |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 401 | TEST_F(StoragePartitionShaderClearTest, ClearShaderCache) { |
| 402 | InitCache(); |
| 403 | EXPECT_EQ(1u, Size()); |
| 404 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 405 | base::RunLoop run_loop; |
[email protected] | ec04d3f | 2013-06-06 21:31:39 | [diff] [blame] | 406 | base::MessageLoop::current()->PostTask( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 407 | FROM_HERE, base::Bind( |
| 408 | &ClearData, |
| 409 | BrowserContext::GetDefaultStoragePartition(browser_context()), |
| 410 | &run_loop)); |
| 411 | run_loop.Run(); |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 412 | EXPECT_EQ(0u, Size()); |
| 413 | } |
| 414 | |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 415 | TEST_F(StoragePartitionImplTest, QuotaClientMaskGeneration) { |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 416 | EXPECT_EQ(storage::QuotaClient::kFileSystem, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 417 | StoragePartitionImpl::GenerateQuotaClientMask( |
| 418 | StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS)); |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 419 | EXPECT_EQ(storage::QuotaClient::kDatabase, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 420 | StoragePartitionImpl::GenerateQuotaClientMask( |
| 421 | StoragePartition::REMOVE_DATA_MASK_WEBSQL)); |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 422 | EXPECT_EQ(storage::QuotaClient::kAppcache, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 423 | StoragePartitionImpl::GenerateQuotaClientMask( |
| 424 | StoragePartition::REMOVE_DATA_MASK_APPCACHE)); |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 425 | EXPECT_EQ(storage::QuotaClient::kIndexedDatabase, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 426 | StoragePartitionImpl::GenerateQuotaClientMask( |
| 427 | StoragePartition::REMOVE_DATA_MASK_INDEXEDDB)); |
[email protected] | cd501a7 | 2014-08-22 19:58:31 | [diff] [blame] | 428 | EXPECT_EQ(storage::QuotaClient::kFileSystem | |
| 429 | storage::QuotaClient::kDatabase | |
| 430 | storage::QuotaClient::kAppcache | |
| 431 | storage::QuotaClient::kIndexedDatabase, |
[email protected] | 93ea188 | 2014-07-10 20:30:12 | [diff] [blame] | 432 | StoragePartitionImpl::GenerateQuotaClientMask(kAllQuotaRemoveMask)); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 433 | } |
| 434 | |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 435 | void PopulateTestQuotaManagedPersistentData(MockQuotaManager* manager) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 436 | manager->AddOrigin(kOrigin2, kPersistent, kClientFile, base::Time()); |
| 437 | manager->AddOrigin(kOrigin3, kPersistent, kClientFile, |
| 438 | base::Time::Now() - base::TimeDelta::FromDays(1)); |
| 439 | |
| 440 | EXPECT_FALSE(manager->OriginHasData(kOrigin1, kPersistent, kClientFile)); |
| 441 | EXPECT_TRUE(manager->OriginHasData(kOrigin2, kPersistent, kClientFile)); |
| 442 | EXPECT_TRUE(manager->OriginHasData(kOrigin3, kPersistent, kClientFile)); |
| 443 | } |
| 444 | |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 445 | void PopulateTestQuotaManagedTemporaryData(MockQuotaManager* manager) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 446 | manager->AddOrigin(kOrigin1, kTemporary, kClientFile, base::Time::Now()); |
| 447 | manager->AddOrigin(kOrigin3, kTemporary, kClientFile, |
| 448 | base::Time::Now() - base::TimeDelta::FromDays(1)); |
| 449 | |
| 450 | EXPECT_TRUE(manager->OriginHasData(kOrigin1, kTemporary, kClientFile)); |
| 451 | EXPECT_FALSE(manager->OriginHasData(kOrigin2, kTemporary, kClientFile)); |
| 452 | EXPECT_TRUE(manager->OriginHasData(kOrigin3, kTemporary, kClientFile)); |
| 453 | } |
| 454 | |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 455 | void PopulateTestQuotaManagedData(MockQuotaManager* manager) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 456 | // Set up kOrigin1 with a temporary quota, kOrigin2 with a persistent |
| 457 | // quota, and kOrigin3 with both. kOrigin1 is modified now, kOrigin2 |
| 458 | // is modified at the beginning of time, and kOrigin3 is modified one day |
| 459 | // ago. |
| 460 | PopulateTestQuotaManagedPersistentData(manager); |
| 461 | PopulateTestQuotaManagedTemporaryData(manager); |
| 462 | } |
| 463 | |
[email protected] | 4cc6b45 | 2014-04-09 00:21:41 | [diff] [blame] | 464 | void PopulateTestQuotaManagedNonBrowsingData(MockQuotaManager* manager) { |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 465 | manager->AddOrigin(kOriginDevTools, kTemporary, kClientFile, base::Time()); |
| 466 | manager->AddOrigin(kOriginDevTools, kPersistent, kClientFile, base::Time()); |
| 467 | } |
| 468 | |
| 469 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverBoth) { |
| 470 | PopulateTestQuotaManagedData(GetMockManager()); |
| 471 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 472 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 473 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 474 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 475 | GetMockManager()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 476 | |
| 477 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 478 | base::MessageLoop::current()->PostTask( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 479 | FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 480 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 481 | |
| 482 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 483 | kClientFile)); |
| 484 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 485 | kClientFile)); |
| 486 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 487 | kClientFile)); |
| 488 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 489 | kClientFile)); |
| 490 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 491 | kClientFile)); |
| 492 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 493 | kClientFile)); |
| 494 | } |
| 495 | |
| 496 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
| 497 | PopulateTestQuotaManagedTemporaryData(GetMockManager()); |
| 498 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 499 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 500 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 501 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 502 | GetMockManager()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 503 | |
| 504 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 505 | base::MessageLoop::current()->PostTask( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 506 | FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 507 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 508 | |
| 509 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 510 | kClientFile)); |
| 511 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 512 | kClientFile)); |
| 513 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 514 | kClientFile)); |
| 515 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 516 | kClientFile)); |
| 517 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 518 | kClientFile)); |
| 519 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 520 | kClientFile)); |
| 521 | } |
| 522 | |
| 523 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
| 524 | PopulateTestQuotaManagedPersistentData(GetMockManager()); |
| 525 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 526 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 527 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 528 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 529 | GetMockManager()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 530 | |
| 531 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 532 | base::MessageLoop::current()->PostTask( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 533 | FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 534 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 535 | |
| 536 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 537 | kClientFile)); |
| 538 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 539 | kClientFile)); |
| 540 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 541 | kClientFile)); |
| 542 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 543 | kClientFile)); |
| 544 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 545 | kClientFile)); |
| 546 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 547 | kClientFile)); |
| 548 | } |
| 549 | |
| 550 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverNeither) { |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 551 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 552 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 553 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 554 | GetMockManager()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 555 | |
| 556 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 557 | base::MessageLoop::current()->PostTask( |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 558 | FROM_HERE, base::Bind(&ClearQuotaData, partition, &run_loop)); |
| 559 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 560 | |
| 561 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 562 | kClientFile)); |
| 563 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 564 | kClientFile)); |
| 565 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 566 | kClientFile)); |
| 567 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 568 | kClientFile)); |
| 569 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 570 | kClientFile)); |
| 571 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 572 | kClientFile)); |
| 573 | } |
| 574 | |
| 575 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
| 576 | PopulateTestQuotaManagedData(GetMockManager()); |
| 577 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 578 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 579 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 580 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 581 | GetMockManager()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 582 | |
| 583 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 584 | base::MessageLoop::current()->PostTask( |
| 585 | FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 586 | partition, kOrigin1, base::Time(), |
| 587 | &run_loop)); |
| 588 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 589 | |
| 590 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 591 | kClientFile)); |
| 592 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 593 | kClientFile)); |
| 594 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 595 | kClientFile)); |
| 596 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 597 | kClientFile)); |
| 598 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 599 | kClientFile)); |
| 600 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 601 | kClientFile)); |
| 602 | } |
| 603 | |
| 604 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastHour) { |
| 605 | PopulateTestQuotaManagedData(GetMockManager()); |
| 606 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 607 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 608 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 609 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 610 | GetMockManager()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 611 | |
| 612 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 613 | base::MessageLoop::current()->PostTask( |
| 614 | FROM_HERE, base::Bind(&ClearQuotaDataForOrigin, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 615 | partition, GURL(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 616 | base::Time::Now() - base::TimeDelta::FromHours(1), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 617 | &run_loop)); |
| 618 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 619 | |
| 620 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 621 | kClientFile)); |
| 622 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 623 | kClientFile)); |
| 624 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 625 | kClientFile)); |
| 626 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 627 | kClientFile)); |
| 628 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 629 | kClientFile)); |
| 630 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 631 | kClientFile)); |
| 632 | } |
| 633 | |
| 634 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedDataForLastWeek) { |
| 635 | PopulateTestQuotaManagedData(GetMockManager()); |
| 636 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 637 | base::RunLoop run_loop; |
| 638 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 639 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 640 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 641 | GetMockManager()); |
| 642 | base::MessageLoop::current()->PostTask( |
| 643 | FROM_HERE, base::Bind(&ClearQuotaDataForNonPersistent, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 644 | partition, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 645 | base::Time::Now() - base::TimeDelta::FromDays(7), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 646 | &run_loop)); |
| 647 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 648 | |
| 649 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 650 | kClientFile)); |
| 651 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 652 | kClientFile)); |
| 653 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 654 | kClientFile)); |
| 655 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 656 | kClientFile)); |
| 657 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 658 | kClientFile)); |
| 659 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 660 | kClientFile)); |
| 661 | } |
| 662 | |
| 663 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedUnprotectedOrigins) { |
| 664 | // Protect kOrigin1. |
[email protected] | 523e5c59 | 2014-04-30 21:46:25 | [diff] [blame] | 665 | scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 666 | new MockSpecialStoragePolicy; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 667 | mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 668 | |
| 669 | PopulateTestQuotaManagedData(GetMockManager()); |
| 670 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 671 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 672 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 673 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 674 | GetMockManager()); |
dcheng | 54c3719d | 2014-08-26 21:52:56 | [diff] [blame^] | 675 | partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 676 | |
| 677 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 678 | base::MessageLoop::current()->PostTask( |
| 679 | FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 680 | partition, GURL(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 681 | base::Bind(&DoesOriginMatchForUnprotectedWeb), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 682 | base::Time(), &run_loop)); |
| 683 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 684 | |
| 685 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 686 | kClientFile)); |
| 687 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 688 | kClientFile)); |
| 689 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 690 | kClientFile)); |
| 691 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 692 | kClientFile)); |
| 693 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 694 | kClientFile)); |
| 695 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 696 | kClientFile)); |
| 697 | } |
| 698 | |
| 699 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedSpecificOrigin) { |
| 700 | // Protect kOrigin1. |
[email protected] | 523e5c59 | 2014-04-30 21:46:25 | [diff] [blame] | 701 | scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 702 | new MockSpecialStoragePolicy; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 703 | mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 704 | |
| 705 | PopulateTestQuotaManagedData(GetMockManager()); |
| 706 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 707 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 708 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 709 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 710 | GetMockManager()); |
dcheng | 54c3719d | 2014-08-26 21:52:56 | [diff] [blame^] | 711 | partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 712 | |
| 713 | // Try to remove kOrigin1. Expect failure. |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 714 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 715 | base::MessageLoop::current()->PostTask( |
| 716 | FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 717 | partition, kOrigin1, |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 718 | base::Bind(&DoesOriginMatchForUnprotectedWeb), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 719 | base::Time(), &run_loop)); |
| 720 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 721 | |
| 722 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 723 | kClientFile)); |
| 724 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 725 | kClientFile)); |
| 726 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 727 | kClientFile)); |
| 728 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 729 | kClientFile)); |
| 730 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 731 | kClientFile)); |
| 732 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 733 | kClientFile)); |
| 734 | } |
| 735 | |
| 736 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedProtectedOrigins) { |
| 737 | // Protect kOrigin1. |
[email protected] | 523e5c59 | 2014-04-30 21:46:25 | [diff] [blame] | 738 | scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 739 | new MockSpecialStoragePolicy; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 740 | mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 741 | |
| 742 | PopulateTestQuotaManagedData(GetMockManager()); |
| 743 | |
| 744 | // Try to remove kOrigin1. Expect success. |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 745 | base::RunLoop run_loop; |
| 746 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 747 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 748 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 749 | GetMockManager()); |
dcheng | 54c3719d | 2014-08-26 21:52:56 | [diff] [blame^] | 750 | partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 751 | base::MessageLoop::current()->PostTask( |
| 752 | FROM_HERE, |
| 753 | base::Bind(&ClearQuotaDataWithOriginMatcher, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 754 | partition, GURL(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 755 | base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 756 | base::Time(), &run_loop)); |
| 757 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 758 | |
| 759 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kTemporary, |
| 760 | kClientFile)); |
| 761 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kTemporary, |
| 762 | kClientFile)); |
| 763 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kTemporary, |
| 764 | kClientFile)); |
| 765 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin1, kPersistent, |
| 766 | kClientFile)); |
| 767 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin2, kPersistent, |
| 768 | kClientFile)); |
| 769 | EXPECT_FALSE(GetMockManager()->OriginHasData(kOrigin3, kPersistent, |
| 770 | kClientFile)); |
| 771 | } |
| 772 | |
| 773 | TEST_F(StoragePartitionImplTest, RemoveQuotaManagedIgnoreDevTools) { |
| 774 | PopulateTestQuotaManagedNonBrowsingData(GetMockManager()); |
| 775 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 776 | base::RunLoop run_loop; |
| 777 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 778 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 779 | partition->OverrideQuotaManagerForTesting( |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 780 | GetMockManager()); |
| 781 | base::MessageLoop::current()->PostTask( |
| 782 | FROM_HERE, base::Bind(&ClearQuotaDataWithOriginMatcher, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 783 | partition, GURL(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 784 | base::Bind(&DoesOriginMatchUnprotected), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 785 | base::Time(), &run_loop)); |
| 786 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 787 | |
| 788 | // Check that devtools data isn't removed. |
| 789 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kTemporary, |
| 790 | kClientFile)); |
| 791 | EXPECT_TRUE(GetMockManager()->OriginHasData(kOriginDevTools, kPersistent, |
| 792 | kClientFile)); |
| 793 | } |
| 794 | |
| 795 | TEST_F(StoragePartitionImplTest, RemoveCookieForever) { |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 796 | RemoveCookieTester tester(browser_context()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 797 | |
| 798 | tester.AddCookie(); |
| 799 | ASSERT_TRUE(tester.ContainsCookie()); |
| 800 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 801 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 802 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 803 | partition->SetURLRequestContext(browser_context()->GetRequestContext()); |
| 804 | |
| 805 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 806 | base::MessageLoop::current()->PostTask( |
| 807 | FROM_HERE, base::Bind(&ClearCookies, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 808 | partition, base::Time(), base::Time::Max(), |
| 809 | &run_loop)); |
| 810 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 811 | |
| 812 | EXPECT_FALSE(tester.ContainsCookie()); |
| 813 | } |
| 814 | |
| 815 | TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) { |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 816 | RemoveCookieTester tester(browser_context()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 817 | |
| 818 | tester.AddCookie(); |
| 819 | ASSERT_TRUE(tester.ContainsCookie()); |
| 820 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 821 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 822 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 823 | base::Time an_hour_ago = base::Time::Now() - base::TimeDelta::FromHours(1); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 824 | partition->SetURLRequestContext(browser_context()->GetRequestContext()); |
| 825 | |
| 826 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 827 | base::MessageLoop::current()->PostTask( |
| 828 | FROM_HERE, base::Bind(&ClearCookies, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 829 | partition, an_hour_ago, base::Time::Max(), |
| 830 | &run_loop)); |
| 831 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 832 | |
| 833 | EXPECT_FALSE(tester.ContainsCookie()); |
| 834 | } |
| 835 | |
| 836 | TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) { |
| 837 | // Protect kOrigin1. |
[email protected] | 523e5c59 | 2014-04-30 21:46:25 | [diff] [blame] | 838 | scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 839 | new MockSpecialStoragePolicy; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 840 | mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 841 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 842 | RemoveLocalStorageTester tester(browser_context()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 843 | |
| 844 | tester.AddDOMStorageTestData(); |
| 845 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 846 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 847 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 848 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 849 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 850 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
dcheng | 54c3719d | 2014-08-26 21:52:56 | [diff] [blame^] | 851 | partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 852 | |
| 853 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 854 | base::MessageLoop::current()->PostTask( |
| 855 | FROM_HERE, |
| 856 | base::Bind(&ClearStuff, |
| 857 | StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 858 | partition, base::Time(), base::Time::Max(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 859 | base::Bind(&DoesOriginMatchForUnprotectedWeb), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 860 | &run_loop)); |
| 861 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 862 | |
| 863 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 864 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 865 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 866 | } |
| 867 | |
| 868 | TEST_F(StoragePartitionImplTest, RemoveProtectedLocalStorageForever) { |
| 869 | // Protect kOrigin1. |
[email protected] | 523e5c59 | 2014-04-30 21:46:25 | [diff] [blame] | 870 | scoped_refptr<MockSpecialStoragePolicy> mock_policy = |
| 871 | new MockSpecialStoragePolicy; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 872 | mock_policy->AddProtected(kOrigin1.GetOrigin()); |
| 873 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 874 | RemoveLocalStorageTester tester(browser_context()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 875 | |
| 876 | tester.AddDOMStorageTestData(); |
| 877 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 878 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 879 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 880 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 881 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 882 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
dcheng | 54c3719d | 2014-08-26 21:52:56 | [diff] [blame^] | 883 | partition->OverrideSpecialStoragePolicyForTesting(mock_policy.get()); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 884 | |
| 885 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 886 | base::MessageLoop::current()->PostTask( |
| 887 | FROM_HERE, |
| 888 | base::Bind(&ClearStuff, |
| 889 | StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 890 | partition, base::Time(), base::Time::Max(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 891 | base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 892 | &run_loop)); |
| 893 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 894 | |
| 895 | // Even if kOrigin1 is protected, it will be deleted since we specify |
| 896 | // ClearData to delete protected data. |
| 897 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 898 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 899 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 900 | } |
| 901 | |
| 902 | TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) { |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 903 | RemoveLocalStorageTester tester(browser_context()); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 904 | |
| 905 | tester.AddDOMStorageTestData(); |
| 906 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 907 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 908 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 909 | |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 910 | StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( |
| 911 | BrowserContext::GetDefaultStoragePartition(browser_context())); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 912 | base::Time a_week_ago = base::Time::Now() - base::TimeDelta::FromDays(7); |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 913 | |
| 914 | base::RunLoop run_loop; |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 915 | base::MessageLoop::current()->PostTask( |
| 916 | FROM_HERE, |
| 917 | base::Bind(&ClearStuff, |
| 918 | StoragePartitionImpl::REMOVE_DATA_MASK_LOCAL_STORAGE, |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 919 | partition, a_week_ago, base::Time::Max(), |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 920 | base::Bind(&DoesOriginMatchForBothProtectedAndUnprotectedWeb), |
[email protected] | 5ff8b2a | 2013-12-28 06:51:42 | [diff] [blame] | 921 | &run_loop)); |
| 922 | run_loop.Run(); |
[email protected] | 88562b51 | 2013-11-06 21:10:44 | [diff] [blame] | 923 | |
| 924 | // kOrigin1 and kOrigin2 do not have age more than a week. |
| 925 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin1)); |
| 926 | EXPECT_FALSE(tester.DOMStorageExistsForOrigin(kOrigin2)); |
| 927 | EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3)); |
| 928 | } |
| 929 | |
[email protected] | 877e261 | 2013-04-05 05:58:18 | [diff] [blame] | 930 | } // namespace content |