| 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/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
| 10 #include "content/browser/browsing_instance.h" | 10 #include "content/browser/browsing_instance.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 class SiteInstanceTestClient : public TestContentClient { | 75 class SiteInstanceTestClient : public TestContentClient { |
| 76 public: | 76 public: |
| 77 SiteInstanceTestClient() { | 77 SiteInstanceTestClient() { |
| 78 } | 78 } |
| 79 | 79 |
| 80 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { | 80 virtual bool HasWebUIScheme(const GURL& url) const OVERRIDE { |
| 81 return url.SchemeIs(chrome::kChromeUIScheme); | 81 return url.SchemeIs(chrome::kChromeUIScheme); |
| 82 } | 82 } |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 class SiteInstanceTestBrowserClient : | 85 class SiteInstanceTestBrowserClient : public content::TestContentBrowserClient { |
| 86 public content::TestContentBrowserClient { | |
| 87 public: | 86 public: |
| 88 SiteInstanceTestBrowserClient() | 87 SiteInstanceTestBrowserClient() |
| 89 : privileged_process_id_(-1) { | 88 : privileged_process_id_(-1) { |
| 90 } | 89 } |
| 91 | 90 |
| 92 virtual content::WebUIControllerFactory* | 91 virtual content::WebUIControllerFactory* |
| 93 GetWebUIControllerFactory() OVERRIDE { | 92 GetWebUIControllerFactory() OVERRIDE { |
| 94 return &factory_; | 93 return &factory_; |
| 95 } | 94 } |
| 96 | 95 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 url_util::AddStandardScheme(kPrivilegedScheme); | 127 url_util::AddStandardScheme(kPrivilegedScheme); |
| 129 url_util::AddStandardScheme(chrome::kChromeUIScheme); | 128 url_util::AddStandardScheme(chrome::kChromeUIScheme); |
| 130 } | 129 } |
| 131 | 130 |
| 132 virtual void TearDown() { | 131 virtual void TearDown() { |
| 133 // Ensure that no RenderProcessHosts are left over after the tests. | 132 // Ensure that no RenderProcessHosts are left over after the tests. |
| 134 EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd()); | 133 EXPECT_TRUE(content::RenderProcessHost::AllHostsIterator().IsAtEnd()); |
| 135 | 134 |
| 136 content::GetContentClient()->set_browser_for_testing(old_browser_client_); | 135 content::GetContentClient()->set_browser_for_testing(old_browser_client_); |
| 137 content::SetContentClient(old_client_); | 136 content::SetContentClient(old_client_); |
| 137 |
| 138 // http://crbug.com/143565 found SiteInstanceTest leaking an |
| 139 // AppCacheDatabase. This happens because some part of the test indirectly |
| 140 // calls StoragePartitionImplMap::PostCreateInitialization(), which posts |
| 141 // a task to the IO thread to create the AppCacheDatabase. Since the |
| 142 // message loop is not running, the AppCacheDatabase ends up getting |
| 143 // created when DrainMessageLoops() gets called at the end of a test case. |
| 144 // Immediately after, the test case ends and the AppCacheDatabase gets |
| 145 // scheduled for deletion. Here, call DrainMessageLoops() again so the |
| 146 // AppCacheDatabase actually gets deleted. |
| 147 DrainMessageLoops(); |
| 138 } | 148 } |
| 139 | 149 |
| 140 void set_privileged_process_id(int process_id) { | 150 void set_privileged_process_id(int process_id) { |
| 141 browser_client_.set_privileged_process_id(process_id); | 151 browser_client_.set_privileged_process_id(process_id); |
| 142 } | 152 } |
| 143 | 153 |
| 144 void DrainMessageLoops() { | 154 void DrainMessageLoops() { |
| 145 // We don't just do this in TearDown() because we create TestBrowserContext | 155 // We don't just do this in TearDown() because we create TestBrowserContext |
| 146 // objects in each test, which will be destructed before | 156 // objects in each test, which will be destructed before |
| 147 // TearDown() is called. | 157 // TearDown() is called. |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 EXPECT_TRUE(instance->HasProcess()); | 678 EXPECT_TRUE(instance->HasProcess()); |
| 669 | 679 |
| 670 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); | 680 EXPECT_FALSE(instance->HasWrongProcessForURL(GURL("http://evernote.com"))); |
| 671 EXPECT_FALSE(instance->HasWrongProcessForURL( | 681 EXPECT_FALSE(instance->HasWrongProcessForURL( |
| 672 GURL("javascript:alert(document.location.href);"))); | 682 GURL("javascript:alert(document.location.href);"))); |
| 673 | 683 |
| 674 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); | 684 EXPECT_TRUE(instance->HasWrongProcessForURL(GURL("chrome://settings"))); |
| 675 | 685 |
| 676 DrainMessageLoops(); | 686 DrainMessageLoops(); |
| 677 } | 687 } |
| OLD | NEW |