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

Side by Side Diff: content/browser/frame_host/navigator_impl_unittest.cc

Issue 1797363002: "Top Document Isolation" mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Suppress tests under --site-per-process Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigation_controller_impl.h"
(...skipping 25 matching lines...) Expand all
36 36
37 #if !defined(OS_ANDROID) 37 #if !defined(OS_ANDROID)
38 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " 38 #include "content/browser/compositor/test/no_transport_image_transport_factory.h "
39 #endif 39 #endif
40 40
41 namespace content { 41 namespace content {
42 42
43 class NavigatorTestWithBrowserSideNavigation 43 class NavigatorTestWithBrowserSideNavigation
44 : public RenderViewHostImplTestHarness { 44 : public RenderViewHostImplTestHarness {
45 public: 45 public:
46 // Re-defines the private RenderFrameHostManager::SiteInstanceDescriptor here 46 using SiteInstanceDescriptor = RenderFrameHostManager::SiteInstanceDescriptor;
47 // to allow access to it from tests. 47 using SiteInstanceRelation = RenderFrameHostManager::SiteInstanceRelation;
48 typedef RenderFrameHostManager::SiteInstanceDescriptor SiteInstanceDescriptor;
49 48
50 void SetUp() override { 49 void SetUp() override {
51 #if !defined(OS_ANDROID) 50 #if !defined(OS_ANDROID)
52 ImageTransportFactory::InitializeForUnitTests( 51 ImageTransportFactory::InitializeForUnitTests(
53 scoped_ptr<ImageTransportFactory>( 52 scoped_ptr<ImageTransportFactory>(
54 new NoTransportImageTransportFactory)); 53 new NoTransportImageTransportFactory));
55 #endif 54 #endif
56 EnableBrowserSideNavigation(); 55 EnableBrowserSideNavigation();
57 RenderViewHostImplTestHarness::SetUp(); 56 RenderViewHostImplTestHarness::SetUp();
58 } 57 }
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 SiteInstanceDescriptor descriptor(unrelated_instance.get()); 1041 SiteInstanceDescriptor descriptor(unrelated_instance.get());
1043 scoped_refptr<SiteInstance> converted_instance = 1042 scoped_refptr<SiteInstance> converted_instance =
1044 ConvertToSiteInstance(rfhm, descriptor, nullptr); 1043 ConvertToSiteInstance(rfhm, descriptor, nullptr);
1045 EXPECT_EQ(unrelated_instance.get(), converted_instance); 1044 EXPECT_EQ(unrelated_instance.get(), converted_instance);
1046 } 1045 }
1047 1046
1048 // 3) Convert a descriptor of a related instance with the same site as the 1047 // 3) Convert a descriptor of a related instance with the same site as the
1049 // current one. 1048 // current one.
1050 GURL kUrlSameSiteAs1("http://www.a.com/foo"); 1049 GURL kUrlSameSiteAs1("http://www.a.com/foo");
1051 { 1050 {
1052 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1, true); 1051 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1,
1052 SiteInstanceRelation::RELATED);
1053 scoped_refptr<SiteInstance> converted_instance = 1053 scoped_refptr<SiteInstance> converted_instance =
1054 ConvertToSiteInstance(rfhm, descriptor, nullptr); 1054 ConvertToSiteInstance(rfhm, descriptor, nullptr);
1055 EXPECT_EQ(current_instance, converted_instance); 1055 EXPECT_EQ(current_instance, converted_instance);
1056 } 1056 }
1057 1057
1058 // 4) Convert a descriptor of a related instance with a site different from 1058 // 4) Convert a descriptor of a related instance with a site different from
1059 // the current one. 1059 // the current one.
1060 GURL kUrlSameSiteAs2("http://www.b.com/foo"); 1060 GURL kUrlSameSiteAs2("http://www.b.com/foo");
1061 scoped_refptr<SiteInstance> related_instance; 1061 scoped_refptr<SiteInstance> related_instance;
1062 { 1062 {
1063 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2, true); 1063 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2,
1064 SiteInstanceRelation::RELATED);
1064 related_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr); 1065 related_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr);
1065 // Should return a new instance, related to the current, set to the new site 1066 // Should return a new instance, related to the current, set to the new site
1066 // URL. 1067 // URL.
1067 EXPECT_TRUE( 1068 EXPECT_TRUE(
1068 current_instance->IsRelatedSiteInstance(related_instance.get())); 1069 current_instance->IsRelatedSiteInstance(related_instance.get()));
1069 EXPECT_NE(current_instance, related_instance.get()); 1070 EXPECT_NE(current_instance, related_instance.get());
1070 EXPECT_NE(unrelated_instance.get(), related_instance.get()); 1071 EXPECT_NE(unrelated_instance.get(), related_instance.get());
1071 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2), 1072 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2),
1072 related_instance->GetSiteURL()); 1073 related_instance->GetSiteURL());
1073 } 1074 }
1074 1075
1075 // 5) Convert a descriptor of an unrelated instance with the same site as the 1076 // 5) Convert a descriptor of an unrelated instance with the same site as the
1076 // current one, several times, with and without candidate sites. 1077 // current one, several times, with and without candidate sites.
1077 { 1078 {
1078 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1, 1079 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1,
1079 false); 1080 SiteInstanceRelation::UNRELATED);
1080 scoped_refptr<SiteInstance> converted_instance_1 = 1081 scoped_refptr<SiteInstance> converted_instance_1 =
1081 ConvertToSiteInstance(rfhm, descriptor, nullptr); 1082 ConvertToSiteInstance(rfhm, descriptor, nullptr);
1082 // Should return a new instance, unrelated to the current one, set to the 1083 // Should return a new instance, unrelated to the current one, set to the
1083 // provided site URL. 1084 // provided site URL.
1084 EXPECT_FALSE( 1085 EXPECT_FALSE(
1085 current_instance->IsRelatedSiteInstance(converted_instance_1.get())); 1086 current_instance->IsRelatedSiteInstance(converted_instance_1.get()));
1086 EXPECT_NE(current_instance, converted_instance_1.get()); 1087 EXPECT_NE(current_instance, converted_instance_1.get());
1087 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get()); 1088 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get());
1088 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs1), 1089 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs1),
1089 converted_instance_1->GetSiteURL()); 1090 converted_instance_1->GetSiteURL());
(...skipping 17 matching lines...) Expand all
1107 ConvertToSiteInstance(rfhm, descriptor, converted_instance_1.get()); 1108 ConvertToSiteInstance(rfhm, descriptor, converted_instance_1.get());
1108 // Should return |converted_instance_1| because its site matches and it is 1109 // Should return |converted_instance_1| because its site matches and it is
1109 // unrelated to the current SiteInstance. 1110 // unrelated to the current SiteInstance.
1110 EXPECT_EQ(converted_instance_1.get(), converted_instance_3); 1111 EXPECT_EQ(converted_instance_1.get(), converted_instance_3);
1111 } 1112 }
1112 1113
1113 // 6) Convert a descriptor of an unrelated instance with the same site of 1114 // 6) Convert a descriptor of an unrelated instance with the same site of
1114 // related_instance and using it as a candidate. 1115 // related_instance and using it as a candidate.
1115 { 1116 {
1116 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2, 1117 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2,
1117 false); 1118 SiteInstanceRelation::UNRELATED);
1118 scoped_refptr<SiteInstance> converted_instance_1 = 1119 scoped_refptr<SiteInstance> converted_instance_1 =
1119 ConvertToSiteInstance(rfhm, descriptor, related_instance.get()); 1120 ConvertToSiteInstance(rfhm, descriptor, related_instance.get());
1120 // Should return a new instance, unrelated to the current, set to the 1121 // Should return a new instance, unrelated to the current, set to the
1121 // provided site URL. 1122 // provided site URL.
1122 EXPECT_FALSE( 1123 EXPECT_FALSE(
1123 current_instance->IsRelatedSiteInstance(converted_instance_1.get())); 1124 current_instance->IsRelatedSiteInstance(converted_instance_1.get()));
1124 EXPECT_NE(related_instance.get(), converted_instance_1.get()); 1125 EXPECT_NE(related_instance.get(), converted_instance_1.get());
1125 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get()); 1126 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get());
1126 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2), 1127 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2),
1127 converted_instance_1->GetSiteURL()); 1128 converted_instance_1->GetSiteURL());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 main_test_rfh()->PrepareForCommit(); 1160 main_test_rfh()->PrepareForCommit();
1160 1161
1161 // Claim that the navigation was within same page. 1162 // Claim that the navigation was within same page.
1162 int bad_msg_count = process()->bad_msg_count(); 1163 int bad_msg_count = process()->bad_msg_count();
1163 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback( 1164 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback(
1164 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1)); 1165 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1));
1165 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1); 1166 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1);
1166 } 1167 }
1167 1168
1168 } // namespace content 1169 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browsing_instance.cc ('k') | content/browser/frame_host/render_frame_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698