Index: content/browser/in_process_webkit/indexed_db_browsertest.cc |
=================================================================== |
--- content/browser/in_process_webkit/indexed_db_browsertest.cc (revision 152131) |
+++ content/browser/in_process_webkit/indexed_db_browsertest.cc (working copy) |
@@ -8,6 +8,7 @@ |
#include "base/file_util.h" |
#include "base/memory/ref_counted.h" |
#include "base/path_service.h" |
+#include "base/process_util.h" |
#include "base/scoped_temp_dir.h" |
#include "base/test/thread_test_helper.h" |
#include "base/utf_string_conversions.h" |
@@ -15,8 +16,11 @@ |
#include "content/browser/web_contents/web_contents_impl.h" |
#include "content/public/browser/browser_context.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/render_process_host.h" |
+#include "content/public/browser/web_contents.h" |
#include "content/public/common/content_paths.h" |
#include "content/public/common/content_switches.h" |
+#include "content/public/common/url_constants.h" |
#include "content/public/test/browser_test_utils.h" |
#include "content/shell/shell.h" |
#include "content/test/content_browser_test.h" |
@@ -55,6 +59,20 @@ |
FAIL() << "Failed: " << js_result; |
} |
} |
+ |
+ void NavigateAndWaitForTitle(Shell* shell, |
+ const char* filename, |
+ const char* hash, |
+ const char* expected_string) { |
+ GURL url = GetTestUrl("indexeddb", filename); |
+ if (hash) |
+ url = GURL(url.spec() + hash); |
+ |
+ string16 expected_title16(ASCIIToUTF16(expected_string)); |
+ TitleWatcher title_watcher(shell->web_contents(), expected_title16); |
+ NavigateToURL(shell, url); |
+ EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
+ } |
}; |
IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { |
@@ -215,4 +233,56 @@ |
SimpleTest(GetTestUrl("indexeddb", "migration_test.html")); |
} |
+// Verify null key path persists after restarting browser. |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, PRE_NullKeyPathPersistence) { |
+ NavigateAndWaitForTitle(shell(), "bug_90635.html", "#part1", |
+ "pass - first run"); |
+} |
+ |
+// Verify null key path persists after restarting browser. |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, NullKeyPathPersistence) { |
+ NavigateAndWaitForTitle(shell(), "bug_90635.html", "#part2", |
+ "pass - second run"); |
+} |
+ |
+// Verify that a VERSION_CHANGE transaction is rolled back after a |
+// renderer/browser crash |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, |
+ PRE_PRE_VersionChangeCrashResilience) { |
+ NavigateAndWaitForTitle(shell(), "version_change_crash.html", "#part1", |
+ "pass - part1 - complete"); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, PRE_VersionChangeCrashResilience) { |
+ NavigateAndWaitForTitle(shell(), "version_change_crash.html", "#part2", |
+ "pass - part2 - crash me"); |
+ NavigateToURL(shell(), GURL(chrome::kChromeUIBrowserCrashHost)); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, VersionChangeCrashResilience) { |
+ NavigateAndWaitForTitle(shell(), "version_change_crash.html", "#part3", |
+ "pass - part3 - rolled back"); |
+} |
+ |
+// Verify that open DB connections are closed when a tab is destroyed. |
+IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ConnectionsClosedOnTabClose) { |
+ NavigateAndWaitForTitle(shell(), "version_change_blocked.html", "#tab1", |
+ "setVersion(1) complete"); |
+ |
+ // Start on a different URL to force a new renderer process. |
+ Shell* new_shell = CreateBrowser(); |
+ NavigateToURL(new_shell, GURL(chrome::kAboutBlankURL)); |
+ NavigateAndWaitForTitle(new_shell, "version_change_blocked.html", "#tab2", |
+ "setVersion(2) blocked"); |
+ |
+ string16 expected_title16(ASCIIToUTF16("setVersion(2) complete")); |
+ TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); |
+ |
+ base::KillProcess( |
+ 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
|
+ shell()->Close(); |
+ |
+ EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
+} |
+ |
} // namespace content |