OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "content/browser/debugger/devtools_manager_impl.h" | 7 #include "content/browser/debugger/devtools_manager_impl.h" |
8 #include "content/browser/debugger/render_view_devtools_agent_host.h" | 8 #include "content/browser/debugger/render_view_devtools_agent_host.h" |
9 #include "content/browser/mock_content_browser_client.h" | 9 #include "content/browser/mock_content_browser_client.h" |
10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 TestDevToolsClientHost client_host; | 189 TestDevToolsClientHost client_host; |
190 DevToolsAgentHost* agent_host = | 190 DevToolsAgentHost* agent_host = |
191 DevToolsAgentHostRegistry::GetDevToolsAgentHost(inspected_rvh); | 191 DevToolsAgentHostRegistry::GetDevToolsAgentHost(inspected_rvh); |
192 DevToolsManager::GetInstance()-> | 192 DevToolsManager::GetInstance()-> |
193 RegisterDevToolsClientHostFor(agent_host, &client_host); | 193 RegisterDevToolsClientHostFor(agent_host, &client_host); |
194 | 194 |
195 // Start with a short timeout. | 195 // Start with a short timeout. |
196 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 196 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
197 // Wait long enough for first timeout and see if it fired. | 197 // Wait long enough for first timeout and see if it fired. |
198 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 198 MessageLoop::current()->PostDelayedTask( |
199 MessageLoop::QuitClosure(), 10); | 199 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); |
200 MessageLoop::current()->Run(); | 200 MessageLoop::current()->Run(); |
201 EXPECT_FALSE(delegate.renderer_unresponsive_received()); | 201 EXPECT_FALSE(delegate.renderer_unresponsive_received()); |
202 | 202 |
203 // Now close devtools and check that the notification is delivered. | 203 // Now close devtools and check that the notification is delivered. |
204 client_host.Close(DevToolsManager::GetInstance()); | 204 client_host.Close(DevToolsManager::GetInstance()); |
205 // Start with a short timeout. | 205 // Start with a short timeout. |
206 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 206 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
207 // Wait long enough for first timeout and see if it fired. | 207 // Wait long enough for first timeout and see if it fired. |
208 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 208 MessageLoop::current()->PostDelayedTask( |
209 MessageLoop::QuitClosure(), 10); | 209 FROM_HERE, MessageLoop::QuitClosure(), TimeDelta::FromMilliseconds(10)); |
210 MessageLoop::current()->Run(); | 210 MessageLoop::current()->Run(); |
211 EXPECT_TRUE(delegate.renderer_unresponsive_received()); | 211 EXPECT_TRUE(delegate.renderer_unresponsive_received()); |
212 | 212 |
213 contents()->SetDelegate(NULL); | 213 contents()->SetDelegate(NULL); |
214 } | 214 } |
215 | 215 |
216 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { | 216 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { |
217 contents()->transition_cross_site = true; | 217 contents()->transition_cross_site = true; |
218 // Navigate to URL. First URL should use first RenderViewHost. | 218 // Navigate to URL. First URL should use first RenderViewHost. |
219 const GURL url("http://www.google.com"); | 219 const GURL url("http://www.google.com"); |
(...skipping 18 matching lines...) Expand all Loading... |
238 | 238 |
239 // Interrupt pending navigation and navigate back to the original site. | 239 // Interrupt pending navigation and navigate back to the original site. |
240 controller().LoadURL( | 240 controller().LoadURL( |
241 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 241 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
242 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED); | 242 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED); |
243 EXPECT_FALSE(contents()->cross_navigation_pending()); | 243 EXPECT_FALSE(contents()->cross_navigation_pending()); |
244 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor( | 244 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor( |
245 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()))); | 245 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()))); |
246 client_host.Close(DevToolsManager::GetInstance()); | 246 client_host.Close(DevToolsManager::GetInstance()); |
247 } | 247 } |
OLD | NEW |