| 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 "build/build_config.h" | 8 #include "build/build_config.h" |
| 10 #include "content/browser/frame_host/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
| 11 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| 12 #include "content/public/common/content_features.h" | 11 #include "content/public/common/content_features.h" |
| 13 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
| 14 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
| 15 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
| 16 #include "content/public/test/test_frame_navigation_observer.h" | 15 #include "content/public/test/test_frame_navigation_observer.h" |
| 17 #include "content/public/test/test_navigation_observer.h" | 16 #include "content/public/test/test_navigation_observer.h" |
| 18 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
| 19 #include "content/test/content_browser_test_utils_internal.h" | 18 #include "content/test/content_browser_test_utils_internal.h" |
| 20 #include "net/dns/mock_host_resolver.h" | 19 #include "net/dns/mock_host_resolver.h" |
| 21 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 22 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 23 | 22 |
| 24 namespace content { | 23 namespace content { |
| 25 | 24 |
| 26 class TopDocumentIsolationTest : public ContentBrowserTest { | 25 class TopDocumentIsolationTest : public ContentBrowserTest { |
| 27 public: | 26 public: |
| 28 TopDocumentIsolationTest() {} | 27 TopDocumentIsolationTest() {} |
| 29 | 28 |
| 30 protected: | 29 protected: |
| 31 std::string DepictFrameTree(FrameTreeNode* node) { | 30 std::string DepictFrameTree(FrameTreeNode* node) { |
| 32 return visualizer_.DepictFrameTree(node); | 31 return visualizer_.DepictFrameTree(node); |
| 33 } | 32 } |
| 34 | 33 |
| 35 void SetUp() override { | 34 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 36 scoped_feature_list_.InitAndEnableFeature(features::kTopDocumentIsolation); | 35 ContentBrowserTest::SetUpCommandLine(command_line); |
| 37 ContentBrowserTest::SetUp(); | 36 content::EnableTopDocumentIsolationForTesting(command_line); |
| 38 } | 37 } |
| 39 | 38 |
| 40 void SetUpOnMainThread() override { | 39 void SetUpOnMainThread() override { |
| 41 host_resolver()->AddRule("*", "127.0.0.1"); | 40 host_resolver()->AddRule("*", "127.0.0.1"); |
| 42 SetupCrossSiteRedirector(embedded_test_server()); | 41 SetupCrossSiteRedirector(embedded_test_server()); |
| 43 ASSERT_TRUE(embedded_test_server()->Start()); | 42 ASSERT_TRUE(embedded_test_server()->Start()); |
| 44 } | 43 } |
| 45 | 44 |
| 46 FrameTreeNode* root() { | 45 FrameTreeNode* root() { |
| 47 return static_cast<WebContentsImpl*>(shell()->web_contents()) | 46 return static_cast<WebContentsImpl*>(shell()->web_contents()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 63 | 62 |
| 64 void RendererInitiatedNavigateToURL(FrameTreeNode* node, const GURL& url) { | 63 void RendererInitiatedNavigateToURL(FrameTreeNode* node, const GURL& url) { |
| 65 TestFrameNavigationObserver nav_observer(node); | 64 TestFrameNavigationObserver nav_observer(node); |
| 66 ASSERT_TRUE( | 65 ASSERT_TRUE( |
| 67 ExecuteScript(node, "window.location.href='" + url.spec() + "'")); | 66 ExecuteScript(node, "window.location.href='" + url.spec() + "'")); |
| 68 nav_observer.Wait(); | 67 nav_observer.Wait(); |
| 69 } | 68 } |
| 70 | 69 |
| 71 private: | 70 private: |
| 72 FrameTreeVisualizer visualizer_; | 71 FrameTreeVisualizer visualizer_; |
| 73 base::test::ScopedFeatureList scoped_feature_list_; | |
| 74 | 72 |
| 75 DISALLOW_COPY_AND_ASSIGN(TopDocumentIsolationTest); | 73 DISALLOW_COPY_AND_ASSIGN(TopDocumentIsolationTest); |
| 76 }; | 74 }; |
| 77 | 75 |
| 78 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, SameSiteDeeplyNested) { | 76 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, SameSiteDeeplyNested) { |
| 79 if (content::AreAllSitesIsolatedForTesting()) | 77 if (content::AreAllSitesIsolatedForTesting()) |
| 80 return; // Top Document Isolation is disabled in this mode. | 78 return; // Top Document Isolation is disabled in this mode. |
| 81 | 79 |
| 82 GURL main_url(embedded_test_server()->GetURL( | 80 GURL main_url(embedded_test_server()->GetURL( |
| 83 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); | 81 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 " C = http://adnetwork.com/", | 633 " C = http://adnetwork.com/", |
| 636 DepictFrameTree(root())); | 634 DepictFrameTree(root())); |
| 637 EXPECT_EQ( | 635 EXPECT_EQ( |
| 638 " Site C ------------ proxies for B\n" | 636 " Site C ------------ proxies for B\n" |
| 639 "Where B = default subframe process\n" | 637 "Where B = default subframe process\n" |
| 640 " C = http://adnetwork.com/", | 638 " C = http://adnetwork.com/", |
| 641 DepictFrameTree(popup_root)); | 639 DepictFrameTree(popup_root)); |
| 642 } | 640 } |
| 643 | 641 |
| 644 } // namespace content | 642 } // namespace content |
| OLD | NEW |