| 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/browser_context.h" |
| 11 #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" | 12 #include "content/public/browser/download_manager.h" |
| 13 #include "content/public/test/content_browser_test_utils.h" | 13 #include "content/public/test/content_browser_test_utils.h" |
| 14 #include "content/public/test/test_utils.h" | 14 #include "content/public/test/test_utils.h" |
| 15 #include "content/shell/browser/shell.h" | 15 #include "content/shell/browser/shell.h" |
| 16 #include "content/shell/browser/shell_download_manager_delegate.h" | 16 #include "content/shell/browser/shell_download_manager_delegate.h" |
| 17 #include "content/test/content_browser_test_utils_internal.h" | 17 #include "content/test/content_browser_test_utils_internal.h" |
| 18 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
| 19 | 19 |
| 20 namespace content { | 20 namespace content { |
| 21 | 21 |
| 22 class SitePerProcessDevToolsBrowserTest | 22 class SitePerProcessDevToolsBrowserTest : public SitePerProcessBrowserTest { |
| 23 : public SitePerProcessBrowserTest { | |
| 24 public: | 23 public: |
| 25 SitePerProcessDevToolsBrowserTest() {} | 24 SitePerProcessDevToolsBrowserTest() {} |
| 25 void SetUpOnMainThread() override { |
| 26 host_resolver()->AddRule("*", "127.0.0.1"); |
| 27 SitePerProcessBrowserTest::SetUpOnMainThread(); |
| 28 } |
| 26 }; | 29 }; |
| 27 | 30 |
| 28 class TestClient: public DevToolsAgentHostClient { | 31 class TestClient: public DevToolsAgentHostClient { |
| 29 public: | 32 public: |
| 30 TestClient() : closed_(false), waiting_for_reply_(false) {} | 33 TestClient() : closed_(false), waiting_for_reply_(false) {} |
| 31 ~TestClient() override {} | 34 ~TestClient() override {} |
| 32 | 35 |
| 33 bool closed() { return closed_; } | 36 bool closed() { return closed_; } |
| 34 | 37 |
| 35 void DispatchProtocolMessage( | 38 void DispatchProtocolMessage( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 59 | 62 |
| 60 // Fails on Android, http://crbug.com/464993. | 63 // Fails on Android, http://crbug.com/464993. |
| 61 #if defined(OS_ANDROID) | 64 #if defined(OS_ANDROID) |
| 62 #define MAYBE_CrossSiteIframeAgentHost DISABLED_CrossSiteIframeAgentHost | 65 #define MAYBE_CrossSiteIframeAgentHost DISABLED_CrossSiteIframeAgentHost |
| 63 #else | 66 #else |
| 64 #define MAYBE_CrossSiteIframeAgentHost CrossSiteIframeAgentHost | 67 #define MAYBE_CrossSiteIframeAgentHost CrossSiteIframeAgentHost |
| 65 #endif | 68 #endif |
| 66 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, | 69 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, |
| 67 MAYBE_CrossSiteIframeAgentHost) { | 70 MAYBE_CrossSiteIframeAgentHost) { |
| 68 DevToolsAgentHost::List list; | 71 DevToolsAgentHost::List list; |
| 69 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 70 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 72 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| 71 NavigateToURL(shell(), main_url); | 73 NavigateToURL(shell(), main_url); |
| 72 | 74 |
| 73 // It is safe to obtain the root frame tree node here, as it doesn't change. | 75 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 74 FrameTreeNode* root = | 76 FrameTreeNode* root = |
| 75 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 77 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 76 GetFrameTree()->root(); | 78 GetFrameTree()->root(); |
| 77 | 79 |
| 78 list = DevToolsAgentHost::GetOrCreateAll(); | 80 list = DevToolsAgentHost::GetOrCreateAll(); |
| 79 EXPECT_EQ(1U, list.size()); | 81 EXPECT_EQ(1U, list.size()); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec()); | 133 EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec()); |
| 132 EXPECT_TRUE(child_client.closed()); | 134 EXPECT_TRUE(child_client.closed()); |
| 133 child_host->DetachClient(&child_client); | 135 child_host->DetachClient(&child_client); |
| 134 child_host = nullptr; | 136 child_host = nullptr; |
| 135 EXPECT_FALSE(parent_client.closed()); | 137 EXPECT_FALSE(parent_client.closed()); |
| 136 parent_host->DetachClient(&parent_client); | 138 parent_host->DetachClient(&parent_client); |
| 137 parent_host = nullptr; | 139 parent_host = nullptr; |
| 138 } | 140 } |
| 139 | 141 |
| 140 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, AgentHostForFrames) { | 142 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, AgentHostForFrames) { |
| 141 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 142 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 143 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| 143 NavigateToURL(shell(), main_url); | 144 NavigateToURL(shell(), main_url); |
| 144 | 145 |
| 145 scoped_refptr<DevToolsAgentHost> page_agent = | 146 scoped_refptr<DevToolsAgentHost> page_agent = |
| 146 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); | 147 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
| 147 | 148 |
| 148 // It is safe to obtain the root frame tree node here, as it doesn't change. | 149 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 149 FrameTreeNode* root = | 150 FrameTreeNode* root = |
| 150 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 151 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 151 GetFrameTree()->root(); | 152 GetFrameTree()->root(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 172 | 173 |
| 173 child_frame_agent = | 174 child_frame_agent = |
| 174 DevToolsAgentHost::GetOrCreateFor(child->current_frame_host()); | 175 DevToolsAgentHost::GetOrCreateFor(child->current_frame_host()); |
| 175 EXPECT_NE(page_agent.get(), child_frame_agent.get()); | 176 EXPECT_NE(page_agent.get(), child_frame_agent.get()); |
| 176 EXPECT_EQ(child_frame_agent->GetParentId(), page_agent->GetId()); | 177 EXPECT_EQ(child_frame_agent->GetParentId(), page_agent->GetId()); |
| 177 EXPECT_NE(child_frame_agent->GetId(), page_agent->GetId()); | 178 EXPECT_NE(child_frame_agent->GetId(), page_agent->GetId()); |
| 178 } | 179 } |
| 179 | 180 |
| 180 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, | 181 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, |
| 181 AgentHostForPageEqualsOneForMainFrame) { | 182 AgentHostForPageEqualsOneForMainFrame) { |
| 182 host_resolver()->AddRule("*", "127.0.0.1"); | |
| 183 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 183 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
| 184 NavigateToURL(shell(), main_url); | 184 NavigateToURL(shell(), main_url); |
| 185 | 185 |
| 186 // It is safe to obtain the root frame tree node here, as it doesn't change. | 186 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 187 FrameTreeNode* root = | 187 FrameTreeNode* root = |
| 188 static_cast<WebContentsImpl*>(shell()->web_contents())-> | 188 static_cast<WebContentsImpl*>(shell()->web_contents())-> |
| 189 GetFrameTree()->root(); | 189 GetFrameTree()->root(); |
| 190 FrameTreeNode* child = root->child_at(0); | 190 FrameTreeNode* child = root->child_at(0); |
| 191 | 191 |
| 192 // Load cross-site page into iframe. | 192 // Load cross-site page into iframe. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 ASSERT_TRUE(NavigateToURLAndExpectNoCommit(shell(), cross_site_url)); | 253 ASSERT_TRUE(NavigateToURLAndExpectNoCommit(shell(), cross_site_url)); |
| 254 | 254 |
| 255 // Check that client is still responding after not committed navigation | 255 // Check that client is still responding after not committed navigation |
| 256 // is finished. | 256 // is finished. |
| 257 agent->DispatchProtocolMessage(&client, message); | 257 agent->DispatchProtocolMessage(&client, message); |
| 258 client.WaitForReply(); | 258 client.WaitForReply(); |
| 259 ASSERT_TRUE(agent->DetachClient(&client)); | 259 ASSERT_TRUE(agent->DetachClient(&client)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace content | 262 } // namespace content |
| OLD | NEW |