| Index: content/browser/frame_host/navigation_controller_impl_browsertest.cc
|
| diff --git a/content/browser/frame_host/navigation_controller_impl_browsertest.cc b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
|
| index 541aaa584b41d1a1d7bdc3a16429f974e5decc74..301f27a133c1f85ab24fd1fb4ea454418030f86a 100644
|
| --- a/content/browser/frame_host/navigation_controller_impl_browsertest.cc
|
| +++ b/content/browser/frame_host/navigation_controller_impl_browsertest.cc
|
| @@ -3,7 +3,6 @@
|
| // found in the LICENSE file.
|
|
|
| #include "base/bind.h"
|
| -#include "base/command_line.h"
|
| #include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "content/browser/frame_host/frame_navigation_entry.h"
|
| @@ -11,6 +10,7 @@
|
| #include "content/browser/frame_host/navigation_controller_impl.h"
|
| #include "content/browser/frame_host/navigation_entry_impl.h"
|
| #include "content/browser/web_contents/web_contents_impl.h"
|
| +#include "content/common/site_isolation_policy.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/resource_controller.h"
|
| #include "content/public/browser/resource_dispatcher_host.h"
|
| @@ -19,7 +19,6 @@
|
| #include "content/public/browser/web_contents.h"
|
| #include "content/public/browser/web_contents_observer.h"
|
| #include "content/public/common/bindings_policy.h"
|
| -#include "content/public/common/content_switches.h"
|
| #include "content/public/common/url_constants.h"
|
| #include "content/public/test/browser_test_utils.h"
|
| #include "content/public/test/content_browser_test.h"
|
| @@ -64,9 +63,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadCrossSiteSubframe) {
|
| // We should only have swapped processes in --site-per-process.
|
| bool cross_process = root->current_frame_host()->GetProcess() !=
|
| root->child_at(0)->current_frame_host()->GetProcess();
|
| - EXPECT_EQ(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess),
|
| - cross_process);
|
| + EXPECT_EQ(AreAllSitesIsolatedForTesting(), cross_process);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, LoadDataWithBaseURL) {
|
| @@ -1159,9 +1156,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| FrameNavigationEntry* root_entry = entry->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should now have one blank subframe FrameNavigationEntry, but
|
| // this does not count as committing a real load.
|
| ASSERT_EQ(1U, entry->root_node()->children.size());
|
| @@ -1186,9 +1182,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(ui::PAGE_TRANSITION_AUTO_SUBFRAME, capturer.transition_type());
|
| }
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The nested entry should have one blank subframe FrameNavigationEntry, but
|
| // this does not count as committing a real load.
|
| ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
|
| @@ -1216,9 +1211,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(1, controller.GetEntryCount());
|
| EXPECT_EQ(entry, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The new entry should have one blank subframe FrameNavigationEntry, but
|
| // this does not count as committing a real load.
|
| ASSERT_EQ(2U, entry->root_node()->children.size());
|
| @@ -1249,9 +1243,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(1, controller.GetEntryCount());
|
| EXPECT_EQ(entry, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should still have one nested subframe FrameNavigationEntry.
|
| ASSERT_EQ(1U, entry->root_node()->children[0]->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| @@ -1281,9 +1274,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(1, controller.GetEntryCount());
|
| EXPECT_EQ(entry, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should still have two subframe FrameNavigationEntries.
|
| ASSERT_EQ(2U, entry->root_node()->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| @@ -1315,9 +1307,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_NE(entry, controller.GetLastCommittedEntry());
|
| NavigationEntryImpl* entry2 = controller.GetLastCommittedEntry();
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| ASSERT_EQ(2U, entry->root_node()->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| entry2->root_node()->children[0]->children[0]->frame_entry.get();
|
| @@ -1331,8 +1322,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_TRUE(root->child_at(1)->has_committed_real_load());
|
|
|
| // Check the end result of the frame tree.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + if (AreAllSitesIsolatedForTesting()) {
|
| FrameTreeVisualizer visualizer;
|
| EXPECT_EQ(
|
| " Site A ------------ proxies for B\n"
|
| @@ -1381,9 +1371,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(main_url, root_entry->url());
|
| EXPECT_FALSE(controller.GetPendingEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should now have a subframe FrameNavigationEntry.
|
| ASSERT_EQ(1U, entry->root_node()->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| @@ -1416,9 +1405,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(main_url, root_entry->url());
|
| EXPECT_FALSE(controller.GetPendingEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should now have 2 subframe FrameNavigationEntries.
|
| ASSERT_EQ(2U, entry->root_node()->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| @@ -1449,9 +1437,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| root_entry = entry->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should now have 2 subframe FrameNavigationEntries.
|
| ASSERT_EQ(2U, entry->root_node()->children.size());
|
| ASSERT_EQ(1U, entry->root_node()->children[1]->children.size());
|
| @@ -1482,9 +1469,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| root_entry = entry->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should now have 3 subframe FrameNavigationEntries.
|
| ASSERT_EQ(3U, entry->root_node()->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| @@ -1514,9 +1500,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| root_entry = entry->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // There should be a corresponding FrameNavigationEntry.
|
| ASSERT_EQ(1U, entry->root_node()->children[2]->children.size());
|
| FrameNavigationEntry* frame_entry =
|
| @@ -1528,8 +1513,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| }
|
|
|
| // Check the end result of the frame tree.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + if (AreAllSitesIsolatedForTesting()) {
|
| FrameTreeVisualizer visualizer;
|
| EXPECT_EQ(
|
| " Site A ------------ proxies for B\n"
|
| @@ -1592,9 +1576,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| FrameNavigationEntry* root_entry2 = entry2->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry2->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should have a new FrameNavigationEntries for the subframe.
|
| ASSERT_EQ(1U, entry2->root_node()->children.size());
|
| EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
|
| @@ -1646,9 +1629,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| FrameNavigationEntry* root_entry3 = entry3->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry3->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should still have FrameNavigationEntries for all 3 subframes.
|
| ASSERT_EQ(2U, entry3->root_node()->children.size());
|
| EXPECT_EQ(frame_url2, entry3->root_node()->children[0]->frame_entry->url());
|
| @@ -1685,9 +1667,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| FrameNavigationEntry* root_entry4 = entry4->root_node()->frame_entry.get();
|
| EXPECT_EQ(main_url, root_entry4->url());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should still have FrameNavigationEntries for all 3 subframes.
|
| ASSERT_EQ(2U, entry4->root_node()->children.size());
|
| EXPECT_EQ(frame_url2, entry4->root_node()->children[0]->frame_entry->url());
|
| @@ -1699,8 +1680,7 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| }
|
|
|
| // Check the end result of the frame tree.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + if (AreAllSitesIsolatedForTesting()) {
|
| FrameTreeVisualizer visualizer;
|
| EXPECT_EQ(
|
| " Site A ------------ proxies for B\n"
|
| @@ -1775,9 +1755,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
|
| EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should have a new FrameNavigationEntries for the subframe.
|
| ASSERT_EQ(1U, entry2->root_node()->children.size());
|
| EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
|
| @@ -1798,9 +1777,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
|
| EXPECT_EQ(entry1, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should have a new FrameNavigationEntries for the subframe.
|
| ASSERT_EQ(1U, entry1->root_node()->children.size());
|
| EXPECT_EQ(frame_url, entry1->root_node()->children[0]->frame_entry->url());
|
| @@ -1821,9 +1799,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
|
| EXPECT_EQ(entry2, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should have a new FrameNavigationEntries for the subframe.
|
| ASSERT_EQ(1U, entry2->root_node()->children.size());
|
| EXPECT_EQ(frame_url2, entry2->root_node()->children[0]->frame_entry->url());
|
| @@ -1844,9 +1821,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
|
| EXPECT_EQ(entry3, controller.GetLastCommittedEntry());
|
|
|
| - // Verify subframe entries if we're in --site-per-process mode.
|
| - if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess)) {
|
| + // Verify subframe entries if they're enabled (e.g. in --site-per-process).
|
| + if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
|
| // The entry should have a new FrameNavigationEntries for the subframe.
|
| ASSERT_EQ(1U, entry3->root_node()->children.size());
|
| EXPECT_EQ(frame_url3, entry3->root_node()->children[0]->frame_entry->url());
|
| @@ -1891,10 +1867,8 @@ IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
|
| EXPECT_NE(isn_1, isn_2);
|
| EXPECT_EQ(dsn_1, dsn_2);
|
|
|
| - // Also test subframe sequence numbers, but only in --site-per-proces mode.
|
| - // (We do not create subframe FrameNavigationEntries in default mode yet.)
|
| - if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kSitePerProcess))
|
| + // 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.
|
|
|