Commit c1ff477d authored by creis's avatar creis Committed by Commit bot

Start removing UseSubframeNavigationEntries from tests.

This mode is always enabled now, so we can remove the code for handling
when it is disabled.  This CL starts with the easy cases in tests.

BUG=236848
TEST=Tests still pass.
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_site_isolation

Review-Url: https://codereview.chromium.org/2616673002
Cr-Commit-Position: refs/heads/master@{#441445}
parent ad545a86
...@@ -199,15 +199,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -199,15 +199,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
controller.GoBack(); controller.GoBack();
back_load_observer.Wait(); back_load_observer.Wait();
// Check title. // Check title. We should load the data URL when going back.
// TODO(creis): The default navigation path incorrectly loads the history_url EXPECT_EQ("One", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
// and claims it loaded the data_url (due to a bug where GoToEntry does not
// handle this case). This is confusing. When using subframe
// FrameNavigationEntries, we load the data URL when going back, as expected.
if (SiteIsolationPolicy::UseSubframeNavigationEntries())
EXPECT_EQ("One", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
else
EXPECT_EQ("form", base::UTF16ToUTF8(shell()->web_contents()->GetTitle()));
// Verify the last committed NavigationEntry. // Verify the last committed NavigationEntry.
NavigationEntryImpl* back_entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* back_entry = controller.GetLastCommittedEntry();
...@@ -1680,18 +1673,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -1680,18 +1673,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get(); FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry->url()); EXPECT_EQ(main_url, root_entry->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // Verify subframe entries. The entry should now have one blank subframe
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { // FrameNavigationEntry, but this does not count as committing a real load.
// The entry should now have one blank subframe FrameNavigationEntry, but ASSERT_EQ(1U, entry->root_node()->children.size());
// this does not count as committing a real load. FrameNavigationEntry* frame_entry =
ASSERT_EQ(1U, entry->root_node()->children.size()); entry->root_node()->children[0]->frame_entry.get();
FrameNavigationEntry* frame_entry = EXPECT_EQ(about_blank_url, frame_entry->url());
entry->root_node()->children[0]->frame_entry.get();
EXPECT_EQ(about_blank_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
// 1a. A nested iframe with no URL should also create a subframe entry but not // 1a. A nested iframe with no URL should also create a subframe entry but not
...@@ -1706,18 +1693,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -1706,18 +1693,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME));
} }
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // Verify subframe entries. The nested entry should have one blank subframe
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { // FrameNavigationEntry, but this does not count as committing a real load.
// The nested entry should have one blank subframe FrameNavigationEntry, but ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
// this does not count as committing a real load. frame_entry = entry->root_node()->children[0]->children[0]->frame_entry.get();
ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); EXPECT_EQ(about_blank_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[0]->children[0]->frame_entry.get();
EXPECT_EQ(about_blank_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load()); EXPECT_FALSE(root->child_at(0)->child_at(0)->has_committed_real_load());
// 2. Create another iframe with an explicit about:blank URL. // 2. Create another iframe with an explicit about:blank URL.
...@@ -1736,18 +1716,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -1736,18 +1716,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetEntryCount()); EXPECT_EQ(1, controller.GetEntryCount());
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // Verify subframe entries. The new entry should have one blank subframe
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { // FrameNavigationEntry, but this does not count as committing a real load.
// The new entry should have one blank subframe FrameNavigationEntry, but ASSERT_EQ(2U, entry->root_node()->children.size());
// this does not count as committing a real load. frame_entry = entry->root_node()->children[1]->frame_entry.get();
ASSERT_EQ(2U, entry->root_node()->children.size()); EXPECT_EQ(about_blank_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[1]->frame_entry.get();
EXPECT_EQ(about_blank_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); EXPECT_FALSE(root->child_at(1)->has_committed_real_load());
// 3. A real same-site navigation in the nested iframe should be AUTO. // 3. A real same-site navigation in the nested iframe should be AUTO.
...@@ -1768,17 +1741,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -1768,17 +1741,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetEntryCount()); EXPECT_EQ(1, controller.GetEntryCount());
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should still have one nested subframe FrameNavigationEntry.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
// The entry should still have one nested subframe FrameNavigationEntry. frame_entry = entry->root_node()->children[0]->children[0]->frame_entry.get();
ASSERT_EQ(1U, entry->root_node()->children[0]->children.size()); EXPECT_EQ(frame_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[0]->children[0]->frame_entry.get();
EXPECT_EQ(frame_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load());
EXPECT_FALSE(root->child_at(1)->has_committed_real_load()); EXPECT_FALSE(root->child_at(1)->has_committed_real_load());
...@@ -1800,17 +1766,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -1800,17 +1766,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetEntryCount()); EXPECT_EQ(1, controller.GetEntryCount());
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should still have two subframe FrameNavigationEntries.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(2U, entry->root_node()->children.size());
// The entry should still have two subframe FrameNavigationEntries. frame_entry = entry->root_node()->children[1]->frame_entry.get();
ASSERT_EQ(2U, entry->root_node()->children.size()); EXPECT_EQ(foo_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[1]->frame_entry.get();
EXPECT_EQ(foo_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load());
EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
...@@ -1833,16 +1792,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -1833,16 +1792,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_NE(entry, controller.GetLastCommittedEntry()); EXPECT_NE(entry, controller.GetLastCommittedEntry());
NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // Verify subframe entries.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(2U, entry->root_node()->children.size());
ASSERT_EQ(2U, entry->root_node()->children.size()); frame_entry =
FrameNavigationEntry* frame_entry = entry2->root_node()->children[0]->children[0]->frame_entry.get();
entry2->root_node()->children[0]->children[0]->frame_entry.get(); EXPECT_EQ(about_blank_url, frame_entry->url());
EXPECT_EQ(about_blank_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
EXPECT_FALSE(root->child_at(0)->has_committed_real_load()); EXPECT_FALSE(root->child_at(0)->has_committed_real_load());
EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load()); EXPECT_TRUE(root->child_at(0)->child_at(0)->has_committed_real_load());
EXPECT_TRUE(root->child_at(1)->has_committed_real_load()); EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
...@@ -2095,18 +2049,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2095,18 +2049,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(main_url, root_entry->url()); EXPECT_EQ(main_url, root_entry->url());
EXPECT_FALSE(controller.GetPendingEntry()); EXPECT_FALSE(controller.GetPendingEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should now have a subframe FrameNavigationEntry.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
// The entry should now have a subframe FrameNavigationEntry. FrameNavigationEntry* frame_entry =
ASSERT_EQ(1U, entry->root_node()->children.size()); entry->root_node()->children[0]->frame_entry.get();
FrameNavigationEntry* frame_entry = EXPECT_EQ(frame_url, frame_entry->url());
entry->root_node()->children[0]->frame_entry.get(); EXPECT_TRUE(root->child_at(0)->has_committed_real_load());
EXPECT_EQ(frame_url, frame_entry->url());
EXPECT_TRUE(root->child_at(0)->has_committed_real_load());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
// 2. Create a second, initially cross-site iframe. // 2. Create a second, initially cross-site iframe.
GURL foo_url(embedded_test_server()->GetURL( GURL foo_url(embedded_test_server()->GetURL(
...@@ -2130,18 +2078,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2130,18 +2078,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(main_url, root_entry->url()); EXPECT_EQ(main_url, root_entry->url());
EXPECT_FALSE(controller.GetPendingEntry()); EXPECT_FALSE(controller.GetPendingEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should now have 2 subframe FrameNavigationEntries.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(2U, entry->root_node()->children.size());
// The entry should now have 2 subframe FrameNavigationEntries. frame_entry = entry->root_node()->children[1]->frame_entry.get();
ASSERT_EQ(2U, entry->root_node()->children.size()); EXPECT_EQ(foo_url, frame_entry->url());
FrameNavigationEntry* frame_entry = EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
entry->root_node()->children[1]->frame_entry.get();
EXPECT_EQ(foo_url, frame_entry->url());
EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
// 3. Create a nested iframe in the second subframe. // 3. Create a nested iframe in the second subframe.
{ {
...@@ -2162,18 +2103,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2162,18 +2103,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
root_entry = entry->root_node()->frame_entry.get(); root_entry = entry->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry->url()); EXPECT_EQ(main_url, root_entry->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should now have 2 subframe FrameNavigationEntries.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(2U, entry->root_node()->children.size());
// The entry should now have 2 subframe FrameNavigationEntries. ASSERT_EQ(1U, entry->root_node()->children[1]->children.size());
ASSERT_EQ(2U, entry->root_node()->children.size()); frame_entry = entry->root_node()->children[1]->children[0]->frame_entry.get();
ASSERT_EQ(1U, entry->root_node()->children[1]->children.size()); EXPECT_EQ(foo_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[1]->children[0]->frame_entry.get();
EXPECT_EQ(foo_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
// 4. Create a third iframe on the same site as the second. This ensures that // 4. Create a third iframe on the same site as the second. This ensures that
// the commit type is correct even when the subframe process already exists. // the commit type is correct even when the subframe process already exists.
...@@ -2195,17 +2129,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2195,17 +2129,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
root_entry = entry->root_node()->frame_entry.get(); root_entry = entry->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry->url()); EXPECT_EQ(main_url, root_entry->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should now have 3 subframe FrameNavigationEntries.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(3U, entry->root_node()->children.size());
// The entry should now have 3 subframe FrameNavigationEntries. frame_entry = entry->root_node()->children[2]->frame_entry.get();
ASSERT_EQ(3U, entry->root_node()->children.size()); EXPECT_EQ(foo_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[2]->frame_entry.get();
EXPECT_EQ(foo_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
// 5. Create a nested iframe on the original site (A-B-A). // 5. Create a nested iframe on the original site (A-B-A).
{ {
...@@ -2227,17 +2154,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2227,17 +2154,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
root_entry = entry->root_node()->frame_entry.get(); root_entry = entry->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry->url()); EXPECT_EQ(main_url, root_entry->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // There should be a corresponding FrameNavigationEntry.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children[2]->children.size());
// There should be a corresponding FrameNavigationEntry. frame_entry = entry->root_node()->children[2]->children[0]->frame_entry.get();
ASSERT_EQ(1U, entry->root_node()->children[2]->children.size()); EXPECT_EQ(frame_url, frame_entry->url());
FrameNavigationEntry* frame_entry =
entry->root_node()->children[2]->children[0]->frame_entry.get();
EXPECT_EQ(frame_url, frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
// Check the end result of the frame tree. // Check the end result of the frame tree.
if (AreAllSitesIsolatedForTesting()) { if (AreAllSitesIsolatedForTesting()) {
...@@ -2304,15 +2224,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2304,15 +2224,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get(); FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry2->url()); EXPECT_EQ(main_url, root_entry2->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a new FrameNavigationEntries for the subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry2->root_node()->children.size());
// The entry should have a new FrameNavigationEntries for the subframe. EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry2->root_node()->children.size());
EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry2->root_node()->children.size());
}
// 3. Create a second, initially cross-site iframe. // 3. Create a second, initially cross-site iframe.
GURL foo_url(embedded_test_server()->GetURL( GURL foo_url(embedded_test_server()->GetURL(
...@@ -2361,20 +2275,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2361,20 +2275,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get(); FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry3->url()); EXPECT_EQ(main_url, root_entry3->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should still have FrameNavigationEntries for all 3 subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(2U, entry3->root_node()->children.size());
// The entry should still have FrameNavigationEntries for all 3 subframes. EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(2U, entry3->root_node()->children.size()); EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url());
EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url()); ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size());
EXPECT_EQ(foo_url, entry3->root_node()->children[1]->frame_entry->url()); EXPECT_EQ(bar_url,
ASSERT_EQ(1U, entry3->root_node()->children[1]->children.size()); entry3->root_node()->children[1]->children[0]->frame_entry->url());
EXPECT_EQ(
bar_url,
entry3->root_node()->children[1]->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry3->root_node()->children.size());
}
// 6. Navigate the second subframe cross-site, clearing its existing subtree. // 6. Navigate the second subframe cross-site, clearing its existing subtree.
GURL baz_url(embedded_test_server()->GetURL( GURL baz_url(embedded_test_server()->GetURL(
...@@ -2404,17 +2311,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2404,17 +2311,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get(); FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get();
EXPECT_EQ(main_url, root_entry4->url()); EXPECT_EQ(main_url, root_entry4->url());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should still have FrameNavigationEntries for all 3 subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(2U, entry4->root_node()->children.size());
// The entry should still have FrameNavigationEntries for all 3 subframes. EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(2U, entry4->root_node()->children.size()); EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url());
EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url()); ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size());
EXPECT_EQ(baz_url, entry4->root_node()->children[1]->frame_entry->url());
ASSERT_EQ(0U, entry4->root_node()->children[1]->children.size());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry4->root_node()->children.size());
}
// Check the end result of the frame tree. // Check the end result of the frame tree.
if (AreAllSitesIsolatedForTesting()) { if (AreAllSitesIsolatedForTesting()) {
...@@ -2464,17 +2365,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2464,17 +2365,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_TRUE(ExecuteScript(root, push_script)); EXPECT_TRUE(ExecuteScript(root, push_script));
EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(subframe_url, entry->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry->root_node()->children.size());
EXPECT_EQ(subframe_url,
entry->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
// 3. Add a nested subframe. // 3. Add a nested subframe.
{ {
...@@ -2488,20 +2382,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2488,20 +2382,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME)); capturer.transition_type(), ui::PAGE_TRANSITION_AUTO_SUBFRAME));
} }
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
entry = controller.GetLastCommittedEntry(); entry = controller.GetLastCommittedEntry();
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(subframe_url, entry->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry->root_node()->children.size()); ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
EXPECT_EQ(subframe_url, EXPECT_EQ(subframe_url,
entry->root_node()->children[0]->frame_entry->url()); entry->root_node()->children[0]->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
EXPECT_EQ(subframe_url,
entry->root_node()->children[0]->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry->root_node()->children.size());
}
} }
// Verify the tree of FrameNavigationEntries after back/forward navigations in a // Verify the tree of FrameNavigationEntries after back/forward navigations in a
...@@ -2568,15 +2455,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2568,15 +2455,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry2->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry2->root_node()->children.size());
EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry2->root_node()->children.size());
}
// 5. Go back in the subframe again to the parent page's site. // 5. Go back in the subframe again to the parent page's site.
{ {
...@@ -2591,15 +2472,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2591,15 +2472,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry1, controller.GetLastCommittedEntry()); EXPECT_EQ(entry1, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry1->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry1->root_node()->children.size());
EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry1->root_node()->children.size());
}
// 6. Go forward in the subframe cross-site. // 6. Go forward in the subframe cross-site.
{ {
...@@ -2614,15 +2489,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2614,15 +2489,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry2->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry2->root_node()->children.size());
EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry2->root_node()->children.size());
}
// 7. Go forward in the subframe again, cross-site. // 7. Go forward in the subframe again, cross-site.
{ {
...@@ -2637,15 +2506,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2637,15 +2506,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); EXPECT_EQ(entry3, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry3->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry3->root_node()->children.size());
EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry3->root_node()->children.size());
}
} }
// Verify the tree of FrameNavigationEntries after subframes are recreated in // Verify the tree of FrameNavigationEntries after subframes are recreated in
...@@ -2685,15 +2548,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2685,15 +2548,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the data subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry2->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the data subframe. EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry2->root_node()->children.size());
EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry2->root_node()->children.size());
}
// 3. Navigate the iframe cross-site to a page with a nested iframe. // 3. Navigate the iframe cross-site to a page with a nested iframe.
GURL frame_url_b(embedded_test_server()->GetURL( GURL frame_url_b(embedded_test_server()->GetURL(
...@@ -2712,20 +2569,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2712,20 +2569,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry3 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the b.com subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry3->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the b.com subframe. ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size());
ASSERT_EQ(1U, entry3->root_node()->children.size()); EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); EXPECT_EQ(data_url,
EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->children[0]->frame_entry->url());
entry3->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(
data_url,
entry3->root_node()->children[0]->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry3->root_node()->children.size());
}
// 4. Navigate the nested iframe cross-site. // 4. Navigate the nested iframe cross-site.
GURL frame_url_c(embedded_test_server()->GetURL( GURL frame_url_c(embedded_test_server()->GetURL(
...@@ -2744,35 +2593,22 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2744,35 +2593,22 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry4 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry4->root_node()->children.size());
// The entry should have FrameNavigationEntries for the subframes. ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size());
ASSERT_EQ(1U, entry4->root_node()->children.size()); EXPECT_EQ(frame_url_b, entry4->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); EXPECT_EQ(frame_url_c,
EXPECT_EQ(frame_url_b, entry4->root_node()->children[0]->children[0]->frame_entry->url());
entry4->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(
frame_url_c,
entry4->root_node()->children[0]->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry4->root_node()->children.size());
}
// Remember the DSNs for later. // Remember the DSNs for later.
int64_t root_dsn = int64_t root_dsn =
entry4->root_node()->frame_entry->document_sequence_number(); entry4->root_node()->frame_entry->document_sequence_number();
int64_t frame_b_dsn = -1; int64_t frame_b_dsn =
int64_t frame_c_dsn = -1; entry4->root_node()->children[0]->frame_entry->document_sequence_number();
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { int64_t frame_c_dsn = entry4->root_node()
frame_b_dsn = entry4->root_node() ->children[0]
->children[0] ->children[0]
->frame_entry->document_sequence_number(); ->frame_entry->document_sequence_number();
frame_c_dsn = entry4->root_node()
->children[0]
->children[0]
->frame_entry->document_sequence_number();
}
// 5. Navigate main frame cross-site, destroying the frames. // 5. Navigate main frame cross-site, destroying the frames.
GURL main_url_d(embedded_test_server()->GetURL( GURL main_url_d(embedded_test_server()->GetURL(
...@@ -2806,30 +2642,21 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2806,30 +2642,21 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(root_dsn, EXPECT_EQ(root_dsn,
entry4->root_node()->frame_entry->document_sequence_number()); entry4->root_node()->frame_entry->document_sequence_number());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry4->root_node()->children.size());
// The entry should have FrameNavigationEntries for the subframes. ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size());
ASSERT_EQ(1U, entry4->root_node()->children.size()); EXPECT_EQ(frame_url_b, entry4->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry4->root_node()->children[0]->children.size()); EXPECT_EQ(frame_url_c,
EXPECT_EQ(frame_url_b, entry4->root_node()->children[0]->children[0]->frame_entry->url());
entry4->root_node()->children[0]->frame_entry->url()); // The subframes should not have changed their DSNs.
EXPECT_EQ( // See https://crbug.com/628286.
frame_url_c, EXPECT_EQ(frame_b_dsn, entry4->root_node()
entry4->root_node()->children[0]->children[0]->frame_entry->url()); ->children[0]
->frame_entry->document_sequence_number());
// The subframes should not have changed their DSNs. EXPECT_EQ(frame_c_dsn, entry4->root_node()
// See https://crbug.com/628286. ->children[0]
EXPECT_EQ(frame_b_dsn, entry4->root_node() ->children[0]
->children[0] ->frame_entry->document_sequence_number());
->frame_entry->document_sequence_number());
EXPECT_EQ(frame_c_dsn, entry4->root_node()
->children[0]
->children[0]
->frame_entry->document_sequence_number());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry4->root_node()->children.size());
}
// Inject a JS value so that we can check for it later. // Inject a JS value so that we can check for it later.
EXPECT_TRUE(content::ExecuteScript(root, "foo=3;")); EXPECT_TRUE(content::ExecuteScript(root, "foo=3;"));
...@@ -2850,20 +2677,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2850,20 +2677,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); EXPECT_EQ(entry3, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry3->root_node()->children.size());
// The entry should have FrameNavigationEntries for the subframes. ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size());
ASSERT_EQ(1U, entry3->root_node()->children.size()); EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry3->root_node()->children[0]->children.size()); EXPECT_EQ(data_url,
EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->children[0]->frame_entry->url());
entry3->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(
data_url,
entry3->root_node()->children[0]->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry3->root_node()->children.size());
}
// Verify that we did not reload the main frame. See https://crbug.com/586234. // Verify that we did not reload the main frame. See https://crbug.com/586234.
{ {
...@@ -2888,15 +2707,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2888,15 +2707,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry2, controller.GetLastCommittedEntry()); EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry2->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the subframe. EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry2->root_node()->children.size());
EXPECT_EQ(data_url, entry2->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry2->root_node()->children.size());
}
// 9. Go back again, to the initial main frame page. // 9. Go back again, to the initial main frame page.
{ {
...@@ -2927,29 +2740,17 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -2927,29 +2740,17 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
EXPECT_EQ(entry3, controller.GetLastCommittedEntry()); EXPECT_EQ(entry3, controller.GetLastCommittedEntry());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry3->root_node()->children.size());
// The entry should have FrameNavigationEntries for the subframes. EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry3->root_node()->children.size()); EXPECT_EQ(data_url,
EXPECT_EQ(frame_url_b, entry3->root_node()->children[0]->children[0]->frame_entry->url());
entry3->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(
data_url,
entry3->root_node()->children[0]->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry3->root_node()->children.size());
}
} }
// Verify that we navigate to the fallback (original) URL if a subframe's // Verify that we navigate to the fallback (original) URL if a subframe's
// FrameNavigationEntry can't be found during a history navigation. // FrameNavigationEntry can't be found during a history navigation.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry_SubframeHistoryFallback) { FrameNavigationEntry_SubframeHistoryFallback) {
// This test only makes sense when subframe FrameNavigationEntries are in use.
if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
return;
// 1. Start on a page with a data URL iframe. // 1. Start on a page with a data URL iframe.
GURL main_url_a(embedded_test_server()->GetURL( GURL main_url_a(embedded_test_server()->GetURL(
"a.com", "/navigation_controller/page_with_data_iframe.html")); "a.com", "/navigation_controller/page_with_data_iframe.html"));
...@@ -3058,10 +2859,6 @@ class DataUrlCommitObserver : public WebContentsObserver { ...@@ -3058,10 +2859,6 @@ class DataUrlCommitObserver : public WebContentsObserver {
// See https://crbug.com/649345. // See https://crbug.com/649345.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry_DynamicSubframeHistoryFallback) { FrameNavigationEntry_DynamicSubframeHistoryFallback) {
// This test only makes sense when subframe FrameNavigationEntries are in use.
if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
return;
// 1. Start on a page with a script-generated iframe. The iframe has a // 1. Start on a page with a script-generated iframe. The iframe has a
// dynamic name, starts at about:blank, and gets navigated to a dynamic data // dynamic name, starts at about:blank, and gets navigated to a dynamic data
// URL as the page is loading. // URL as the page is loading.
...@@ -3171,10 +2968,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3171,10 +2968,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
// The entry should have a FrameNavigationEntry for the blank subframe. // The entry should have a FrameNavigationEntry for the blank subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
}
// 2. Navigate the main frame, destroying the frames. // 2. Navigate the main frame, destroying the frames.
GURL main_url_2(embedded_test_server()->GetURL( GURL main_url_2(embedded_test_server()->GetURL(
...@@ -3210,10 +3005,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3210,10 +3005,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// The entry should have a FrameNavigationEntry for the blank subframe. // The entry should have a FrameNavigationEntry for the blank subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
}
} }
// Verify that we correctly load nested iframes injected into a page if we go // Verify that we correctly load nested iframes injected into a page if we go
...@@ -3248,12 +3041,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3248,12 +3041,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
// The entry should have FrameNavigationEntries for the subframes. // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); EXPECT_EQ(inner_url,
EXPECT_EQ(inner_url, entry->root_node()->children[0]->children[0]->frame_entry->url());
entry->root_node()->children[0]->children[0]->frame_entry->url());
}
// Set a value in the form which will be stored in the PageState. // Set a value in the form which will be stored in the PageState.
EXPECT_TRUE( EXPECT_TRUE(
...@@ -3288,12 +3079,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3288,12 +3079,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// The entry should have FrameNavigationEntries for the subframes. // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url()); EXPECT_EQ(inner_url,
EXPECT_EQ(inner_url, entry->root_node()->children[0]->children[0]->frame_entry->url());
entry->root_node()->children[0]->children[0]->frame_entry->url());
}
// With injected about:blank iframes, we never restore form values from // With injected about:blank iframes, we never restore form values from
// PageState. // PageState.
...@@ -3343,12 +3132,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3343,12 +3132,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
// The entry should have FrameNavigationEntries for the subframes. // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); EXPECT_EQ(inner_url,
EXPECT_EQ(inner_url, entry->root_node()->children[0]->children[0]->frame_entry->url());
entry->root_node()->children[0]->children[0]->frame_entry->url());
}
// Set a value in the form which will be stored in the PageState. // Set a value in the form which will be stored in the PageState.
EXPECT_TRUE( EXPECT_TRUE(
...@@ -3385,12 +3172,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3385,12 +3172,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// The entry should have FrameNavigationEntries for the subframes. // The entry should have FrameNavigationEntries for the subframes.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(srcdoc_url, entry->root_node()->children[0]->frame_entry->url()); EXPECT_EQ(inner_url,
EXPECT_EQ(inner_url, entry->root_node()->children[0]->children[0]->frame_entry->url());
entry->root_node()->children[0]->children[0]->frame_entry->url());
}
// With injected iframe srcdoc pages, we do restore form values from // With injected iframe srcdoc pages, we do restore form values from
// PageState. // PageState.
...@@ -3432,10 +3217,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3432,10 +3217,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
NavigationEntryImpl* entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
// The entry should have a FrameNavigationEntry for the blank subframe. // The entry should have a FrameNavigationEntry for the blank subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
}
// 3. Navigate the main frame, destroying the frames. // 3. Navigate the main frame, destroying the frames.
GURL main_url_2(embedded_test_server()->GetURL( GURL main_url_2(embedded_test_server()->GetURL(
...@@ -3462,10 +3245,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3462,10 +3245,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// The entry should have a FrameNavigationEntry for the blank subframe. // The entry should have a FrameNavigationEntry for the blank subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
}
} }
// Ensure we don't crash if an onload handler removes an about:blank frame after // Ensure we don't crash if an onload handler removes an about:blank frame after
...@@ -3490,10 +3271,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3490,10 +3271,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// The entry should have a FrameNavigationEntry for the blank subframe, even // The entry should have a FrameNavigationEntry for the blank subframe, even
// though it is being removed from the page. // though it is being removed from the page.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
}
// 2. Navigate the main frame, destroying the frames. // 2. Navigate the main frame, destroying the frames.
GURL main_url_2(embedded_test_server()->GetURL( GURL main_url_2(embedded_test_server()->GetURL(
...@@ -3521,10 +3300,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3521,10 +3300,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry, controller.GetLastCommittedEntry()); EXPECT_EQ(entry, controller.GetLastCommittedEntry());
// The entry should have a FrameNavigationEntry for the blank subframe. // The entry should have a FrameNavigationEntry for the blank subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
ASSERT_EQ(1U, entry->root_node()->children.size()); EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(blank_url, entry->root_node()->children[0]->frame_entry->url());
}
} }
// Verifies that we clear the children FrameNavigationEntries if a history // Verifies that we clear the children FrameNavigationEntries if a history
...@@ -3551,8 +3328,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3551,8 +3328,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(initial_url, root->current_url()); EXPECT_EQ(initial_url, root->current_url());
EXPECT_EQ(2U, root->child_count()); EXPECT_EQ(2U, root->child_count());
NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry();
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) EXPECT_EQ(2U, entry1->root_node()->children.size());
EXPECT_EQ(2U, entry1->root_node()->children.size());
// 2. Navigate both iframes to a page with a nested iframe. // 2. Navigate both iframes to a page with a nested iframe.
GURL frame_url(embedded_test_server()->GetURL( GURL frame_url(embedded_test_server()->GetURL(
...@@ -3569,17 +3345,14 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3569,17 +3345,14 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(3, controller.GetEntryCount()); EXPECT_EQ(3, controller.GetEntryCount());
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process).
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { // Verify subframe entries.
NavigationEntryImpl::TreeNode* root_node = entry2->root_node(); NavigationEntryImpl::TreeNode* root_node = entry2->root_node();
ASSERT_EQ(2U, root_node->children.size()); ASSERT_EQ(2U, root_node->children.size());
EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url()); EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url());
EXPECT_EQ(data_url, EXPECT_EQ(data_url, root_node->children[0]->children[0]->frame_entry->url());
root_node->children[0]->children[0]->frame_entry->url()); EXPECT_EQ(frame_url, root_node->children[1]->frame_entry->url());
EXPECT_EQ(frame_url, root_node->children[1]->frame_entry->url()); EXPECT_EQ(data_url, root_node->children[1]->children[0]->frame_entry->url());
EXPECT_EQ(data_url,
root_node->children[1]->children[0]->frame_entry->url());
}
// Cause the first iframe to redirect when we come back later. It will go // Cause the first iframe to redirect when we come back later. It will go
// cross-site to a page with an about:blank iframe. // cross-site to a page with an about:blank iframe.
...@@ -3597,12 +3370,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3597,12 +3370,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// We should not have lost subframe entries for the nested frame. // We should not have lost subframe entries for the nested frame.
EXPECT_EQ(3, controller.GetEntryCount()); EXPECT_EQ(3, controller.GetEntryCount());
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { FrameNavigationEntry* nested_entry =
FrameNavigationEntry* nested_entry = entry2->GetFrameEntry(root->child_at(0)->child_at(0));
entry2->GetFrameEntry(root->child_at(0)->child_at(0)); EXPECT_TRUE(nested_entry);
EXPECT_TRUE(nested_entry); EXPECT_EQ(data_url, nested_entry->url());
EXPECT_EQ(data_url, nested_entry->url());
}
// 3. Navigate the main frame to a different page. When we come back, we'll // 3. Navigate the main frame to a different page. When we come back, we'll
// commit the main frame first and have no pending entry when navigating the // commit the main frame first and have no pending entry when navigating the
...@@ -3629,15 +3400,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3629,15 +3400,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// Check the FrameNavigationEntries as well. // Check the FrameNavigationEntries as well.
EXPECT_EQ(4, controller.GetEntryCount()); EXPECT_EQ(4, controller.GetEntryCount());
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(frame_redirect_dest_url,
EXPECT_EQ(frame_redirect_dest_url, entry2->GetFrameEntry(root->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(0))->url()); EXPECT_EQ(blank_url,
EXPECT_EQ(blank_url, entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); EXPECT_EQ(frame_url, entry2->GetFrameEntry(root->child_at(1))->url());
EXPECT_EQ(frame_url, entry2->GetFrameEntry(root->child_at(1))->url()); EXPECT_EQ(data_url,
EXPECT_EQ(data_url, entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url());
}
// In --site-per-process, we're misclassifying the subframe redirect in step 6 // In --site-per-process, we're misclassifying the subframe redirect in step 6
// below. For now, skip the rest of the test in that mode. // below. For now, skip the rest of the test in that mode.
...@@ -3681,16 +3450,14 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3681,16 +3450,14 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// Check the FrameNavigationEntries as well. // Check the FrameNavigationEntries as well.
EXPECT_EQ(4, controller.GetEntryCount()); EXPECT_EQ(4, controller.GetEntryCount());
EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(frame_redirect_dest_url,
EXPECT_EQ(frame_redirect_dest_url, entry2->GetFrameEntry(root->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(0))->url()); EXPECT_EQ(blank_url,
EXPECT_EQ(blank_url, entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url()); EXPECT_EQ(frame_redirect_dest_url,
EXPECT_EQ(frame_redirect_dest_url, entry2->GetFrameEntry(root->child_at(1))->url());
entry2->GetFrameEntry(root->child_at(1))->url()); EXPECT_EQ(blank_url,
EXPECT_EQ(blank_url, entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(1)->child_at(0))->url());
}
// Now cause the main frame to redirect to a page with no frames when we come // Now cause the main frame to redirect to a page with no frames when we come
// back to it. // back to it.
...@@ -3739,8 +3506,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3739,8 +3506,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(initial_url, root->current_url()); EXPECT_EQ(initial_url, root->current_url());
EXPECT_EQ(1U, root->child_count()); EXPECT_EQ(1U, root->child_count());
NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry();
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) EXPECT_EQ(1U, entry1->root_node()->children.size());
EXPECT_EQ(1U, entry1->root_node()->children.size());
// 2. Navigate the iframe to a page with a nested iframe. // 2. Navigate the iframe to a page with a nested iframe.
GURL frame_url(embedded_test_server()->GetURL( GURL frame_url(embedded_test_server()->GetURL(
...@@ -3754,14 +3520,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3754,14 +3520,12 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(2, controller.GetEntryCount()); EXPECT_EQ(2, controller.GetEntryCount());
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process).
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { // Verify subframe entries.
NavigationEntryImpl::TreeNode* root_node = entry2->root_node(); NavigationEntryImpl::TreeNode* root_node = entry2->root_node();
ASSERT_EQ(1U, root_node->children.size()); ASSERT_EQ(1U, root_node->children.size());
EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url()); EXPECT_EQ(frame_url, root_node->children[0]->frame_entry->url());
EXPECT_EQ(data_url, EXPECT_EQ(data_url, root_node->children[0]->children[0]->frame_entry->url());
root_node->children[0]->children[0]->frame_entry->url());
}
// Cause the iframe to redirect when we come back later. It will go // Cause the iframe to redirect when we come back later. It will go
// same-origin to a page with an about:blank iframe. // same-origin to a page with an about:blank iframe.
...@@ -3778,12 +3542,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3778,12 +3542,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// We should not have lost subframe entries for the nested frame. // We should not have lost subframe entries for the nested frame.
EXPECT_EQ(2, controller.GetEntryCount()); EXPECT_EQ(2, controller.GetEntryCount());
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { FrameNavigationEntry* nested_entry =
FrameNavigationEntry* nested_entry = entry2->GetFrameEntry(root->child_at(0)->child_at(0));
entry2->GetFrameEntry(root->child_at(0)->child_at(0)); EXPECT_TRUE(nested_entry);
EXPECT_TRUE(nested_entry); EXPECT_EQ(data_url, nested_entry->url());
EXPECT_EQ(data_url, nested_entry->url());
}
// 3. Navigate the main frame to a different page. When we come back, we'll // 3. Navigate the main frame to a different page. When we come back, we'll
// commit the main frame first and have no pending entry when navigating the // commit the main frame first and have no pending entry when navigating the
...@@ -3809,12 +3571,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3809,12 +3571,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// Check the FrameNavigationEntries as well. // Check the FrameNavigationEntries as well.
EXPECT_EQ(3, controller.GetEntryCount()); EXPECT_EQ(3, controller.GetEntryCount());
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(frame_redirect_dest_url,
EXPECT_EQ(frame_redirect_dest_url, entry2->GetFrameEntry(root->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(0))->url()); EXPECT_EQ(blank_url,
EXPECT_EQ(blank_url, entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url());
entry2->GetFrameEntry(root->child_at(0)->child_at(0))->url());
}
// Now cause the main frame to redirect to a page with no frames when we come // Now cause the main frame to redirect to a page with no frames when we come
// back to it. // back to it.
...@@ -3871,15 +3631,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3871,15 +3631,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry1 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the data subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry1->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the data subframe. EXPECT_EQ(data_url, entry1->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry1->root_node()->children.size());
EXPECT_EQ(data_url, entry1->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry1->root_node()->children.size());
}
// 2. Navigate the iframe cross-site. // 2. Navigate the iframe cross-site.
GURL frame_url_b(embedded_test_server()->GetURL( GURL frame_url_b(embedded_test_server()->GetURL(
...@@ -3897,16 +3651,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3897,16 +3651,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry(); NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the b.com subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry2->root_node()->children.size());
// The entry should have a FrameNavigationEntry for the b.com subframe. EXPECT_EQ(frame_url_b, entry2->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, entry2->root_node()->children.size());
EXPECT_EQ(frame_url_b,
entry2->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, entry2->root_node()->children.size());
}
// 3. Navigate main frame cross-site, destroying the frames. // 3. Navigate main frame cross-site, destroying the frames.
GURL main_url_c(embedded_test_server()->GetURL( GURL main_url_c(embedded_test_server()->GetURL(
...@@ -3930,17 +3677,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3930,17 +3677,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(0U, restored_entry->root_node()->children.size()); EXPECT_EQ(0U, restored_entry->root_node()->children.size());
restored_entry->SetPageState(entry2->GetPageState()); restored_entry->SetPageState(entry2->GetPageState());
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the b.com subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(main_url_a, restored_entry->root_node()->frame_entry->url());
// The entry should have a FrameNavigationEntry for the b.com subframe. ASSERT_EQ(1U, restored_entry->root_node()->children.size());
EXPECT_EQ(main_url_a, restored_entry->root_node()->frame_entry->url()); EXPECT_EQ(frame_url_b,
ASSERT_EQ(1U, restored_entry->root_node()->children.size()); restored_entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(frame_url_b,
restored_entry->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, restored_entry->root_node()->children.size());
}
// 5. Restore the new entry in a new tab and verify the correct URLs load. // 5. Restore the new entry in a new tab and verify the correct URLs load.
std::vector<std::unique_ptr<NavigationEntry>> entries; std::vector<std::unique_ptr<NavigationEntry>> entries;
...@@ -3970,17 +3711,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -3970,17 +3711,11 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(0, new_controller.GetLastCommittedEntryIndex()); EXPECT_EQ(0, new_controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* new_entry = new_controller.GetLastCommittedEntry(); NavigationEntryImpl* new_entry = new_controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the b.com subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(main_url_a, new_entry->root_node()->frame_entry->url());
// The entry should have a FrameNavigationEntry for the b.com subframe. ASSERT_EQ(1U, new_entry->root_node()->children.size());
EXPECT_EQ(main_url_a, new_entry->root_node()->frame_entry->url()); EXPECT_EQ(frame_url_b,
ASSERT_EQ(1U, new_entry->root_node()->children.size()); new_entry->root_node()->children[0]->frame_entry->url());
EXPECT_EQ(frame_url_b,
new_entry->root_node()->children[0]->frame_entry->url());
} else {
// There are no subframe FrameNavigationEntries by default.
EXPECT_EQ(0U, new_entry->root_node()->children.size());
}
} }
// Verify that we can finish loading a page on restore if the PageState is // Verify that we can finish loading a page on restore if the PageState is
...@@ -4032,16 +3767,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -4032,16 +3767,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
NavigationEntryImpl* new_entry = controller.GetLastCommittedEntry(); NavigationEntryImpl* new_entry = controller.GetLastCommittedEntry();
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // The entry should have a FrameNavigationEntry for the blank subframe.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(main_url, new_entry->root_node()->frame_entry->url());
// The entry should have a FrameNavigationEntry for the blank subframe. ASSERT_EQ(1U, new_entry->root_node()->children.size());
EXPECT_EQ(main_url, new_entry->root_node()->frame_entry->url()); EXPECT_EQ(blank_url, new_entry->root_node()->children[0]->frame_entry->url());
ASSERT_EQ(1U, new_entry->root_node()->children.size());
EXPECT_EQ(blank_url,
new_entry->root_node()->children[0]->frame_entry->url());
} else {
EXPECT_EQ(0U, new_entry->root_node()->children.size());
}
// Verify that the parent was able to script the iframe. // Verify that the parent was able to script the iframe.
std::string expected_text("Injected text"); std::string expected_text("Injected text");
...@@ -4078,10 +3807,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -4078,10 +3807,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
controller.GetLastCommittedEntry()->GetFrameEntry(root); controller.GetLastCommittedEntry()->GetFrameEntry(root);
EXPECT_EQ("", frame_entry->frame_unique_name()); EXPECT_EQ("", frame_entry->frame_unique_name());
// Test subframe unique names only if enabled, e.g. in --site-per-process.
if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
return;
// 2. Add an unnamed subframe, which does an AUTO_SUBFRAME navigation. // 2. Add an unnamed subframe, which does an AUTO_SUBFRAME navigation.
{ {
LoadCommittedCapturer capturer(shell()->web_contents()); LoadCommittedCapturer capturer(shell()->web_contents());
...@@ -4321,11 +4046,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -4321,11 +4046,9 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_NE(main_site_instance, EXPECT_NE(main_site_instance,
subframe->current_frame_host()->GetSiteInstance()); subframe->current_frame_host()->GetSiteInstance());
} }
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { FrameNavigationEntry* subframe_entry =
FrameNavigationEntry* subframe_entry = controller.GetLastCommittedEntry()->GetFrameEntry(subframe);
controller.GetLastCommittedEntry()->GetFrameEntry(subframe); EXPECT_EQ(frame_url, subframe_entry->url());
EXPECT_EQ(frame_url, subframe_entry->url());
}
// 3. Reload the main frame. // 3. Reload the main frame.
{ {
...@@ -4387,10 +4110,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -4387,10 +4110,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_NE(isn_1, isn_2); EXPECT_NE(isn_1, isn_2);
EXPECT_EQ(dsn_1, dsn_2); EXPECT_EQ(dsn_1, dsn_2);
// Test subframe sequence numbers only if enabled, e.g. in --site-per-process.
if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
return;
// 3. Add a subframe, which does an AUTO_SUBFRAME navigation. // 3. Add a subframe, which does an AUTO_SUBFRAME navigation.
{ {
LoadCommittedCapturer capturer(shell()->web_contents()); LoadCommittedCapturer capturer(shell()->web_contents());
...@@ -4477,16 +4196,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -4477,16 +4196,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry->GetRedirectChain().size(), 1u); EXPECT_EQ(entry->GetRedirectChain().size(), 1u);
EXPECT_EQ(entry->GetRedirectChain()[0], main_url); EXPECT_EQ(entry->GetRedirectChain()[0], main_url);
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // Check that the FrameNavigationEntry's redirect chain contains 2 urls.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
// Check that the FrameNavigationEntry's redirect chain contains 2 urls. FrameNavigationEntry* frame_entry =
ASSERT_EQ(1U, entry->root_node()->children.size()); entry->root_node()->children[0]->frame_entry.get();
FrameNavigationEntry* frame_entry = EXPECT_EQ(frame_entry->redirect_chain().size(), 2u);
entry->root_node()->children[0]->frame_entry.get(); EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url);
EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url);
EXPECT_EQ(frame_entry->redirect_chain()[0], iframe_redirect_url);
EXPECT_EQ(frame_entry->redirect_chain()[1], iframe_final_url);
}
} }
// Verifies that FrameNavigationEntry's redirect chain is created and stored on // Verifies that FrameNavigationEntry's redirect chain is created and stored on
...@@ -4518,16 +4234,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -4518,16 +4234,13 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(entry->GetRedirectChain().size(), 1u); EXPECT_EQ(entry->GetRedirectChain().size(), 1u);
EXPECT_EQ(entry->GetRedirectChain()[0], main_url); EXPECT_EQ(entry->GetRedirectChain()[0], main_url);
// Verify subframe entries if they're enabled (e.g. in --site-per-process). // Check that the FrameNavigationEntry's redirect chain contains 2 urls.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { ASSERT_EQ(1U, entry->root_node()->children.size());
// Check that the FrameNavigationEntry's redirect chain contains 2 urls. FrameNavigationEntry* frame_entry =
ASSERT_EQ(1U, entry->root_node()->children.size()); entry->root_node()->children[0]->frame_entry.get();
FrameNavigationEntry* frame_entry = EXPECT_EQ(frame_entry->redirect_chain().size(), 2u);
entry->root_node()->children[0]->frame_entry.get(); EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url);
EXPECT_EQ(frame_entry->redirect_chain().size(), 2u); EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url);
EXPECT_EQ(frame_entry->redirect_chain()[0], frame_redirect_url);
EXPECT_EQ(frame_entry->redirect_chain()[1], frame_final_url);
}
} }
// Support a set of tests that isolate only a subset of sites with // Support a set of tests that isolate only a subset of sites with
...@@ -6069,9 +5782,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6069,9 +5782,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// is recorded on a subframe level. // is recorded on a subframe level.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
PostInSubframe) { PostInSubframe) {
if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
return;
GURL page_with_form_url = embedded_test_server()->GetURL( GURL page_with_form_url = embedded_test_server()->GetURL(
"/navigation_controller/subframe_form.html"); "/navigation_controller/subframe_form.html");
EXPECT_TRUE(NavigateToURL(shell(), page_with_form_url)); EXPECT_TRUE(NavigateToURL(shell(), page_with_form_url));
...@@ -6184,16 +5894,14 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6184,16 +5894,14 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); FrameNavigationEntry* root_entry = entry->GetFrameEntry(root);
EXPECT_NE(nullptr, root_entry); EXPECT_NE(nullptr, root_entry);
EXPECT_EQ("", root_entry->frame_unique_name()); EXPECT_EQ("", root_entry->frame_unique_name());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(3U, entry->root_node()->children.size());
EXPECT_EQ(3U, entry->root_node()->children.size());
// * The first child of the main frame is named and has two more children.
// * The first child of the main frame is named and has two more children. FrameTreeNode* frame = root->child_at(0);
FrameTreeNode* frame = root->child_at(0); FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame);
FrameNavigationEntry* frame_entry = entry->GetFrameEntry(frame); EXPECT_NE(nullptr, frame_entry);
EXPECT_NE(nullptr, frame_entry); EXPECT_EQ("1-1-name", frame_entry->frame_unique_name());
EXPECT_EQ("1-1-name", frame_entry->frame_unique_name()); EXPECT_EQ(2U, entry->root_node()->children[0]->children.size());
EXPECT_EQ(2U, entry->root_node()->children[0]->children.size());
}
} }
// Removing the first child of the main frame should remove the corresponding // Removing the first child of the main frame should remove the corresponding
...@@ -6206,10 +5914,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6206,10 +5914,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
{ {
FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); FrameNavigationEntry* root_entry = entry->GetFrameEntry(root);
EXPECT_NE(nullptr, root_entry); EXPECT_NE(nullptr, root_entry);
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(3U, entry->root_node()->children.size());
EXPECT_EQ(3U, entry->root_node()->children.size()); EXPECT_EQ(2U, entry->root_node()->children[0]->children.size());
EXPECT_EQ(2U, entry->root_node()->children[0]->children.size());
}
} }
// Now, insert a frame with the same name as the previously removed one // Now, insert a frame with the same name as the previously removed one
...@@ -6228,9 +5934,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6228,9 +5934,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
{ {
FrameNavigationEntry* root_entry = entry->GetFrameEntry(root); FrameNavigationEntry* root_entry = entry->GetFrameEntry(root);
EXPECT_NE(nullptr, root_entry); EXPECT_NE(nullptr, root_entry);
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(2U, entry->root_node()->children.size());
EXPECT_EQ(2U, entry->root_node()->children.size());
}
} }
} }
...@@ -6260,12 +5964,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6260,12 +5964,10 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// When a frame is removed from the page, the corresponding // When a frame is removed from the page, the corresponding
// FrameNavigationEntry is not removed. This is done intentionally to support // FrameNavigationEntry is not removed. This is done intentionally to support
// back-forward navigations in subframes and more intuitive UX on tab restore. // back-forward navigations in subframes and more intuitive UX on tab restore.
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(1U, nav_entry->root_node()->children.size());
EXPECT_EQ(1U, nav_entry->root_node()->children.size()); FrameNavigationEntry* frame_entry =
FrameNavigationEntry* frame_entry = nav_entry->root_node()->children[0]->frame_entry.get();
nav_entry->root_node()->children[0]->frame_entry.get(); EXPECT_EQ("foo-frame-name", frame_entry->frame_unique_name());
EXPECT_EQ("foo-frame-name", frame_entry->frame_unique_name());
}
EXPECT_TRUE(ExecuteScript(root, kAddFrameScript)); EXPECT_TRUE(ExecuteScript(root, kAddFrameScript));
EXPECT_EQ(1U, root->child_count()); EXPECT_EQ(1U, root->child_count());
...@@ -6276,17 +5978,15 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6276,17 +5978,15 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
EXPECT_EQ(1U, root->child_at(0)->child_count()); EXPECT_EQ(1U, root->child_at(0)->child_count());
EXPECT_EQ("foo-frame-name", root->child_at(0)->child_at(0)->frame_name()); EXPECT_EQ("foo-frame-name", root->child_at(0)->child_at(0)->frame_name());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(1U, nav_entry->root_node()->children.size());
EXPECT_EQ(1U, nav_entry->root_node()->children.size());
NavigationEntryImpl::TreeNode* tree_node = NavigationEntryImpl::TreeNode* tree_node =
nav_entry->root_node()->children[0]; nav_entry->root_node()->children[0];
EXPECT_EQ(1U, tree_node->children.size()); EXPECT_EQ(1U, tree_node->children.size());
tree_node = tree_node->children[0]; tree_node = tree_node->children[0];
EXPECT_EQ(0U, tree_node->children.size()); EXPECT_EQ(0U, tree_node->children.size());
EXPECT_EQ("foo-frame-name", tree_node->frame_entry->frame_unique_name()); EXPECT_EQ("foo-frame-name", tree_node->frame_entry->frame_unique_name());
}
EXPECT_TRUE(ExecuteScript(root->child_at(0), kRemoveFrameScript)); EXPECT_TRUE(ExecuteScript(root->child_at(0), kRemoveFrameScript));
EXPECT_EQ(0U, root->child_at(0)->child_count()); EXPECT_EQ(0U, root->child_at(0)->child_count());
...@@ -6311,25 +6011,20 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6311,25 +6011,20 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// for the name and leave it around. // for the name and leave it around.
EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript));
EXPECT_EQ(1U, root->child_count()); EXPECT_EQ(1U, root->child_count());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(1U, nav_entry->root_node()->children.size());
EXPECT_EQ(1U, nav_entry->root_node()->children.size()); tree_node = nav_entry->root_node()->children[0];
tree_node = nav_entry->root_node()->children[0];
}
EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript));
EXPECT_EQ(0U, root->child_count()); EXPECT_EQ(0U, root->child_count());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) EXPECT_EQ(1U, nav_entry->root_node()->children.size());
EXPECT_EQ(1U, nav_entry->root_node()->children.size());
// Add another frame with the same name as before. The matching logic // Add another frame with the same name as before. The matching logic
// should consider them the same and result in the FrameNavigationEntry // should consider them the same and result in the FrameNavigationEntry
// being reused. // being reused.
EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript)); EXPECT_TRUE(ExecuteScript(root, kAddNamedFrameScript));
EXPECT_EQ(1U, root->child_count()); EXPECT_EQ(1U, root->child_count());
if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { EXPECT_EQ(1U, nav_entry->root_node()->children.size());
EXPECT_EQ(1U, nav_entry->root_node()->children.size()); EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]);
EXPECT_EQ(tree_node, nav_entry->root_node()->children[0]);
}
EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript)); EXPECT_TRUE(ExecuteScript(root, kRemoveFrameScript));
EXPECT_EQ(0U, root->child_count()); EXPECT_EQ(0U, root->child_count());
...@@ -6777,9 +6472,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, ...@@ -6777,9 +6472,6 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
// Check that the referrer is stored inside FrameNavigationEntry for subframes. // Check that the referrer is stored inside FrameNavigationEntry for subframes.
IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
RefererStoredForSubFrame) { RefererStoredForSubFrame) {
if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
return;
const NavigationControllerImpl& controller = const NavigationControllerImpl& controller =
static_cast<const NavigationControllerImpl&>( static_cast<const NavigationControllerImpl&>(
shell()->web_contents()->GetController()); shell()->web_contents()->GetController());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment