Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: chrome/worker/worker_uitest.cc

Issue 232001: Resubmitting fix for 22174 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/worker_host/worker_service.h" 5 #include "chrome/browser/worker_host/worker_service.h"
6 #include "chrome/test/automation/browser_proxy.h" 6 #include "chrome/test/automation/browser_proxy.h"
7 #include "chrome/test/automation/tab_proxy.h" 7 #include "chrome/test/automation/tab_proxy.h"
8 #include "chrome/test/ui/ui_layout_test.h" 8 #include "chrome/test/ui/ui_layout_test.h"
9 9
10 static const char kTestCompleteCookie[] = "status"; 10 static const char kTestCompleteCookie[] = "status";
(...skipping 20 matching lines...) Expand all
31 RunTest(L"single_worker.html"); 31 RunTest(L"single_worker.html");
32 } 32 }
33 33
34 TEST_F(WorkerTest, MultipleWorkers) { 34 TEST_F(WorkerTest, MultipleWorkers) {
35 RunTest(L"multi_worker.html"); 35 RunTest(L"multi_worker.html");
36 } 36 }
37 37
38 TEST_F(WorkerTest, WorkerFastLayoutTests) { 38 TEST_F(WorkerTest, WorkerFastLayoutTests) {
39 static const char* kLayoutTestFiles[] = { 39 static const char* kLayoutTestFiles[] = {
40 "stress-js-execution.html", 40 "stress-js-execution.html",
41 #if defined(OS_WIN)
42 // Workers don't properly initialize the V8 stack guard.
43 // (http://code.google.com/p/chromium/issues/detail?id=21653).
41 "use-machine-stack.html", 44 "use-machine-stack.html",
45 #endif
42 "worker-call.html", 46 "worker-call.html",
43 //"worker-close.html", 47 // Disabled because cloning ports are too slow in Chromium to meet the
48 // thresholds in this test.
49 // http://code.google.com/p/chromium/issues/detail?id=22780
50 // "worker-cloneport.html",
51
52 // Disabled because worker exceptions outside of script eval() are not
53 // reported (http://code.google.com/p/chromium/issues/detail?id=20953)
54 // "worker-close.html",
44 "worker-constructor.html", 55 "worker-constructor.html",
45 "worker-context-gc.html", 56 "worker-context-gc.html",
57 "worker-context-multi-port.html",
46 "worker-event-listener.html", 58 "worker-event-listener.html",
47 "worker-gc.html", 59 "worker-gc.html",
60 // worker-lifecycle.html relies on layoutTestController.workerThreadCount
61 // which is not currently implemented.
62 // "worker-lifecycle.html",
48 "worker-location.html", 63 "worker-location.html",
49 "worker-messageport.html", 64 "worker-messageport.html",
50 "worker-messageport-gc.html", 65 "worker-messageport-gc.html",
66 "worker-multi-port.html",
51 "worker-navigator.html", 67 "worker-navigator.html",
52 "worker-replace-global-constructor.html", 68 "worker-replace-global-constructor.html",
53 "worker-replace-self.html", 69 "worker-replace-self.html",
54 "worker-script-error.html", 70 "worker-script-error.html",
55 "worker-terminate.html", 71 "worker-terminate.html",
56 "worker-timeout.html" 72 "worker-timeout.html"
57 }; 73 };
58 74
59 FilePath fast_test_dir; 75 FilePath fast_test_dir;
60 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests"); 76 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests");
61 fast_test_dir = fast_test_dir.AppendASCII("fast"); 77 fast_test_dir = fast_test_dir.AppendASCII("fast");
62 78
63 FilePath worker_test_dir; 79 FilePath worker_test_dir;
64 worker_test_dir = worker_test_dir.AppendASCII("workers"); 80 worker_test_dir = worker_test_dir.AppendASCII("workers");
65 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false); 81 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false);
66 82
83 // Worker tests also rely on common files in js/resources.
84 FilePath js_dir = fast_test_dir.AppendASCII("js");
85 FilePath resource_dir;
86 resource_dir = resource_dir.AppendASCII("resources");
87 AddResourceForLayoutTest(js_dir, resource_dir);
88
67 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) 89 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
68 RunLayoutTest(kLayoutTestFiles[i], false); 90 RunLayoutTest(kLayoutTestFiles[i], false);
69 } 91 }
70 92
71 TEST_F(WorkerTest, WorkerHttpLayoutTests) { 93 TEST_F(WorkerTest, WorkerHttpLayoutTests) {
72 static const char* kLayoutTestFiles[] = { 94 static const char* kLayoutTestFiles[] = {
73 // flakey? BUG 16934 "text-encoding.html", 95 // flakey? BUG 16934 "text-encoding.html",
96 #if defined(OS_WIN)
97 // Fails on the mac (and linux?):
98 // http://code.google.com/p/chromium/issues/detail?id=22599
74 "worker-importScripts.html", 99 "worker-importScripts.html",
100 #endif
75 "worker-redirect.html", 101 "worker-redirect.html",
76 }; 102 };
77 103
78 FilePath http_test_dir; 104 FilePath http_test_dir;
79 http_test_dir = http_test_dir.AppendASCII("LayoutTests"); 105 http_test_dir = http_test_dir.AppendASCII("LayoutTests");
80 http_test_dir = http_test_dir.AppendASCII("http"); 106 http_test_dir = http_test_dir.AppendASCII("http");
81 http_test_dir = http_test_dir.AppendASCII("tests"); 107 http_test_dir = http_test_dir.AppendASCII("tests");
82 108
83 FilePath worker_test_dir; 109 FilePath worker_test_dir;
84 worker_test_dir = worker_test_dir.AppendASCII("workers"); 110 worker_test_dir = worker_test_dir.AppendASCII("workers");
85 InitializeForLayoutTest(http_test_dir, worker_test_dir, true); 111 InitializeForLayoutTest(http_test_dir, worker_test_dir, true);
86 112
87 StartHttpServer(new_http_root_dir_); 113 StartHttpServer(new_http_root_dir_);
88 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) 114 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
89 RunLayoutTest(kLayoutTestFiles[i], true); 115 RunLayoutTest(kLayoutTestFiles[i], true);
90 StopHttpServer(); 116 StopHttpServer();
91 } 117 }
92 118
93 TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) { 119 TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) {
94 static const char* kLayoutTestFiles[] = { 120 static const char* kLayoutTestFiles[] = {
95 "abort-exception-assert.html", 121 "abort-exception-assert.html",
122 #if defined(OS_WIN)
123 // Fails on the mac (and linux?):
124 // http://code.google.com/p/chromium/issues/detail?id=22599
96 "close.html", 125 "close.html",
126 #endif
97 //"methods-async.html", 127 //"methods-async.html",
98 //"methods.html", 128 //"methods.html",
99 "xmlhttprequest-file-not-found.html" 129 "xmlhttprequest-file-not-found.html"
100 }; 130 };
101 131
102 FilePath http_test_dir; 132 FilePath http_test_dir;
103 http_test_dir = http_test_dir.AppendASCII("LayoutTests"); 133 http_test_dir = http_test_dir.AppendASCII("LayoutTests");
104 http_test_dir = http_test_dir.AppendASCII("http"); 134 http_test_dir = http_test_dir.AppendASCII("http");
105 http_test_dir = http_test_dir.AppendASCII("tests"); 135 http_test_dir = http_test_dir.AppendASCII("tests");
106 136
(...skipping 13 matching lines...) Expand all
120 "message-channel-gc.html", 150 "message-channel-gc.html",
121 "message-channel-gc-2.html", 151 "message-channel-gc-2.html",
122 "message-channel-gc-3.html", 152 "message-channel-gc-3.html",
123 "message-channel-gc-4.html", 153 "message-channel-gc-4.html",
124 "message-port.html", 154 "message-port.html",
125 "message-port-clone.html", 155 "message-port-clone.html",
126 "message-port-constructor-for-deleted-document.html", 156 "message-port-constructor-for-deleted-document.html",
127 "message-port-deleted-document.html", 157 "message-port-deleted-document.html",
128 "message-port-deleted-frame.html", 158 "message-port-deleted-frame.html",
129 "message-port-inactive-document.html", 159 "message-port-inactive-document.html",
160 "message-port-multi.html",
130 "message-port-no-wrapper.html", 161 "message-port-no-wrapper.html",
131 // Only works with run-webkit-tests --leaks. 162 // Only works with run-webkit-tests --leaks.
132 //"message-channel-listener-circular-ownership.html", 163 //"message-channel-listener-circular-ownership.html",
133 }; 164 };
134 165
135 FilePath fast_test_dir; 166 FilePath fast_test_dir;
136 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests"); 167 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests");
137 fast_test_dir = fast_test_dir.AppendASCII("fast"); 168 fast_test_dir = fast_test_dir.AppendASCII("fast");
138 169
139 FilePath worker_test_dir; 170 FilePath worker_test_dir;
140 worker_test_dir = worker_test_dir.AppendASCII("events"); 171 worker_test_dir = worker_test_dir.AppendASCII("events");
141 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false); 172 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false);
142 173
174 // MessagePort tests also rely on common files in js/resources.
175 FilePath js_dir = fast_test_dir.AppendASCII("js");
176 FilePath resource_dir;
177 resource_dir = resource_dir.AppendASCII("resources");
178 AddResourceForLayoutTest(js_dir, resource_dir);
179
143 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) 180 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i)
144 RunLayoutTest(kLayoutTestFiles[i], false); 181 RunLayoutTest(kLayoutTestFiles[i], false);
145 } 182 }
146 183
184 // Disable LimitPerPage on Linux. Seems to work on Mac though:
185 // http://code.google.com/p/chromium/issues/detail?id=22608
186 #if !defined(OS_LINUX)
147 TEST_F(WorkerTest, LimitPerPage) { 187 TEST_F(WorkerTest, LimitPerPage) {
148 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 188 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
149 GURL url = GetTestUrl(L"workers", L"many_workers.html"); 189 GURL url = GetTestUrl(L"workers", L"many_workers.html");
150 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); 190 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1));
151 191
152 scoped_refptr<TabProxy> tab(GetActiveTab()); 192 scoped_refptr<TabProxy> tab(GetActiveTab());
153 ASSERT_TRUE(tab.get()); 193 ASSERT_TRUE(tab.get());
154 ASSERT_TRUE(tab->NavigateToURL(url)); 194 ASSERT_TRUE(tab->NavigateToURL(url));
155 195
156 EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), 196 EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1),
157 UITest::GetBrowserProcessCount()); 197 UITest::GetBrowserProcessCount());
158 } 198 }
199 #endif
159 200
201 // Disable LimitTotal on Linux and Mac.
202 // http://code.google.com/p/chromium/issues/detail?id=22608
203 #if defined(OS_WIN)
160 TEST_F(WorkerTest, LimitTotal) { 204 TEST_F(WorkerTest, LimitTotal) {
161 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; 205 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate;
162 int total_workers = WorkerService::kMaxWorkersWhenSeparate; 206 int total_workers = WorkerService::kMaxWorkersWhenSeparate;
163 207
164 int tab_count = (total_workers / max_workers_per_tab) + 1; 208 int tab_count = (total_workers / max_workers_per_tab) + 1;
165 GURL url = GetTestUrl(L"workers", L"many_workers.html"); 209 GURL url = GetTestUrl(L"workers", L"many_workers.html");
166 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); 210 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab));
167 211
168 scoped_refptr<TabProxy> tab(GetActiveTab()); 212 scoped_refptr<TabProxy> tab(GetActiveTab());
169 ASSERT_TRUE(tab.get()); 213 ASSERT_TRUE(tab.get());
170 ASSERT_TRUE(tab->NavigateToURL(url)); 214 ASSERT_TRUE(tab->NavigateToURL(url));
171 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); 215 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
172 for (int i = 1; i < tab_count; ++i) 216 for (int i = 1; i < tab_count; ++i)
173 window->AppendTab(url); 217 window->AppendTab(url);
174 218
175 // Check that we didn't create more than the max number of workers. 219 // Check that we didn't create more than the max number of workers.
176 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), 220 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count),
177 UITest::GetBrowserProcessCount()); 221 UITest::GetBrowserProcessCount());
178 222
179 // Now close the first tab and check that the queued workers were started. 223 // Now close the first tab and check that the queued workers were started.
180 tab->Close(true); 224 tab->Close(true);
181 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); 225 tab->NavigateToURL(GetTestUrl(L"google", L"google.html"));
182 226
183 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), 227 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count),
184 UITest::GetBrowserProcessCount()); 228 UITest::GetBrowserProcessCount());
185 } 229 }
230 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698