Index: content/browser/site_per_process_browsertest.cc |
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc |
index e37ac97cce8c36d84da18942b1816e0b5ff3fc48..73f6d00a1740881cb97a1bd3185b7ecf00cde0dd 100644 |
--- a/content/browser/site_per_process_browsertest.cc |
+++ b/content/browser/site_per_process_browsertest.cc |
@@ -5,6 +5,7 @@ |
#include "base/command_line.h" |
#include "base/strings/stringprintf.h" |
#include "base/strings/utf_string_conversions.h" |
+#include "content/browser/renderer_host/frame_tree.h" |
#include "content/browser/web_contents/web_contents_impl.h" |
#include "content/public/browser/notification_observer.h" |
#include "content/public/browser/notification_service.h" |
@@ -16,6 +17,7 @@ |
#include "content/shell/browser/shell.h" |
#include "content/test/content_browser_test.h" |
#include "content/test/content_browser_test_utils.h" |
+#include "net/dns/mock_host_resolver.h" |
namespace content { |
@@ -139,9 +141,7 @@ void RedirectNotificationObserver::Observe( |
} |
class SitePerProcessBrowserTest : public ContentBrowserTest { |
- public: |
- SitePerProcessBrowserTest() {} |
- |
+ protected: |
bool NavigateIframeToURL(Shell* window, |
const GURL& url, |
std::string iframe_id) { |
@@ -399,4 +399,78 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
} |
} |
+// Ensures FrameTree correctly reflects page structure during navigations. |
+IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
+ FrameTreeShape) { |
+ host_resolver()->AddRule("*", "127.0.0.1"); |
+ ASSERT_TRUE(test_server()->Start()); |
+ |
+ GURL base_url = test_server()->GetURL("files/site_isolation/"); |
+ GURL::Replacements replace_host; |
+ std::string host_str("A.com"); // Must stay in scope with replace_host. |
+ replace_host.SetHostStr(host_str); |
+ base_url = base_url.ReplaceComponents(replace_host); |
+ |
+ // Load doc without iframes. Verify FrameTree just has root. |
+ // Frame tree: |
+ // Site-A Root |
+ NavigateToURL(shell(), base_url.Resolve("blank.html")); |
+ FrameTreeNode* root = |
+ static_cast<WebContentsImpl*>(shell()->web_contents())-> |
+ GetFrameTree()->GetRootForTesting(); |
+ EXPECT_EQ(0U, root->child_count()); |
+ |
+ // Add 2 same-site frames. Verify 3 nodes in tree with proper names. |
+ // Frame tree: |
+ // Site-A Root -- Site-A frame1 |
+ // \-- Site-A frame2 |
+ WindowedNotificationObserver observer1( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<NavigationController>( |
+ &shell()->web_contents()->GetController())); |
+ NavigateToURL(shell(), base_url.Resolve("frames-X-X.html")); |
+ observer1.Wait(); |
+ ASSERT_EQ(2U, root->child_count()); |
+ EXPECT_EQ(0U, root->child_at(0)->child_count()); |
+ EXPECT_EQ(0U, root->child_at(1)->child_count()); |
+ |
+ /* |
+ // nav second frame cross-site document also having 2 frames. Verify 5 nodes |
Charlie Reis
2013/09/27 19:19:21
If we want to move forward with this CL, let's rem
awong
2013/09/27 20:50:09
Done.
|
+ // in tree with proper names. |
+ // Frame tree: |
+ // Site-A Root -- Site-A frame1 |
+ // \-- Site-B frame2 -- SiteB frame1 |
+ // \-- SiteB frame2 |
+ NavigateToURL(shell(), base_url.Resolve("frames-A-B_0_B-B.html")); |
+ WindowedNotificationObserver observer2( |
+ content::NOTIFICATION_LOAD_STOP, |
+ content::Source<NavigationController>( |
+ &shell()->web_contents()->GetController())); |
+ ASSERT_TRUE(ExecuteScriptInFrame(shell()->web_contents(), "/iframe[1]", |
+ |
+ "var site_b_base = 'http://B.com:' + document.location.port;" |
+" document.getElementById('frame-2').src =" |
+" site_b_base + '/files/site_isolation/frames-X-X.html';")); |
+ observer2.Wait(); |
+ ASSERT_EQ(2U, root->child_count()); |
+ EXPECT_EQ(0U, root->child_at(0)->child_count()); |
+ ASSERT_EQ(2U, root->child_at(1)->child_count()); |
+ ASSERT_EQ(0U, root->child_at(1)->child_at(0)->child_count()); |
+ EXPECT_EQ(0U, root->child_at(1)->child_at(1)->child_count()); |
+ |
+ // nav second frame in cross-side document having. |
+ // How to trigger? Maybe just nav it to a page with a same-site frame? |
+ // Frame tree: |
+ // Site-A Root -- Site-A frame1 |
+ // \-- Site-B frame2 -- SiteA frame1 |
+ // \-- SiteB frame2 |
+ NavigateToURL(shell(), base_url.Resolve("frames-A-B_0_A-B.html")); |
+ ASSERT_EQ(2U, root->child_count()); |
+ EXPECT_EQ(0U, root->child_at(0)->child_count()); |
+ ASSERT_EQ(2U, root->child_at(1)->child_count()); |
+ ASSERT_EQ(0U, root->child_at(1)->child_at(0)->child_count()); |
+ EXPECT_EQ(0U, root->child_at(1)->child_at(1)->child_count()); |
+ */ |
} |
+ |
+} // namespace content |