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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 #include "content/browser/devtools/devtools_manager.h" | 8 #include "content/browser/devtools/devtools_manager.h" |
9 #include "content/browser/devtools/shared_worker_devtools_manager.h" | 9 #include "content/browser/devtools/shared_worker_devtools_manager.h" |
10 #include "content/browser/shared_worker/shared_worker_instance.h" | 10 #include "content/browser/shared_worker/shared_worker_instance.h" |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 EXPECT_TRUE(delegate.renderer_unresponsive_received()); | 244 EXPECT_TRUE(delegate.renderer_unresponsive_received()); |
245 | 245 |
246 contents()->SetDelegate(NULL); | 246 contents()->SetDelegate(NULL); |
247 } | 247 } |
248 | 248 |
249 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { | 249 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { |
250 // Navigate to URL. First URL should use first RenderViewHost. | 250 // Navigate to URL. First URL should use first RenderViewHost. |
251 const GURL url("http://www.google.com"); | 251 const GURL url("http://www.google.com"); |
252 controller().LoadURL( | 252 controller().LoadURL( |
253 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 253 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 254 int pending_id = controller().GetPendingEntry()->GetUniqueID(); |
254 contents()->GetMainFrame()->PrepareForCommit(); | 255 contents()->GetMainFrame()->PrepareForCommit(); |
255 contents()->TestDidNavigate( | 256 contents()->TestDidNavigate(contents()->GetMainFrame(), 1, pending_id, true, |
256 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); | 257 url, ui::PAGE_TRANSITION_TYPED); |
257 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 258 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
258 | 259 |
259 TestDevToolsClientHost client_host; | 260 TestDevToolsClientHost client_host; |
260 client_host.InspectAgentHost( | 261 client_host.InspectAgentHost( |
261 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); | 262 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); |
262 | 263 |
263 // Navigate to new site which should get a new RenderViewHost. | 264 // Navigate to new site which should get a new RenderViewHost. |
264 const GURL url2("http://www.yahoo.com"); | 265 const GURL url2("http://www.yahoo.com"); |
265 controller().LoadURL( | 266 controller().LoadURL( |
266 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 267 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
267 contents()->GetMainFrame()->PrepareForCommit(); | 268 contents()->GetMainFrame()->PrepareForCommit(); |
268 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); | 269 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); |
269 EXPECT_EQ(client_host.agent_host(), | 270 EXPECT_EQ(client_host.agent_host(), |
270 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); | 271 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); |
271 | 272 |
272 // Interrupt pending navigation and navigate back to the original site. | 273 // Interrupt pending navigation and navigate back to the original site. |
273 controller().LoadURL( | 274 controller().LoadURL( |
274 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 275 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 276 pending_id = controller().GetPendingEntry()->GetUniqueID(); |
275 contents()->GetMainFrame()->PrepareForCommit(); | 277 contents()->GetMainFrame()->PrepareForCommit(); |
276 contents()->TestDidNavigate( | 278 contents()->TestDidNavigate(contents()->GetMainFrame(), 1, pending_id, false, |
277 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); | 279 url, ui::PAGE_TRANSITION_TYPED); |
278 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); | 280 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); |
279 EXPECT_EQ(client_host.agent_host(), | 281 EXPECT_EQ(client_host.agent_host(), |
280 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); | 282 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); |
281 client_host.Close(); | 283 client_host.Close(); |
282 } | 284 } |
283 | 285 |
284 class TestExternalAgentDelegate: public DevToolsExternalAgentProxyDelegate { | 286 class TestExternalAgentDelegate: public DevToolsExternalAgentProxyDelegate { |
285 std::map<std::string,int> event_counter_; | 287 std::map<std::string,int> event_counter_; |
286 | 288 |
287 void recordEvent(const std::string& name) { | 289 void recordEvent(const std::string& name) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 TestDevToolsClientHost client_host; | 326 TestDevToolsClientHost client_host; |
325 client_host.InspectAgentHost(agent_host.get()); | 327 client_host.InspectAgentHost(agent_host.get()); |
326 agent_host->DispatchProtocolMessage("message1"); | 328 agent_host->DispatchProtocolMessage("message1"); |
327 agent_host->DispatchProtocolMessage("message2"); | 329 agent_host->DispatchProtocolMessage("message2"); |
328 agent_host->DispatchProtocolMessage("message2"); | 330 agent_host->DispatchProtocolMessage("message2"); |
329 | 331 |
330 client_host.Close(); | 332 client_host.Close(); |
331 } | 333 } |
332 | 334 |
333 } // namespace content | 335 } // namespace content |
OLD | NEW |