| 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/file_path.h" | 5 #include "base/file_path.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/platform_thread.h" | 8 #include "base/platform_thread.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/worker_host/worker_service.h" | 10 #include "chrome/browser/worker_host/worker_service.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 FilePath expected_result_path(result_dir_path); | 281 FilePath expected_result_path(result_dir_path); |
| 282 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); | 282 expected_result_path = expected_result_path.AppendASCII(test_case_file_name); |
| 283 expected_result_path = expected_result_path.InsertBeforeExtension( | 283 expected_result_path = expected_result_path.InsertBeforeExtension( |
| 284 FILE_PATH_LITERAL("-expected")); | 284 FILE_PATH_LITERAL("-expected")); |
| 285 expected_result_path = | 285 expected_result_path = |
| 286 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); | 286 expected_result_path.ReplaceExtension(FILE_PATH_LITERAL("txt")); |
| 287 return file_util::ReadFileToString(expected_result_path, | 287 return file_util::ReadFileToString(expected_result_path, |
| 288 expected_result_value); | 288 expected_result_value); |
| 289 } | 289 } |
| 290 | 290 |
| 291 TEST_F(WorkerTest, SingleWorker) { | 291 TEST_F(WorkerTest, DISABLED_SingleWorker) { |
| 292 RunTest(L"single_worker.html"); | 292 RunTest(L"single_worker.html"); |
| 293 } | 293 } |
| 294 | 294 |
| 295 TEST_F(WorkerTest, MultipleWorkers) { | 295 TEST_F(WorkerTest, DISABLED_MultipleWorkers) { |
| 296 RunTest(L"multi_worker.html"); | 296 RunTest(L"multi_worker.html"); |
| 297 } | 297 } |
| 298 | 298 |
| 299 TEST_F(WorkerTest, WorkerFastLayoutTests) { | 299 TEST_F(WorkerTest, DISABLED_WorkerFastLayoutTests) { |
| 300 static const char* kLayoutTestFiles[] = { | 300 static const char* kLayoutTestFiles[] = { |
| 301 "stress-js-execution.html", | 301 "stress-js-execution.html", |
| 302 "use-machine-stack.html", | 302 "use-machine-stack.html", |
| 303 "worker-call.html", | 303 "worker-call.html", |
| 304 "worker-close.html", | 304 "worker-close.html", |
| 305 "worker-constructor.html", | 305 "worker-constructor.html", |
| 306 "worker-context-gc.html", | 306 "worker-context-gc.html", |
| 307 "worker-event-listener.html", | 307 "worker-event-listener.html", |
| 308 "worker-gc.html", | 308 "worker-gc.html", |
| 309 "worker-location.html", | 309 "worker-location.html", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 320 fast_test_dir = fast_test_dir.AppendASCII("fast"); | 320 fast_test_dir = fast_test_dir.AppendASCII("fast"); |
| 321 | 321 |
| 322 FilePath worker_test_dir; | 322 FilePath worker_test_dir; |
| 323 worker_test_dir = worker_test_dir.AppendASCII("workers"); | 323 worker_test_dir = worker_test_dir.AppendASCII("workers"); |
| 324 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false); | 324 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false); |
| 325 | 325 |
| 326 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) | 326 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) |
| 327 RunLayoutTest(kLayoutTestFiles[i], false); | 327 RunLayoutTest(kLayoutTestFiles[i], false); |
| 328 } | 328 } |
| 329 | 329 |
| 330 TEST_F(WorkerTest, WorkerHttpLayoutTests) { | 330 TEST_F(WorkerTest, DISABLED_WorkerHttpLayoutTests) { |
| 331 static const char* kLayoutTestFiles[] = { | 331 static const char* kLayoutTestFiles[] = { |
| 332 // flakey? BUG 16934 "text-encoding.html", | 332 // flakey? BUG 16934 "text-encoding.html", |
| 333 "worker-importScripts.html", | 333 "worker-importScripts.html", |
| 334 "worker-redirect.html", | 334 "worker-redirect.html", |
| 335 }; | 335 }; |
| 336 | 336 |
| 337 FilePath http_test_dir; | 337 FilePath http_test_dir; |
| 338 http_test_dir = http_test_dir.AppendASCII("LayoutTests"); | 338 http_test_dir = http_test_dir.AppendASCII("LayoutTests"); |
| 339 http_test_dir = http_test_dir.AppendASCII("http"); | 339 http_test_dir = http_test_dir.AppendASCII("http"); |
| 340 http_test_dir = http_test_dir.AppendASCII("tests"); | 340 http_test_dir = http_test_dir.AppendASCII("tests"); |
| 341 | 341 |
| 342 FilePath worker_test_dir; | 342 FilePath worker_test_dir; |
| 343 worker_test_dir = worker_test_dir.AppendASCII("workers"); | 343 worker_test_dir = worker_test_dir.AppendASCII("workers"); |
| 344 InitializeForLayoutTest(http_test_dir, worker_test_dir, true); | 344 InitializeForLayoutTest(http_test_dir, worker_test_dir, true); |
| 345 | 345 |
| 346 StartHttpServer(new_http_root_dir_); | 346 StartHttpServer(new_http_root_dir_); |
| 347 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) | 347 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) |
| 348 RunLayoutTest(kLayoutTestFiles[i], true); | 348 RunLayoutTest(kLayoutTestFiles[i], true); |
| 349 StopHttpServer(); | 349 StopHttpServer(); |
| 350 } | 350 } |
| 351 | 351 |
| 352 TEST_F(WorkerTest, WorkerXhrHttpLayoutTests) { | 352 TEST_F(WorkerTest, DISABLED_WorkerXhrHttpLayoutTests) { |
| 353 static const char* kLayoutTestFiles[] = { | 353 static const char* kLayoutTestFiles[] = { |
| 354 "abort-exception-assert.html", | 354 "abort-exception-assert.html", |
| 355 "close.html", | 355 "close.html", |
| 356 //"methods-async.html", | 356 //"methods-async.html", |
| 357 //"methods.html", | 357 //"methods.html", |
| 358 "xmlhttprequest-file-not-found.html" | 358 "xmlhttprequest-file-not-found.html" |
| 359 }; | 359 }; |
| 360 | 360 |
| 361 FilePath http_test_dir; | 361 FilePath http_test_dir; |
| 362 http_test_dir = http_test_dir.AppendASCII("LayoutTests"); | 362 http_test_dir = http_test_dir.AppendASCII("LayoutTests"); |
| 363 http_test_dir = http_test_dir.AppendASCII("http"); | 363 http_test_dir = http_test_dir.AppendASCII("http"); |
| 364 http_test_dir = http_test_dir.AppendASCII("tests"); | 364 http_test_dir = http_test_dir.AppendASCII("tests"); |
| 365 | 365 |
| 366 FilePath worker_test_dir; | 366 FilePath worker_test_dir; |
| 367 worker_test_dir = worker_test_dir.AppendASCII("xmlhttprequest"); | 367 worker_test_dir = worker_test_dir.AppendASCII("xmlhttprequest"); |
| 368 worker_test_dir = worker_test_dir.AppendASCII("workers"); | 368 worker_test_dir = worker_test_dir.AppendASCII("workers"); |
| 369 InitializeForLayoutTest(http_test_dir, worker_test_dir, true); | 369 InitializeForLayoutTest(http_test_dir, worker_test_dir, true); |
| 370 | 370 |
| 371 StartHttpServer(new_http_root_dir_); | 371 StartHttpServer(new_http_root_dir_); |
| 372 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) | 372 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) |
| 373 RunLayoutTest(kLayoutTestFiles[i], true); | 373 RunLayoutTest(kLayoutTestFiles[i], true); |
| 374 StopHttpServer(); | 374 StopHttpServer(); |
| 375 } | 375 } |
| 376 | 376 |
| 377 TEST_F(WorkerTest, MessagePorts) { | 377 TEST_F(WorkerTest, DISABLED_MessagePorts) { |
| 378 static const char* kLayoutTestFiles[] = { | 378 static const char* kLayoutTestFiles[] = { |
| 379 "message-channel-gc.html", | 379 "message-channel-gc.html", |
| 380 "message-channel-gc-2.html", | 380 "message-channel-gc-2.html", |
| 381 "message-channel-gc-3.html", | 381 "message-channel-gc-3.html", |
| 382 "message-channel-gc-4.html", | 382 "message-channel-gc-4.html", |
| 383 "message-port.html", | 383 "message-port.html", |
| 384 "message-port-clone.html", | 384 "message-port-clone.html", |
| 385 "message-port-constructor-for-deleted-document.html", | 385 "message-port-constructor-for-deleted-document.html", |
| 386 "message-port-deleted-document.html", | 386 "message-port-deleted-document.html", |
| 387 "message-port-deleted-frame.html", | 387 "message-port-deleted-frame.html", |
| 388 "message-port-inactive-document.html", | 388 "message-port-inactive-document.html", |
| 389 "message-port-no-wrapper.html", | 389 "message-port-no-wrapper.html", |
| 390 // Only works with run-webkit-tests --leaks. | 390 // Only works with run-webkit-tests --leaks. |
| 391 //"message-channel-listener-circular-ownership.html", | 391 //"message-channel-listener-circular-ownership.html", |
| 392 }; | 392 }; |
| 393 | 393 |
| 394 FilePath fast_test_dir; | 394 FilePath fast_test_dir; |
| 395 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests"); | 395 fast_test_dir = fast_test_dir.AppendASCII("LayoutTests"); |
| 396 fast_test_dir = fast_test_dir.AppendASCII("fast"); | 396 fast_test_dir = fast_test_dir.AppendASCII("fast"); |
| 397 | 397 |
| 398 FilePath worker_test_dir; | 398 FilePath worker_test_dir; |
| 399 worker_test_dir = worker_test_dir.AppendASCII("events"); | 399 worker_test_dir = worker_test_dir.AppendASCII("events"); |
| 400 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false); | 400 InitializeForLayoutTest(fast_test_dir, worker_test_dir, false); |
| 401 | 401 |
| 402 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) | 402 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) |
| 403 RunLayoutTest(kLayoutTestFiles[i], false); | 403 RunLayoutTest(kLayoutTestFiles[i], false); |
| 404 } | 404 } |
| 405 | 405 |
| 406 TEST_F(WorkerTest, LimitPerPage) { | 406 TEST_F(WorkerTest, DISABLED_LimitPerPage) { |
| 407 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 407 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
| 408 GURL url = GetTestUrl(L"workers", L"many_workers.html"); | 408 GURL url = GetTestUrl(L"workers", L"many_workers.html"); |
| 409 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); | 409 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab + 1)); |
| 410 | 410 |
| 411 scoped_refptr<TabProxy> tab(GetActiveTab()); | 411 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 412 ASSERT_TRUE(tab.get()); | 412 ASSERT_TRUE(tab.get()); |
| 413 ASSERT_TRUE(tab->NavigateToURL(url)); | 413 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 414 | 414 |
| 415 EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), | 415 EXPECT_EQ(max_workers_per_tab + 1 + (UITest::in_process_renderer() ? 0 : 1), |
| 416 UITest::GetBrowserProcessCount()); | 416 UITest::GetBrowserProcessCount()); |
| 417 } | 417 } |
| 418 | 418 |
| 419 TEST_F(WorkerTest, LimitTotal) { | 419 TEST_F(WorkerTest, DISABLED_LimitTotal) { |
| 420 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; | 420 int max_workers_per_tab = WorkerService::kMaxWorkersPerTabWhenSeparate; |
| 421 int total_workers = WorkerService::kMaxWorkersWhenSeparate; | 421 int total_workers = WorkerService::kMaxWorkersWhenSeparate; |
| 422 | 422 |
| 423 int tab_count = (total_workers / max_workers_per_tab) + 1; | 423 int tab_count = (total_workers / max_workers_per_tab) + 1; |
| 424 GURL url = GetTestUrl(L"workers", L"many_workers.html"); | 424 GURL url = GetTestUrl(L"workers", L"many_workers.html"); |
| 425 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); | 425 url = GURL(url.spec() + StringPrintf("?count=%d", max_workers_per_tab)); |
| 426 | 426 |
| 427 scoped_refptr<TabProxy> tab(GetActiveTab()); | 427 scoped_refptr<TabProxy> tab(GetActiveTab()); |
| 428 ASSERT_TRUE(tab.get()); | 428 ASSERT_TRUE(tab.get()); |
| 429 ASSERT_TRUE(tab->NavigateToURL(url)); | 429 ASSERT_TRUE(tab->NavigateToURL(url)); |
| 430 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 430 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 431 for (int i = 1; i < tab_count; ++i) | 431 for (int i = 1; i < tab_count; ++i) |
| 432 window->AppendTab(url); | 432 window->AppendTab(url); |
| 433 | 433 |
| 434 // Check that we didn't create more than the max number of workers. | 434 // Check that we didn't create more than the max number of workers. |
| 435 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), | 435 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), |
| 436 UITest::GetBrowserProcessCount()); | 436 UITest::GetBrowserProcessCount()); |
| 437 | 437 |
| 438 // Now close the first tab and check that the queued workers were started. | 438 // Now close the first tab and check that the queued workers were started. |
| 439 tab->Close(true); | 439 tab->Close(true); |
| 440 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); | 440 tab->NavigateToURL(GetTestUrl(L"google", L"google.html")); |
| 441 | 441 |
| 442 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), | 442 EXPECT_EQ(total_workers + 1 + (UITest::in_process_renderer() ? 0 : tab_count), |
| 443 UITest::GetBrowserProcessCount()); | 443 UITest::GetBrowserProcessCount()); |
| 444 } | 444 } |
| OLD | NEW |