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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Attaching to both agent hosts. | 103 // Attaching to both agent hosts. |
104 scoped_refptr<DevToolsAgentHost> child_host = list[1]; | 104 scoped_refptr<DevToolsAgentHost> child_host = list[1]; |
105 TestClient child_client; | 105 TestClient child_client; |
106 child_host->AttachClient(&child_client); | 106 child_host->AttachClient(&child_client); |
107 scoped_refptr<DevToolsAgentHost> parent_host = list[0]; | 107 scoped_refptr<DevToolsAgentHost> parent_host = list[0]; |
108 TestClient parent_client; | 108 TestClient parent_client; |
109 parent_host->AttachClient(&parent_client); | 109 parent_host->AttachClient(&parent_client); |
110 | 110 |
111 // Send message to parent and child frames and get result back. | 111 // Send message to parent and child frames and get result back. |
112 char message[] = "{\"id\": 0, \"method\": \"incorrect.method\"}"; | 112 char message[] = "{\"id\": 0, \"method\": \"incorrect.method\"}"; |
113 child_host->DispatchProtocolMessage(message); | 113 child_host->DispatchProtocolMessage(&child_client, message); |
114 child_client.WaitForReply(); | 114 child_client.WaitForReply(); |
115 parent_host->DispatchProtocolMessage(message); | 115 parent_host->DispatchProtocolMessage(&parent_client, message); |
116 parent_client.WaitForReply(); | 116 parent_client.WaitForReply(); |
117 | 117 |
118 // Load back same-site page into iframe. | 118 // Load back same-site page into iframe. |
119 NavigateFrameToURL(root->child_at(0), http_url); | 119 NavigateFrameToURL(root->child_at(0), http_url); |
120 | 120 |
121 list = DevToolsAgentHost::GetOrCreateAll(); | 121 list = DevToolsAgentHost::GetOrCreateAll(); |
122 EXPECT_EQ(1U, list.size()); | 122 EXPECT_EQ(1U, list.size()); |
123 EXPECT_EQ(DevToolsAgentHost::TYPE_WEB_CONTENTS, list[0]->GetType()); | 123 EXPECT_EQ(DevToolsAgentHost::TYPE_WEB_CONTENTS, list[0]->GetType()); |
124 EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec()); | 124 EXPECT_EQ(main_url.spec(), list[0]->GetURL().spec()); |
125 EXPECT_TRUE(child_client.closed()); | 125 EXPECT_TRUE(child_client.closed()); |
126 child_host->DetachClient(); | 126 child_host->DetachClient(&child_client); |
127 child_host = nullptr; | 127 child_host = nullptr; |
128 EXPECT_FALSE(parent_client.closed()); | 128 EXPECT_FALSE(parent_client.closed()); |
129 parent_host->DetachClient(); | 129 parent_host->DetachClient(&parent_client); |
130 parent_host = nullptr; | 130 parent_host = nullptr; |
131 } | 131 } |
132 | 132 |
133 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, AgentHostForFrames) { | 133 IN_PROC_BROWSER_TEST_F(SitePerProcessDevToolsBrowserTest, AgentHostForFrames) { |
134 host_resolver()->AddRule("*", "127.0.0.1"); | 134 host_resolver()->AddRule("*", "127.0.0.1"); |
135 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); | 135 GURL main_url(embedded_test_server()->GetURL("/site_per_process_main.html")); |
136 NavigateToURL(shell(), main_url); | 136 NavigateToURL(shell(), main_url); |
137 | 137 |
138 scoped_refptr<DevToolsAgentHost> page_agent = | 138 scoped_refptr<DevToolsAgentHost> page_agent = |
139 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); | 139 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 DevToolsAgentHost::GetOrCreateFor(root->current_frame_host()); | 194 DevToolsAgentHost::GetOrCreateFor(root->current_frame_host()); |
195 EXPECT_NE(main_frame_agent.get(), child_frame_agent.get()); | 195 EXPECT_NE(main_frame_agent.get(), child_frame_agent.get()); |
196 | 196 |
197 // Agent for web contents should be the the main frame's one. | 197 // Agent for web contents should be the the main frame's one. |
198 scoped_refptr<DevToolsAgentHost> page_agent = | 198 scoped_refptr<DevToolsAgentHost> page_agent = |
199 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); | 199 DevToolsAgentHost::GetOrCreateFor(shell()->web_contents()); |
200 EXPECT_EQ(page_agent.get(), main_frame_agent.get()); | 200 EXPECT_EQ(page_agent.get(), main_frame_agent.get()); |
201 } | 201 } |
202 | 202 |
203 } // namespace content | 203 } // namespace content |
OLD | NEW |