OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "content/browser/frame_host/frame_tree.h" | 6 #include "content/browser/frame_host/frame_tree.h" |
7 #include "content/browser/frame_host/frame_tree_node.h" | 7 #include "content/browser/frame_host/frame_tree_node.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.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/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 | 192 |
193 // Load a same-site page into iframe and it should still be live. | 193 // Load a same-site page into iframe and it should still be live. |
194 GURL http_url(test_server()->GetURL("files/title1.html")); | 194 GURL http_url(test_server()->GetURL("files/title1.html")); |
195 NavigateFrameToURL(root->child_at(0), http_url); | 195 NavigateFrameToURL(root->child_at(0), http_url); |
196 EXPECT_TRUE( | 196 EXPECT_TRUE( |
197 root->current_frame_host()->render_view_host()->IsRenderViewLive()); | 197 root->current_frame_host()->render_view_host()->IsRenderViewLive()); |
198 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); | 198 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
199 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); | 199 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); |
200 } | 200 } |
201 | 201 |
202 // Ensure that origins are correctly set on navigations. | |
203 IN_PROC_BROWSER_TEST_F(FrameTreeBrowserTest, OriginSetOnNavigation) { | |
204 host_resolver()->AddRule("*", "127.0.0.1"); | |
205 ASSERT_TRUE(test_server()->Start()); | |
206 GURL main_url(test_server()->GetURL("files/frame_tree/top.html")); | |
207 NavigateToURL(shell(), main_url); | |
Charlie Reis
2014/11/19 00:46:18
EXPECT_TRUE? (Here and below.)
alexmos
2014/11/19 02:49:27
Indeed :) I was holding off on rebasing, which I
| |
208 | |
209 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
210 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
211 ->GetFrameTree()->root(); | |
212 | |
213 // Extra '/' is added because the replicated origin is serialized in RFC 6454 | |
214 // format, which dictates no trailing '/', whereas GURL::GetOrigin does put a | |
215 // '/' at the end. | |
216 EXPECT_EQ(root->current_replication_state().origin.string() + '/', | |
217 main_url.GetOrigin().spec()); | |
218 | |
219 GURL frame_url(test_server()->GetURL("files/title1.html")); | |
220 NavigateFrameToURL(root->child_at(0), frame_url); | |
221 | |
222 EXPECT_EQ( | |
223 root->child_at(0)->current_replication_state().origin.string() + '/', | |
224 frame_url.GetOrigin().spec()); | |
225 | |
226 GURL data_url("data:text/html,foo"); | |
227 NavigateToURL(shell(), data_url); | |
228 | |
229 // Navigating to a data URL should set a unique origin. This is represented | |
230 // as "null" per RFC 6454. | |
231 EXPECT_EQ(root->current_replication_state().origin.string(), "null"); | |
232 | |
233 // Re-navigating to a normal URL should update the origin. | |
234 NavigateToURL(shell(), main_url); | |
235 EXPECT_EQ(root->current_replication_state().origin.string() + '/', | |
236 main_url.GetOrigin().spec()); | |
237 } | |
238 | |
202 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { | 239 class CrossProcessFrameTreeBrowserTest : public ContentBrowserTest { |
203 public: | 240 public: |
204 CrossProcessFrameTreeBrowserTest() {} | 241 CrossProcessFrameTreeBrowserTest() {} |
205 | 242 |
206 void SetUpCommandLine(base::CommandLine* command_line) override { | 243 void SetUpCommandLine(base::CommandLine* command_line) override { |
207 command_line->AppendSwitch(switches::kSitePerProcess); | 244 command_line->AppendSwitch(switches::kSitePerProcess); |
208 } | 245 } |
209 | 246 |
210 private: | 247 private: |
211 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest); | 248 DISALLOW_COPY_AND_ASSIGN(CrossProcessFrameTreeBrowserTest); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 | 307 |
271 // Ensure that the RenderViews and RenderFrames are all live. | 308 // Ensure that the RenderViews and RenderFrames are all live. |
272 EXPECT_TRUE( | 309 EXPECT_TRUE( |
273 root->current_frame_host()->render_view_host()->IsRenderViewLive()); | 310 root->current_frame_host()->render_view_host()->IsRenderViewLive()); |
274 EXPECT_TRUE( | 311 EXPECT_TRUE( |
275 child->current_frame_host()->render_view_host()->IsRenderViewLive()); | 312 child->current_frame_host()->render_view_host()->IsRenderViewLive()); |
276 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); | 313 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
277 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); | 314 EXPECT_TRUE(root->child_at(0)->current_frame_host()->IsRenderFrameLive()); |
278 } | 315 } |
279 | 316 |
317 IN_PROC_BROWSER_TEST_F(CrossProcessFrameTreeBrowserTest, | |
318 OriginSetOnCrossProcessNavigations) { | |
319 host_resolver()->AddRule("*", "127.0.0.1"); | |
Charlie Reis
2014/11/19 00:46:18
nit: 2 space indent
(I think git cl format would p
alexmos
2014/11/19 02:49:27
Done.
| |
320 ASSERT_TRUE(test_server()->Start()); | |
321 GURL main_url(test_server()->GetURL("files/site_per_process_main.html")); | |
322 NavigateToURL(shell(), main_url); | |
Charlie Reis
2014/11/19 00:46:18
EXPECT_TRUE?
alexmos
2014/11/19 02:49:27
See above.
| |
323 | |
324 // It is safe to obtain the root frame tree node here, as it doesn't change. | |
325 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | |
326 ->GetFrameTree()->root(); | |
327 | |
328 EXPECT_EQ(root->current_replication_state().origin.string() + '/', | |
329 main_url.GetOrigin().spec()); | |
330 | |
331 // First frame is an about:blank frame. Check that its origin is correctly | |
332 // inherited from the parent. | |
333 EXPECT_EQ( | |
334 root->child_at(0)->current_replication_state().origin.string() + '/', | |
335 main_url.GetOrigin().spec()); | |
336 | |
337 // These must stay in scope with replace_host. | |
338 GURL::Replacements replace_host; | |
339 std::string foo_com("foo.com"); | |
340 | |
341 // Load cross-site page into the first frame | |
Charlie Reis
2014/11/19 00:46:18
nit: End with period.
alexmos
2014/11/19 02:49:26
Done.
| |
342 GURL cross_site_url(test_server()->GetURL("files/title2.html")); | |
343 replace_host.SetHostStr(foo_com); | |
344 cross_site_url = cross_site_url.ReplaceComponents(replace_host); | |
345 NavigateFrameToURL(root->child_at(0), cross_site_url); | |
346 | |
347 EXPECT_EQ( | |
348 root->child_at(0)->current_replication_state().origin.string() + '/', | |
349 cross_site_url.GetOrigin().spec()); | |
350 | |
351 // the root's origin shouldn't have changed | |
Charlie Reis
2014/11/19 00:46:18
nit: Capitalize, end with period.
alexmos
2014/11/19 02:49:27
Done.
| |
352 EXPECT_EQ(root->current_replication_state().origin.string() + '/', | |
353 main_url.GetOrigin().spec()); | |
354 } | |
355 | |
280 } // namespace content | 356 } // namespace content |
OLD | NEW |