| 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/cancelable_callback.h" | 6 #include "base/cancelable_callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // At first check that JavaScript part of the front-end is loaded by | 87 // At first check that JavaScript part of the front-end is loaded by |
| 88 // checking that global variable uiTests exists(it's created after all js | 88 // checking that global variable uiTests exists(it's created after all js |
| 89 // files have been loaded) and has runTest method. | 89 // files have been loaded) and has runTest method. |
| 90 ASSERT_TRUE( | 90 ASSERT_TRUE( |
| 91 content::ExecuteScriptAndExtractString( | 91 content::ExecuteScriptAndExtractString( |
| 92 window->GetRenderViewHost(), | 92 window->GetRenderViewHost(), |
| 93 "window.domAutomationController.send(" | 93 "window.domAutomationController.send(" |
| 94 " '' + (window.uiTests && (typeof uiTests.runTest)));", | 94 " '' + (window.uiTests && (typeof uiTests.runTest)));", |
| 95 &result)); | 95 &result)); |
| 96 | 96 |
| 97 if (result == "function") { | 97 ASSERT_EQ("function", result) << "DevTools front-end is broken."; |
| 98 ASSERT_TRUE( | 98 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
| 99 content::ExecuteScriptAndExtractString( | 99 window->GetRenderViewHost(), |
| 100 window->GetRenderViewHost(), | 100 base::StringPrintf("uiTests.runTest('%s')", test_name), |
| 101 base::StringPrintf("uiTests.runTest('%s')", test_name), | 101 &result)); |
| 102 &result)); | 102 EXPECT_EQ("[OK]", result); |
| 103 EXPECT_EQ("[OK]", result); | |
| 104 } else { | |
| 105 FAIL() << "DevTools front-end is broken."; | |
| 106 } | |
| 107 } | 103 } |
| 108 | 104 |
| 109 } // namespace | 105 } // namespace |
| 110 | 106 |
| 111 class DevToolsSanityTest : public InProcessBrowserTest { | 107 class DevToolsSanityTest : public InProcessBrowserTest { |
| 112 public: | 108 public: |
| 113 DevToolsSanityTest() | 109 DevToolsSanityTest() |
| 114 : window_(NULL), | 110 : window_(NULL), |
| 115 inspected_rvh_(NULL) {} | 111 inspected_rvh_(NULL) {} |
| 116 | 112 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return native_dialog; | 312 return native_dialog; |
| 317 } | 313 } |
| 318 }; | 314 }; |
| 319 | 315 |
| 320 class DevToolsUnresponsiveBeforeUnloadTest: public DevToolsBeforeUnloadTest { | 316 class DevToolsUnresponsiveBeforeUnloadTest: public DevToolsBeforeUnloadTest { |
| 321 public: | 317 public: |
| 322 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {} | 318 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {} |
| 323 }; | 319 }; |
| 324 | 320 |
| 325 void TimeoutCallback(const std::string& timeout_message) { | 321 void TimeoutCallback(const std::string& timeout_message) { |
| 326 FAIL() << timeout_message; | 322 ADD_FAILURE() << timeout_message; |
| 327 base::MessageLoop::current()->Quit(); | 323 base::MessageLoop::current()->Quit(); |
| 328 } | 324 } |
| 329 | 325 |
| 330 // Base class for DevTools tests that test devtools functionality for | 326 // Base class for DevTools tests that test devtools functionality for |
| 331 // extensions and content scripts. | 327 // extensions and content scripts. |
| 332 class DevToolsExtensionTest : public DevToolsSanityTest, | 328 class DevToolsExtensionTest : public DevToolsSanityTest, |
| 333 public content::NotificationObserver { | 329 public content::NotificationObserver { |
| 334 public: | 330 public: |
| 335 DevToolsExtensionTest() : DevToolsSanityTest() { | 331 DevToolsExtensionTest() : DevToolsSanityTest() { |
| 336 PathService::Get(chrome::DIR_TEST_DATA, &test_extensions_dir_); | 332 PathService::Get(chrome::DIR_TEST_DATA, &test_extensions_dir_); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 GURL url = test_server()->GetURL(test_page); | 485 GURL url = test_server()->GetURL(test_page); |
| 490 ui_test_utils::NavigateToURL(browser(), url); | 486 ui_test_utils::NavigateToURL(browser(), url); |
| 491 | 487 |
| 492 scoped_refptr<WorkerData> worker_data = WaitForFirstSharedWorker(); | 488 scoped_refptr<WorkerData> worker_data = WaitForFirstSharedWorker(); |
| 493 OpenDevToolsWindowForSharedWorker(worker_data.get()); | 489 OpenDevToolsWindowForSharedWorker(worker_data.get()); |
| 494 RunTestFunction(window_, test_name); | 490 RunTestFunction(window_, test_name); |
| 495 CloseDevToolsWindow(); | 491 CloseDevToolsWindow(); |
| 496 } | 492 } |
| 497 | 493 |
| 498 static void TerminateWorkerOnIOThread(scoped_refptr<WorkerData> worker_data) { | 494 static void TerminateWorkerOnIOThread(scoped_refptr<WorkerData> worker_data) { |
| 499 if (WorkerService::GetInstance()->TerminateWorker( | 495 if (!WorkerService::GetInstance()->TerminateWorker( |
| 500 worker_data->worker_process_id, worker_data->worker_route_id)) { | 496 worker_data->worker_process_id, worker_data->worker_route_id)) |
| 501 WorkerService::GetInstance()->AddObserver( | 497 FAIL() << "Failed to terminate worker.\n"; |
| 502 new WorkerTerminationObserver(worker_data.get())); | 498 WorkerService::GetInstance()->AddObserver( |
| 503 return; | 499 new WorkerTerminationObserver(worker_data.get())); |
| 504 } | |
| 505 FAIL() << "Failed to terminate worker.\n"; | |
| 506 } | 500 } |
| 507 | 501 |
| 508 static void TerminateWorker(scoped_refptr<WorkerData> worker_data) { | 502 static void TerminateWorker(scoped_refptr<WorkerData> worker_data) { |
| 509 BrowserThread::PostTask( | 503 BrowserThread::PostTask( |
| 510 BrowserThread::IO, FROM_HERE, | 504 BrowserThread::IO, FROM_HERE, |
| 511 base::Bind(&TerminateWorkerOnIOThread, worker_data)); | 505 base::Bind(&TerminateWorkerOnIOThread, worker_data)); |
| 512 content::RunMessageLoop(); | 506 content::RunMessageLoop(); |
| 513 } | 507 } |
| 514 | 508 |
| 515 static void WaitForFirstSharedWorkerOnIOThread( | 509 static void WaitForFirstSharedWorkerOnIOThread( |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 977 | 971 |
| 978 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { | 972 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, RemoteDebugger) { |
| 979 #if defined(OS_WIN) && defined(USE_ASH) | 973 #if defined(OS_WIN) && defined(USE_ASH) |
| 980 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 974 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
| 981 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 975 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
| 982 return; | 976 return; |
| 983 #endif | 977 #endif |
| 984 | 978 |
| 985 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; | 979 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; |
| 986 } | 980 } |
| OLD | NEW |