Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/process_util.h" | |
| 11 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
| 12 #include "base/test/thread_test_helper.h" | 13 #include "base/test/thread_test_helper.h" |
| 13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" | 15 #include "content/browser/in_process_webkit/indexed_db_context_impl.h" |
| 15 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 19 #include "content/public/browser/render_process_host.h" | |
| 20 #include "content/public/browser/web_contents.h" | |
| 18 #include "content/public/common/content_paths.h" | 21 #include "content/public/common/content_paths.h" |
| 19 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/url_constants.h" | |
| 20 #include "content/public/test/browser_test_utils.h" | 24 #include "content/public/test/browser_test_utils.h" |
| 21 #include "content/shell/shell.h" | 25 #include "content/shell/shell.h" |
| 22 #include "content/test/content_browser_test.h" | 26 #include "content/test/content_browser_test.h" |
| 23 #include "content/test/content_browser_test_utils.h" | 27 #include "content/test/content_browser_test_utils.h" |
| 24 #include "net/base/net_util.h" | 28 #include "net/base/net_util.h" |
| 25 #include "webkit/database/database_util.h" | 29 #include "webkit/database/database_util.h" |
| 26 #include "webkit/quota/mock_special_storage_policy.h" | 30 #include "webkit/quota/mock_special_storage_policy.h" |
| 27 #include "webkit/quota/quota_manager.h" | 31 #include "webkit/quota/quota_manager.h" |
| 28 #include "webkit/quota/special_storage_policy.h" | 32 #include "webkit/quota/special_storage_policy.h" |
| 29 | 33 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 48 LOG(INFO) << "Navigation done."; | 52 LOG(INFO) << "Navigation done."; |
| 49 std::string result = the_browser->web_contents()->GetURL().ref(); | 53 std::string result = the_browser->web_contents()->GetURL().ref(); |
| 50 if (result != "pass") { | 54 if (result != "pass") { |
| 51 std::string js_result; | 55 std::string js_result; |
| 52 ASSERT_TRUE(ExecuteJavaScriptAndExtractString( | 56 ASSERT_TRUE(ExecuteJavaScriptAndExtractString( |
| 53 the_browser->web_contents()->GetRenderViewHost(), L"", | 57 the_browser->web_contents()->GetRenderViewHost(), L"", |
| 54 L"window.domAutomationController.send(getLog())", &js_result)); | 58 L"window.domAutomationController.send(getLog())", &js_result)); |
| 55 FAIL() << "Failed: " << js_result; | 59 FAIL() << "Failed: " << js_result; |
| 56 } | 60 } |
| 57 } | 61 } |
| 62 | |
| 63 void NavigateAndWaitForTitle(Shell* shell, | |
| 64 const char* filename, | |
| 65 const char* hash, | |
| 66 const char* expected_string) { | |
| 67 GURL url = GetTestUrl("indexeddb", filename); | |
| 68 if (hash) | |
| 69 url = GURL(url.spec() + hash); | |
| 70 | |
| 71 string16 expected_title16(ASCIIToUTF16(expected_string)); | |
| 72 TitleWatcher title_watcher(shell->web_contents(), expected_title16); | |
| 73 NavigateToURL(shell, url); | |
| 74 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | |
| 75 } | |
| 58 }; | 76 }; |
| 59 | 77 |
| 60 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { | 78 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { |
| 61 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); | 79 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); |
| 62 } | 80 } |
| 63 | 81 |
| 64 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { | 82 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { |
| 65 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), | 83 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), |
| 66 true /* incognito */); | 84 true /* incognito */); |
| 67 } | 85 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 ASSERT_TRUE(file_util::CopyDirectory(test_data_dir, | 226 ASSERT_TRUE(file_util::CopyDirectory(test_data_dir, |
| 209 context_impl->data_path(), | 227 context_impl->data_path(), |
| 210 kRecursive)); | 228 kRecursive)); |
| 211 } | 229 } |
| 212 }; | 230 }; |
| 213 | 231 |
| 214 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithVersion0Schema, MigrationTest) { | 232 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithVersion0Schema, MigrationTest) { |
| 215 SimpleTest(GetTestUrl("indexeddb", "migration_test.html")); | 233 SimpleTest(GetTestUrl("indexeddb", "migration_test.html")); |
| 216 } | 234 } |
| 217 | 235 |
| 236 // Verify null key path persists after restarting browser. | |
| 237 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, PRE_NullKeyPathPersistence) { | |
| 238 NavigateAndWaitForTitle(shell(), "bug_90635.html", "#part1", | |
| 239 "pass - first run"); | |
| 240 } | |
| 241 | |
| 242 // Verify null key path persists after restarting browser. | |
| 243 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, NullKeyPathPersistence) { | |
| 244 NavigateAndWaitForTitle(shell(), "bug_90635.html", "#part2", | |
| 245 "pass - second run"); | |
| 246 } | |
| 247 | |
| 248 // Verify that a VERSION_CHANGE transaction is rolled back after a | |
| 249 // renderer/browser crash | |
| 250 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, | |
| 251 PRE_PRE_VersionChangeCrashResilience) { | |
| 252 NavigateAndWaitForTitle(shell(), "version_change_crash.html", "#part1", | |
| 253 "pass - part1 - complete"); | |
| 254 } | |
| 255 | |
| 256 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, PRE_VersionChangeCrashResilience) { | |
| 257 NavigateAndWaitForTitle(shell(), "version_change_crash.html", "#part2", | |
| 258 "pass - part2 - crash me"); | |
| 259 NavigateToURL(shell(), GURL(chrome::kChromeUIBrowserCrashHost)); | |
| 260 } | |
| 261 | |
| 262 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, VersionChangeCrashResilience) { | |
| 263 NavigateAndWaitForTitle(shell(), "version_change_crash.html", "#part3", | |
| 264 "pass - part3 - rolled back"); | |
| 265 } | |
| 266 | |
| 267 // Verify that open DB connections are closed when a tab is destroyed. | |
| 268 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ConnectionsClosedOnTabClose) { | |
| 269 NavigateAndWaitForTitle(shell(), "version_change_blocked.html", "#tab1", | |
| 270 "setVersion(1) complete"); | |
| 271 | |
| 272 // Start on a different URL to force a new renderer process. | |
| 273 Shell* new_shell = CreateBrowser(); | |
| 274 NavigateToURL(new_shell, GURL(chrome::kAboutBlankURL)); | |
| 275 NavigateAndWaitForTitle(new_shell, "version_change_blocked.html", "#tab2", | |
| 276 "setVersion(2) blocked"); | |
| 277 | |
| 278 string16 expected_title16(ASCIIToUTF16("setVersion(2) complete")); | |
| 279 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); | |
| 280 | |
| 281 base::KillProcess( | |
| 282 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); | |
|
dgrogan
2012/08/17 23:41:27
Could you annotate 0 and true with constants or co
jam
2012/08/18 00:45:10
My preference is not to do this. I realize some de
| |
| 283 shell()->Close(); | |
| 284 | |
| 285 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | |
| 286 } | |
| 287 | |
| 218 } // namespace content | 288 } // namespace content |
| OLD | NEW |