Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: content/browser/debugger/devtools_manager_unittest.cc

Issue 8572010: DevTools: reattach to previous RVH when pending navigation is being canceled (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added missing OVERRIDE Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_client_host.h" 7 #include "content/browser/debugger/devtools_client_host.h"
8 #include "content/browser/debugger/devtools_manager.h" 8 #include "content/browser/debugger/devtools_manager.h"
9 #include "content/browser/debugger/render_view_devtools_agent_host.h" 9 #include "content/browser/debugger/render_view_devtools_agent_host.h"
10 #include "content/browser/mock_content_browser_client.h" 10 #include "content/browser/mock_content_browser_client.h"
11 #include "content/browser/renderer_host/test_render_view_host.h" 11 #include "content/browser/renderer_host/test_render_view_host.h"
12 #include "content/browser/tab_contents/tab_contents_delegate.h" 12 #include "content/browser/tab_contents/tab_contents_delegate.h"
13 #include "content/browser/tab_contents/test_tab_contents.h" 13 #include "content/browser/tab_contents/test_tab_contents.h"
14 #include "content/common/view_messages.h"
14 #include "content/public/browser/content_browser_client.h" 15 #include "content/public/browser/content_browser_client.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 17
17 using base::TimeDelta; 18 using base::TimeDelta;
18 19
19 namespace { 20 namespace {
20 21
21 class TestDevToolsClientHost : public DevToolsClientHost { 22 class TestDevToolsClientHost : public DevToolsClientHost {
22 public: 23 public:
23 TestDevToolsClientHost() 24 TestDevToolsClientHost()
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 class DevToolsManagerTestBrowserClient 89 class DevToolsManagerTestBrowserClient
89 : public content::MockContentBrowserClient { 90 : public content::MockContentBrowserClient {
90 public: 91 public:
91 DevToolsManagerTestBrowserClient() { 92 DevToolsManagerTestBrowserClient() {
92 } 93 }
93 94
94 virtual DevToolsManager* GetDevToolsManager() OVERRIDE { 95 virtual DevToolsManager* GetDevToolsManager() OVERRIDE {
95 return &dev_tools_manager_; 96 return &dev_tools_manager_;
96 } 97 }
97 98
99 virtual bool ShouldSwapProcessesForNavigation(
100 const GURL& current_url,
101 const GURL& new_url) OVERRIDE {
102 return true;
103 }
104
98 private: 105 private:
99 DevToolsManager dev_tools_manager_; 106 DevToolsManager dev_tools_manager_;
100 107
101 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient); 108 DISALLOW_COPY_AND_ASSIGN(DevToolsManagerTestBrowserClient);
102 }; 109 };
103 110
104 } // namespace 111 } // namespace
105 112
106 class DevToolsManagerTest : public RenderViewHostTestHarness { 113 class DevToolsManagerTest : public RenderViewHostTestHarness {
107 public: 114 public:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Start with a short timeout. 198 // Start with a short timeout.
192 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10)); 199 inspected_rvh->StartHangMonitorTimeout(TimeDelta::FromMilliseconds(10));
193 // Wait long enough for first timeout and see if it fired. 200 // Wait long enough for first timeout and see if it fired.
194 MessageLoop::current()->PostDelayedTask(FROM_HERE, 201 MessageLoop::current()->PostDelayedTask(FROM_HERE,
195 new MessageLoop::QuitTask(), 10); 202 new MessageLoop::QuitTask(), 10);
196 MessageLoop::current()->Run(); 203 MessageLoop::current()->Run();
197 EXPECT_TRUE(delegate.renderer_unresponsive_received()); 204 EXPECT_TRUE(delegate.renderer_unresponsive_received());
198 205
199 contents()->set_delegate(NULL); 206 contents()->set_delegate(NULL);
200 } 207 }
208
209 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) {
210 contents()->transition_cross_site = true;
211 TestRenderViewHost* orig_rvh = rvh();
212 // Navigate to URL. First URL should use first RenderViewHost.
213 const GURL url("http://www.google.com");
214 controller().LoadURL(
215 url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
216 ViewHostMsg_FrameNavigate_Params params1;
217 InitNavigateParams(&params1, 1, url, content::PAGE_TRANSITION_TYPED);
218 contents()->TestDidNavigate(orig_rvh, params1);
219 EXPECT_FALSE(contents()->cross_navigation_pending());
220
221 TestDevToolsClientHost client_host;
222 DevToolsManager* devtools_manager = DevToolsManager::GetInstance();
223 devtools_manager->RegisterDevToolsClientHostFor(rvh(), &client_host);
224
225 // Navigate to new site which should get a new RenderViewHost.
226 const GURL url2("http://www.yahoo.com");
227 controller().LoadURL(
228 url2, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
229 EXPECT_TRUE(contents()->cross_navigation_pending());
230 EXPECT_EQ(&client_host,
231 devtools_manager->GetDevToolsClientHostFor(pending_rvh()));
232
233 // Interrupt pending navigation and navigate back to the original site.
234 controller().LoadURL(
235 url, GURL(), content::PAGE_TRANSITION_TYPED, std::string());
236 contents()->TestDidNavigate(orig_rvh, params1);
237 EXPECT_FALSE(contents()->cross_navigation_pending());
238 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor(rvh()));
239 client_host.Close();
240 }
OLDNEW
« no previous file with comments | « content/browser/debugger/devtools_manager.cc ('k') | content/browser/tab_contents/render_view_host_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698