OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // Make sure we wait until the destructor has run. | 211 // Make sure we wait until the destructor has run. |
212 scoped_refptr<base::ThreadTestHelper> helper( | 212 scoped_refptr<base::ThreadTestHelper> helper( |
213 new base::ThreadTestHelper( | 213 new base::ThreadTestHelper( |
214 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT))); | 214 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT))); |
215 ASSERT_TRUE(helper->Run()); | 215 ASSERT_TRUE(helper->Run()); |
216 | 216 |
217 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); | 217 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); |
218 EXPECT_FALSE(file_util::DirectoryExists(session_only_path)); | 218 EXPECT_FALSE(file_util::DirectoryExists(session_only_path)); |
219 } | 219 } |
220 | 220 |
| 221 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, SaveSessionState) { |
| 222 ScopedTempDir temp_dir; |
| 223 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 224 |
| 225 FilePath normal_path; |
| 226 FilePath session_only_path; |
| 227 |
| 228 // Create the scope which will ensure we run the destructor of the webkit |
| 229 // context. |
| 230 { |
| 231 TestingProfile profile; |
| 232 |
| 233 const GURL kNormalOrigin("http://normal/"); |
| 234 const GURL kSessionOnlyOrigin("http://session-only/"); |
| 235 scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy = |
| 236 new quota::MockSpecialStoragePolicy; |
| 237 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); |
| 238 |
| 239 // Create some indexedDB paths. |
| 240 // With the levelDB backend, these are directories. |
| 241 WebKitContext *webkit_context = profile.GetWebKitContext(); |
| 242 IndexedDBContext* idb_context = webkit_context->indexed_db_context(); |
| 243 |
| 244 // Override the storage policy with our own. |
| 245 idb_context->special_storage_policy_ = special_storage_policy; |
| 246 idb_context->set_clear_local_state_on_exit(true); |
| 247 idb_context->set_data_path_for_testing(temp_dir.path()); |
| 248 |
| 249 // Save session state. This should bypass the destruction-time deletion. |
| 250 idb_context->SaveSessionState(); |
| 251 |
| 252 normal_path = idb_context->GetIndexedDBFilePath( |
| 253 DatabaseUtil::GetOriginIdentifier(kNormalOrigin)); |
| 254 session_only_path = idb_context->GetIndexedDBFilePath( |
| 255 DatabaseUtil::GetOriginIdentifier(kSessionOnlyOrigin)); |
| 256 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); |
| 257 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); |
| 258 } |
| 259 |
| 260 // Make sure we wait until the destructor has run. |
| 261 scoped_refptr<base::ThreadTestHelper> helper( |
| 262 new base::ThreadTestHelper( |
| 263 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT))); |
| 264 ASSERT_TRUE(helper->Run()); |
| 265 |
| 266 // No data was cleared because of SaveSessionState. |
| 267 EXPECT_TRUE(file_util::DirectoryExists(normal_path)); |
| 268 EXPECT_TRUE(file_util::DirectoryExists(session_only_path)); |
| 269 } |
| 270 |
221 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { | 271 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { |
222 public: | 272 public: |
223 virtual void SetUpOnMainThread() { | 273 virtual void SetUpOnMainThread() { |
224 const int kInitialQuotaKilobytes = 5000; | 274 const int kInitialQuotaKilobytes = 5000; |
225 const int kTemporaryStorageQuotaMaxSize = kInitialQuotaKilobytes | 275 const int kTemporaryStorageQuotaMaxSize = kInitialQuotaKilobytes |
226 * 1024 * QuotaManager::kPerHostTemporaryPortion; | 276 * 1024 * QuotaManager::kPerHostTemporaryPortion; |
227 SetTempQuota( | 277 SetTempQuota( |
228 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager()); | 278 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager()); |
229 } | 279 } |
230 | 280 |
(...skipping 25 matching lines...) Expand all Loading... |
256 virtual void SetUpCommandLine(CommandLine* command_line) { | 306 virtual void SetUpCommandLine(CommandLine* command_line) { |
257 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 307 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
258 } | 308 } |
259 }; | 309 }; |
260 | 310 |
261 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, | 311 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, |
262 DatabaseCallbacksTest) { | 312 DatabaseCallbacksTest) { |
263 SimpleTest( | 313 SimpleTest( |
264 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html")))); | 314 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html")))); |
265 } | 315 } |
OLD | NEW |