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