OLD | NEW |
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 Loading... |
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 |
OLD | NEW |