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 "base/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/site_per_process_browsertest.h" | 8 #include "content/browser/site_per_process_browsertest.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/public/browser/browser_context.h" |
10 #include "content/public/browser/devtools_agent_host.h" | 11 #include "content/public/browser/devtools_agent_host.h" |
| 12 #include "content/public/browser/download_manager.h" |
11 #include "content/public/test/content_browser_test_utils.h" | 13 #include "content/public/test/content_browser_test_utils.h" |
12 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
13 #include "content/shell/browser/shell.h" | 15 #include "content/shell/browser/shell.h" |
| 16 #include "content/shell/browser/shell_download_manager_delegate.h" |
14 #include "content/test/content_browser_test_utils_internal.h" | 17 #include "content/test/content_browser_test_utils_internal.h" |
15 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
16 | 19 |
17 namespace content { | 20 namespace content { |
18 | 21 |
19 class SitePerProcessDevToolsBrowserTest | 22 class SitePerProcessDevToolsBrowserTest |
20 : public SitePerProcessBrowserTest { | 23 : public SitePerProcessBrowserTest { |
21 public: | 24 public: |
22 SitePerProcessDevToolsBrowserTest() {} | 25 SitePerProcessDevToolsBrowserTest() {} |
23 }; | 26 }; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 EXPECT_NE(main_frame_agent.get(), child_frame_agent.get()); | 204 EXPECT_NE(main_frame_agent.get(), child_frame_agent.get()); |
202 EXPECT_EQ(child_frame_agent->GetParentId(), main_frame_agent->GetId()); | 205 EXPECT_EQ(child_frame_agent->GetParentId(), main_frame_agent->GetId()); |
203 EXPECT_NE(child_frame_agent->GetId(), main_frame_agent->GetId()); | 206 EXPECT_NE(child_frame_agent->GetId(), main_frame_agent->GetId()); |
204 | 207 |
205 // Agent for web contents should be the the main frame's one. | 208 // Agent for web contents should be the the main frame's one. |
206 scoped_refptr<DevToolsAgentHost> page_agent = | 209 scoped_refptr<DevToolsAgentHost> page_agent = |
207 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); | 210 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
208 EXPECT_EQ(page_agent.get(), main_frame_agent.get()); | 211 EXPECT_EQ(page_agent.get(), main_frame_agent.get()); |
209 } | 212 } |
210 | 213 |
| 214 class SitePerProcessDownloadDevToolsBrowserTest |
| 215 : public SitePerProcessBrowserTest { |
| 216 public: |
| 217 SitePerProcessDownloadDevToolsBrowserTest() {} |
| 218 |
| 219 void SetUpOnMainThread() override { |
| 220 SitePerProcessBrowserTest::SetUpOnMainThread(); |
| 221 ASSERT_TRUE(downloads_directory_.CreateUniqueTempDir()); |
| 222 DownloadManager* download_manager = BrowserContext::GetDownloadManager( |
| 223 shell()->web_contents()->GetBrowserContext()); |
| 224 ShellDownloadManagerDelegate* download_delegate = |
| 225 static_cast<ShellDownloadManagerDelegate*>( |
| 226 download_manager->GetDelegate()); |
| 227 download_delegate->SetDownloadBehaviorForTesting( |
| 228 downloads_directory_.GetPath()); |
| 229 } |
| 230 |
| 231 base::ScopedTempDir downloads_directory_; |
| 232 }; |
| 233 |
| 234 IN_PROC_BROWSER_TEST_F(SitePerProcessDownloadDevToolsBrowserTest, |
| 235 NotCommittedNavigationDoesNotBlockAgent) { |
| 236 ASSERT_TRUE( |
| 237 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); |
| 238 scoped_refptr<DevToolsAgentHost> agent = |
| 239 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
| 240 TestClient client; |
| 241 ASSERT_TRUE(agent->AttachClient(&client)); |
| 242 char message[] = "{\"id\": 0, \"method\": \"incorrect.method\"}"; |
| 243 // Check that client is responsive. |
| 244 agent->DispatchProtocolMessage(&client, message); |
| 245 client.WaitForReply(); |
| 246 |
| 247 // Do cross process navigation that ends up being download, which will be |
| 248 // not committed navigation in that web contents/render frame. |
| 249 GURL::Replacements replace_host; |
| 250 GURL cross_site_url(embedded_test_server()->GetURL("/download/empty.bin")); |
| 251 replace_host.SetHostStr("foo.com"); |
| 252 cross_site_url = cross_site_url.ReplaceComponents(replace_host); |
| 253 ASSERT_TRUE(NavigateToURLAndExpectNoCommit(shell(), cross_site_url)); |
| 254 |
| 255 // Check that client is still responding after not committed navigation |
| 256 // is finished. |
| 257 agent->DispatchProtocolMessage(&client, message); |
| 258 client.WaitForReply(); |
| 259 ASSERT_TRUE(agent->DetachClient(&client)); |
| 260 } |
| 261 |
211 } // namespace content | 262 } // namespace content |
OLD | NEW |