summaryrefslogtreecommitdiffstats
path: root/chrome/worker
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 22:51:03 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 22:51:03 +0000
commit11de3e98153ad8dcb9e6628e527f7bfb2ca0a8ed (patch)
tree53cd07aaba6e6294b18a43a362980f8aa4a27142 /chrome/worker
parent51570ddfc079a32dc5e78887f730b7aa270b916e (diff)
downloadchromium_src-11de3e98153ad8dcb9e6628e527f7bfb2ca0a8ed.zip
chromium_src-11de3e98153ad8dcb9e6628e527f7bfb2ca0a8ed.tar.gz
chromium_src-11de3e98153ad8dcb9e6628e527f7bfb2ca0a8ed.tar.bz2
Implement a max worker count of 16 per tab and 64 total. Any workers created after that are queued.
Review URL: http://codereview.chromium.org/125242 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18763 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/worker')
-rw-r--r--chrome/worker/DEPS1
-rw-r--r--chrome/worker/worker_uitest.cc39
2 files changed, 40 insertions, 0 deletions
diff --git a/chrome/worker/DEPS b/chrome/worker/DEPS
index cf8be8e..5d7c881 100644
--- a/chrome/worker/DEPS
+++ b/chrome/worker/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+chrome/browser/worker_host", # For UI test.
"+chrome/renderer",
"+chrome/worker",
"+sandbox/src",
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());
+}