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/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" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const GURL kProtectedOrigin("chrome-extension://foo/"); | 139 const GURL kProtectedOrigin("chrome-extension://foo/"); |
140 const GURL kUnprotectedOrigin("http://foo/"); | 140 const GURL kUnprotectedOrigin("http://foo/"); |
141 quota::SpecialStoragePolicy* policy = profile.GetSpecialStoragePolicy(); | 141 quota::SpecialStoragePolicy* policy = profile.GetSpecialStoragePolicy(); |
142 ASSERT_TRUE(policy->IsStorageProtected(kProtectedOrigin)); | 142 ASSERT_TRUE(policy->IsStorageProtected(kProtectedOrigin)); |
143 ASSERT_FALSE(policy->IsStorageProtected(kUnprotectedOrigin)); | 143 ASSERT_FALSE(policy->IsStorageProtected(kUnprotectedOrigin)); |
144 | 144 |
145 // Create some indexedDB paths. | 145 // Create some indexedDB paths. |
146 // With the levelDB backend, these are directories. | 146 // With the levelDB backend, these are directories. |
147 WebKitContext *webkit_context = profile.GetWebKitContext(); | 147 WebKitContext *webkit_context = profile.GetWebKitContext(); |
148 IndexedDBContext* idb_context = webkit_context->indexed_db_context(); | 148 IndexedDBContext* idb_context = webkit_context->indexed_db_context(); |
149 idb_context->set_data_path(temp_dir.path()); | 149 idb_context->set_data_path_for_testing(temp_dir.path()); |
150 protected_path = idb_context->GetIndexedDBFilePath( | 150 protected_path = idb_context->GetIndexedDBFilePath( |
151 DatabaseUtil::GetOriginIdentifier(kProtectedOrigin)); | 151 DatabaseUtil::GetOriginIdentifier(kProtectedOrigin)); |
152 unprotected_path = idb_context->GetIndexedDBFilePath( | 152 unprotected_path = idb_context->GetIndexedDBFilePath( |
153 DatabaseUtil::GetOriginIdentifier(kUnprotectedOrigin)); | 153 DatabaseUtil::GetOriginIdentifier(kUnprotectedOrigin)); |
154 ASSERT_TRUE(file_util::CreateDirectory(protected_path)); | 154 ASSERT_TRUE(file_util::CreateDirectory(protected_path)); |
155 ASSERT_TRUE(file_util::CreateDirectory(unprotected_path)); | 155 ASSERT_TRUE(file_util::CreateDirectory(unprotected_path)); |
156 | 156 |
157 // Setup to clear all unprotected origins on exit. | 157 // Setup to clear all unprotected origins on exit. |
158 webkit_context->set_clear_local_state_on_exit(true); | 158 webkit_context->set_clear_local_state_on_exit(true); |
159 } | 159 } |
(...skipping 28 matching lines...) Expand all Loading... |
188 new quota::MockSpecialStoragePolicy; | 188 new quota::MockSpecialStoragePolicy; |
189 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); | 189 special_storage_policy->AddSessionOnly(kSessionOnlyOrigin); |
190 | 190 |
191 // Create some indexedDB paths. | 191 // Create some indexedDB paths. |
192 // With the levelDB backend, these are directories. | 192 // With the levelDB backend, these are directories. |
193 WebKitContext *webkit_context = profile.GetWebKitContext(); | 193 WebKitContext *webkit_context = profile.GetWebKitContext(); |
194 IndexedDBContext* idb_context = webkit_context->indexed_db_context(); | 194 IndexedDBContext* idb_context = webkit_context->indexed_db_context(); |
195 | 195 |
196 // Override the storage policy with our own. | 196 // Override the storage policy with our own. |
197 idb_context->special_storage_policy_ = special_storage_policy; | 197 idb_context->special_storage_policy_ = special_storage_policy; |
198 idb_context->set_data_path(temp_dir.path()); | 198 idb_context->set_data_path_for_testing(temp_dir.path()); |
199 | 199 |
200 normal_path = idb_context->GetIndexedDBFilePath( | 200 normal_path = idb_context->GetIndexedDBFilePath( |
201 DatabaseUtil::GetOriginIdentifier(kNormalOrigin)); | 201 DatabaseUtil::GetOriginIdentifier(kNormalOrigin)); |
202 session_only_path = idb_context->GetIndexedDBFilePath( | 202 session_only_path = idb_context->GetIndexedDBFilePath( |
203 DatabaseUtil::GetOriginIdentifier(kSessionOnlyOrigin)); | 203 DatabaseUtil::GetOriginIdentifier(kSessionOnlyOrigin)); |
204 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); | 204 ASSERT_TRUE(file_util::CreateDirectory(normal_path)); |
205 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); | 205 ASSERT_TRUE(file_util::CreateDirectory(session_only_path)); |
206 } | 206 } |
207 | 207 |
208 // Make sure we wait until the destructor has run. | 208 // Make sure we wait until the destructor has run. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 virtual void SetUpCommandLine(CommandLine* command_line) { | 264 virtual void SetUpCommandLine(CommandLine* command_line) { |
265 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 265 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
266 } | 266 } |
267 }; | 267 }; |
268 | 268 |
269 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, | 269 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithGCExposed, |
270 DatabaseCallbacksTest) { | 270 DatabaseCallbacksTest) { |
271 SimpleTest( | 271 SimpleTest( |
272 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html")))); | 272 testUrl(FilePath(FILE_PATH_LITERAL("database_callbacks_first.html")))); |
273 } | 273 } |
OLD | NEW |