diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-21 08:43:39 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-21 08:43:39 +0000 |
commit | 51549da314ab40bfce645bb6c5875c4e5ec12f67 (patch) | |
tree | 3e559616fcd7e3e21b694dcf6ed57794a85c6f0d /chrome_frame/test | |
parent | 4d409d77dfaa84a06547d3e0a45191cf803fbb9d (diff) | |
download | chromium_src-51549da314ab40bfce645bb6c5875c4e5ec12f67.zip chromium_src-51549da314ab40bfce645bb6c5875c4e5ec12f67.tar.gz chromium_src-51549da314ab40bfce645bb6c5875c4e5ec12f67.tar.bz2 |
Tommi, please review everything. John please review the changes to plugin_service.cc/.h
The test automation provider registers itself as a protocol factory for http/https requests. This
is to ensure that intercepts set by the url request network tests work correctly. I was seeing these
tests fail consistently on my setup as their intercept function would never get called.
The other change is to add a simple mechanism based on a boolean flag to disable browser side plugins
like gears which also intercept network requests and expect to be called on the IO thread. The chrome
frame network tests run in a relatively simple environment where the network tests run in a separate thread
(not the IO thread) which causes a number of DCHECKS to fire in debug build test runs. The flag used to
determine whether browser plugins are loaded defaults to true.
Review URL: http://codereview.chromium.org/414017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/net/fake_external_tab.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/net/test_automation_provider.cc | 20 | ||||
-rw-r--r-- | chrome_frame/test/net/test_automation_provider.h | 17 |
3 files changed, 26 insertions, 14 deletions
diff --git a/chrome_frame/test/net/fake_external_tab.cc b/chrome_frame/test/net/fake_external_tab.cc index 5168372..5caadd33 100644 --- a/chrome_frame/test/net/fake_external_tab.cc +++ b/chrome_frame/test/net/fake_external_tab.cc @@ -19,6 +19,7 @@ #include "base/scoped_variant_win.h" #include "chrome/browser/browser_prefs.h" +#include "chrome/browser/plugin_service.h" #include "chrome/browser/process_singleton.h" #include "chrome/browser/profile_manager.h" #include "chrome/browser/renderer_host/render_process_host.h" @@ -28,7 +29,6 @@ #include "chrome/common/chrome_switches.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" - #include "chrome_frame/utils.h" #include "chrome_frame/test/chrome_frame_test_utils.h" #include "chrome_frame/test/net/dialog_watchdog.h" @@ -386,6 +386,7 @@ int main(int argc, char** argv) { watchdog.AddObserver(&credentials); testing::InitGoogleTest(&argc, argv); FilterDisabledTests(); + PluginService::EnableChromePlugins(false); CFUrlRequestUnittestRunner test_suite(argc, argv); test_suite.RunMainUIThread(); return 0; diff --git a/chrome_frame/test/net/test_automation_provider.cc b/chrome_frame/test/net/test_automation_provider.cc index f1a3b13..d9cd8db 100644 --- a/chrome_frame/test/net/test_automation_provider.cc +++ b/chrome_frame/test/net/test_automation_provider.cc @@ -23,16 +23,22 @@ bool CFTestsDisabled() { } // end namespace +TestAutomationProvider* TestAutomationProvider::g_provider_instance_ = NULL; + TestAutomationProvider::TestAutomationProvider( Profile* profile, TestAutomationProviderDelegate* delegate) : AutomationProvider(profile), tab_handle_(-1), delegate_(delegate) { filter_ = new TestAutomationResourceMessageFilter(this); - URLRequest::RegisterRequestInterceptor(this); + URLRequest::RegisterProtocolFactory("http", + TestAutomationProvider::Factory); + URLRequest::RegisterProtocolFactory("https", + TestAutomationProvider::Factory); + g_provider_instance_ = this; } TestAutomationProvider::~TestAutomationProvider() { - URLRequest::UnregisterRequestInterceptor(this); + g_provider_instance_ = NULL; } void TestAutomationProvider::OnMessageReceived(const IPC::Message& msg) { @@ -56,7 +62,8 @@ bool TestAutomationProvider::Send(IPC::Message* msg) { return AutomationProvider::Send(msg); } -URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { +URLRequestJob* TestAutomationProvider::Factory(URLRequest* request, + const std::string& scheme) { if (CFTestsDisabled()) return NULL; @@ -67,8 +74,8 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { // We could also check if the current thread is our TestUrlRequest thread // and only intercept requests that belong to that thread. - if (request->GetUserData(NULL) == NULL) { - DCHECK(tab_handle_ != -1); + if (g_provider_instance_ && request->GetUserData(NULL) == NULL) { + DCHECK(g_provider_instance_->tab_handle_ != -1); // We generate our own request id which is also what // ResourceDispatcherHost does (well, the id is actually generated by // ResourceDispatcher). Since these requests are divided into with @@ -76,7 +83,8 @@ URLRequestJob* TestAutomationProvider::MaybeIntercept(URLRequest* request) { // a little easier, we have a significantly higher start value. static int new_id = 0x00100000; URLRequestAutomationJob* job = new URLRequestAutomationJob(request, - tab_handle_, new_id++, filter_); + g_provider_instance_->tab_handle_, new_id++, + g_provider_instance_->filter_); return job; } } diff --git a/chrome_frame/test/net/test_automation_provider.h b/chrome_frame/test/net/test_automation_provider.h index 75830ba..a745537 100644 --- a/chrome_frame/test/net/test_automation_provider.h +++ b/chrome_frame/test/net/test_automation_provider.h @@ -19,22 +19,23 @@ class TestAutomationProviderDelegate { // (see TestAutomationResourceMessageFilter) and know when the initial // ExternalTab has been loaded. // In order to intercept UrlRequests and make the URLRequestAutomationJob class -// handle requests from unit tests, we also implement URLRequest::Interceptor. +// handle requests from unit tests, we register a protocol factory for +// http/https. class TestAutomationProvider - : public AutomationProvider, - public URLRequest::Interceptor { + : public AutomationProvider { public: explicit TestAutomationProvider(Profile* profile, TestAutomationProviderDelegate* delegate); virtual ~TestAutomationProvider(); - + // AutomationProvider overrides. virtual void OnMessageReceived(const IPC::Message& msg); virtual bool Send(IPC::Message* msg); - // URLRequest::Interceptor. - virtual URLRequestJob* MaybeIntercept(URLRequest* request); + // Protocol factory for handling http/https requests over automation. + static URLRequestJob* Factory(URLRequest* request, + const std::string& scheme); // Call to instantiate and initialize a new instance of // TestAutomationProvider. @@ -47,6 +48,8 @@ class TestAutomationProvider scoped_refptr<TestAutomationResourceMessageFilter> filter_; int tab_handle_; TestAutomationProviderDelegate* delegate_; + + static TestAutomationProvider* g_provider_instance_; }; -#endif CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ +#endif // CHROME_FRAME_TEST_NET_TEST_AUTOMATION_PROVIDER_H_ |