Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: content/browser/frame_host/frame_tree_browsertest.cc

Issue 692973005: Pass origin information for remote frame creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add EXPECT_TRUE to NavigateToURL in new tests; nits Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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");
nasko 2014/11/20 17:22:54 Let's use the EmbeddedTestServer in all new tests.
ncarter (slow) 2014/11/20 20:50:45 The three second version: - test_server() becomes
alexmos 2014/11/20 21:09:10 As we discussed in person, I can do that in a sepa
nasko 2014/11/20 21:21:21 Acknowledged.
205 ASSERT_TRUE(test_server()->Start());
206 GURL main_url(test_server()->GetURL("files/frame_tree/top.html"));
207 EXPECT_TRUE(NavigateToURL(shell(), main_url));
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 EXPECT_TRUE(NavigateToURL(shell(), data_url));
nasko 2014/11/20 17:22:54 Why not navigate another iframe on the page instea
alexmos 2014/11/20 21:09:10 Interesting -- doing that made the test crash when
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 EXPECT_TRUE(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
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");
nasko 2014/11/20 17:22:54 Same as the other tests, let's use EmbeddedTestSer
alexmos 2014/11/20 21:09:10 See above -- will do the whole file in a separate
320 ASSERT_TRUE(test_server()->Start());
321 GURL main_url(test_server()->GetURL("files/site_per_process_main.html"));
322 EXPECT_TRUE(NavigateToURL(shell(), main_url));
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;
nasko 2014/11/20 17:22:54 Ah, you also skip all that boilerplate code and ju
alexmos 2014/11/20 21:09:10 test_server() doesn't support this, right? If so,
nasko 2014/11/20 21:21:21 Yes, the API is on the EmbeddedTestServer. This wa
339 std::string foo_com("foo.com");
340
341 // Load cross-site page into the first frame.
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.
352 EXPECT_EQ(root->current_replication_state().origin.string() + '/',
353 main_url.GetOrigin().spec());
354 }
355
280 } // namespace content 356 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/frame_tree_node.h » ('j') | content/browser/frame_host/navigator_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698