| Index: content/browser/loader/resource_dispatcher_host_unittest.cc
|
| diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
|
| index 4a9e27553dd59efdc099870f899e4872016bbef9..b1215ed9cf82f84a79e4515cdca54b1d1a4bbea7 100644
|
| --- a/content/browser/loader/resource_dispatcher_host_unittest.cc
|
| +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
|
| @@ -5,6 +5,7 @@
|
| #include <vector>
|
|
|
| #include "base/bind.h"
|
| +#include "base/command_line.h"
|
| #include "base/files/file_path.h"
|
| #include "base/memory/scoped_vector.h"
|
| #include "base/message_loop/message_loop.h"
|
| @@ -15,6 +16,7 @@
|
| #include "content/browser/browser_thread_impl.h"
|
| #include "content/browser/child_process_security_policy_impl.h"
|
| #include "content/browser/loader/resource_dispatcher_host_impl.h"
|
| +#include "content/browser/loader/resource_loader.h"
|
| #include "content/browser/loader/resource_message_filter.h"
|
| #include "content/browser/loader/resource_request_info_impl.h"
|
| #include "content/browser/worker_host/worker_service_impl.h"
|
| @@ -26,6 +28,7 @@
|
| #include "content/public/browser/resource_dispatcher_host_delegate.h"
|
| #include "content/public/browser/resource_request_info.h"
|
| #include "content/public/browser/resource_throttle.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "content/public/common/process_type.h"
|
| #include "content/public/common/resource_response.h"
|
| #include "content/public/test/test_browser_context.h"
|
| @@ -523,7 +526,6 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| cache_thread_(BrowserThread::CACHE, &message_loop_),
|
| io_thread_(BrowserThread::IO, &message_loop_),
|
| old_factory_(NULL),
|
| - resource_type_(ResourceType::SUB_RESOURCE),
|
| send_data_received_acks_(false) {
|
| browser_context_.reset(new TestBrowserContext());
|
| BrowserContext::EnsureResourceContextInitialized(browser_context_.get());
|
| @@ -594,17 +596,17 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| message_loop_.RunUntilIdle();
|
| }
|
|
|
| - // Creates a request using the current test object as the filter.
|
| + // Creates a request using the current test object as the filter and
|
| + // SubResource as the resource type.
|
| void MakeTestRequest(int render_view_id,
|
| int request_id,
|
| const GURL& url);
|
|
|
| - // Generates a request using the given filter. This will probably be a
|
| - // ForwardingFilter.
|
| - void MakeTestRequest(ResourceMessageFilter* filter,
|
| - int render_view_id,
|
| - int request_id,
|
| - const GURL& url);
|
| + // Generates a request using the given filter and resource type.
|
| + void MakeTestRequestWithResourceType(ResourceMessageFilter* filter,
|
| + int render_view_id, int request_id,
|
| + const GURL& url,
|
| + ResourceType::Type type);
|
|
|
| void CancelRequest(int request_id);
|
|
|
| @@ -634,11 +636,6 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| SetResponse(headers, std::string());
|
| }
|
|
|
| - // Sets a particular resource type for any request from now on.
|
| - void SetResourceType(ResourceType::Type type) {
|
| - resource_type_ = type;
|
| - }
|
| -
|
| void SendDataReceivedACKs(bool send_acks) {
|
| send_data_received_acks_ = send_acks;
|
| }
|
| @@ -724,7 +721,6 @@ class ResourceDispatcherHostTest : public testing::Test,
|
| std::string response_data_;
|
| std::string scheme_;
|
| net::URLRequest::ProtocolFactory* old_factory_;
|
| - ResourceType::Type resource_type_;
|
| bool send_data_received_acks_;
|
| std::set<int> child_ids_;
|
| static ResourceDispatcherHostTest* test_fixture_;
|
| @@ -741,19 +737,21 @@ int ResourceDispatcherHostTest::url_request_jobs_created_count_ = 0;
|
| void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id,
|
| int request_id,
|
| const GURL& url) {
|
| - MakeTestRequest(filter_.get(), render_view_id, request_id, url);
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + url, ResourceType::SUB_RESOURCE);
|
| }
|
|
|
| -void ResourceDispatcherHostTest::MakeTestRequest(
|
| +void ResourceDispatcherHostTest::MakeTestRequestWithResourceType(
|
| ResourceMessageFilter* filter,
|
| int render_view_id,
|
| int request_id,
|
| - const GURL& url) {
|
| + const GURL& url,
|
| + ResourceType::Type type) {
|
| // If it's already there, this'll be dropped on the floor, which is fine.
|
| child_ids_.insert(filter->child_id());
|
|
|
| ResourceHostMsg_Request request =
|
| - CreateResourceRequest("GET", resource_type_, url);
|
| + CreateResourceRequest("GET", type, url);
|
| ResourceHostMsg_RequestResource msg(render_view_id, request_id, request);
|
| bool msg_was_ok;
|
| host_.OnMessageReceived(msg, filter, &msg_was_ok);
|
| @@ -908,6 +906,102 @@ TEST_F(ResourceDispatcherHostTest, Cancel) {
|
| CheckCancelledRequestCompleteMessage(msgs[1][1]);
|
| }
|
|
|
| +// Shows that unlike normal requests, detachable async requests are not
|
| +// immediately canceled, and will complete within a timeout period.
|
| +TEST_F(ResourceDispatcherHostTest, DetachableIgnoreCancel) {
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + command_line->AppendSwitch(switches::kDelayDetachableCancellation);
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1,
|
| + net::URLRequestTestJob::test_url_1(),
|
| + ResourceType::PREFETCH);
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 2,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::PREFETCH);
|
| + MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3());
|
| +
|
| + // test_url_1 is synchronous and already complete.
|
| + EXPECT_EQ(2, host_.pending_requests());
|
| + // We need to make sure that the request comes from the renderer, else it
|
| + // won't delay.
|
| + host_.CancelRequest(filter_->child_id(), 2, true);
|
| + host_.CancelRequest(filter_->child_id(), 3, true);
|
| +
|
| + // Process any completion messages from cancelling.
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| +
|
| + EXPECT_EQ(1, host_.pending_requests());
|
| +
|
| + // Run the requests to completion.
|
| + while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| +
|
| + EXPECT_EQ(0, host_.pending_requests());
|
| +
|
| + ResourceIPCAccumulator::ClassifiedMessages msgs;
|
| + accum_.GetClassifiedMessages(&msgs);
|
| +
|
| + ASSERT_EQ(3U, msgs.size());
|
| +
|
| + // The first fetch was synchronous and should have completed successfully.
|
| + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type());
|
| + ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][1].type());
|
| +
|
| + // The prefetch should have ignored the cancel and completed. Note that
|
| + // prefetches run detached and do not receive data notifications.
|
| + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
|
| + ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[1][1].type());
|
| + // Verify that there was no error.
|
| + int request_id;
|
| + int error_code;
|
| + PickleIterator iter(msgs[1][1]);
|
| + ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id));
|
| + ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &error_code));
|
| + EXPECT_EQ(0, error_code);
|
| +
|
| + // Request 3 should have been cancelled immediately.
|
| + ASSERT_EQ(2U, msgs[2].size());
|
| + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[2][0].type());
|
| + CheckCancelledRequestCompleteMessage(msgs[2][1]);
|
| +}
|
| +
|
| +// Shows that detached requests will timeout if the request takes too long to
|
| +// complete.
|
| +TEST_F(ResourceDispatcherHostTest, DetachedResourceTimesOut) {
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| + command_line->AppendSwitchASCII(switches::kDelayDetachableCancellation,
|
| + "200");
|
| +
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::PREFETCH);
|
| + host_.CancelRequest(filter_->child_id(), 1, true);
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| + EXPECT_EQ(1, host_.pending_requests());
|
| +
|
| + // Wait until after the delay timer times before letting any Reads complete.
|
| + base::OneShotTimer<base::MessageLoop> timer;
|
| + timer.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(210),
|
| + base::MessageLoop::current(), &base::MessageLoop::QuitWhenIdle);
|
| +
|
| + // We should have cancelled the prefetch by now.
|
| + base::MessageLoop::current()->Run();
|
| + EXPECT_EQ(0, host_.pending_requests());
|
| +
|
| + // In case any messages are still to be processed.
|
| + while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| + base::MessageLoop::current()->RunUntilIdle();
|
| +
|
| + ResourceIPCAccumulator::ClassifiedMessages msgs;
|
| + accum_.GetClassifiedMessages(&msgs);
|
| +
|
| + ASSERT_EQ(1U, msgs.size());
|
| +
|
| + // The request should have cancelled.
|
| + ASSERT_EQ(2U, msgs[0].size());
|
| + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type());
|
| + CheckCancelledRequestCompleteMessage(msgs[0][1]);
|
| +}
|
| +
|
| TEST_F(ResourceDispatcherHostTest, CancelWhileStartIsDeferred) {
|
| bool was_deleted = false;
|
|
|
| @@ -1077,15 +1171,17 @@ TEST_F(ResourceDispatcherHostTest, TestProcessCancel) {
|
| ResourceHostMsg_Request request = CreateResourceRequest(
|
| "GET", ResourceType::SUB_RESOURCE, net::URLRequestTestJob::test_url_1());
|
|
|
| - MakeTestRequest(test_filter.get(), 0, 1,
|
| - net::URLRequestTestJob::test_url_1());
|
| + MakeTestRequestWithResourceType(test_filter.get(), 0, 1,
|
| + net::URLRequestTestJob::test_url_1(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| // request 2 goes to us
|
| MakeTestRequest(0, 2, net::URLRequestTestJob::test_url_2());
|
|
|
| // request 3 goes to the test delegate
|
| - MakeTestRequest(test_filter.get(), 0, 3,
|
| - net::URLRequestTestJob::test_url_3());
|
| + MakeTestRequestWithResourceType(test_filter.get(), 0, 3,
|
| + net::URLRequestTestJob::test_url_3(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| // Make sure all requests have finished stage one. test_url_1 will have
|
| // finished.
|
| @@ -1218,12 +1314,18 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
|
|
|
| host_.BlockRequestsForRoute(second_filter->child_id(), 0);
|
|
|
| - MakeTestRequest(filter_.get(), 0, 1, net::URLRequestTestJob::test_url_1());
|
| - MakeTestRequest(second_filter.get(), 0, 2,
|
| - net::URLRequestTestJob::test_url_2());
|
| - MakeTestRequest(filter_.get(), 0, 3, net::URLRequestTestJob::test_url_3());
|
| - MakeTestRequest(second_filter.get(), 0, 4,
|
| - net::URLRequestTestJob::test_url_1());
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1,
|
| + net::URLRequestTestJob::test_url_1(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(second_filter.get(), 0, 2,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 3,
|
| + net::URLRequestTestJob::test_url_3(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(second_filter.get(), 0, 4,
|
| + net::URLRequestTestJob::test_url_1(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| // Simulate process death.
|
| host_.CancelRequestsForProcess(second_filter->child_id());
|
| @@ -1257,13 +1359,24 @@ TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
|
| host_.BlockRequestsForRoute(filter_->child_id(), 2);
|
| host_.BlockRequestsForRoute(second_filter->child_id(), 1);
|
|
|
| - MakeTestRequest(filter_.get(), 0, 1, net::URLRequestTestJob::test_url_1());
|
| - MakeTestRequest(filter_.get(), 1, 2, net::URLRequestTestJob::test_url_2());
|
| - MakeTestRequest(filter_.get(), 0, 3, net::URLRequestTestJob::test_url_3());
|
| - MakeTestRequest(second_filter.get(), 1, 4,
|
| - net::URLRequestTestJob::test_url_1());
|
| - MakeTestRequest(filter_.get(), 2, 5, net::URLRequestTestJob::test_url_2());
|
| - MakeTestRequest(filter_.get(), 2, 6, net::URLRequestTestJob::test_url_3());
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1,
|
| + net::URLRequestTestJob::test_url_1(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(filter_.get(), 1, 2,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 3,
|
| + net::URLRequestTestJob::test_url_3(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(second_filter.get(), 1, 4,
|
| + net::URLRequestTestJob::test_url_1(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(filter_.get(), 2, 5,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(filter_.get(), 2, 6,
|
| + net::URLRequestTestJob::test_url_3(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| host_.CancelRequestsForProcess(filter_->child_id());
|
| host_.CancelRequestsForProcess(second_filter->child_id());
|
| @@ -1322,22 +1435,27 @@ TEST_F(ResourceDispatcherHostTest, TooMuchOutstandingRequestsMemory) {
|
|
|
| // Saturate the number of outstanding requests for our process.
|
| for (size_t i = 0; i < kMaxRequests; ++i) {
|
| - MakeTestRequest(filter_.get(), 0, i + 1,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, i + 1,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| }
|
|
|
| // Issue two more requests for our process -- these should fail immediately.
|
| - MakeTestRequest(filter_.get(), 0, kMaxRequests + 1,
|
| - net::URLRequestTestJob::test_url_2());
|
| - MakeTestRequest(filter_.get(), 0, kMaxRequests + 2,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, kMaxRequests + 1,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, kMaxRequests + 2,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| // Issue two requests for the second process -- these should succeed since
|
| // it is just process 0 that is saturated.
|
| - MakeTestRequest(second_filter.get(), 0, kMaxRequests + 3,
|
| - net::URLRequestTestJob::test_url_2());
|
| - MakeTestRequest(second_filter.get(), 0, kMaxRequests + 4,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(second_filter.get(), 0, kMaxRequests + 3,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| + MakeTestRequestWithResourceType(second_filter.get(), 0, kMaxRequests + 4,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| // Flush all the pending requests.
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| @@ -1388,23 +1506,27 @@ TEST_F(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
|
|
|
| // Saturate the number of outstanding requests for our process.
|
| for (size_t i = 0; i < kMaxRequestsPerProcess; ++i) {
|
| - MakeTestRequest(filter_.get(), 0, i + 1,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, i + 1,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
| }
|
|
|
| // Issue another request for our process -- this should fail immediately.
|
| - MakeTestRequest(filter_.get(), 0, kMaxRequestsPerProcess + 1,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, kMaxRequestsPerProcess + 1,
|
| + net::URLRequestTestJob::test_url_2(),
|
| + ResourceType::SUB_RESOURCE);
|
|
|
| // Issue a request for the second process -- this should succeed, because it
|
| // is just process 0 that is saturated.
|
| - MakeTestRequest(second_filter.get(), 0, kMaxRequestsPerProcess + 2,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(
|
| + second_filter.get(), 0, kMaxRequestsPerProcess + 2,
|
| + net::URLRequestTestJob::test_url_2(), ResourceType::SUB_RESOURCE);
|
|
|
| // Issue a request for the third process -- this should fail, because the
|
| // global limit has been reached.
|
| - MakeTestRequest(third_filter.get(), 0, kMaxRequestsPerProcess + 3,
|
| - net::URLRequestTestJob::test_url_2());
|
| + MakeTestRequestWithResourceType(
|
| + third_filter.get(), 0, kMaxRequestsPerProcess + 3,
|
| + net::URLRequestTestJob::test_url_2(), ResourceType::SUB_RESOURCE);
|
|
|
| // Flush all the pending requests.
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| @@ -1544,11 +1666,11 @@ TEST_F(ResourceDispatcherHostTest, ForbiddenDownload) {
|
| std::string response_data("<html><title>Test One</title></html>");
|
| SetResponse(raw_headers, response_data);
|
|
|
| - // Only MAIN_FRAMEs can trigger a download.
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| -
|
| HandleScheme("http");
|
| - MakeTestRequest(0, 1, GURL("http:bla"));
|
| +
|
| + // Only MAIN_FRAMEs can trigger a download.
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1, GURL("http:bla"),
|
| + ResourceType::MAIN_FRAME);
|
|
|
| // Flush all pending requests.
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| @@ -1595,11 +1717,12 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
|
| response_data.resize(1025, ' ');
|
|
|
| SetResponse(raw_headers, response_data);
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| SetDelayedCompleteJobGeneration(true);
|
| HandleScheme("http");
|
|
|
| - MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + GURL("http://example.com/blah"),
|
| + ResourceType::MAIN_FRAME);
|
| // Return some data so that the request is identified as a download
|
| // and the proper resource handlers are created.
|
| EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
|
| @@ -1630,11 +1753,12 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
|
| response_data.resize(1025, ' ');
|
|
|
| SetResponse(raw_headers, response_data);
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| SetDelayedCompleteJobGeneration(true);
|
| HandleScheme("http");
|
|
|
| - MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + GURL("http://example.com/blah"),
|
| + ResourceType::MAIN_FRAME);
|
| // Return some data so that the request is identified as a download
|
| // and the proper resource handlers are created.
|
| EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
|
| @@ -1671,10 +1795,12 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
|
| std::string response_data("<html>foobar</html>");
|
|
|
| SetResponse(raw_headers, response_data);
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| HandleScheme("http");
|
|
|
| - MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + GURL("http://example.com/blah"),
|
| + ResourceType::MAIN_FRAME);
|
| +
|
|
|
| GlobalRequestID global_request_id(filter_->child_id(), request_id);
|
| host_.MarkAsTransferredNavigation(global_request_id,
|
| @@ -1711,7 +1837,6 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationHtml) {
|
| SetResponse("HTTP/1.1 302 Found\n"
|
| "Location: http://other.com/blech\n\n");
|
|
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| HandleScheme("http");
|
|
|
| // Temporarily replace ContentBrowserClient with one that will trigger the
|
| @@ -1719,7 +1844,8 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationHtml) {
|
| TransfersAllNavigationsContentBrowserClient new_client;
|
| ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
|
|
| - MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + GURL("http://example.com/blah"), ResourceType::MAIN_FRAME);
|
|
|
| // Now that we're blocked on the redirect, update the response and unblock by
|
| // telling the AsyncResourceHandler to follow the redirect.
|
| @@ -1782,7 +1908,6 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationText) {
|
| SetResponse("HTTP/1.1 302 Found\n"
|
| "Location: http://other.com/blech\n\n");
|
|
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| HandleScheme("http");
|
|
|
| // Temporarily replace ContentBrowserClient with one that will trigger the
|
| @@ -1790,7 +1915,9 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationText) {
|
| TransfersAllNavigationsContentBrowserClient new_client;
|
| ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
|
|
| - MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + GURL("http://example.com/blah"),
|
| + ResourceType::MAIN_FRAME);
|
|
|
| // Now that we're blocked on the redirect, update the response and unblock by
|
| // telling the AsyncResourceHandler to follow the redirect. Use a text/plain
|
| @@ -1854,7 +1981,6 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
|
| "Location: http://other.com/blech\n\n");
|
| const std::string kResponseBody = "hello world";
|
|
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| HandleScheme("http");
|
|
|
| // Temporarily replace ContentBrowserClient with one that will trigger the
|
| @@ -1943,7 +2069,6 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
| SetResponse("HTTP/1.1 302 Found\n"
|
| "Location: http://other.com/blech\n\n");
|
|
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| HandleScheme("http");
|
|
|
| // Temporarily replace ContentBrowserClient with one that will trigger the
|
| @@ -1951,7 +2076,9 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
| TransfersAllNavigationsContentBrowserClient new_client;
|
| ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
|
|
| - MakeTestRequest(render_view_id, request_id, GURL("http://example.com/blah"));
|
| + MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| + GURL("http://example.com/blah"),
|
| + ResourceType::MAIN_FRAME);
|
|
|
| // Now that we're blocked on the redirect, simulate hitting another redirect.
|
| SetResponse("HTTP/1.1 302 Found\n"
|
| @@ -2024,10 +2151,10 @@ TEST_F(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
| TEST_F(ResourceDispatcherHostTest, UnknownURLScheme) {
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| - SetResourceType(ResourceType::MAIN_FRAME);
|
| HandleScheme("http");
|
|
|
| - MakeTestRequest(0, 1, GURL("foo://bar"));
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1, GURL("foo://bar"),
|
| + ResourceType::MAIN_FRAME);
|
|
|
| // Flush all pending requests.
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| @@ -2074,6 +2201,29 @@ TEST_F(ResourceDispatcherHostTest, DataReceivedACKs) {
|
| EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][size - 1].type());
|
| }
|
|
|
| +// Request a very large detachable resource. This verifies that the data is not
|
| +// sent to the render process.
|
| +TEST_F(ResourceDispatcherHostTest, DetachableNoDataSentOrReceived) {
|
| + EXPECT_EQ(0, host_.pending_requests());
|
| +
|
| + SendDataReceivedACKs(true);
|
| +
|
| + HandleScheme("big-job");
|
| +
|
| + // This request would normally result in many messages (>300).
|
| + MakeTestRequestWithResourceType(filter_.get(), 0, 1,
|
| + GURL("big-job:0123456789,1000000"),
|
| + ResourceType::PREFETCH);
|
| +
|
| + // Sort all the messages we saw by request.
|
| + ResourceIPCAccumulator::ClassifiedMessages msgs;
|
| + accum_.GetClassifiedMessages(&msgs);
|
| +
|
| + EXPECT_EQ(2u, msgs[0].size());
|
| + ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type());
|
| + ASSERT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][1].type());
|
| +}
|
| +
|
| TEST_F(ResourceDispatcherHostTest, DelayedDataReceivedACKs) {
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
|
|