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_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 } | 59 } |
60 | 60 |
61 void NavigateAndWaitForTitle(Shell* shell, | 61 void NavigateAndWaitForTitle(Shell* shell, |
62 const char* filename, | 62 const char* filename, |
63 const char* hash, | 63 const char* hash, |
64 const char* expected_string) { | 64 const char* expected_string) { |
65 GURL url = GetTestUrl("indexeddb", filename); | 65 GURL url = GetTestUrl("indexeddb", filename); |
66 if (hash) | 66 if (hash) |
67 url = GURL(url.spec() + hash); | 67 url = GURL(url.spec() + hash); |
68 | 68 |
69 string16 expected_title16(ASCIIToUTF16(expected_string)); | 69 base::string16 expected_title16(ASCIIToUTF16(expected_string)); |
70 TitleWatcher title_watcher(shell->web_contents(), expected_title16); | 70 TitleWatcher title_watcher(shell->web_contents(), expected_title16); |
71 NavigateToURL(shell, url); | 71 NavigateToURL(shell, url); |
72 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 72 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
73 } | 73 } |
74 | 74 |
75 IndexedDBContextImpl* GetContext() { | 75 IndexedDBContextImpl* GetContext() { |
76 StoragePartition* partition = | 76 StoragePartition* partition = |
77 BrowserContext::GetDefaultStoragePartition( | 77 BrowserContext::GetDefaultStoragePartition( |
78 shell()->web_contents()->GetBrowserContext()); | 78 shell()->web_contents()->GetBrowserContext()); |
79 return static_cast<IndexedDBContextImpl*>(partition->GetIndexedDBContext()); | 79 return static_cast<IndexedDBContextImpl*>(partition->GetIndexedDBContext()); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ConnectionsClosedOnTabClose) { | 392 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ConnectionsClosedOnTabClose) { |
393 NavigateAndWaitForTitle(shell(), "version_change_blocked.html", "#tab1", | 393 NavigateAndWaitForTitle(shell(), "version_change_blocked.html", "#tab1", |
394 "setVersion(2) complete"); | 394 "setVersion(2) complete"); |
395 | 395 |
396 // Start on a different URL to force a new renderer process. | 396 // Start on a different URL to force a new renderer process. |
397 Shell* new_shell = CreateBrowser(); | 397 Shell* new_shell = CreateBrowser(); |
398 NavigateToURL(new_shell, GURL(kAboutBlankURL)); | 398 NavigateToURL(new_shell, GURL(kAboutBlankURL)); |
399 NavigateAndWaitForTitle(new_shell, "version_change_blocked.html", "#tab2", | 399 NavigateAndWaitForTitle(new_shell, "version_change_blocked.html", "#tab2", |
400 "setVersion(3) blocked"); | 400 "setVersion(3) blocked"); |
401 | 401 |
402 string16 expected_title16(ASCIIToUTF16("setVersion(3) complete")); | 402 base::string16 expected_title16(ASCIIToUTF16("setVersion(3) complete")); |
403 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); | 403 TitleWatcher title_watcher(new_shell->web_contents(), expected_title16); |
404 | 404 |
405 base::KillProcess( | 405 base::KillProcess( |
406 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); | 406 shell()->web_contents()->GetRenderProcessHost()->GetHandle(), 0, true); |
407 shell()->Close(); | 407 shell()->Close(); |
408 | 408 |
409 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 409 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
410 } | 410 } |
411 | 411 |
412 // Verify that a "close" event is fired at database connections when | 412 // Verify that a "close" event is fired at database connections when |
413 // the backing store is deleted. | 413 // the backing store is deleted. |
414 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ForceCloseEventTest) { | 414 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, ForceCloseEventTest) { |
415 NavigateAndWaitForTitle(shell(), "force_close_event.html", NULL, | 415 NavigateAndWaitForTitle(shell(), "force_close_event.html", NULL, |
416 "connection ready"); | 416 "connection ready"); |
417 | 417 |
418 GetContext()->TaskRunner()->PostTask( | 418 GetContext()->TaskRunner()->PostTask( |
419 FROM_HERE, | 419 FROM_HERE, |
420 base::Bind(&IndexedDBContextImpl::DeleteForOrigin, | 420 base::Bind(&IndexedDBContextImpl::DeleteForOrigin, |
421 GetContext(), | 421 GetContext(), |
422 GURL("file:///"))); | 422 GURL("file:///"))); |
423 | 423 |
424 string16 expected_title16(ASCIIToUTF16("connection closed")); | 424 base::string16 expected_title16(ASCIIToUTF16("connection closed")); |
425 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | 425 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); |
426 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | 426 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); |
427 } | 427 } |
428 | 428 |
429 class IndexedDBBrowserTestSingleProcess : public IndexedDBBrowserTest { | 429 class IndexedDBBrowserTestSingleProcess : public IndexedDBBrowserTest { |
430 public: | 430 public: |
431 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 431 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
432 command_line->AppendSwitch(switches::kSingleProcess); | 432 command_line->AppendSwitch(switches::kSingleProcess); |
433 } | 433 } |
434 }; | 434 }; |
435 | 435 |
436 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 436 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
437 RenderThreadShutdownTest) { | 437 RenderThreadShutdownTest) { |
438 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 438 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
439 } | 439 } |
440 | 440 |
441 } // namespace content | 441 } // namespace content |
OLD | NEW |