Chromium Code Reviews| Index: content/browser/loader/resource_dispatcher_host_browsertest.cc |
| diff --git a/content/browser/loader/resource_dispatcher_host_browsertest.cc b/content/browser/loader/resource_dispatcher_host_browsertest.cc |
| index 9eb73c108a91f4c0945e1f95bf3d2bbb6508a083..13ed958ec18a070a1116abb3a464274b1931e4af 100644 |
| --- a/content/browser/loader/resource_dispatcher_host_browsertest.cc |
| +++ b/content/browser/loader/resource_dispatcher_host_browsertest.cc |
| @@ -10,6 +10,9 @@ |
| #include "content/browser/web_contents/web_contents_impl.h" |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_thread.h" |
| +#include "content/public/browser/resource_dispatcher_host.h" |
| +#include "content/public/browser/resource_dispatcher_host_delegate.h" |
| +#include "content/public/browser/resource_request_info.h" |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/url_constants.h" |
| #include "content/public/test/browser_test_utils.h" |
| @@ -472,4 +475,47 @@ IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, CookiePolicy) { |
| CheckTitleTest(url, "cookie set"); |
| } |
| +class PageTransitionResourceDispatcherHostDelegate |
| + : public ResourceDispatcherHostDelegate { |
| + public: |
| + PageTransitionResourceDispatcherHostDelegate(GURL watch) : watch_(watch) {} |
| + |
| + // ResourceDispatcherHostDelegate implementation: |
| + |
|
Charlie Reis
2014/11/13 00:49:35
nit: No blank line.
|
| + void RequestBeginning(net::URLRequest* request, |
| + ResourceContext* resource_context, |
| + AppCacheService* appcache_service, |
| + ResourceType resource_type, |
| + ScopedVector<ResourceThrottle>* throttles) override { |
| + if (request->url() == watch_) { |
| + const ResourceRequestInfo* info = |
| + ResourceRequestInfo::ForRequest(request); |
| + page_transition_ = info->GetPageTransition(); |
| + } |
| + } |
| + |
| + ui::PageTransition page_transition() { return page_transition_; } |
| + |
| + private: |
| + GURL watch_; |
|
Charlie Reis
2014/11/13 00:49:35
nit: watch_url_
|
| + ui::PageTransition page_transition_; |
| +}; |
| + |
| +// Test that ui::PAGE_TRANSITION_CLIENT_REDIRECT is correctly set |
| +// when encountering a meta refresh tag. |
| +IN_PROC_BROWSER_TEST_F(ResourceDispatcherHostBrowserTest, |
| + PageTransitionClientRedirect) { |
| + ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| + |
| + PageTransitionResourceDispatcherHostDelegate delegate( |
| + embedded_test_server()->GetURL("/some_page.html")); |
| + ResourceDispatcherHost::Get()->SetDelegate(&delegate); |
| + |
| + NavigateToURL(shell(), |
| + embedded_test_server()->GetURL("/client_redirect.html")); |
| + |
| + EXPECT_TRUE( |
| + delegate.page_transition() & ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
| +} |
| + |
| } // namespace content |