| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/test/scoped_feature_list.h" | |
| 9 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
| 10 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 11 #include "content/public/common/content_features.h" | 10 #include "content/public/common/content_features.h" |
| 12 #include "content/public/test/browser_test_utils.h" | 11 #include "content/public/test/browser_test_utils.h" |
| 13 #include "content/public/test/content_browser_test.h" | 12 #include "content/public/test/content_browser_test.h" |
| 14 #include "content/public/test/content_browser_test_utils.h" | 13 #include "content/public/test/content_browser_test_utils.h" |
| 15 #include "content/public/test/test_frame_navigation_observer.h" | 14 #include "content/public/test/test_frame_navigation_observer.h" |
| 16 #include "content/public/test/test_navigation_observer.h" | 15 #include "content/public/test/test_navigation_observer.h" |
| 17 #include "content/shell/browser/shell.h" | 16 #include "content/shell/browser/shell.h" |
| 18 #include "content/test/content_browser_test_utils_internal.h" | 17 #include "content/test/content_browser_test_utils_internal.h" |
| 19 #include "net/dns/mock_host_resolver.h" | 18 #include "net/dns/mock_host_resolver.h" |
| 20 #include "net/test/embedded_test_server/embedded_test_server.h" | 19 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "url/gurl.h" | 20 #include "url/gurl.h" |
| 22 | 21 |
| 23 namespace content { | 22 namespace content { |
| 24 | 23 |
| 25 class TopDocumentIsolationTest : public ContentBrowserTest { | 24 class TopDocumentIsolationTest : public ContentBrowserTest { |
| 26 public: | 25 public: |
| 27 TopDocumentIsolationTest() {} | 26 TopDocumentIsolationTest() {} |
| 28 | 27 |
| 29 protected: | 28 protected: |
| 30 std::string DepictFrameTree(FrameTreeNode* node) { | 29 std::string DepictFrameTree(FrameTreeNode* node) { |
| 31 return visualizer_.DepictFrameTree(node); | 30 return visualizer_.DepictFrameTree(node); |
| 32 } | 31 } |
| 33 | 32 |
| 34 void SetUp() override { | 33 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 35 scoped_feature_list_.InitAndEnableFeature(features::kTopDocumentIsolation); | 34 ContentBrowserTest::SetUpCommandLine(command_line); |
| 36 ContentBrowserTest::SetUp(); | 35 content::EnableTopDocumentIsolationForTesting(command_line); |
| 37 } | 36 } |
| 38 | 37 |
| 39 void SetUpOnMainThread() override { | 38 void SetUpOnMainThread() override { |
| 40 host_resolver()->AddRule("*", "127.0.0.1"); | 39 host_resolver()->AddRule("*", "127.0.0.1"); |
| 41 SetupCrossSiteRedirector(embedded_test_server()); | 40 SetupCrossSiteRedirector(embedded_test_server()); |
| 42 ASSERT_TRUE(embedded_test_server()->Start()); | 41 ASSERT_TRUE(embedded_test_server()->Start()); |
| 43 } | 42 } |
| 44 | 43 |
| 45 FrameTreeNode* root() { | 44 FrameTreeNode* root() { |
| 46 return static_cast<WebContentsImpl*>(shell()->web_contents()) | 45 return static_cast<WebContentsImpl*>(shell()->web_contents()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 | 61 |
| 63 void RendererInitiatedNavigateToURL(FrameTreeNode* node, const GURL& url) { | 62 void RendererInitiatedNavigateToURL(FrameTreeNode* node, const GURL& url) { |
| 64 TestFrameNavigationObserver nav_observer(node); | 63 TestFrameNavigationObserver nav_observer(node); |
| 65 ASSERT_TRUE( | 64 ASSERT_TRUE( |
| 66 ExecuteScript(node, "window.location.href='" + url.spec() + "'")); | 65 ExecuteScript(node, "window.location.href='" + url.spec() + "'")); |
| 67 nav_observer.Wait(); | 66 nav_observer.Wait(); |
| 68 } | 67 } |
| 69 | 68 |
| 70 private: | 69 private: |
| 71 FrameTreeVisualizer visualizer_; | 70 FrameTreeVisualizer visualizer_; |
| 72 base::test::ScopedFeatureList scoped_feature_list_; | |
| 73 | 71 |
| 74 DISALLOW_COPY_AND_ASSIGN(TopDocumentIsolationTest); | 72 DISALLOW_COPY_AND_ASSIGN(TopDocumentIsolationTest); |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, SameSiteDeeplyNested) { | 75 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, SameSiteDeeplyNested) { |
| 78 if (content::AreAllSitesIsolatedForTesting()) | 76 if (content::AreAllSitesIsolatedForTesting()) |
| 79 return; // Top Document Isolation is disabled in this mode. | 77 return; // Top Document Isolation is disabled in this mode. |
| 80 | 78 |
| 81 GURL main_url(embedded_test_server()->GetURL( | 79 GURL main_url(embedded_test_server()->GetURL( |
| 82 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 80 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 " C = http://adnetwork.com/", | 605 " C = http://adnetwork.com/", |
| 608 DepictFrameTree(root())); | 606 DepictFrameTree(root())); |
| 609 EXPECT_EQ( | 607 EXPECT_EQ( |
| 610 " Site C ------------ proxies for B\n" | 608 " Site C ------------ proxies for B\n" |
| 611 "Where B = default subframe process\n" | 609 "Where B = default subframe process\n" |
| 612 " C = http://adnetwork.com/", | 610 " C = http://adnetwork.com/", |
| 613 DepictFrameTree(popup_root)); | 611 DepictFrameTree(popup_root)); |
| 614 } | 612 } |
| 615 | 613 |
| 616 } // namespace content | 614 } // namespace content |
| OLD | NEW |