| 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/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 #include "storage/browser/quota/quota_manager.h" | 40 #include "storage/browser/quota/quota_manager.h" |
| 41 | 41 |
| 42 using base::ASCIIToUTF16; | 42 using base::ASCIIToUTF16; |
| 43 using storage::QuotaManager; | 43 using storage::QuotaManager; |
| 44 using storage::DatabaseUtil; | 44 using storage::DatabaseUtil; |
| 45 | 45 |
| 46 namespace content { | 46 namespace content { |
| 47 | 47 |
| 48 // This browser test is aimed towards exercising the IndexedDB bindings and | 48 // This browser test is aimed towards exercising the IndexedDB bindings and |
| 49 // the actual implementation that lives in the browser side. | 49 // the actual implementation that lives in the browser side. |
| 50 class IndexedDBBrowserTest : public ContentBrowserTest { | 50 class IndexedDBBrowserTest : public ContentBrowserTest, |
| 51 public ::testing::WithParamInterface<const char*> { |
| 51 public: | 52 public: |
| 52 IndexedDBBrowserTest() : disk_usage_(-1) {} | 53 IndexedDBBrowserTest() : disk_usage_(-1) {} |
| 53 | 54 |
| 54 void SetUp() override { | 55 void SetUp() override { |
| 55 GetTestClassFactory()->Reset(); | 56 GetTestClassFactory()->Reset(); |
| 56 IndexedDBClassFactory::SetIndexedDBClassFactoryGetter(GetIDBClassFactory); | 57 IndexedDBClassFactory::SetIndexedDBClassFactoryGetter(GetIDBClassFactory); |
| 57 ContentBrowserTest::SetUp(); | 58 ContentBrowserTest::SetUp(); |
| 58 } | 59 } |
| 59 | 60 |
| 60 void TearDown() override { | 61 void TearDown() override { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 181 } |
| 181 | 182 |
| 182 virtual void DidGetBlobFileCount(int count) { blob_file_count_ = count; } | 183 virtual void DidGetBlobFileCount(int count) { blob_file_count_ = count; } |
| 183 | 184 |
| 184 int64 disk_usage_; | 185 int64 disk_usage_; |
| 185 int blob_file_count_ = 0; | 186 int blob_file_count_ = 0; |
| 186 | 187 |
| 187 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTest); | 188 DISALLOW_COPY_AND_ASSIGN(IndexedDBBrowserTest); |
| 188 }; | 189 }; |
| 189 | 190 |
| 190 class IndexedDBBrowserTestWithExperimentalAPIs | |
| 191 : public IndexedDBBrowserTest, | |
| 192 public ::testing::WithParamInterface<const char*> { | |
| 193 public: | |
| 194 void SetUpCommandLine(base::CommandLine* command_line) override { | |
| 195 command_line->AppendSwitch( | |
| 196 switches::kEnableExperimentalWebPlatformFeatures); | |
| 197 } | |
| 198 }; | |
| 199 | |
| 200 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { | 191 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTest) { |
| 201 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); | 192 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html")); |
| 202 } | 193 } |
| 203 | 194 |
| 204 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { | 195 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorTestIncognito) { |
| 205 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), | 196 SimpleTest(GetTestUrl("indexeddb", "cursor_test.html"), |
| 206 true /* incognito */); | 197 true /* incognito */); |
| 207 } | 198 } |
| 208 | 199 |
| 209 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorPrefetch) { | 200 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CursorPrefetch) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 235 } | 226 } |
| 236 | 227 |
| 237 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, TransactionTest) { | 228 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, TransactionTest) { |
| 238 SimpleTest(GetTestUrl("indexeddb", "transaction_test.html")); | 229 SimpleTest(GetTestUrl("indexeddb", "transaction_test.html")); |
| 239 } | 230 } |
| 240 | 231 |
| 241 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CallbackAccounting) { | 232 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, CallbackAccounting) { |
| 242 SimpleTest(GetTestUrl("indexeddb", "callback_accounting.html")); | 233 SimpleTest(GetTestUrl("indexeddb", "callback_accounting.html")); |
| 243 } | 234 } |
| 244 | 235 |
| 245 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestWithExperimentalAPIs, | 236 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, GetAllMaxMessageSize) { |
| 246 GetAllMaxMessageSize) { | |
| 247 SimpleTest(GetTestUrl("indexeddb", "getall_max_message_size.html")); | 237 SimpleTest(GetTestUrl("indexeddb", "getall_max_message_size.html")); |
| 248 } | 238 } |
| 249 | 239 |
| 250 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DoesntHangTest) { | 240 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, DoesntHangTest) { |
| 251 SimpleTest(GetTestUrl("indexeddb", "transaction_run_forever.html")); | 241 SimpleTest(GetTestUrl("indexeddb", "transaction_run_forever.html")); |
| 252 CrashTab(shell()->web_contents()); | 242 CrashTab(shell()->web_contents()); |
| 253 SimpleTest(GetTestUrl("indexeddb", "transaction_not_blocked.html")); | 243 SimpleTest(GetTestUrl("indexeddb", "transaction_not_blocked.html")); |
| 254 } | 244 } |
| 255 | 245 |
| 256 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, Bug84933Test) { | 246 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, Bug84933Test) { |
| (...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 http_response->set_code(net::HTTP_OK); | 684 http_response->set_code(net::HTTP_OK); |
| 695 std::string file_contents; | 685 std::string file_contents; |
| 696 if (!base::ReadFileToString(resource_path, &file_contents)) | 686 if (!base::ReadFileToString(resource_path, &file_contents)) |
| 697 return scoped_ptr<net::test_server::HttpResponse>(); | 687 return scoped_ptr<net::test_server::HttpResponse>(); |
| 698 http_response->set_content(file_contents); | 688 http_response->set_content(file_contents); |
| 699 return http_response.Pass(); | 689 return http_response.Pass(); |
| 700 } | 690 } |
| 701 | 691 |
| 702 } // namespace | 692 } // namespace |
| 703 | 693 |
| 704 // Experimental for IDBObjectStore.getAll() | 694 IN_PROC_BROWSER_TEST_P(IndexedDBBrowserTest, OperationOnCorruptedOpenDatabase) { |
| 705 using IndexedDBBrowserCorruptionTest = IndexedDBBrowserTestWithExperimentalAPIs; | |
| 706 | |
| 707 IN_PROC_BROWSER_TEST_P(IndexedDBBrowserCorruptionTest, | |
| 708 OperationOnCorruptedOpenDatabase) { | |
| 709 ASSERT_TRUE(embedded_test_server()->Started() || | 695 ASSERT_TRUE(embedded_test_server()->Started() || |
| 710 embedded_test_server()->InitializeAndWaitUntilReady()); | 696 embedded_test_server()->InitializeAndWaitUntilReady()); |
| 711 const GURL& origin_url = embedded_test_server()->base_url(); | 697 const GURL& origin_url = embedded_test_server()->base_url(); |
| 712 embedded_test_server()->RegisterRequestHandler( | 698 embedded_test_server()->RegisterRequestHandler( |
| 713 base::Bind(&CorruptDBRequestHandler, | 699 base::Bind(&CorruptDBRequestHandler, |
| 714 base::Unretained(GetContext()), | 700 base::Unretained(GetContext()), |
| 715 origin_url, | 701 origin_url, |
| 716 s_corrupt_db_test_prefix, | 702 s_corrupt_db_test_prefix, |
| 717 this)); | 703 this)); |
| 718 | 704 |
| 719 std::string test_file = s_corrupt_db_test_prefix + | 705 std::string test_file = s_corrupt_db_test_prefix + |
| 720 "corrupted_open_db_detection.html#" + GetParam(); | 706 "corrupted_open_db_detection.html#" + GetParam(); |
| 721 SimpleTest(embedded_test_server()->GetURL(test_file)); | 707 SimpleTest(embedded_test_server()->GetURL(test_file)); |
| 722 | 708 |
| 723 test_file = s_corrupt_db_test_prefix + "corrupted_open_db_recovery.html"; | 709 test_file = s_corrupt_db_test_prefix + "corrupted_open_db_recovery.html"; |
| 724 SimpleTest(embedded_test_server()->GetURL(test_file)); | 710 SimpleTest(embedded_test_server()->GetURL(test_file)); |
| 725 } | 711 } |
| 726 | 712 |
| 727 INSTANTIATE_TEST_CASE_P(IndexedDBBrowserCorruptionTestInstantiation, | 713 INSTANTIATE_TEST_CASE_P(IndexedDBBrowserTestInstantiation, |
| 728 IndexedDBBrowserCorruptionTest, | 714 IndexedDBBrowserTest, |
| 729 ::testing::Values("failGetBlobJournal", | 715 ::testing::Values("failGetBlobJournal", |
| 730 "get", | 716 "get", |
| 731 "getAll", | 717 "getAll", |
| 732 "failWebkitGetDatabaseNames", | 718 "failWebkitGetDatabaseNames", |
| 733 "iterate", | 719 "iterate", |
| 734 "failTransactionCommit", | 720 "failTransactionCommit", |
| 735 "clearObjectStore")); | 721 "clearObjectStore")); |
| 736 | 722 |
| 737 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, | 723 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTest, |
| 738 DeleteCompactsBackingStore) { | 724 DeleteCompactsBackingStore) { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 command_line->AppendSwitch(switches::kSingleProcess); | 835 command_line->AppendSwitch(switches::kSingleProcess); |
| 850 } | 836 } |
| 851 }; | 837 }; |
| 852 | 838 |
| 853 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 839 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
| 854 RenderThreadShutdownTest) { | 840 RenderThreadShutdownTest) { |
| 855 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 841 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
| 856 } | 842 } |
| 857 | 843 |
| 858 } // namespace content | 844 } // namespace content |
| OLD | NEW |