OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/child_process_security_policy.h" | 6 #include "chrome/browser/child_process_security_policy.h" |
7 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 7 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
8 #include "chrome/browser/renderer_host/render_view_host.h" | 8 #include "chrome/browser/renderer_host/render_view_host.h" |
9 #include "chrome/browser/renderer_host/test/test_render_view_host.h" | 9 #include "chrome/browser/renderer_host/test/test_render_view_host.h" |
10 #include "chrome/browser/tab_contents/navigation_entry.h" | 10 #include "chrome/browser/tab_contents/navigation_entry.h" |
11 #include "chrome/browser/tab_contents/tab_contents.h" | 11 #include "chrome/browser/tab_contents/tab_contents.h" |
12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/url_constants.h" |
13 #include "chrome/common/render_messages.h" | 14 #include "chrome/common/render_messages.h" |
14 #include "chrome/test/testing_profile.h" | 15 #include "chrome/test/testing_profile.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 class SiteInstanceTest : public testing::Test { | 18 class SiteInstanceTest : public testing::Test { |
18 private: | 19 private: |
19 MessageLoopForUI message_loop_; | 20 MessageLoopForUI message_loop_; |
20 }; | 21 }; |
21 | 22 |
22 namespace { | 23 namespace { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 240 |
240 // Test of distinguishing URLs from different sites. Most of this logic is | 241 // Test of distinguishing URLs from different sites. Most of this logic is |
241 // tested in RegistryControlledDomainTest. This test focuses on URLs with | 242 // tested in RegistryControlledDomainTest. This test focuses on URLs with |
242 // different schemes or ports. | 243 // different schemes or ports. |
243 TEST_F(SiteInstanceTest, IsSameWebSite) { | 244 TEST_F(SiteInstanceTest, IsSameWebSite) { |
244 GURL url_foo = GURL("http://foo/a.html"); | 245 GURL url_foo = GURL("http://foo/a.html"); |
245 GURL url_foo2 = GURL("http://foo/b.html"); | 246 GURL url_foo2 = GURL("http://foo/b.html"); |
246 GURL url_foo_https = GURL("https://foo/a.html"); | 247 GURL url_foo_https = GURL("https://foo/a.html"); |
247 GURL url_foo_port = GURL("http://foo:8080/a.html"); | 248 GURL url_foo_port = GURL("http://foo:8080/a.html"); |
248 GURL url_javascript = GURL("javascript:alert(1);"); | 249 GURL url_javascript = GURL("javascript:alert(1);"); |
249 GURL url_crash = GURL("about:crash"); | 250 GURL url_crash = GURL(chrome::kAboutCrashURL); |
250 GURL url_hang = GURL("about:hang"); | 251 GURL url_hang = GURL(chrome::kAboutHangURL); |
251 GURL url_shorthang = GURL("about:shorthang"); | 252 GURL url_shorthang = GURL(chrome::kAboutShorthangURL); |
252 | 253 |
253 // Same scheme and port -> same site. | 254 // Same scheme and port -> same site. |
254 EXPECT_TRUE(SiteInstance::IsSameWebSite(url_foo, url_foo2)); | 255 EXPECT_TRUE(SiteInstance::IsSameWebSite(url_foo, url_foo2)); |
255 | 256 |
256 // Different scheme -> different site. | 257 // Different scheme -> different site. |
257 EXPECT_FALSE(SiteInstance::IsSameWebSite(url_foo, url_foo_https)); | 258 EXPECT_FALSE(SiteInstance::IsSameWebSite(url_foo, url_foo_https)); |
258 | 259 |
259 // Different port -> same site. | 260 // Different port -> same site. |
260 // (Changes to document.domain make renderer ignore the port.) | 261 // (Changes to document.domain make renderer ignore the port.) |
261 EXPECT_TRUE(SiteInstance::IsSameWebSite(url_foo, url_foo_port)); | 262 EXPECT_TRUE(SiteInstance::IsSameWebSite(url_foo, url_foo_port)); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 // Make sure none of differing privilege processes are mixed. | 450 // Make sure none of differing privilege processes are mixed. |
450 EXPECT_NE(extension1_instance->GetProcess(), dom1_instance->GetProcess()); | 451 EXPECT_NE(extension1_instance->GetProcess(), dom1_instance->GetProcess()); |
451 | 452 |
452 for (size_t i = 0; i < chrome::kMaxRendererProcessCount; ++i) { | 453 for (size_t i = 0; i < chrome::kMaxRendererProcessCount; ++i) { |
453 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); | 454 EXPECT_NE(extension1_instance->GetProcess(), hosts[i]); |
454 EXPECT_NE(dom1_instance->GetProcess(), hosts[i]); | 455 EXPECT_NE(dom1_instance->GetProcess(), hosts[i]); |
455 } | 456 } |
456 | 457 |
457 STLDeleteContainerPointers(hosts.begin(), hosts.end()); | 458 STLDeleteContainerPointers(hosts.begin(), hosts.end()); |
458 } | 459 } |
OLD | NEW |