OLD | NEW |
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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
7 #include "base/string16.h" | 7 #include "base/string16.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/browsing_instance.h" | 9 #include "content/browser/browsing_instance.h" |
10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
11 #include "content/browser/mock_content_browser_client.h" | 11 #include "content/browser/mock_content_browser_client.h" |
| 12 #include "content/browser/renderer_host/mock_render_process_host.h" |
12 #include "content/browser/renderer_host/render_process_host_impl.h" | 13 #include "content/browser/renderer_host/render_process_host_impl.h" |
13 #include "content/browser/renderer_host/render_view_host_impl.h" | 14 #include "content/browser/renderer_host/render_view_host_impl.h" |
14 #include "content/browser/renderer_host/test_render_view_host.h" | 15 #include "content/browser/renderer_host/test_render_view_host.h" |
15 #include "content/browser/site_instance_impl.h" | 16 #include "content/browser/site_instance_impl.h" |
16 #include "content/browser/tab_contents/navigation_entry_impl.h" | 17 #include "content/browser/tab_contents/navigation_entry_impl.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/public/browser/web_ui_controller_factory.h" | 19 #include "content/public/browser/web_ui_controller_factory.h" |
19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
20 #include "content/public/common/content_constants.h" | 21 #include "content/public/common/content_constants.h" |
21 #include "content/public/common/url_constants.h" | 22 #include "content/public/common/url_constants.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 (*delete_counter_)++; | 183 (*delete_counter_)++; |
183 } | 184 } |
184 | 185 |
185 int* delete_counter_; | 186 int* delete_counter_; |
186 }; | 187 }; |
187 | 188 |
188 } // namespace | 189 } // namespace |
189 | 190 |
190 // Test to ensure no memory leaks for SiteInstance objects. | 191 // Test to ensure no memory leaks for SiteInstance objects. |
191 TEST_F(SiteInstanceTest, SiteInstanceDestructor) { | 192 TEST_F(SiteInstanceTest, SiteInstanceDestructor) { |
192 // The existence of these factories will cause TabContents to create our test | 193 // The existence of this object will cause TabContents to create our |
193 // one instead of the real one. | 194 // test one instead of the real one. |
194 MockRenderProcessHostFactory rph_factory; | 195 content::RenderViewHostTestEnabler rvh_test_enabler; |
195 TestRenderViewHostFactory rvh_factory(&rph_factory); | |
196 int site_delete_counter = 0; | 196 int site_delete_counter = 0; |
197 int browsing_delete_counter = 0; | 197 int browsing_delete_counter = 0; |
198 const GURL url("test:foo"); | 198 const GURL url("test:foo"); |
199 | 199 |
200 // Ensure that instances are deleted when their NavigationEntries are gone. | 200 // Ensure that instances are deleted when their NavigationEntries are gone. |
201 TestSiteInstance* instance = | 201 TestSiteInstance* instance = |
202 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter, | 202 TestSiteInstance::CreateTestSiteInstance(NULL, &site_delete_counter, |
203 &browsing_delete_counter); | 203 &browsing_delete_counter); |
204 EXPECT_EQ(0, site_delete_counter); | 204 EXPECT_EQ(0, site_delete_counter); |
205 | 205 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 host.reset(instance->GetProcess()); | 598 host.reset(instance->GetProcess()); |
599 EXPECT_TRUE(host.get() != NULL); | 599 EXPECT_TRUE(host.get() != NULL); |
600 EXPECT_TRUE(instance->HasProcess()); | 600 EXPECT_TRUE(instance->HasProcess()); |
601 | 601 |
602 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 602 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
603 EXPECT_FALSE(instance->HasWrongProcessForURL( | 603 EXPECT_FALSE(instance->HasWrongProcessForURL( |
604 GURL("javascript:alert(document.location.href);"))); | 604 GURL("javascript:alert(document.location.href);"))); |
605 | 605 |
606 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 606 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
607 } | 607 } |
OLD | NEW |