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

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

Issue 1002803002: Classify navigations without page id in parallel to the existing classifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: relax the dcheck Created 5 years, 7 months 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
OLDNEW
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 EXPECT_TRUE(delegate.renderer_unresponsive_received()); 160 EXPECT_TRUE(delegate.renderer_unresponsive_received());
161 161
162 contents()->SetDelegate(NULL); 162 contents()->SetDelegate(NULL);
163 } 163 }
164 164
165 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) { 165 TEST_F(DevToolsManagerTest, ReattachOnCancelPendingNavigation) {
166 // Navigate to URL. First URL should use first RenderViewHost. 166 // Navigate to URL. First URL should use first RenderViewHost.
167 const GURL url("http://www.google.com"); 167 const GURL url("http://www.google.com");
168 controller().LoadURL( 168 controller().LoadURL(
169 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 169 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
170 int pending_id = controller().GetPendingEntry()->GetUniqueID();
170 contents()->GetMainFrame()->PrepareForCommit(); 171 contents()->GetMainFrame()->PrepareForCommit();
171 contents()->TestDidNavigate( 172 contents()->TestDidNavigate(contents()->GetMainFrame(), 1, pending_id, true,
172 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); 173 url, ui::PAGE_TRANSITION_TYPED);
173 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 174 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
174 175
175 TestDevToolsClientHost client_host; 176 TestDevToolsClientHost client_host;
176 client_host.InspectAgentHost( 177 client_host.InspectAgentHost(
177 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); 178 DevToolsAgentHost::GetOrCreateFor(web_contents()).get());
178 179
179 // Navigate to new site which should get a new RenderViewHost. 180 // Navigate to new site which should get a new RenderViewHost.
180 const GURL url2("http://www.yahoo.com"); 181 const GURL url2("http://www.yahoo.com");
181 controller().LoadURL( 182 controller().LoadURL(
182 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 183 url2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
183 contents()->GetMainFrame()->PrepareForCommit(); 184 contents()->GetMainFrame()->PrepareForCommit();
184 EXPECT_TRUE(contents()->CrossProcessNavigationPending()); 185 EXPECT_TRUE(contents()->CrossProcessNavigationPending());
185 EXPECT_EQ(client_host.agent_host(), 186 EXPECT_EQ(client_host.agent_host(),
186 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); 187 DevToolsAgentHost::GetOrCreateFor(web_contents()).get());
187 188
188 // Interrupt pending navigation and navigate back to the original site. 189 // Interrupt pending navigation and navigate back to the original site.
189 controller().LoadURL( 190 controller().LoadURL(
190 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 191 url, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
192 pending_id = controller().GetPendingEntry()->GetUniqueID();
191 contents()->GetMainFrame()->PrepareForCommit(); 193 contents()->GetMainFrame()->PrepareForCommit();
192 contents()->TestDidNavigate( 194 contents()->TestDidNavigate(contents()->GetMainFrame(), 1, pending_id, false,
193 contents()->GetMainFrame(), 1, url, ui::PAGE_TRANSITION_TYPED); 195 url, ui::PAGE_TRANSITION_TYPED);
194 EXPECT_FALSE(contents()->CrossProcessNavigationPending()); 196 EXPECT_FALSE(contents()->CrossProcessNavigationPending());
195 EXPECT_EQ(client_host.agent_host(), 197 EXPECT_EQ(client_host.agent_host(),
196 DevToolsAgentHost::GetOrCreateFor(web_contents()).get()); 198 DevToolsAgentHost::GetOrCreateFor(web_contents()).get());
197 client_host.Close(); 199 client_host.Close();
198 } 200 }
199 201
200 class TestExternalAgentDelegate: public DevToolsExternalAgentProxyDelegate { 202 class TestExternalAgentDelegate: public DevToolsExternalAgentProxyDelegate {
201 std::map<std::string,int> event_counter_; 203 std::map<std::string,int> event_counter_;
202 204
203 void recordEvent(const std::string& name) { 205 void recordEvent(const std::string& name) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 TestDevToolsClientHost client_host; 242 TestDevToolsClientHost client_host;
241 client_host.InspectAgentHost(agent_host.get()); 243 client_host.InspectAgentHost(agent_host.get());
242 agent_host->DispatchProtocolMessage("message1"); 244 agent_host->DispatchProtocolMessage("message1");
243 agent_host->DispatchProtocolMessage("message2"); 245 agent_host->DispatchProtocolMessage("message2");
244 agent_host->DispatchProtocolMessage("message2"); 246 agent_host->DispatchProtocolMessage("message2");
245 247
246 client_host.Close(); 248 client_host.Close();
247 } 249 }
248 250
249 } // namespace content 251 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698