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

Side by Side Diff: content/browser/in_process_webkit/indexed_db_browsertest.cc

Issue 7692016: Delete indexedDBs from the cookie tree ui. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/test/thread_test_helper.h" 10 #include "base/test/thread_test_helper.h"
11 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/test/base/in_process_browser_test.h" 13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/browser/in_process_webkit/indexed_db_context.h" 16 #include "content/browser/in_process_webkit/indexed_db_context.h"
17 #include "content/browser/in_process_webkit/webkit_context.h" 17 #include "content/browser/in_process_webkit/webkit_context.h"
18 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
19 #include "content/common/content_switches.h" 19 #include "content/common/content_switches.h"
20 #include "webkit/database/database_util.h"
20 #include "webkit/quota/quota_manager.h" 21 #include "webkit/quota/quota_manager.h"
22 #include "webkit/quota/special_storage_policy.h"
21 23
22 using quota::QuotaManager; 24 using quota::QuotaManager;
25 using webkit_database::DatabaseUtil;
23 26
24 // This browser test is aimed towards exercising the IndexedDB bindings and 27 // This browser test is aimed towards exercising the IndexedDB bindings and
25 // the actual implementation that lives in the browser side (in_process_webkit). 28 // the actual implementation that lives in the browser side (in_process_webkit).
26 class IndexedDBBrowserTest : public InProcessBrowserTest { 29 class IndexedDBBrowserTest : public InProcessBrowserTest {
27 public: 30 public:
28 IndexedDBBrowserTest() { 31 IndexedDBBrowserTest() {
29 EnableDOMAutomation(); 32 EnableDOMAutomation();
30 } 33 }
31 34
32 virtual void SetUpCommandLine(CommandLine* command_line) { 35 virtual void SetUpCommandLine(CommandLine* command_line) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, Bug84933Test) { 120 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, Bug84933Test) {
118 const GURL url = testUrl(FilePath(FILE_PATH_LITERAL("bug_84933.html"))); 121 const GURL url = testUrl(FilePath(FILE_PATH_LITERAL("bug_84933.html")));
119 122
120 // Just navigate to the URL. Test will crash if it fails. 123 // Just navigate to the URL. Test will crash if it fails.
121 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 1); 124 ui_test_utils::NavigateToURLBlockUntilNavigationsComplete(browser(), url, 1);
122 } 125 }
123 126
124 // In proc browser test is needed here because ClearLocalState indirectly calls 127 // In proc browser test is needed here because ClearLocalState indirectly calls
125 // WebKit's isMainThread through WebSecurityOrigin->SecurityOrigin. 128 // WebKit's isMainThread through WebSecurityOrigin->SecurityOrigin.
126 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ClearLocalState) { 129 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ClearLocalState) {
127 // Create test files.
128 ScopedTempDir temp_dir; 130 ScopedTempDir temp_dir;
129 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 131 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
130 FilePath indexeddb_dir = temp_dir.path().Append(
131 IndexedDBContext::kIndexedDBDirectory);
132 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir));
133 132
134 FilePath::StringType file_name_1(FILE_PATH_LITERAL("http_foo_0")); 133 FilePath protected_path;
135 file_name_1.append(IndexedDBContext::kIndexedDBExtension); 134 FilePath unprotected_path;
136 FilePath::StringType file_name_2(FILE_PATH_LITERAL("chrome-extension_foo_0"));
137 file_name_2.append(IndexedDBContext::kIndexedDBExtension);
138 FilePath temp_file_path_1 = indexeddb_dir.Append(file_name_1);
139 FilePath temp_file_path_2 = indexeddb_dir.Append(file_name_2);
140
141 ASSERT_EQ(1, file_util::WriteFile(temp_file_path_1, ".", 1));
142 ASSERT_EQ(1, file_util::WriteFile(temp_file_path_2, "o", 1));
143 135
144 // Create the scope which will ensure we run the destructor of the webkit 136 // Create the scope which will ensure we run the destructor of the webkit
145 // context which should trigger the clean up. 137 // context which should trigger the clean up.
146 { 138 {
147 TestingProfile profile; 139 TestingProfile profile;
140
141 // Test our assumptions about what is protected and what is not.
142 const GURL kProtectedOrigin("chrome-extension://foo/");
143 const GURL kUnprotectedOrigin("http://foo/");
144 quota::SpecialStoragePolicy* policy = profile.GetSpecialStoragePolicy();
145 ASSERT_TRUE(policy->IsStorageProtected(kProtectedOrigin));
146 ASSERT_FALSE(policy->IsStorageProtected(kUnprotectedOrigin));
147
148 // Create some indexedDB paths.
149 // With the levelDB backend, these are directories.
148 WebKitContext *webkit_context = profile.GetWebKitContext(); 150 WebKitContext *webkit_context = profile.GetWebKitContext();
149 webkit_context->indexed_db_context()->set_data_path(indexeddb_dir); 151 IndexedDBContext* idb_context = webkit_context->indexed_db_context();
152 idb_context->set_data_path(temp_dir.path());
153 protected_path = idb_context->GetIndexedDBFilePath(
154 DatabaseUtil::GetOriginIdentifier(kProtectedOrigin));
155 unprotected_path = idb_context->GetIndexedDBFilePath(
156 DatabaseUtil::GetOriginIdentifier(kUnprotectedOrigin));
157 ASSERT_TRUE(file_util::CreateDirectory(protected_path));
158 ASSERT_TRUE(file_util::CreateDirectory(unprotected_path));
159
160 // Setup to clear all unprotected origins on exit.
150 webkit_context->set_clear_local_state_on_exit(true); 161 webkit_context->set_clear_local_state_on_exit(true);
151 } 162 }
163
152 // Make sure we wait until the destructor has run. 164 // Make sure we wait until the destructor has run.
153 scoped_refptr<base::ThreadTestHelper> helper( 165 scoped_refptr<base::ThreadTestHelper> helper(
154 new base::ThreadTestHelper( 166 new base::ThreadTestHelper(
155 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT))); 167 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT)));
156 ASSERT_TRUE(helper->Run()); 168 ASSERT_TRUE(helper->Run());
157 169
158 // Because we specified https for scheme to be skipped the second file 170 ASSERT_TRUE(file_util::DirectoryExists(protected_path));
159 // should survive and the first go into vanity. 171 ASSERT_FALSE(file_util::DirectoryExists(unprotected_path));
160 ASSERT_FALSE(file_util::PathExists(temp_file_path_1));
161 ASSERT_TRUE(file_util::PathExists(temp_file_path_2));
162 } 172 }
163 173
164 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest { 174 class IndexedDBBrowserTestWithLowQuota : public IndexedDBBrowserTest {
165 public: 175 public:
166 virtual void SetUpOnMainThread() { 176 virtual void SetUpOnMainThread() {
167 const int kInitialQuotaKilobytes = 5000; 177 const int kInitialQuotaKilobytes = 5000;
168 const int kTemporaryStorageQuotaMaxSize = kInitialQuotaKilobytes 178 const int kTemporaryStorageQuotaMaxSize = kInitialQuotaKilobytes
169 * 1024 * QuotaManager::kPerHostTemporaryPortion; 179 * 1024 * QuotaManager::kPerHostTemporaryPortion;
170 SetTempQuota( 180 SetTempQuota(
171 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager()); 181 kTemporaryStorageQuotaMaxSize, browser()->profile()->GetQuotaManager());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 virtual void SetUpCommandLine(CommandLine* command_line) { 220 virtual void SetUpCommandLine(CommandLine* command_line) {
211 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); 221 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
212 } 222 }
213 }; 223 };
214 224
215 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, 225 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed,
216 DatabaseCallbacksTest) { 226 DatabaseCallbacksTest) {
217 SimpleTest( 227 SimpleTest(
218 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html")))); 228 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html"))));
219 } 229 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/cookies_tree_model_util.cc ('k') | content/browser/in_process_webkit/indexed_db_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698