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

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: 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/");
ncarter (slow) 2017/05/31 17:32:54 This test maybe ought to exercise a case with www.
alexmos 2017/05/31 23:02:26 Done. Also added a case to make sure the inner sc
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
797 TEST_F(SiteInstanceTest, DefaultSubframeSiteInstance) { 824 TEST_F(SiteInstanceTest, DefaultSubframeSiteInstance) {
798 if (AreAllSitesIsolatedForTesting()) 825 if (AreAllSitesIsolatedForTesting())
799 return; // --top-document-isolation is not possible. 826 return; // --top-document-isolation is not possible.
800 827
801 base::test::ScopedFeatureList scoped_feature_list; 828 base::test::ScopedFeatureList scoped_feature_list;
802 scoped_feature_list.InitAndEnableFeature(features::kTopDocumentIsolation); 829 scoped_feature_list.InitAndEnableFeature(features::kTopDocumentIsolation);
803 830
804 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext()); 831 std::unique_ptr<TestBrowserContext> browser_context(new TestBrowserContext());
805 scoped_refptr<SiteInstanceImpl> main_instance = 832 scoped_refptr<SiteInstanceImpl> main_instance =
806 SiteInstanceImpl::Create(browser_context.get()); 833 SiteInstanceImpl::Create(browser_context.get());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 nullptr, isolated_foo_url)); 930 nullptr, isolated_foo_url));
904 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess( 931 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
905 nullptr, isolated_bar_url)); 932 nullptr, isolated_bar_url));
906 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess( 933 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
907 nullptr, isolated_blob_foo_url)); 934 nullptr, isolated_blob_foo_url));
908 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess( 935 EXPECT_TRUE(SiteInstanceImpl::DoesSiteRequireDedicatedProcess(
909 nullptr, isolated_filesystem_foo_url)); 936 nullptr, isolated_filesystem_foo_url));
910 } 937 }
911 938
912 } // namespace content 939 } // 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