| OLD | NEW | 
|    1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2011 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/file_path.h" |    5 #include "base/file_path.h" | 
|    6 #include "base/string_util.h" |    6 #include "base/string_util.h" | 
|    7 #include "base/test/test_timeouts.h" |    7 #include "base/test/test_timeouts.h" | 
|    8 #include "base/threading/platform_thread.h" |    8 #include "base/threading/platform_thread.h" | 
|    9 #include "chrome/app/chrome_command_ids.h" |    9 #include "chrome/app/chrome_command_ids.h" | 
|   10 #include "chrome/common/url_constants.h" |   10 #include "chrome/common/url_constants.h" | 
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  149     printf("Test: %s\n", test_case_file_name.c_str()); |  149     printf("Test: %s\n", test_case_file_name.c_str()); | 
|  150     RunLayoutTest(test_case_file_name, kNoHttpPort); |  150     RunLayoutTest(test_case_file_name, kNoHttpPort); | 
|  151  |  151  | 
|  152     // Navigate to a blank page so that any workers are cleaned up. |  152     // Navigate to a blank page so that any workers are cleaned up. | 
|  153     // This helps leaks trackers do a better job of reporting. |  153     // This helps leaks trackers do a better job of reporting. | 
|  154     scoped_refptr<TabProxy> tab(GetActiveTab()); |  154     scoped_refptr<TabProxy> tab(GetActiveTab()); | 
|  155     GURL about_url(chrome::kAboutBlankURL); |  155     GURL about_url(chrome::kAboutBlankURL); | 
|  156     EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(about_url)); |  156     EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(about_url)); | 
|  157   } |  157   } | 
|  158  |  158  | 
|  159   void RunWorkerFileSystemLayoutTest(const std::string& test_case_file_name) { |  | 
|  160     FilePath worker_test_dir; |  | 
|  161     worker_test_dir = worker_test_dir.AppendASCII("fast"); |  | 
|  162  |  | 
|  163     FilePath filesystem_test_dir; |  | 
|  164     filesystem_test_dir = filesystem_test_dir.AppendASCII("filesystem"); |  | 
|  165     filesystem_test_dir = filesystem_test_dir.AppendASCII("workers"); |  | 
|  166     InitializeForLayoutTest(worker_test_dir, filesystem_test_dir, kNoHttpPort); |  | 
|  167  |  | 
|  168     FilePath resource_dir; |  | 
|  169     resource_dir = resource_dir.AppendASCII("resources"); |  | 
|  170     AddResourceForLayoutTest(worker_test_dir.AppendASCII("filesystem"), |  | 
|  171                              resource_dir); |  | 
|  172  |  | 
|  173     RunLayoutTest(test_case_file_name, kNoHttpPort); |  | 
|  174  |  | 
|  175     // Navigate to a blank page so that any workers are cleaned up. |  | 
|  176     // This helps leaks trackers do a better job of reporting. |  | 
|  177     scoped_refptr<TabProxy> tab(GetActiveTab()); |  | 
|  178     DCHECK(tab.get()); |  | 
|  179     GURL about_url(chrome::kAboutBlankURL); |  | 
|  180     EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(about_url)); |  | 
|  181   } |  | 
|  182  |  | 
|  183   bool NavigateAndWaitForAuth(TabProxy* tab, const GURL& url) { |  159   bool NavigateAndWaitForAuth(TabProxy* tab, const GURL& url) { | 
|  184     // Pass a large number of navigations to tell the tab to block until an auth |  160     // Pass a large number of navigations to tell the tab to block until an auth | 
|  185     // dialog pops up. |  161     // dialog pops up. | 
|  186     EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, |  162     EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_AUTH_NEEDED, | 
|  187               tab->NavigateToURLBlockUntilNavigationsComplete(url, 100)); |  163               tab->NavigateToURLBlockUntilNavigationsComplete(url, 100)); | 
|  188     return tab->NeedsAuth(); |  164     return tab->NeedsAuth(); | 
|  189   } |  165   } | 
|  190 }; |  166 }; | 
|  191  |  167  | 
|  192  |  168  | 
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  698                                         FilePath(kSingleSharedWorkersFile)); |  674                                         FilePath(kSingleSharedWorkersFile)); | 
|  699   url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); |  675   url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); | 
|  700   ASSERT_TRUE(window->AppendTab(url2)); |  676   ASSERT_TRUE(window->AppendTab(url2)); | 
|  701  |  677  | 
|  702   std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |  678   std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 
|  703       kTestCompleteCookie, TestTimeouts::action_max_timeout_ms()); |  679       kTestCompleteCookie, TestTimeouts::action_max_timeout_ms()); | 
|  704   ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); |  680   ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); | 
|  705   ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); |  681   ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); | 
|  706 } |  682 } | 
|  707  |  683  | 
|  708 // FileSystem worker tests. |  684 class WorkerFileSystemTest : public WorkerTest { | 
|  709 // They are disabled for now as the feature is not enabled by default. |  685  protected: | 
|  710 // http://crbug.com/32277 |  686   void RunWorkerFileSystemLayoutTest(const std::string& test_case_file_name) { | 
|  711 TEST_F(WorkerTest, DISABLED_WorkerFileSystemTemporaryTest) { |  687     FilePath worker_test_dir; | 
 |  688     worker_test_dir = worker_test_dir.AppendASCII("fast"); | 
 |  689  | 
 |  690     FilePath filesystem_test_dir; | 
 |  691     filesystem_test_dir = filesystem_test_dir.AppendASCII("filesystem"); | 
 |  692     filesystem_test_dir = filesystem_test_dir.AppendASCII("workers"); | 
 |  693     InitializeForLayoutTest(worker_test_dir, filesystem_test_dir, kNoHttpPort); | 
 |  694  | 
 |  695     FilePath resource_dir; | 
 |  696     resource_dir = resource_dir.AppendASCII("resources"); | 
 |  697     AddResourceForLayoutTest(worker_test_dir.AppendASCII("filesystem"), | 
 |  698                              resource_dir); | 
 |  699  | 
 |  700     // FS tests also rely on common files in js/resources. | 
 |  701     FilePath js_dir = worker_test_dir.AppendASCII("js"); | 
 |  702     FilePath js_resource_dir; | 
 |  703     js_resource_dir = js_resource_dir.AppendASCII("resources"); | 
 |  704     AddResourceForLayoutTest(js_dir, js_resource_dir); | 
 |  705  | 
 |  706     RunLayoutTest(test_case_file_name, kNoHttpPort); | 
 |  707  | 
 |  708     // Navigate to a blank page so that any workers are cleaned up. | 
 |  709     // This helps leaks trackers do a better job of reporting. | 
 |  710     scoped_refptr<TabProxy> tab(GetActiveTab()); | 
 |  711     ASSERT_TRUE(tab.get()); | 
 |  712     GURL about_url(chrome::kAboutBlankURL); | 
 |  713     EXPECT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(about_url)); | 
 |  714   } | 
 |  715 }; | 
 |  716  | 
 |  717 TEST_F(WorkerFileSystemTest, Temporary) { | 
|  712   RunWorkerFileSystemLayoutTest("simple-temporary.html"); |  718   RunWorkerFileSystemLayoutTest("simple-temporary.html"); | 
|  713 } |  719 } | 
|  714  |  720  | 
|  715 TEST_F(WorkerTest, DISABLED_WorkerFileSystemPersistentTest) { |  721 TEST_F(WorkerFileSystemTest, Persistent) { | 
|  716   RunWorkerFileSystemLayoutTest("simple-persistent.html"); |  722   RunWorkerFileSystemLayoutTest("simple-persistent.html"); | 
|  717 } |  723 } | 
|  718  |  724  | 
|  719 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncTemporaryTest) { |  725 TEST_F(WorkerFileSystemTest, SyncTemporary) { | 
|  720   RunWorkerFileSystemLayoutTest("simple-temporary-sync.html"); |  726   RunWorkerFileSystemLayoutTest("simple-temporary-sync.html"); | 
|  721 } |  727 } | 
|  722  |  728  | 
|  723 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncPersistentTest) { |  729 TEST_F(WorkerFileSystemTest, SyncPersistent) { | 
|  724   RunWorkerFileSystemLayoutTest("simple-persistent-sync.html"); |  730   RunWorkerFileSystemLayoutTest("simple-persistent-sync.html"); | 
|  725 } |  731 } | 
|  726  |  732  | 
|  727 TEST_F(WorkerTest, DISABLED_WorkerFileSystemAsyncOperationsTest) { |  733 TEST_F(WorkerFileSystemTest, AsyncOperations) { | 
|  728   RunWorkerFileSystemLayoutTest("async-operations.html"); |  734   RunWorkerFileSystemLayoutTest("async-operations.html"); | 
|  729 } |  735 } | 
|  730  |  736  | 
|  731 TEST_F(WorkerTest, DISABLED_WorkerFileSystemSyncOperationsTest) { |  737 TEST_F(WorkerFileSystemTest, SyncOperations) { | 
|  732   RunWorkerFileSystemLayoutTest("sync-operations.html"); |  738   RunWorkerFileSystemLayoutTest("sync-operations.html"); | 
|  733 } |  739 } | 
 |  740  | 
 |  741 TEST_F(WorkerFileSystemTest, FileEntryToURISync) { | 
 |  742   RunWorkerFileSystemLayoutTest("file-entry-to-uri-sync.html"); | 
 |  743 } | 
 |  744  | 
 |  745 #if defined(OS_LINUX) | 
 |  746 // These tests fail on Linux due to an assert in WebKit's RNG. | 
 |  747 // See http://webkit.org/b/55728. | 
 |  748 #define FileFromFileEntry DISABLED_FileFromFileEntry | 
 |  749 #define FileFromFileEntrySync DISABLED_FileFromFileEntrySync | 
 |  750 #define FileWriterTruncateExtend DISABLED_FileWriterTruncateExtend | 
 |  751 #define FileWriterSyncTruncateExtend DISABLED_FileWriterSyncTruncateExtend | 
 |  752 #define FileWriterSyncWriteOverlapped DISABLED_FileWriterSyncWriteOverlapped | 
 |  753 #elif defined(OS_WIN) | 
 |  754 // See http://crbug.com/75548 | 
 |  755 #define FileWriterTruncateExtend DISABLED_FileWriterTruncateExtend | 
 |  756 #define FileWriterSyncTruncateExtend DISABLED_FileWriterSyncTruncateExtend | 
 |  757 #define FileWriterSyncWriteOverlapped DISABLED_FileWriterSyncWriteOverlapped | 
 |  758 #endif | 
 |  759 TEST_F(WorkerFileSystemTest, FileFromFileEntry) { | 
 |  760   RunWorkerFileSystemLayoutTest("file-from-file-entry.html"); | 
 |  761 } | 
 |  762  | 
 |  763 TEST_F(WorkerFileSystemTest, FileFromFileEntrySync) { | 
 |  764   RunWorkerFileSystemLayoutTest("file-from-file-entry-sync.html"); | 
 |  765 } | 
 |  766  | 
 |  767 TEST_F(WorkerFileSystemTest, FileWriterTruncateExtend) { | 
 |  768   RunWorkerFileSystemLayoutTest("file-writer-truncate-extend.html"); | 
 |  769 } | 
 |  770  | 
 |  771 TEST_F(WorkerFileSystemTest, FileWriterSyncTruncateExtend) { | 
 |  772   RunWorkerFileSystemLayoutTest("file-writer-sync-truncate-extend.html"); | 
 |  773 } | 
 |  774  | 
 |  775 TEST_F(WorkerFileSystemTest, FileWriterSyncWriteOverlapped) { | 
 |  776   RunWorkerFileSystemLayoutTest("file-writer-sync-write-overlapped.html"); | 
 |  777 } | 
| OLD | NEW |