| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/location.h" | |
| 7 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/single_thread_task_runner.h" | |
| 9 #include "base/thread_task_runner_handle.h" | |
| 10 #include "base/time/time.h" | 7 #include "base/time/time.h" |
| 11 #include "content/browser/devtools/devtools_manager.h" | 8 #include "content/browser/devtools/devtools_manager.h" |
| 12 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 9 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
| 13 #include "content/browser/shared_worker/shared_worker_instance.h" | 10 #include "content/browser/shared_worker/shared_worker_instance.h" |
| 14 #include "content/browser/shared_worker/worker_storage_partition.h" | 11 #include "content/browser/shared_worker/worker_storage_partition.h" |
| 15 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.h" |
| 16 #include "content/public/browser/browser_context.h" | 13 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/content_browser_client.h" | 14 #include "content/public/browser/content_browser_client.h" |
| 18 #include "content/public/browser/devtools_agent_host.h" | 15 #include "content/public/browser/devtools_agent_host.h" |
| 19 #include "content/public/browser/devtools_external_agent_proxy.h" | 16 #include "content/public/browser/devtools_external_agent_proxy.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 contents()->SetDelegate(&delegate); | 133 contents()->SetDelegate(&delegate); |
| 137 | 134 |
| 138 TestDevToolsClientHost client_host; | 135 TestDevToolsClientHost client_host; |
| 139 scoped_refptr<DevToolsAgentHost> agent_host(DevToolsAgentHost::GetOrCreateFor( | 136 scoped_refptr<DevToolsAgentHost> agent_host(DevToolsAgentHost::GetOrCreateFor( |
| 140 WebContents::FromRenderViewHost(inspected_rvh))); | 137 WebContents::FromRenderViewHost(inspected_rvh))); |
| 141 client_host.InspectAgentHost(agent_host.get()); | 138 client_host.InspectAgentHost(agent_host.get()); |
| 142 | 139 |
| 143 // Start with a short timeout. | 140 // Start with a short timeout. |
| 144 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 141 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 145 // Wait long enough for first timeout and see if it fired. | 142 // Wait long enough for first timeout and see if it fired. |
| 146 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 143 base::MessageLoop::current()->PostDelayedTask( |
| 147 FROM_HERE, base::MessageLoop::QuitClosure(), | 144 FROM_HERE, |
| 145 base::MessageLoop::QuitClosure(), |
| 148 TimeDelta::FromMilliseconds(10)); | 146 TimeDelta::FromMilliseconds(10)); |
| 149 base::MessageLoop::current()->Run(); | 147 base::MessageLoop::current()->Run(); |
| 150 EXPECT_FALSE(delegate.renderer_unresponsive_received()); | 148 EXPECT_FALSE(delegate.renderer_unresponsive_received()); |
| 151 | 149 |
| 152 // Now close devtools and check that the notification is delivered. | 150 // Now close devtools and check that the notification is delivered. |
| 153 client_host.Close(); | 151 client_host.Close(); |
| 154 // Start with a short timeout. | 152 // Start with a short timeout. |
| 155 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); | 153 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); |
| 156 // Wait long enough for first timeout and see if it fired. | 154 // Wait long enough for first timeout and see if it fired. |
| 157 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 155 base::MessageLoop::current()->PostDelayedTask( |
| 158 FROM_HERE, base::MessageLoop::QuitClosure(), | 156 FROM_HERE, |
| 157 base::MessageLoop::QuitClosure(), |
| 159 TimeDelta::FromMilliseconds(10)); | 158 TimeDelta::FromMilliseconds(10)); |
| 160 base::MessageLoop::current()->Run(); | 159 base::MessageLoop::current()->Run(); |
| 161 EXPECT_TRUE(delegate.renderer_unresponsive_received()); | 160 EXPECT_TRUE(delegate.renderer_unresponsive_received()); |
| 162 | 161 |
| 163 contents()->SetDelegate(NULL); | 162 contents()->SetDelegate(NULL); |
| 164 } | 163 } |
| 165 | 164 |
| 166 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { | 165 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { |
| 167 // Navigate to URL. First URL should use first RenderViewHost. | 166 // Navigate to URL. First URL should use first RenderViewHost. |
| 168 const GURL url("http://www.google.com"); | 167 const GURL url("http://www.google.com"); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 TestDevToolsClientHost client_host; | 242 TestDevToolsClientHost client_host; |
| 244 client_host.InspectAgentHost(agent_host.get()); | 243 client_host.InspectAgentHost(agent_host.get()); |
| 245 agent_host->DispatchProtocolMessage("message1"); | 244 agent_host->DispatchProtocolMessage("message1"); |
| 246 agent_host->DispatchProtocolMessage("message2"); | 245 agent_host->DispatchProtocolMessage("message2"); |
| 247 agent_host->DispatchProtocolMessage("message2"); | 246 agent_host->DispatchProtocolMessage("message2"); |
| 248 | 247 |
| 249 client_host.Close(); | 248 client_host.Close(); |
| 250 } | 249 } |
| 251 | 250 |
| 252 } // namespace content | 251 } // namespace content |
| OLD | NEW |