OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/in_process_webkit/indexed_db_context.h" | 11 #include "chrome/browser/in_process_webkit/indexed_db_context.h" |
12 #include "chrome/browser/in_process_webkit/webkit_context.h" | |
13 #include "chrome/browser/prefs/pref_service.h" | |
12 #include "chrome/browser/tab_contents/tab_contents.h" | 14 #include "chrome/browser/tab_contents/tab_contents.h" |
13 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/pref_names.h" | |
15 #include "chrome/test/in_process_browser_test.h" | 18 #include "chrome/test/in_process_browser_test.h" |
19 #include "chrome/test/testing_profile.h" | |
20 #include "chrome/test/thread_test_helper.h" | |
16 #include "chrome/test/ui_test_utils.h" | 21 #include "chrome/test/ui_test_utils.h" |
17 | 22 |
18 // This browser test is aimed towards exercising the IndexedDB bindings and | 23 // This browser test is aimed towards exercising the IndexedDB bindings and |
19 // the actual implementation that lives in the browser side (in_process_webkit). | 24 // the actual implementation that lives in the browser side (in_process_webkit). |
20 class IndexedDBBrowserTest : public InProcessBrowserTest { | 25 class IndexedDBBrowserTest : public InProcessBrowserTest { |
21 public: | 26 public: |
22 IndexedDBBrowserTest() { | 27 IndexedDBBrowserTest() { |
23 EnableDOMAutomation(); | 28 EnableDOMAutomation(); |
24 } | 29 } |
25 | 30 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 // In proc browser test is needed here because ClearLocalState indirectly calls | 90 // In proc browser test is needed here because ClearLocalState indirectly calls |
86 // WebKit's isMainThread through WebSecurityOrigin->SecurityOrigin. | 91 // WebKit's isMainThread through WebSecurityOrigin->SecurityOrigin. |
87 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ClearLocalState) { | 92 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ClearLocalState) { |
88 // Create test files. | 93 // Create test files. |
89 ScopedTempDir temp_dir; | 94 ScopedTempDir temp_dir; |
90 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 95 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
91 FilePath indexeddb_dir = temp_dir.path().Append( | 96 FilePath indexeddb_dir = temp_dir.path().Append( |
92 IndexedDBContext::kIndexedDBDirectory); | 97 IndexedDBContext::kIndexedDBDirectory); |
93 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); | 98 ASSERT_TRUE(file_util::CreateDirectory(indexeddb_dir)); |
94 | 99 |
95 FilePath::StringType file_name_1(FILE_PATH_LITERAL("http_www.google.com_0")); | 100 FilePath::StringType file_name_1(FILE_PATH_LITERAL("http_foo_0")); |
96 file_name_1.append(IndexedDBContext::kIndexedDBExtension); | 101 file_name_1.append(IndexedDBContext::kIndexedDBExtension); |
97 FilePath::StringType file_name_2(FILE_PATH_LITERAL("https_www.google.com_0")); | 102 FilePath::StringType file_name_2(FILE_PATH_LITERAL("chrome-extension_foo_0")); |
98 file_name_2.append(IndexedDBContext::kIndexedDBExtension); | 103 file_name_2.append(IndexedDBContext::kIndexedDBExtension); |
99 FilePath temp_file_path_1 = indexeddb_dir.Append(file_name_1); | 104 FilePath temp_file_path_1 = indexeddb_dir.Append(file_name_1); |
100 FilePath temp_file_path_2 = indexeddb_dir.Append(file_name_2); | 105 FilePath temp_file_path_2 = indexeddb_dir.Append(file_name_2); |
101 | 106 |
102 ASSERT_EQ(1, file_util::WriteFile(temp_file_path_1, ".", 1)); | 107 ASSERT_EQ(1, file_util::WriteFile(temp_file_path_1, ".", 1)); |
103 ASSERT_EQ(1, file_util::WriteFile(temp_file_path_2, "o", 1)); | 108 ASSERT_EQ(1, file_util::WriteFile(temp_file_path_2, "o", 1)); |
104 | 109 |
105 IndexedDBContext::ClearLocalState(temp_dir.path(), "https"); | 110 // create the scope which will ensure we run the destructor of the webkit |
111 // context which should trigger the clean up. | |
112 TestingProfile profile; | |
113 profile.GetPrefs()->SetBoolean(prefs::kClearSiteDataOnExit, true); | |
114 scoped_refptr<WebKitContext> webkit_context(new WebKitContext(&profile)); | |
115 webkit_context->indexed_db_context()->set_data_path(indexeddb_dir); | |
116 webkit_context->Release(); | |
jochen (gone - plz use gerrit)
2010/11/29 13:29:33
release
pastarmovj
2010/11/29 13:45:12
Done.
| |
117 // Make sure we wait until the destructor has run. | |
118 scoped_refptr<ThreadTestHelper> helper( | |
119 new ThreadTestHelper(BrowserThread::WEBKIT)); | |
120 ASSERT_TRUE(helper->Run()); | |
106 | 121 |
107 // Because we specified https for scheme to be skipped the second file | 122 // Because we specified https for scheme to be skipped the second file |
108 // should survive and the first go into vanity. | 123 // should survive and the first go into vanity. |
109 ASSERT_FALSE(file_util::PathExists(temp_file_path_1)); | 124 ASSERT_FALSE(file_util::PathExists(temp_file_path_1)); |
110 ASSERT_TRUE(file_util::PathExists(temp_file_path_2)); | 125 ASSERT_TRUE(file_util::PathExists(temp_file_path_2)); |
111 } | 126 } |
OLD | NEW |