Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/browser/top_document_isolation_browsertest.cc

Issue 2987563004: Revert of Use FrameIsAd to decide whether to isolate a frame in TopDocumentIsolation mode. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
8 #include "build/build_config.h" 9 #include "build/build_config.h"
9 #include "content/browser/frame_host/frame_tree_node.h" 10 #include "content/browser/frame_host/frame_tree_node.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
11 #include "content/public/common/content_features.h" 12 #include "content/public/common/content_features.h"
12 #include "content/public/test/browser_test_utils.h" 13 #include "content/public/test/browser_test_utils.h"
13 #include "content/public/test/content_browser_test.h" 14 #include "content/public/test/content_browser_test.h"
14 #include "content/public/test/content_browser_test_utils.h" 15 #include "content/public/test/content_browser_test_utils.h"
15 #include "content/public/test/test_frame_navigation_observer.h" 16 #include "content/public/test/test_frame_navigation_observer.h"
16 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
17 #include "content/shell/browser/shell.h" 18 #include "content/shell/browser/shell.h"
18 #include "content/test/content_browser_test_utils_internal.h" 19 #include "content/test/content_browser_test_utils_internal.h"
19 #include "net/dns/mock_host_resolver.h" 20 #include "net/dns/mock_host_resolver.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h" 21 #include "net/test/embedded_test_server/embedded_test_server.h"
21 #include "url/gurl.h" 22 #include "url/gurl.h"
22 23
23 namespace content { 24 namespace content {
24 25
25 class TopDocumentIsolationTest : public ContentBrowserTest { 26 class TopDocumentIsolationTest : public ContentBrowserTest {
26 public: 27 public:
27 TopDocumentIsolationTest() {} 28 TopDocumentIsolationTest() {}
28 29
29 protected: 30 protected:
30 std::string DepictFrameTree(FrameTreeNode* node) { 31 std::string DepictFrameTree(FrameTreeNode* node) {
31 return visualizer_.DepictFrameTree(node); 32 return visualizer_.DepictFrameTree(node);
32 } 33 }
33 34
34 void SetUpCommandLine(base::CommandLine* command_line) override { 35 void SetUp() override {
35 ContentBrowserTest::SetUpCommandLine(command_line); 36 scoped_feature_list_.InitAndEnableFeature(features::kTopDocumentIsolation);
36 content::EnableTopDocumentIsolationForTesting(command_line); 37 ContentBrowserTest::SetUp();
37 } 38 }
38 39
39 void SetUpOnMainThread() override { 40 void SetUpOnMainThread() override {
40 host_resolver()->AddRule("*", "127.0.0.1"); 41 host_resolver()->AddRule("*", "127.0.0.1");
41 SetupCrossSiteRedirector(embedded_test_server()); 42 SetupCrossSiteRedirector(embedded_test_server());
42 ASSERT_TRUE(embedded_test_server()->Start()); 43 ASSERT_TRUE(embedded_test_server()->Start());
43 } 44 }
44 45
45 FrameTreeNode* root() { 46 FrameTreeNode* root() {
46 return static_cast<WebContentsImpl*>(shell()->web_contents()) 47 return static_cast<WebContentsImpl*>(shell()->web_contents())
(...skipping 15 matching lines...) Expand all
62 63
63 void RendererInitiatedNavigateToURL(FrameTreeNode* node, const GURL& url) { 64 void RendererInitiatedNavigateToURL(FrameTreeNode* node, const GURL& url) {
64 TestFrameNavigationObserver nav_observer(node); 65 TestFrameNavigationObserver nav_observer(node);
65 ASSERT_TRUE( 66 ASSERT_TRUE(
66 ExecuteScript(node, "window.location.href='" + url.spec() + "'")); 67 ExecuteScript(node, "window.location.href='" + url.spec() + "'"));
67 nav_observer.Wait(); 68 nav_observer.Wait();
68 } 69 }
69 70
70 private: 71 private:
71 FrameTreeVisualizer visualizer_; 72 FrameTreeVisualizer visualizer_;
73 base::test::ScopedFeatureList scoped_feature_list_;
72 74
73 DISALLOW_COPY_AND_ASSIGN(TopDocumentIsolationTest); 75 DISALLOW_COPY_AND_ASSIGN(TopDocumentIsolationTest);
74 }; 76 };
75 77
76 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, SameSiteDeeplyNested) { 78 IN_PROC_BROWSER_TEST_F(TopDocumentIsolationTest, SameSiteDeeplyNested) {
77 if (content::AreAllSitesIsolatedForTesting()) 79 if (content::AreAllSitesIsolatedForTesting())
78 return; // Top Document Isolation is disabled in this mode. 80 return; // Top Document Isolation is disabled in this mode.
79 81
80 GURL main_url(embedded_test_server()->GetURL( 82 GURL main_url(embedded_test_server()->GetURL(
81 "a.com", "/cross_site_iframe_factory.html?a(a,a(a,a(a)))")); 83 "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
633 " C = http://adnetwork.com/", 635 " C = http://adnetwork.com/",
634 DepictFrameTree(root())); 636 DepictFrameTree(root()));
635 EXPECT_EQ( 637 EXPECT_EQ(
636 " Site C ------------ proxies for B\n" 638 " Site C ------------ proxies for B\n"
637 "Where B = default subframe process\n" 639 "Where B = default subframe process\n"
638 " C = http://adnetwork.com/", 640 " C = http://adnetwork.com/",
639 DepictFrameTree(popup_root)); 641 DepictFrameTree(popup_root));
640 } 642 }
641 643
642 } // namespace content 644 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager.cc ('k') | content/public/browser/content_browser_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698