| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/app/chrome_dll_resource.h" | 6 #include "chrome/app/chrome_dll_resource.h" |
| 7 #include "chrome/browser/worker_host/worker_service.h" | 7 #include "chrome/browser/worker_host/worker_service.h" |
| 8 #include "chrome/common/chrome_switches.h" | 8 #include "chrome/common/chrome_switches.h" |
| 9 #include "chrome/test/automation/browser_proxy.h" | 9 #include "chrome/test/automation/browser_proxy.h" |
| 10 #include "chrome/test/automation/tab_proxy.h" | 10 #include "chrome/test/automation/tab_proxy.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 GURL url = GetTestUrl(L"workers", test_case); | 26 GURL url = GetTestUrl(L"workers", test_case); |
| 27 ASSERT_TRUE(tab->NavigateToURL(url)); | 27 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 28 | 28 |
| 29 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 29 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |
| 30 kTestCompleteCookie, action_max_timeout_ms()); | 30 kTestCompleteCookie, action_max_timeout_ms()); |
| 31 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); | 31 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 void RunIncognitoTest(const std::wstring& test_case) { | 34 void RunIncognitoTest(const std::wstring& test_case) { |
| 35 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 35 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 36 ASSERT_TRUE(browser.get()); |
| 37 |
| 36 // Open an Incognito window. | 38 // Open an Incognito window. |
| 37 int window_count; | |
| 38 ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); | 39 ASSERT_TRUE(browser->RunCommand(IDC_NEW_INCOGNITO_WINDOW)); |
| 39 scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1)); | 40 scoped_refptr<BrowserProxy> incognito(automation()->GetBrowserWindow(1)); |
| 40 scoped_refptr<TabProxy> tab(incognito->GetTab(0)); | 41 ASSERT_TRUE(incognito.get()); |
| 42 int window_count; |
| 41 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 43 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 42 ASSERT_EQ(2, window_count); | 44 ASSERT_EQ(2, window_count); |
| 43 | 45 |
| 46 scoped_refptr<TabProxy> tab(incognito->GetTab(0)); |
| 47 ASSERT_TRUE(tab.get()); |
| 48 |
| 44 GURL url = GetTestUrl(L"workers", test_case); | 49 GURL url = GetTestUrl(L"workers", test_case); |
| 45 ASSERT_TRUE(tab->NavigateToURL(url)); | 50 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 46 | 51 |
| 47 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 52 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |
| 48 kTestCompleteCookie, action_max_timeout_ms()); | 53 kTestCompleteCookie, action_max_timeout_ms()); |
| 49 | 54 |
| 50 // Close the incognito window | 55 // Close the incognito window |
| 51 ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); | 56 ASSERT_TRUE(incognito->RunCommand(IDC_CLOSE_WINDOW)); |
| 52 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 57 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 53 ASSERT_EQ(1, window_count); | 58 ASSERT_EQ(1, window_count); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 153 |
| 149 const wchar_t kDocRoot[] = L"chrome/test/data/workers"; | 154 const wchar_t kDocRoot[] = L"chrome/test/data/workers"; |
| 150 | 155 |
| 151 // http://crbug.com/36630 termination issues, disabled on all platforms. | 156 // http://crbug.com/36630 termination issues, disabled on all platforms. |
| 152 // http://crbug.com/33344 - NavigateAndWaitForAuth times out on the Windows | 157 // http://crbug.com/33344 - NavigateAndWaitForAuth times out on the Windows |
| 153 // build bots. | 158 // build bots. |
| 154 // Make sure that auth dialog is displayed from worker context. | 159 // Make sure that auth dialog is displayed from worker context. |
| 155 TEST_F(WorkerTest, DISABLED_WorkerHttpAuth) { | 160 TEST_F(WorkerTest, DISABLED_WorkerHttpAuth) { |
| 156 scoped_refptr<HTTPTestServer> server = | 161 scoped_refptr<HTTPTestServer> server = |
| 157 HTTPTestServer::CreateServer(kDocRoot, NULL); | 162 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 163 ASSERT_TRUE(NULL != server.get()); |
| 158 | 164 |
| 159 ASSERT_TRUE(NULL != server.get()); | |
| 160 scoped_refptr<TabProxy> tab(GetActiveTab()); | 165 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 166 ASSERT_TRUE(tab.get()); |
| 167 |
| 161 GURL url = server->TestServerPage("files/worker_auth.html"); | 168 GURL url = server->TestServerPage("files/worker_auth.html"); |
| 162 EXPECT_TRUE(NavigateAndWaitForAuth(tab, url)); | 169 EXPECT_TRUE(NavigateAndWaitForAuth(tab, url)); |
| 163 } | 170 } |
| 164 | 171 |
| 165 // http://crbug.com/36630 termination issues, disabled on all platforms. | 172 // http://crbug.com/36630 termination issues, disabled on all platforms. |
| 166 // http://crbug.com/33344 - NavigateAndWaitForAuth times out on the Windows | 173 // http://crbug.com/33344 - NavigateAndWaitForAuth times out on the Windows |
| 167 // build bots. | 174 // build bots. |
| 168 // Make sure that auth dialog is displayed from shared worker context. | 175 // Make sure that auth dialog is displayed from shared worker context. |
| 169 TEST_F(WorkerTest, DISABLED_SharedWorkerHttpAuth) { | 176 TEST_F(WorkerTest, DISABLED_SharedWorkerHttpAuth) { |
| 170 scoped_refptr<HTTPTestServer> server = | 177 scoped_refptr<HTTPTestServer> server = |
| 171 HTTPTestServer::CreateServer(kDocRoot, NULL); | 178 HTTPTestServer::CreateServer(kDocRoot, NULL); |
| 172 ASSERT_TRUE(NULL != server.get()); | 179 ASSERT_TRUE(NULL != server.get()); |
| 180 |
| 173 scoped_refptr<TabProxy> tab(GetActiveTab()); | 181 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 174 EXPECT_EQ(1, GetTabCount()); | 182 ASSERT_TRUE(tab.get()); |
| 183 |
| 175 GURL url = server->TestServerPage("files/shared_worker_auth.html"); | 184 GURL url = server->TestServerPage("files/shared_worker_auth.html"); |
| 176 EXPECT_TRUE(NavigateAndWaitForAuth(tab, url)); | 185 EXPECT_TRUE(NavigateAndWaitForAuth(tab, url)); |
| 177 // TODO(atwilson): Add support to automation framework to test for auth | 186 // TODO(atwilson): Add support to automation framework to test for auth |
| 178 // dialogs displayed by non-navigating tabs. | 187 // dialogs displayed by non-navigating tabs. |
| 179 } | 188 } |
| 180 | 189 |
| 181 TEST_F(WorkerTest, StressJSExecution) { | 190 TEST_F(WorkerTest, StressJSExecution) { |
| 182 RunWorkerFastLayoutTest("stress-js-execution.html"); | 191 RunWorkerFastLayoutTest("stress-js-execution.html"); |
| 183 } | 192 } |
| 184 | 193 |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 491 } |
| 483 | 492 |
| 484 // http://crbug.com/30307, disabled on Linux | 493 // http://crbug.com/30307, disabled on Linux |
| 485 // This has been flaky on Windows since r39931. http://crbug.com/36800 | 494 // This has been flaky on Windows since r39931. http://crbug.com/36800 |
| 486 // http://crbug.com/36630. Termination issues, disabled on all platforms. | 495 // http://crbug.com/36630. Termination issues, disabled on all platforms. |
| 487 TEST_F(WorkerTest, DISABLED_LimitPerPage) { | 496 TEST_F(WorkerTest, DISABLED_LimitPerPage) { |
| 488 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 497 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
| 489 GURL url = GetTestUrl(L"workers", L"many_workers.html"); | 498 GURL url = GetTestUrl(L"workers", L"many_workers.html"); |
| 490 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); | 499 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); |
| 491 | 500 |
| 492 scoped_refptr<TabProxy> tab(GetActiveTab()); | 501 NavigateToURL(url); |
| 493 ASSERT_TRUE(tab.get()); | |
| 494 ASSERT_TRUE(tab->NavigateToURL(url)); | |
| 495 | |
| 496 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); | 502 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); |
| 497 } | 503 } |
| 498 | 504 |
| 499 // Doesn't crash, but on all platforms, it sometimes fails. | 505 // Doesn't crash, but on all platforms, it sometimes fails. |
| 500 // http://crbug.com/28445. Made FLAKY | 506 // http://crbug.com/28445. Made FLAKY |
| 501 // http://crbug.com/36630. Termination issues, disabled on all platforms. | 507 // http://crbug.com/36630. Termination issues, disabled on all platforms. |
| 502 TEST_F(WorkerTest, DISABLED_LimitTotal) { | 508 TEST_F(WorkerTest, DISABLED_LimitTotal) { |
| 503 #if !defined(OS_LINUX) | 509 #if !defined(OS_LINUX) |
| 504 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 510 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
| 505 int total_workers = WorkerService::kMaxWorkersWhenSeparate; | 511 int total_workers = WorkerService::kMaxWorkersWhenSeparate; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); | 569 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); |
| 564 | 570 |
| 565 scoped_refptr<TabProxy> tab(GetActiveTab()); | 571 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 566 ASSERT_TRUE(tab.get()); | 572 ASSERT_TRUE(tab.get()); |
| 567 ASSERT_TRUE(tab->NavigateToURL(url)); | 573 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 568 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); | 574 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); |
| 569 | 575 |
| 570 // Create same set of workers in new tab (leaves one worker queued from this | 576 // Create same set of workers in new tab (leaves one worker queued from this |
| 571 // tab). | 577 // tab). |
| 572 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 578 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 579 ASSERT_TRUE(window.get()); |
| 573 ASSERT_TRUE(window->AppendTab(url)); | 580 ASSERT_TRUE(window->AppendTab(url)); |
| 574 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab)); | 581 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab)); |
| 575 | 582 |
| 576 // Now shutdown one of the shared workers - this will fire both queued | 583 // Now shutdown one of the shared workers - this will fire both queued |
| 577 // workers, but only one instance should be started | 584 // workers, but only one instance should be started |
| 578 GURL url2 = GetTestUrl(L"workers", L"shutdown_shared_worker.html?id=0"); | 585 GURL url2 = GetTestUrl(L"workers", L"shutdown_shared_worker.html?id=0"); |
| 579 ASSERT_TRUE(window->AppendTab(url2)); | 586 ASSERT_TRUE(window->AppendTab(url2)); |
| 580 | 587 |
| 581 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 588 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |
| 582 kTestCompleteCookie, action_max_timeout_ms()); | 589 kTestCompleteCookie, action_max_timeout_ms()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 593 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); | 600 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab+1)); |
| 594 | 601 |
| 595 scoped_refptr<TabProxy> tab(GetActiveTab()); | 602 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 596 ASSERT_TRUE(tab.get()); | 603 ASSERT_TRUE(tab.get()); |
| 597 ASSERT_TRUE(tab->NavigateToURL(url)); | 604 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 598 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); | 605 ASSERT_TRUE(WaitForProcessCountToBe(1, max_workers_per_tab)); |
| 599 // First window has hit its limit. Now launch second window which creates | 606 // First window has hit its limit. Now launch second window which creates |
| 600 // the same worker that was queued in the first window, to ensure it gets | 607 // the same worker that was queued in the first window, to ensure it gets |
| 601 // connected to the first window too. | 608 // connected to the first window too. |
| 602 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 609 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 610 ASSERT_TRUE(window.get()); |
| 603 GURL url2 = GetTestUrl(L"workers", L"single_shared_worker.html"); | 611 GURL url2 = GetTestUrl(L"workers", L"single_shared_worker.html"); |
| 604 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); | 612 url2 = GURL(url2.spec() + StringPrintf("?id=%d", max_workers_per_tab)); |
| 605 ASSERT_TRUE(window->AppendTab(url2)); | 613 ASSERT_TRUE(window->AppendTab(url2)); |
| 606 | 614 |
| 607 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, | 615 std::string value = WaitUntilCookieNonEmpty(tab.get(), url, |
| 608 kTestCompleteCookie, action_max_timeout_ms()); | 616 kTestCompleteCookie, action_max_timeout_ms()); |
| 609 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); | 617 ASSERT_STREQ(kTestCompleteSuccess, value.c_str()); |
| 610 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); | 618 ASSERT_TRUE(WaitForProcessCountToBe(2, max_workers_per_tab+1)); |
| 611 } | 619 } |
| OLD | NEW |