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

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

Issue 2913443002: Fix scheme check in SiteInstance::IsSameWebSite for nested URLs. (Closed)
Patch Set: Nick's comments Created 3 years, 6 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
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/site_instance_impl.h" 5 #include "content/browser/site_instance_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 EXPECT_TRUE(instance->HasSite()); 787 EXPECT_TRUE(instance->HasSite());
788 EXPECT_TRUE(instance->GetSiteURL().is_empty()); 788 EXPECT_TRUE(instance->GetSiteURL().is_empty());
789 host.reset(instance->GetProcess()); 789 host.reset(instance->GetProcess());
790 790
791 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite( 791 EXPECT_FALSE(RenderProcessHostImpl::GetProcessHostForSite(
792 browser_context.get(), GURL())); 792 browser_context.get(), GURL()));
793 793
794 DrainMessageLoop(); 794 DrainMessageLoop();
795 } 795 }
796 796
797 // Check that an URL is considered same-site with blob: and filesystem: URLs
798 // with a matching inner origin. See https://crbug.com/726370.
799 TEST_F(SiteInstanceTest, IsSameWebsiteForNestedURLs) {
800 GURL foo_url("http://foo.com/");
801 GURL bar_url("http://bar.com/");
802 GURL blob_foo_url("blob:http://foo.com/uuid");
803 GURL blob_bar_url("blob:http://bar.com/uuid");
804 GURL fs_foo_url("filesystem:http://foo.com/path/");
805 GURL fs_bar_url("filesystem:http://bar.com/path/");
806
807 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, foo_url, blob_foo_url));
808 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, blob_foo_url, foo_url));
809 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, foo_url, blob_bar_url));
810 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, blob_foo_url, bar_url));
811
812 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, foo_url, fs_foo_url));
813 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, fs_foo_url, foo_url));
814 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, foo_url, fs_bar_url));
815 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, fs_foo_url, bar_url));
816
817 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, blob_foo_url, fs_foo_url));
818 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, blob_foo_url, fs_bar_url));
819 EXPECT_FALSE(
820 SiteInstance::IsSameWebSite(nullptr, blob_foo_url, blob_bar_url));
821 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, fs_foo_url, fs_bar_url));
822
823 // Verify that the scheme and ETLD+1 are used for comparison.
824 GURL www_bar_url("http://www.bar.com/");
825 GURL bar_org_url("http://bar.org/");
826 GURL https_bar_url("https://bar.com/");
827 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, www_bar_url, bar_url));
828 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, www_bar_url, blob_bar_url));
829 EXPECT_TRUE(SiteInstance::IsSameWebSite(nullptr, www_bar_url, fs_bar_url));
830 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, bar_org_url, bar_url));
831 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, bar_org_url, blob_bar_url));
832 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, bar_org_url, fs_bar_url));
833 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, https_bar_url, bar_url));
834 EXPECT_FALSE(
835 SiteInstance::IsSameWebSite(nullptr, https_bar_url, blob_bar_url));
836 EXPECT_FALSE(SiteInstance::IsSameWebSite(nullptr, https_bar_url, fs_bar_url));
837 }
838
797 TEST_F(SiteInstanceTest, DefaultSubframeSiteInstance) { 839 TEST_F(SiteInstanceTest, DefaultSubframeSiteInstance) {
798 if (AreAllSitesIsolatedForTesting()) 840 if (AreAllSitesIsolatedForTesting())
799 return; // --top-document-isolation is not possible. 841 return; // --top-document-isolation is not possible.
800 842
801 base::test::ScopedFeatureList scoped_feature_list; 843 base::test::ScopedFeatureList scoped_feature_list;
802 scoped_feature_list.InitAndEnableFeature(features::kTopDocumentIsolation); 844 scoped_feature_list.InitAndEnableFeature(features::kTopDocumentIsolation);
803 845
804 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); 846 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
805 scoped_refptr<SiteInstanceImpl> main_instance = 847 scoped_refptr<SiteInstanceImpl> main_instance =
806 SiteInstanceImpl::Create(browser_context.get()); 848 SiteInstanceImpl::Create(browser_context.get());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 nullptr, isolated_foo_url)); 945 nullptr, isolated_foo_url));
904 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess( 946 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
905 nullptr, isolated_bar_url)); 947 nullptr, isolated_bar_url));
906 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess( 948 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
907 nullptr, isolated_blob_foo_url)); 949 nullptr, isolated_blob_foo_url));
908 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess( 950 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
909 nullptr, isolated_filesystem_foo_url)); 951 nullptr, isolated_filesystem_foo_url));
910 } 952 }
911 953
912 } // namespace content 954 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_instance_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698