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

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: Fix up tests. Necessary rebase to obtain browsertest util behavior change. 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 982 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 SiteInstanceDescriptor descriptor(unrelated_instance.get()); 1040 SiteInstanceDescriptor descriptor(unrelated_instance.get());
1042 SiteInstance* converted_instance = 1041 SiteInstance* converted_instance =
1043 ConvertToSiteInstance(rfhm, descriptor, nullptr); 1042 ConvertToSiteInstance(rfhm, descriptor, nullptr);
1044 EXPECT_EQ(unrelated_instance.get(), converted_instance); 1043 EXPECT_EQ(unrelated_instance.get(), converted_instance);
1045 } 1044 }
1046 1045
1047 // 3) Convert a descriptor of a related instance with the same site as the 1046 // 3) Convert a descriptor of a related instance with the same site as the
1048 // current one. 1047 // current one.
1049 GURL kUrlSameSiteAs1("http://www.a.com/foo"); 1048 GURL kUrlSameSiteAs1("http://www.a.com/foo");
1050 { 1049 {
1051 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1, true); 1050 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1,
1051 SiteInstanceRelation::RELATED);
1052 SiteInstance* converted_instance = 1052 SiteInstance* converted_instance =
1053 ConvertToSiteInstance(rfhm, descriptor, nullptr); 1053 ConvertToSiteInstance(rfhm, descriptor, nullptr);
1054 EXPECT_EQ(current_instance, converted_instance); 1054 EXPECT_EQ(current_instance, converted_instance);
1055 } 1055 }
1056 1056
1057 // 4) Convert a descriptor of a related instance with a site different from 1057 // 4) Convert a descriptor of a related instance with a site different from
1058 // the current one. 1058 // the current one.
1059 GURL kUrlSameSiteAs2("http://www.b.com/foo"); 1059 GURL kUrlSameSiteAs2("http://www.b.com/foo");
1060 scoped_refptr<SiteInstance> related_instance; 1060 scoped_refptr<SiteInstance> related_instance;
1061 { 1061 {
1062 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2, true); 1062 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2,
1063 SiteInstanceRelation::RELATED);
1063 related_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr); 1064 related_instance = ConvertToSiteInstance(rfhm, descriptor, nullptr);
1064 // Should return a new instance, related to the current, set to the new site 1065 // Should return a new instance, related to the current, set to the new site
1065 // URL. 1066 // URL.
1066 EXPECT_TRUE( 1067 EXPECT_TRUE(
1067 current_instance->IsRelatedSiteInstance(related_instance.get())); 1068 current_instance->IsRelatedSiteInstance(related_instance.get()));
1068 EXPECT_NE(current_instance, related_instance.get()); 1069 EXPECT_NE(current_instance, related_instance.get());
1069 EXPECT_NE(unrelated_instance.get(), related_instance.get()); 1070 EXPECT_NE(unrelated_instance.get(), related_instance.get());
1070 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2), 1071 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2),
1071 related_instance->GetSiteURL()); 1072 related_instance->GetSiteURL());
1072 } 1073 }
1073 1074
1074 // 5) Convert a descriptor of an unrelated instance with the same site as the 1075 // 5) Convert a descriptor of an unrelated instance with the same site as the
1075 // current one, several times, with and without candidate sites. 1076 // current one, several times, with and without candidate sites.
1076 { 1077 {
1077 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1, 1078 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs1,
1078 false); 1079 SiteInstanceRelation::UNRELATED);
1079 scoped_refptr<SiteInstance> converted_instance_1 = 1080 scoped_refptr<SiteInstance> converted_instance_1 =
1080 ConvertToSiteInstance(rfhm, descriptor, nullptr); 1081 ConvertToSiteInstance(rfhm, descriptor, nullptr);
1081 // Should return a new instance, unrelated to the current one, set to the 1082 // Should return a new instance, unrelated to the current one, set to the
1082 // provided site URL. 1083 // provided site URL.
1083 EXPECT_FALSE( 1084 EXPECT_FALSE(
1084 current_instance->IsRelatedSiteInstance(converted_instance_1.get())); 1085 current_instance->IsRelatedSiteInstance(converted_instance_1.get()));
1085 EXPECT_NE(current_instance, converted_instance_1.get()); 1086 EXPECT_NE(current_instance, converted_instance_1.get());
1086 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get()); 1087 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get());
1087 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs1), 1088 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs1),
1088 converted_instance_1->GetSiteURL()); 1089 converted_instance_1->GetSiteURL());
(...skipping 17 matching lines...) Expand all
1106 ConvertToSiteInstance(rfhm, descriptor, converted_instance_1.get()); 1107 ConvertToSiteInstance(rfhm, descriptor, converted_instance_1.get());
1107 // Should return |converted_instance_1| because its site matches and it is 1108 // Should return |converted_instance_1| because its site matches and it is
1108 // unrelated to the current SiteInstance. 1109 // unrelated to the current SiteInstance.
1109 EXPECT_EQ(converted_instance_1.get(), converted_instance_3); 1110 EXPECT_EQ(converted_instance_1.get(), converted_instance_3);
1110 } 1111 }
1111 1112
1112 // 6) Convert a descriptor of an unrelated instance with the same site of 1113 // 6) Convert a descriptor of an unrelated instance with the same site of
1113 // related_instance and using it as a candidate. 1114 // related_instance and using it as a candidate.
1114 { 1115 {
1115 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2, 1116 SiteInstanceDescriptor descriptor(browser_context(), kUrlSameSiteAs2,
1116 false); 1117 SiteInstanceRelation::UNRELATED);
1117 scoped_refptr<SiteInstance> converted_instance_1 = 1118 scoped_refptr<SiteInstance> converted_instance_1 =
1118 ConvertToSiteInstance(rfhm, descriptor, related_instance.get()); 1119 ConvertToSiteInstance(rfhm, descriptor, related_instance.get());
1119 // Should return a new instance, unrelated to the current, set to the 1120 // Should return a new instance, unrelated to the current, set to the
1120 // provided site URL. 1121 // provided site URL.
1121 EXPECT_FALSE( 1122 EXPECT_FALSE(
1122 current_instance->IsRelatedSiteInstance(converted_instance_1.get())); 1123 current_instance->IsRelatedSiteInstance(converted_instance_1.get()));
1123 EXPECT_NE(related_instance.get(), converted_instance_1.get()); 1124 EXPECT_NE(related_instance.get(), converted_instance_1.get());
1124 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get()); 1125 EXPECT_NE(unrelated_instance.get(), converted_instance_1.get());
1125 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2), 1126 EXPECT_EQ(SiteInstance::GetSiteForURL(browser_context(), kUrlSameSiteAs2),
1126 converted_instance_1->GetSiteURL()); 1127 converted_instance_1->GetSiteURL());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 main_test_rfh()->PrepareForCommit(); 1159 main_test_rfh()->PrepareForCommit();
1159 1160
1160 // Claim that the navigation was within same page. 1161 // Claim that the navigation was within same page.
1161 int bad_msg_count = process()->bad_msg_count(); 1162 int bad_msg_count = process()->bad_msg_count();
1162 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback( 1163 GetSpeculativeRenderFrameHost(node)->SendNavigateWithModificationCallback(
1163 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1)); 1164 0, entry_id, true, kUrl2, base::Bind(SetWithinPage, kUrl1));
1164 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1); 1165 EXPECT_EQ(process()->bad_msg_count(), bad_msg_count + 1);
1165 } 1166 }
1166 1167
1167 } // namespace content 1168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698