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

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

Issue 1835943003: [DevTools] Use main frame when searching/creating DevToolsAgentHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 "build/build_config.h" 5 #include "build/build_config.h"
6 #include "content/browser/frame_host/frame_tree.h" 6 #include "content/browser/frame_host/frame_tree.h"
7 #include "content/browser/site_per_process_browsertest.h" 7 #include "content/browser/site_per_process_browsertest.h"
8 #include "content/browser/web_contents/web_contents_impl.h" 8 #include "content/browser/web_contents/web_contents_impl.h"
9 #include "content/public/browser/devtools_agent_host.h" 9 #include "content/public/browser/devtools_agent_host.h"
10 #include "content/public/test/content_browser_test_utils.h" 10 #include "content/public/test/content_browser_test_utils.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 GURL cross_site_url(embedded_test_server()->GetURL("/title2.html")); 161 GURL cross_site_url(embedded_test_server()->GetURL("/title2.html"));
162 replace_host.SetHostStr("foo.com"); 162 replace_host.SetHostStr("foo.com");
163 cross_site_url = cross_site_url.ReplaceComponents(replace_host); 163 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
164 NavigateFrameToURL(root->child_at(0), cross_site_url); 164 NavigateFrameToURL(root->child_at(0), cross_site_url);
165 165
166 child_frame_agent = 166 child_frame_agent =
167 DevToolsAgentHost::GetOrCreateFor(child->current_frame_host()); 167 DevToolsAgentHost::GetOrCreateFor(child->current_frame_host());
168 EXPECT_NE(page_agent.get(), child_frame_agent.get()); 168 EXPECT_NE(page_agent.get(), child_frame_agent.get());
169 } 169 }
170 170
171 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest,
172 AgentHostForPageEqualsOneForMainFrame) {
173 host_resolver()->AddRule("*", "127.0.0.1");
174 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html"));
175 NavigateToURL(shell(), main_url);
176
177 // It is safe to obtain the root frame tree node here, as it doesn't change.
178 FrameTreeNode* root =
179 static_cast<WebContentsImpl*>(shell()->web_contents())->
180 GetFrameTree()->root();
181 FrameTreeNode* child = root->child_at(0);
182
183 // Load cross-site page into iframe.
184 GURL::Replacements replace_host;
185 GURL cross_site_url(embedded_test_server()->GetURL("/title2.html"));
186 replace_host.SetHostStr("foo.com");
187 cross_site_url = cross_site_url.ReplaceComponents(replace_host);
188 NavigateFrameToURL(child, cross_site_url);
189
190 // First ask for child frame, then for main frame.
191 scoped_refptr<DevToolsAgentHost> child_frame_agent =
192 DevToolsAgentHost::GetOrCreateFor(child->current_frame_host());
193 scoped_refptr<DevToolsAgentHost> main_frame_agent =
194 DevToolsAgentHost::GetOrCreateFor(root->current_frame_host());
195 EXPECT_NE(main_frame_agent.get(), child_frame_agent.get());
196
197 // Agent for web contents should be the the main frame's one.
198 scoped_refptr<DevToolsAgentHost> page_agent =
199 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents());
200 EXPECT_EQ(page_agent.get(), main_frame_agent.get());
201 }
202
171 } // namespace content 203 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/render_frame_devtools_agent_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698