diff options
Diffstat (limited to 'chrome/worker/worker_uitest.cc')
-rw-r--r-- | chrome/worker/worker_uitest.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/chrome/worker/worker_uitest.cc b/chrome/worker/worker_uitest.cc index d4b5095..4cf9014 100644 --- a/chrome/worker/worker_uitest.cc +++ b/chrome/worker/worker_uitest.cc @@ -2,7 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/worker_host/worker_service.h" #include "chrome/common/chrome_switches.h" +#include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" @@ -37,3 +39,40 @@ TEST_F(WorkerTest, MultipleWorkers) { RunTest(L"multi_worker.html"); } +TEST_F(WorkerTest, LimitPerPage) { + int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; + GURL url = GetTestUrl(L"workers", L"many_workers.html"); + url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); + + scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab->NavigateToURL(url)); + + EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), + UITest::GetBrowserProcessCount()); +} + +TEST_F(WorkerTest, LimitTotal) { + int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; + int total_workers = WorkerService::kMaxWorkersWhenSeparate; + + int tab_count = (total_workers / max_workers_per_tab) + 1; + GURL url = GetTestUrl(L"workers", L"many_workers.html"); + url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); + + scoped_refptr<TabProxy> tab(GetActiveTab()); + ASSERT_TRUE(tab->NavigateToURL(url)); + scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); + for (int i = 1; i < tab_count; ++i) + window->AppendTab(url); + + // Check that we didn't create more than the max number of workers. + EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), + UITest::GetBrowserProcessCount()); + + // Now close the first tab and check that the queued workers were started. + tab->Close(true); + tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); + + EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), + UITest::GetBrowserProcessCount()); +} |