| 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" |
| 11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
| 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/test_timeouts.h" | 15 #include "base/test/test_timeouts.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" | 17 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" |
| 18 #include "chrome/browser/devtools/device/self_device_provider.h" |
| 17 #include "chrome/browser/devtools/devtools_window_testing.h" | 19 #include "chrome/browser/devtools/devtools_window_testing.h" |
| 18 #include "chrome/browser/extensions/extension_apitest.h" | 20 #include "chrome/browser/extensions/extension_apitest.h" |
| 19 #include "chrome/browser/extensions/extension_browsertest.h" | 21 #include "chrome/browser/extensions/extension_browsertest.h" |
| 20 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
| 21 #include "chrome/browser/extensions/unpacked_installer.h" | 23 #include "chrome/browser/extensions/unpacked_installer.h" |
| 22 #include "chrome/browser/lifetime/application_lifetime.h" | 24 #include "chrome/browser/lifetime/application_lifetime.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
| 25 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
| 26 #include "chrome/browser/ui/browser_iterator.h" | 28 #include "chrome/browser/ui/browser_iterator.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; | 82 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; |
| 81 const char kSharedWorkerTestPage[] = | 83 const char kSharedWorkerTestPage[] = |
| 82 "files/workers/workers_ui_shared_worker.html"; | 84 "files/workers/workers_ui_shared_worker.html"; |
| 83 const char kSharedWorkerTestWorker[] = | 85 const char kSharedWorkerTestWorker[] = |
| 84 "files/workers/workers_ui_shared_worker.js"; | 86 "files/workers/workers_ui_shared_worker.js"; |
| 85 const char kReloadSharedWorkerTestPage[] = | 87 const char kReloadSharedWorkerTestPage[] = |
| 86 "files/workers/debug_shared_worker_initialization.html"; | 88 "files/workers/debug_shared_worker_initialization.html"; |
| 87 const char kReloadSharedWorkerTestWorker[] = | 89 const char kReloadSharedWorkerTestWorker[] = |
| 88 "files/workers/debug_shared_worker_initialization.js"; | 90 "files/workers/debug_shared_worker_initialization.js"; |
| 89 | 91 |
| 92 const int kRemoteDebuggingPort = 9225; |
| 93 |
| 90 void RunTestFunction(DevToolsWindow* window, const char* test_name) { | 94 void RunTestFunction(DevToolsWindow* window, const char* test_name) { |
| 91 std::string result; | 95 std::string result; |
| 92 | 96 |
| 93 RenderViewHost* rvh = DevToolsWindowTesting::Get(window)-> | 97 RenderViewHost* rvh = DevToolsWindowTesting::Get(window)-> |
| 94 main_web_contents()->GetRenderViewHost(); | 98 main_web_contents()->GetRenderViewHost(); |
| 95 // At first check that JavaScript part of the front-end is loaded by | 99 // At first check that JavaScript part of the front-end is loaded by |
| 96 // checking that global variable uiTests exists(it's created after all js | 100 // checking that global variable uiTests exists(it's created after all js |
| 97 // files have been loaded) and has runTest method. | 101 // files have been loaded) and has runTest method. |
| 98 ASSERT_TRUE( | 102 ASSERT_TRUE( |
| 99 content::ExecuteScriptAndExtractString( | 103 content::ExecuteScriptAndExtractString( |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 DevToolsAgentHost::GetOrCreateFor(web_contents).get(); | 923 DevToolsAgentHost::GetOrCreateFor(web_contents).get(); |
| 920 const std::string agent_id = agent_raw->GetId(); | 924 const std::string agent_id = agent_raw->GetId(); |
| 921 ASSERT_EQ(agent_raw, DevToolsAgentHost::GetForId(agent_id).get()) | 925 ASSERT_EQ(agent_raw, DevToolsAgentHost::GetForId(agent_id).get()) |
| 922 << "DevToolsAgentHost cannot be found by id"; | 926 << "DevToolsAgentHost cannot be found by id"; |
| 923 browser()->tab_strip_model()-> | 927 browser()->tab_strip_model()-> |
| 924 CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); | 928 CloseWebContentsAt(0, TabStripModel::CLOSE_NONE); |
| 925 ASSERT_FALSE(DevToolsAgentHost::GetForId(agent_id).get()) | 929 ASSERT_FALSE(DevToolsAgentHost::GetForId(agent_id).get()) |
| 926 << "DevToolsAgentHost is not released when the tab is closed"; | 930 << "DevToolsAgentHost is not released when the tab is closed"; |
| 927 } | 931 } |
| 928 | 932 |
| 929 class RemoteDebuggingTest: public ExtensionApiTest { | 933 class RemoteDebuggingTest : public ExtensionApiTest { |
| 930 void SetUpCommandLine(base::CommandLine* command_line) override { | 934 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 931 ExtensionApiTest::SetUpCommandLine(command_line); | 935 ExtensionApiTest::SetUpCommandLine(command_line); |
| 932 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, "9222"); | 936 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, "9222"); |
| 933 | 937 |
| 934 // Override the extension root path. | 938 // Override the extension root path. |
| 935 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); | 939 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_); |
| 936 test_data_dir_ = test_data_dir_.AppendASCII("devtools"); | 940 test_data_dir_ = test_data_dir_.AppendASCII("devtools"); |
| 937 } | 941 } |
| 938 }; | 942 }; |
| 939 | 943 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 959 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsDisabled, true); | 963 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsDisabled, true); |
| 960 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 964 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 961 content::WebContents* web_contents = | 965 content::WebContents* web_contents = |
| 962 browser()->tab_strip_model()->GetWebContentsAt(0); | 966 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 963 scoped_refptr<content::DevToolsAgentHost> agent( | 967 scoped_refptr<content::DevToolsAgentHost> agent( |
| 964 content::DevToolsAgentHost::GetOrCreateFor(web_contents)); | 968 content::DevToolsAgentHost::GetOrCreateFor(web_contents)); |
| 965 DevToolsWindow::OpenDevToolsWindow(web_contents); | 969 DevToolsWindow::OpenDevToolsWindow(web_contents); |
| 966 DevToolsWindow* window = DevToolsWindow::FindDevToolsWindow(agent.get()); | 970 DevToolsWindow* window = DevToolsWindow::FindDevToolsWindow(agent.get()); |
| 967 ASSERT_FALSE(window); | 971 ASSERT_FALSE(window); |
| 968 } | 972 } |
| 973 |
| 974 class RemoteWebSocketTest : public DevToolsSanityTest { |
| 975 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 976 DevToolsSanityTest::SetUpCommandLine(command_line); |
| 977 command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort, |
| 978 base::IntToString(kRemoteDebuggingPort)); |
| 979 } |
| 980 }; |
| 981 |
| 982 IN_PROC_BROWSER_TEST_F(RemoteWebSocketTest, TestWebSocket) { |
| 983 AndroidDeviceManager::DeviceProviders device_providers; |
| 984 device_providers.push_back(new SelfAsDeviceProvider(kRemoteDebuggingPort)); |
| 985 DevToolsAndroidBridge::Factory::GetForProfile(browser()->profile())-> |
| 986 set_device_providers_for_test(device_providers); |
| 987 RunTest("testRemoteWebSocket", "about:blank"); |
| 988 } |
| OLD | NEW |