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

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

Issue 281653003: DRAFT CL: Add FrameNavigationEntry and track subframe session histories. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 5 years, 9 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/test/histogram_tester.h" 8 #include "base/test/histogram_tester.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/frame_host/cross_site_transferring_request.h" 10 #include "content/browser/frame_host/cross_site_transferring_request.h"
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return ntp_rfh; 373 return ntp_rfh;
374 } 374 }
375 375
376 // Returns the RenderFrameHost that should be used in the navigation to 376 // Returns the RenderFrameHost that should be used in the navigation to
377 // |entry|. 377 // |entry|.
378 RenderFrameHostImpl* GetFrameHostForNavigation( 378 RenderFrameHostImpl* GetFrameHostForNavigation(
379 RenderFrameHostManager* manager, 379 RenderFrameHostManager* manager,
380 const NavigationEntryImpl& entry) { 380 const NavigationEntryImpl& entry) {
381 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 381 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
382 switches::kEnableBrowserSideNavigation)) { 382 switches::kEnableBrowserSideNavigation)) {
383 // TODO(creis): Navigate the entry's main frame.
383 scoped_ptr<NavigationRequest> navigation_request = 384 scoped_ptr<NavigationRequest> navigation_request =
384 NavigationRequest::CreateBrowserInitiated( 385 NavigationRequest::CreateBrowserInitiated(
385 manager->frame_tree_node_, entry, FrameMsg_Navigate_Type::NORMAL, 386 manager->frame_tree_node_, entry, FrameMsg_Navigate_Type::NORMAL,
386 base::TimeTicks::Now(), 387 base::TimeTicks::Now(),
387 static_cast<NavigationControllerImpl*>(&controller())); 388 static_cast<NavigationControllerImpl*>(&controller()));
388 return manager->GetFrameHostForNavigation(*navigation_request); 389 return manager->GetFrameHostForNavigation(*navigation_request);
389 } 390 }
390 return manager->Navigate(entry); 391 return manager->NavigateMainFrame(entry);
391 } 392 }
392 393
393 // Returns the pending RenderFrameHost. 394 // Returns the pending RenderFrameHost.
394 // PlzNavigate: returns the speculative RenderFrameHost. 395 // PlzNavigate: returns the speculative RenderFrameHost.
395 RenderFrameHostImpl* GetPendingFrameHost( 396 RenderFrameHostImpl* GetPendingFrameHost(
396 RenderFrameHostManager* manager) { 397 RenderFrameHostManager* manager) {
397 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 398 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
398 switches::kEnableBrowserSideNavigation)) { 399 switches::kEnableBrowserSideNavigation)) {
399 return manager->speculative_render_frame_host_.get(); 400 return manager->speculative_render_frame_host_.get();
400 } 401 }
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1515 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); 1516 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting();
1516 1517
1517 RenderFrameHostImpl* host = NULL; 1518 RenderFrameHostImpl* host = NULL;
1518 1519
1519 // 1) The first navigation. -------------------------- 1520 // 1) The first navigation. --------------------------
1520 const GURL kUrl1("http://www.google.com/"); 1521 const GURL kUrl1("http://www.google.com/");
1521 NavigationEntryImpl entry1( 1522 NavigationEntryImpl entry1(
1522 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(), 1523 NULL /* instance */, -1 /* page_id */, kUrl1, Referrer(),
1523 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, 1524 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED,
1524 false /* is_renderer_init */); 1525 false /* is_renderer_init */);
1525 host = manager->Navigate(entry1); 1526 host = manager->NavigateMainFrame(entry1);
1526 1527
1527 // The RenderFrameHost created in Init will be reused. 1528 // The RenderFrameHost created in Init will be reused.
1528 EXPECT_TRUE(host == manager->current_frame_host()); 1529 EXPECT_TRUE(host == manager->current_frame_host());
1529 EXPECT_FALSE(manager->pending_frame_host()); 1530 EXPECT_FALSE(manager->pending_frame_host());
1530 EXPECT_EQ(manager->current_frame_host()->GetSiteInstance(), instance); 1531 EXPECT_EQ(manager->current_frame_host()->GetSiteInstance(), instance);
1531 1532
1532 // Commit. 1533 // Commit.
1533 manager->DidNavigateFrame(host, true); 1534 manager->DidNavigateFrame(host, true);
1534 // Commit to SiteInstance should be delayed until RenderFrame commit. 1535 // Commit to SiteInstance should be delayed until RenderFrame commit.
1535 EXPECT_EQ(host, manager->current_frame_host()); 1536 EXPECT_EQ(host, manager->current_frame_host());
1536 ASSERT_TRUE(host); 1537 ASSERT_TRUE(host);
1537 EXPECT_TRUE(host->GetSiteInstance()->HasSite()); 1538 EXPECT_TRUE(host->GetSiteInstance()->HasSite());
1538 1539
1539 // 2) Navigate to a different domain. ------------------------- 1540 // 2) Navigate to a different domain. -------------------------
1540 // Guests stay in the same process on navigation. 1541 // Guests stay in the same process on navigation.
1541 const GURL kUrl2("http://www.chromium.org"); 1542 const GURL kUrl2("http://www.chromium.org");
1542 NavigationEntryImpl entry2( 1543 NavigationEntryImpl entry2(
1543 NULL /* instance */, -1 /* page_id */, kUrl2, 1544 NULL /* instance */, -1 /* page_id */, kUrl2,
1544 Referrer(kUrl1, blink::WebReferrerPolicyDefault), 1545 Referrer(kUrl1, blink::WebReferrerPolicyDefault),
1545 base::string16() /* title */, ui::PAGE_TRANSITION_LINK, 1546 base::string16() /* title */, ui::PAGE_TRANSITION_LINK,
1546 true /* is_renderer_init */); 1547 true /* is_renderer_init */);
1547 host = manager->Navigate(entry2); 1548 host = manager->NavigateMainFrame(entry2);
1548 1549
1549 // The RenderFrameHost created in Init will be reused. 1550 // The RenderFrameHost created in Init will be reused.
1550 EXPECT_EQ(host, manager->current_frame_host()); 1551 EXPECT_EQ(host, manager->current_frame_host());
1551 EXPECT_FALSE(manager->pending_frame_host()); 1552 EXPECT_FALSE(manager->pending_frame_host());
1552 1553
1553 // Commit. 1554 // Commit.
1554 manager->DidNavigateFrame(host, true); 1555 manager->DidNavigateFrame(host, true);
1555 EXPECT_EQ(host, manager->current_frame_host()); 1556 EXPECT_EQ(host, manager->current_frame_host());
1556 ASSERT_TRUE(host); 1557 ASSERT_TRUE(host);
1557 EXPECT_EQ(host->GetSiteInstance(), instance); 1558 EXPECT_EQ(host->GetSiteInstance(), instance);
(...skipping 14 matching lines...) Expand all
1572 Source<WebContents>(web_contents.get())); 1573 Source<WebContents>(web_contents.get()));
1573 1574
1574 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting(); 1575 RenderFrameHostManager* manager = web_contents->GetRenderManagerForTesting();
1575 1576
1576 // 1) The first navigation. -------------------------- 1577 // 1) The first navigation. --------------------------
1577 const GURL kUrl1("http://www.google.com/"); 1578 const GURL kUrl1("http://www.google.com/");
1578 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1, 1579 NavigationEntryImpl entry1(NULL /* instance */, -1 /* page_id */, kUrl1,
1579 Referrer(), base::string16() /* title */, 1580 Referrer(), base::string16() /* title */,
1580 ui::PAGE_TRANSITION_TYPED, 1581 ui::PAGE_TRANSITION_TYPED,
1581 false /* is_renderer_init */); 1582 false /* is_renderer_init */);
1582 RenderFrameHostImpl* host = manager->Navigate(entry1); 1583 RenderFrameHostImpl* host = manager->NavigateMainFrame(entry1);
1583 1584
1584 // The RenderFrameHost created in Init will be reused. 1585 // The RenderFrameHost created in Init will be reused.
1585 EXPECT_EQ(host, manager->current_frame_host()); 1586 EXPECT_EQ(host, manager->current_frame_host());
1586 EXPECT_FALSE(manager->pending_frame_host()); 1587 EXPECT_FALSE(manager->pending_frame_host());
1587 1588
1588 // We should observe a notification. 1589 // We should observe a notification.
1589 EXPECT_TRUE( 1590 EXPECT_TRUE(
1590 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED)); 1591 notifications.Check1AndReset(NOTIFICATION_RENDER_VIEW_HOST_CHANGED));
1591 notifications.Reset(); 1592 notifications.Reset();
1592 1593
1593 // Commit. 1594 // Commit.
1594 manager->DidNavigateFrame(host, true); 1595 manager->DidNavigateFrame(host, true);
1595 1596
1596 // Commit to SiteInstance should be delayed until RenderFrame commits. 1597 // Commit to SiteInstance should be delayed until RenderFrame commits.
1597 EXPECT_EQ(host, manager->current_frame_host()); 1598 EXPECT_EQ(host, manager->current_frame_host());
1598 EXPECT_FALSE(host->GetSiteInstance()->HasSite()); 1599 EXPECT_FALSE(host->GetSiteInstance()->HasSite());
1599 host->GetSiteInstance()->SetSite(kUrl1); 1600 host->GetSiteInstance()->SetSite(kUrl1);
1600 1601
1601 // 2) Cross-site navigate to next site. ------------------------- 1602 // 2) Cross-site navigate to next site. -------------------------
1602 const GURL kUrl2("http://www.example.com"); 1603 const GURL kUrl2("http://www.example.com");
1603 NavigationEntryImpl entry2( 1604 NavigationEntryImpl entry2(
1604 NULL /* instance */, -1 /* page_id */, kUrl2, Referrer(), 1605 NULL /* instance */, -1 /* page_id */, kUrl2, Referrer(),
1605 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED, 1606 base::string16() /* title */, ui::PAGE_TRANSITION_TYPED,
1606 false /* is_renderer_init */); 1607 false /* is_renderer_init */);
1607 RenderFrameHostImpl* host2 = manager->Navigate(entry2); 1608 RenderFrameHostImpl* host2 = manager->NavigateMainFrame(entry2);
1608 1609
1609 // A new RenderFrameHost should be created. 1610 // A new RenderFrameHost should be created.
1610 ASSERT_EQ(host2, manager->pending_frame_host()); 1611 ASSERT_EQ(host2, manager->pending_frame_host());
1611 EXPECT_NE(host2, host); 1612 EXPECT_NE(host2, host);
1612 1613
1613 EXPECT_EQ(host, manager->current_frame_host()); 1614 EXPECT_EQ(host, manager->current_frame_host());
1614 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out()); 1615 EXPECT_FALSE(manager->current_frame_host()->is_swapped_out());
1615 EXPECT_EQ(host2, manager->pending_frame_host()); 1616 EXPECT_EQ(host2, manager->pending_frame_host());
1616 1617
1617 // 3) Close the tab. ------------------------- 1618 // 3) Close the tab. -------------------------
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1908 #if 0 1909 #if 0
1909 // TODO(nick): Currently a proxy to the removed frame lingers in the parent. 1910 // TODO(nick): Currently a proxy to the removed frame lingers in the parent.
1910 // Enable this assert below once the proxies to the subframe are correctly 1911 // Enable this assert below once the proxies to the subframe are correctly
1911 // cleaned up after detach. http://crbug.com/444955. 1912 // cleaned up after detach. http://crbug.com/444955.
1912 ASSERT_TRUE(site_instance->HasOneRef()) 1913 ASSERT_TRUE(site_instance->HasOneRef())
1913 << "This SiteInstance should be destroyable now."; 1914 << "This SiteInstance should be destroyable now.";
1914 #endif 1915 #endif
1915 } 1916 }
1916 1917
1917 } // namespace content 1918 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698