OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/string16.h" | 5 #include "base/string16.h" |
6 #include "chrome/browser/browsing_instance.h" | 6 #include "chrome/browser/browsing_instance.h" |
7 #include "chrome/browser/child_process_security_policy.h" | 7 #include "chrome/browser/child_process_security_policy.h" |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 #include "chrome/browser/renderer_host/render_view_host.h" | 9 #include "chrome/browser/renderer_host/render_view_host.h" |
10 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 10 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
11 #include "chrome/browser/tab_contents/navigation_entry.h" | 11 #include "chrome/browser/tab_contents/navigation_entry.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Pages are irrelevant. | 217 // Pages are irrelevant. |
218 GURL test_url = GURL("http://www.google.com/index.html"); | 218 GURL test_url = GURL("http://www.google.com/index.html"); |
219 EXPECT_EQ(GURL("http://google.com"), SiteInstance::GetSiteForURL(test_url)); | 219 EXPECT_EQ(GURL("http://google.com"), SiteInstance::GetSiteForURL(test_url)); |
220 | 220 |
221 // Ports are irrlevant. | 221 // Ports are irrlevant. |
222 test_url = GURL("https://www.google.com:8080"); | 222 test_url = GURL("https://www.google.com:8080"); |
223 EXPECT_EQ(GURL("https://google.com"), SiteInstance::GetSiteForURL(test_url)); | 223 EXPECT_EQ(GURL("https://google.com"), SiteInstance::GetSiteForURL(test_url)); |
224 | 224 |
225 // Javascript URLs have no site. | 225 // Javascript URLs have no site. |
226 test_url = GURL("javascript:foo();"); | 226 test_url = GURL("javascript:foo();"); |
227 EXPECT_EQ(GURL::EmptyGURL(), SiteInstance::GetSiteForURL(test_url)); | 227 EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(test_url)); |
228 | 228 |
229 test_url = GURL("http://foo/a.html"); | 229 test_url = GURL("http://foo/a.html"); |
230 EXPECT_EQ(GURL("http://foo"), SiteInstance::GetSiteForURL(test_url)); | 230 EXPECT_EQ(GURL("http://foo"), SiteInstance::GetSiteForURL(test_url)); |
231 | 231 |
232 test_url = GURL("file:///C:/Downloads/"); | 232 test_url = GURL("file:///C:/Downloads/"); |
233 EXPECT_EQ(GURL::EmptyGURL(), SiteInstance::GetSiteForURL(test_url)); | 233 EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(test_url)); |
234 | 234 |
235 // TODO(creis): Do we want to special case file URLs to ensure they have | 235 // TODO(creis): Do we want to special case file URLs to ensure they have |
236 // either no site or a special "file://" site? We currently return | 236 // either no site or a special "file://" site? We currently return |
237 // "file://home/" as the site, which seems broken. | 237 // "file://home/" as the site, which seems broken. |
238 // test_url = GURL("file://home/"); | 238 // test_url = GURL("file://home/"); |
239 // EXPECT_EQ(GURL::EmptyGURL(), SiteInstance::GetSiteForURL(test_url)); | 239 // EXPECT_EQ(GURL(), SiteInstance::GetSiteForURL(test_url)); |
240 } | 240 } |
241 | 241 |
242 // Test of distinguishing URLs from different sites. Most of this logic is | 242 // Test of distinguishing URLs from different sites. Most of this logic is |
243 // tested in RegistryControlledDomainTest. This test focuses on URLs with | 243 // tested in RegistryControlledDomainTest. This test focuses on URLs with |
244 // different schemes or ports. | 244 // different schemes or ports. |
245 TEST_F(SiteInstanceTest, IsSameWebSite) { | 245 TEST_F(SiteInstanceTest, IsSameWebSite) { |
246 GURL url_foo = GURL("http://foo/a.html"); | 246 GURL url_foo = GURL("http://foo/a.html"); |
247 GURL url_foo2 = GURL("http://foo/b.html"); | 247 GURL url_foo2 = GURL("http://foo/b.html"); |
248 GURL url_foo_https = GURL("https://foo/a.html"); | 248 GURL url_foo_https = GURL("https://foo/a.html"); |
249 GURL url_foo_port = GURL("http://foo:8080/a.html"); | 249 GURL url_foo_port = GURL("http://foo:8080/a.html"); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 GURL("chrome-extension://baz/bar"))); | 518 GURL("chrome-extension://baz/bar"))); |
519 EXPECT_EQ(s5a, s5b); | 519 EXPECT_EQ(s5a, s5b); |
520 | 520 |
521 // The derived profiles with the different sites. | 521 // The derived profiles with the different sites. |
522 scoped_refptr<SiteInstance> s6a(instance1->GetSiteInstanceForURL( | 522 scoped_refptr<SiteInstance> s6a(instance1->GetSiteInstanceForURL( |
523 GURL("chrome-extension://baz/bar"))); | 523 GURL("chrome-extension://baz/bar"))); |
524 scoped_refptr<SiteInstance> s6b(instance3->GetSiteInstanceForURL( | 524 scoped_refptr<SiteInstance> s6b(instance3->GetSiteInstanceForURL( |
525 GURL("chrome-extension://foo/boo"))); | 525 GURL("chrome-extension://foo/boo"))); |
526 EXPECT_NE(s6a, s6b); | 526 EXPECT_NE(s6a, s6b); |
527 } | 527 } |
OLD | NEW |