Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
| 12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
| 13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
| 14 #include "content/browser/worker_host/worker_process_host.h" | 14 #include "content/browser/worker_host/worker_process_host.h" |
| 15 #include "content/browser/worker_host/worker_service_impl.h" | 15 #include "content/browser/worker_host/worker_service_impl.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/common/content_paths.h" | 17 #include "content/public/common/content_paths.h" |
| 18 #include "content/public/test/browser_test_utils.h" | 18 #include "content/public/test/browser_test_utils.h" |
| 19 #include "content/public/test/test_utils.h" | 19 #include "content/public/test/test_utils.h" |
| 20 #include "content/shell/shell.h" | 20 #include "content/shell/shell.h" |
| 21 #include "content/shell/shell_content_browser_client.h" | 21 #include "content/shell/shell_content_browser_client.h" |
| 22 #include "content/shell/shell_resource_dispatcher_host_delegate.h" | 22 #include "content/shell/shell_resource_dispatcher_host_delegate.h" |
| 23 #include "content/test/content_browser_test_utils.h" | 23 #include "content/test/content_browser_test_utils.h" |
| 24 #include "content/test/layout_browsertest.h" | 24 #include "content/test/layout_browsertest.h" |
| 25 #include "googleurl/src/gurl.h" | 25 #include "googleurl/src/gurl.h" |
| 26 #include "net/test/test_server.h" | |
| 26 | 27 |
| 27 using content::BrowserThread; | 28 using content::BrowserThread; |
| 28 using content::WorkerServiceImpl; | 29 using content::WorkerServiceImpl; |
| 29 | 30 |
| 30 class WorkerLayoutTest : public InProcessBrowserLayoutTest { | 31 class WorkerLayoutTest : public InProcessBrowserLayoutTest { |
| 31 public: | 32 public: |
| 32 WorkerLayoutTest() : InProcessBrowserLayoutTest( | 33 WorkerLayoutTest() : InProcessBrowserLayoutTest( |
| 33 FilePath(), FilePath().AppendASCII("fast").AppendASCII("workers")) { | 34 FilePath(), FilePath().AppendASCII("fast").AppendASCII("workers")) { |
| 34 } | 35 } |
| 35 }; | 36 }; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 // "shared-worker-methods.html", | 215 // "shared-worker-methods.html", |
| 215 "shared-worker-xhr-file-not-found.html", | 216 "shared-worker-xhr-file-not-found.html", |
| 216 | 217 |
| 217 "xmlhttprequest-file-not-found.html" | 218 "xmlhttprequest-file-not-found.html" |
| 218 }; | 219 }; |
| 219 | 220 |
| 220 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) | 221 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) |
| 221 RunHttpLayoutTest(kLayoutTestFiles[i]); | 222 RunHttpLayoutTest(kLayoutTestFiles[i]); |
| 222 } | 223 } |
| 223 | 224 |
| 224 class WorkerWebSocketHttpLayoutTest : public InProcessBrowserLayoutTest { | |
| 225 public: | |
| 226 WorkerWebSocketHttpLayoutTest() : InProcessBrowserLayoutTest( | |
| 227 FilePath(), | |
| 228 FilePath().AppendASCII("http").AppendASCII("tests"). | |
| 229 AppendASCII("websocket").AppendASCII("tests").AppendASCII("hybi"). | |
| 230 AppendASCII("workers"), | |
| 231 -1) { | |
| 232 } | |
| 233 }; | |
| 234 | |
| 235 IN_PROC_BROWSER_TEST_F(WorkerWebSocketHttpLayoutTest, DISABLED_Tests) { | |
| 236 static const char* kLayoutTestFiles[] = { | |
| 237 "close-in-onmessage-crash.html", | |
| 238 "close-in-shared-worker.html", | |
| 239 "close-in-worker.html", | |
| 240 "shared-worker-simple.html", | |
| 241 "worker-handshake-challenge-randomness.html", | |
| 242 "worker-simple.html" | |
| 243 }; | |
| 244 | |
| 245 FilePath websocket_test_dir; | |
| 246 ASSERT_TRUE(PathService::Get(content::DIR_LAYOUT_TESTS, &websocket_test_dir)); | |
| 247 | |
| 248 content::TestWebSocketServer websocket_server; | |
| 249 ASSERT_TRUE(websocket_server.Start(websocket_test_dir)); | |
| 250 | |
| 251 for (size_t i = 0; i < arraysize(kLayoutTestFiles); ++i) | |
| 252 RunHttpLayoutTest(kLayoutTestFiles[i]); | |
| 253 } | |
| 254 | |
| 255 class WorkerTest : public content::ContentBrowserTest { | 225 class WorkerTest : public content::ContentBrowserTest { |
| 256 public: | 226 public: |
| 257 WorkerTest() {} | 227 WorkerTest() {} |
| 258 | 228 |
| 259 GURL GetTestURL(const std::string& test_case, const std::string& query) { | 229 GURL GetTestURL(const std::string& test_case, const std::string& query) { |
| 260 FilePath test_file_path = content::GetTestFilePath( | 230 FilePath test_file_path = content::GetTestFilePath( |
| 261 "workers", test_case.c_str()); | 231 "workers", test_case.c_str()); |
| 262 return content::GetFileUrlWithQuery(test_file_path, query); | 232 return content::GetFileUrlWithQuery(test_file_path, query); |
| 263 } | 233 } |
| 264 | 234 |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 | 443 |
| 474 // First window has hit its limit. Now launch second window which creates | 444 // First window has hit its limit. Now launch second window which creates |
| 475 // the same worker that was queued in the first window, to ensure it gets | 445 // the same worker that was queued in the first window, to ensure it gets |
| 476 // connected to the first window too. | 446 // connected to the first window too. |
| 477 query = StringPrintf("?id=%d", max_workers_per_tab); | 447 query = StringPrintf("?id=%d", max_workers_per_tab); |
| 478 url = GetTestURL("single_shared_worker.html", query); | 448 url = GetTestURL("single_shared_worker.html", query); |
| 479 content::NavigateToURL(CreateBrowser(), url); | 449 content::NavigateToURL(CreateBrowser(), url); |
| 480 | 450 |
| 481 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); | 451 ASSERT_TRUE(WaitForWorkerProcessCount(max_workers_per_tab + 1)); |
| 482 } | 452 } |
| 453 | |
| 454 IN_PROC_BROWSER_TEST_F(WorkerTest, WebSocketSharedWorker) { | |
| 455 // Launch WebSocket server. | |
| 456 FilePath test_file_path = content::GetTestFilePath("workers", ""); | |
|
bashi
2012/10/15 08:02:21
Is |test_file_path| used?
Takashi Toyoshima
2012/10/15 08:14:34
Good catch!
I will remove this line.
I took a new
| |
| 457 net::TestServer ws_server(net::TestServer::TYPE_WS, | |
| 458 net::TestServer::kLocalhost, | |
| 459 FilePath(FILE_PATH_LITERAL("net/data/websocket"))); | |
| 460 ASSERT_TRUE(ws_server.Start()); | |
| 461 | |
| 462 // Generate test URL. | |
| 463 std::string scheme("http"); | |
| 464 GURL::Replacements replacements; | |
| 465 replacements.SetSchemeStr(scheme); | |
| 466 GURL url = ws_server.GetURL( | |
| 467 "websocket_shared_worker.html").ReplaceComponents(replacements); | |
| 468 | |
| 469 // Run test. | |
| 470 content::Shell* window = shell(); | |
| 471 const string16 expected_title = ASCIIToUTF16("OK"); | |
| 472 content::TitleWatcher title_watcher(window->web_contents(), expected_title); | |
| 473 content::NavigateToURL(window, url); | |
| 474 string16 final_title = title_watcher.WaitAndGetTitle(); | |
| 475 EXPECT_EQ(expected_title, final_title); | |
| 476 } | |
| OLD | NEW |