diff --git a/BUILD.gn b/BUILD.gn index c974a6e99..d883fab46 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -413,6 +413,8 @@ static_library("libcef_static") { "libcef/browser/net_service/resource_handler_wrapper.h", "libcef/browser/net_service/resource_request_handler_wrapper.cc", "libcef/browser/net_service/resource_request_handler_wrapper.h", + "libcef/browser/net_service/response_filter_wrapper.cc", + "libcef/browser/net_service/response_filter_wrapper.h", "libcef/browser/net_service/stream_reader_url_loader.cc", "libcef/browser/net_service/stream_reader_url_loader.h", "libcef/browser/net_service/url_loader_factory_getter.cc", diff --git a/libcef/browser/net_service/proxy_url_loader_factory.cc b/libcef/browser/net_service/proxy_url_loader_factory.cc index 8b14b7bcc..1fbc2ce45 100644 --- a/libcef/browser/net_service/proxy_url_loader_factory.cc +++ b/libcef/browser/net_service/proxy_url_loader_factory.cc @@ -352,7 +352,7 @@ void InterceptedRequest::Restart() { base::BindOnce(&InterceptedRequest::BeforeRequestReceived, weak_factory_.GetWeakPtr(), original_url), base::BindOnce(&InterceptedRequest::SendErrorAndCompleteImmediately, - weak_factory_.GetWeakPtr(), net::ERR_ABORTED)); + weak_factory_.GetWeakPtr())); } void InterceptedRequest::OnLoaderCreated( @@ -524,7 +524,9 @@ void InterceptedRequest::OnTransferSizeUpdated(int32_t transfer_size_diff) { void InterceptedRequest::OnStartLoadingResponseBody( mojo::ScopedDataPipeConsumerHandle body) { - target_client_->OnStartLoadingResponseBody(std::move(body)); + target_client_->OnStartLoadingResponseBody( + factory_->request_handler_->OnFilterResponseBody(id_, request_, + std::move(body))); } void InterceptedRequest::OnComplete( @@ -988,6 +990,14 @@ void InterceptedRequestHandler::OnRequestResponse( redirect_info.has_value() ? redirect_info->new_url : GURL()); } +mojo::ScopedDataPipeConsumerHandle +InterceptedRequestHandler::OnFilterResponseBody( + const RequestId& id, + const network::ResourceRequest& request, + mojo::ScopedDataPipeConsumerHandle body) { + return body; +} + //============================== // ProxyURLLoaderFactory //============================== diff --git a/libcef/browser/net_service/proxy_url_loader_factory.h b/libcef/browser/net_service/proxy_url_loader_factory.h index 1f7629fc9..be9a4aa05 100644 --- a/libcef/browser/net_service/proxy_url_loader_factory.h +++ b/libcef/browser/net_service/proxy_url_loader_factory.h @@ -39,7 +39,7 @@ class InterceptedRequestHandler { using OnBeforeRequestResultCallback = base::OnceCallback; - using CancelRequestCallback = base::OnceClosure; + using CancelRequestCallback = base::OnceCallback; virtual void OnBeforeRequest(const RequestId& id, network::ResourceRequest* request, bool request_was_redirected, @@ -102,6 +102,12 @@ class InterceptedRequestHandler { base::Optional redirect_info, OnRequestResponseResultCallback callback); + // Called to optionally filter the response body. + virtual mojo::ScopedDataPipeConsumerHandle OnFilterResponseBody( + const RequestId& id, + const network::ResourceRequest& request, + mojo::ScopedDataPipeConsumerHandle body); + // Called on completion notification from the loader (successful or not). virtual void OnRequestComplete( const RequestId& id, diff --git a/libcef/browser/net_service/resource_request_handler_wrapper.cc b/libcef/browser/net_service/resource_request_handler_wrapper.cc index dbe08c5e6..25e57a975 100644 --- a/libcef/browser/net_service/resource_request_handler_wrapper.cc +++ b/libcef/browser/net_service/resource_request_handler_wrapper.cc @@ -10,6 +10,7 @@ #include "libcef/browser/net_service/cookie_helper.h" #include "libcef/browser/net_service/proxy_url_loader_factory.h" #include "libcef/browser/net_service/resource_handler_wrapper.h" +#include "libcef/browser/net_service/response_filter_wrapper.h" #include "libcef/browser/resource_context.h" #include "libcef/browser/thread_util.h" #include "libcef/common/content_client.h" @@ -478,7 +479,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { if (!allow) { // Cancel the request. - std::move(state->cancel_callback_).Run(); + std::move(state->cancel_callback_).Run(net::ERR_ABORTED); return; } @@ -713,6 +714,43 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { std::move(callback).Run(); } + mojo::ScopedDataPipeConsumerHandle OnFilterResponseBody( + const RequestId& id, + const network::ResourceRequest& request, + mojo::ScopedDataPipeConsumerHandle body) override { + CEF_REQUIRE_IOT(); + + RequestState* state = GetState(id); + DCHECK(state); + + if (state->handler_) { + auto filter = state->handler_->GetResourceResponseFilter( + GetBrowser(), frame_, state->pending_request_.get(), + state->pending_response_.get()); + if (filter) { + return CreateResponseFilterHandler( + filter, std::move(body), + base::BindOnce(&InterceptedRequestHandlerWrapper::OnFilterError, + weak_ptr_factory_.GetWeakPtr(), id)); + } + } + + return body; + } + + void OnFilterError(const RequestId& id) { + CEF_REQUIRE_IOT(); + + RequestState* state = GetState(id); + if (!state) { + // The request may have been canceled while the async callback was + // pending. + return; + } + + std::move(state->cancel_callback_).Run(net::ERR_CONTENT_DECODING_FAILED); + } + void OnRequestComplete( const RequestId& id, const network::ResourceRequest& request, @@ -852,7 +890,8 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { // Cancel any pending requests. while (!request_map_.empty()) { // Results in a call to RemoveState(). - std::move(request_map_.begin()->second->cancel_callback_).Run(); + std::move(request_map_.begin()->second->cancel_callback_) + .Run(net::ERR_ABORTED); } } diff --git a/libcef/browser/net_service/response_filter_wrapper.cc b/libcef/browser/net_service/response_filter_wrapper.cc new file mode 100644 index 000000000..9b451b8b7 --- /dev/null +++ b/libcef/browser/net_service/response_filter_wrapper.cc @@ -0,0 +1,296 @@ +// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#include "libcef/browser/net_service/response_filter_wrapper.h" + +#include + +#include "mojo/public/cpp/system/simple_watcher.h" +#include "mojo/public/cpp/system/string_data_pipe_producer.h" + +namespace net_service { + +namespace { + +// Match the default |capacity_num_bytes| value from mojo::Core::CreateDataPipe. +static const size_t kBufferSize = 64 * 1024; // 64 Kbytes. +static const size_t kMinBufferSpace = 1024; // 1 Kbytes. + +class ResponseFilterWrapper { + public: + ResponseFilterWrapper(CefRefPtr filter, + mojo::ScopedDataPipeConsumerHandle source_handle, + base::OnceClosure error_callback); + + // Creates and returns the output handle, or |source_handle| on failure. + bool CreateOutputHandle(mojo::ScopedDataPipeConsumerHandle* output_handle); + + private: + void OnSourceReadable(MojoResult, const mojo::HandleSignalsState&); + void Filter(const char* data, size_t size); + void Write(std::unique_ptr data); + void OnWriteComplete(std::unique_ptr, MojoResult result); + void Drain(bool complete); + void MaybeSuccess(); + void Cleanup(bool success); + + CefRefPtr filter_; + mojo::ScopedDataPipeConsumerHandle source_handle_; + base::OnceClosure error_callback_; + + std::unique_ptr forwarder_; + mojo::SimpleWatcher source_watcher_; + + bool read_pending_ = false; + bool write_pending_ = false; + std::queue> pending_data_; + cef_response_filter_status_t last_status_ = RESPONSE_FILTER_NEED_MORE_DATA; + + DISALLOW_COPY_AND_ASSIGN(ResponseFilterWrapper); +}; + +ResponseFilterWrapper::ResponseFilterWrapper( + CefRefPtr filter, + mojo::ScopedDataPipeConsumerHandle source_handle, + base::OnceClosure error_callback) + : filter_(filter), + source_handle_(std::move(source_handle)), + error_callback_(std::move(error_callback)), + source_watcher_(FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL) {} + +bool ResponseFilterWrapper::CreateOutputHandle( + mojo::ScopedDataPipeConsumerHandle* output_handle) { + if (!filter_->InitFilter()) { + *output_handle = std::move(source_handle_); + return false; + } + + mojo::ScopedDataPipeProducerHandle forwarding_handle; + if (CreateDataPipe(nullptr, &forwarding_handle, output_handle) != + MOJO_RESULT_OK) { + *output_handle = std::move(source_handle_); + return false; + } + + forwarder_ = std::make_unique( + std::move(forwarding_handle)); + + source_watcher_.Watch( + source_handle_.get(), + MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED, + MOJO_TRIGGER_CONDITION_SIGNALS_SATISFIED, + base::BindRepeating(&ResponseFilterWrapper::OnSourceReadable, + base::Unretained(this))); + source_watcher_.ArmOrNotify(); + read_pending_ = true; + + return true; +} + +void ResponseFilterWrapper::OnSourceReadable(MojoResult, + const mojo::HandleSignalsState&) { + const void* buffer = nullptr; + uint32_t read_bytes = 0; + MojoResult result = source_handle_->BeginReadData(&buffer, &read_bytes, + MOJO_READ_DATA_FLAG_NONE); + if (result == MOJO_RESULT_SHOULD_WAIT) { + source_watcher_.ArmOrNotify(); + return; + } + + if (result != MOJO_RESULT_OK) { + // Whole body has been read, or something went wrong. + Drain(result == MOJO_RESULT_FAILED_PRECONDITION); + return; + } + + Filter(static_cast(buffer), read_bytes); + if (last_status_ == RESPONSE_FILTER_ERROR) { + // Something went wrong. + Drain(false); + return; + } + + source_handle_->EndReadData(read_bytes); + source_watcher_.ArmOrNotify(); +} + +void ResponseFilterWrapper::Filter(const char* data, size_t size) { + size_t data_in_size = size; + auto data_in_ptr = data_in_size > 0 ? data : nullptr; + + size_t data_out_offset = 0; + std::unique_ptr data_out; + + while (true) { + size_t data_in_read = 0; + + if (!data_out) { + // Start a new buffer. Should have no offset to begin with. + DCHECK_EQ(0U, data_out_offset); + data_out = std::make_unique(); + data_out->resize(kBufferSize); + } + + auto data_out_ptr = data_out->data() + data_out_offset; + size_t data_out_size = kBufferSize - data_out_offset; + size_t data_out_written = 0; + + last_status_ = filter_->Filter( + const_cast(data_in_ptr), data_in_size, data_in_read, + const_cast(data_out_ptr), data_out_size, data_out_written); + if (last_status_ == RESPONSE_FILTER_ERROR) + break; + + // Validate the out values. + if (data_in_read > data_in_size) { + LOG(ERROR) << "potential buffer overflow; data_in_read > data_in_size"; + last_status_ = RESPONSE_FILTER_ERROR; + break; + } + if (data_out_written > data_out_size) { + LOG(ERROR) + << "potential buffer overflow; data_out_written > data_out_size"; + last_status_ = RESPONSE_FILTER_ERROR; + break; + } + if (data_out_written == 0 && data_in_read != data_in_size) { + LOG(ERROR) << "when no data is written all input must be consumed; " + "data_out_written == 0 && data_in_read != data_in_size"; + last_status_ = RESPONSE_FILTER_ERROR; + break; + } + + if (data_out_written > 0) { + data_out_offset += data_out_written; + if (data_out_offset > kBufferSize - kMinBufferSpace) { + // The buffer is full or almost full. Write the data that we've + // received so far and start a new buffer. + data_out->resize(data_out_offset); + Write(std::move(data_out)); + data_out_offset = 0; + } + } + + if (data_in_read < data_in_size) { + // Keep going until the user reads all data. + data_in_ptr += data_in_read; + data_in_size -= data_in_read; + continue; + } + + // At this point the user has read all data... + if (data_in_ptr) { + // Clear the input buffer. + data_in_read = data_in_size = 0; + data_in_ptr = nullptr; + } + + if (data_out_written == data_out_size && + last_status_ == RESPONSE_FILTER_NEED_MORE_DATA) { + // Output buffer was filled, but data is still pending. + continue; + } + + if (data_out_offset > 0) { + // Write the last of the data that we've received. + data_out->resize(data_out_offset); + Write(std::move(data_out)); + } + + break; + } +} + +void ResponseFilterWrapper::Write(std::unique_ptr data) { + if (write_pending_) { + // Only one write at a time is supported. + pending_data_.push(std::move(data)); + return; + } + + write_pending_ = true; + + base::StringPiece string_piece(*data); + forwarder_->Write(string_piece, + mojo::StringDataPipeProducer::AsyncWritingMode:: + STRING_STAYS_VALID_UNTIL_COMPLETION, + base::BindOnce(&ResponseFilterWrapper::OnWriteComplete, + base::Unretained(this), std::move(data))); +} + +void ResponseFilterWrapper::OnWriteComplete(std::unique_ptr, + MojoResult result) { + write_pending_ = false; + + if (result != MOJO_RESULT_OK) { + // Something went wrong. + Cleanup(false); + return; + } + + MaybeSuccess(); +} + +void ResponseFilterWrapper::Drain(bool complete) { + read_pending_ = false; + source_handle_.reset(); + source_watcher_.Cancel(); + + if (!complete) { + // Something went wrong. + Cleanup(false); + return; + } + + if (last_status_ == RESPONSE_FILTER_NEED_MORE_DATA) { + // Let the user write any remaining data. + Filter(nullptr, 0); + if (last_status_ != RESPONSE_FILTER_DONE) { + // Something went wrong. + Cleanup(false); + return; + } + } + + MaybeSuccess(); +} + +void ResponseFilterWrapper::MaybeSuccess() { + if (!write_pending_ && !pending_data_.empty()) { + // Write the next data segment. + auto next = std::move(pending_data_.front()); + pending_data_.pop(); + Write(std::move(next)); + return; + } + + if (!read_pending_ && !write_pending_) + Cleanup(true); +} + +void ResponseFilterWrapper::Cleanup(bool success) { + if (!success && error_callback_) + std::move(error_callback_).Run(); + delete this; +} + +} // namespace + +mojo::ScopedDataPipeConsumerHandle CreateResponseFilterHandler( + CefRefPtr filter, + mojo::ScopedDataPipeConsumerHandle source_handle, + base::OnceClosure error_callback) { + // |filter_wrapper| will delete itself when filtering is complete if + // CreateOutputHandle returns true. Otherwise, it will return the + // original |source_handle|. + auto filter_wrapper = new ResponseFilterWrapper( + filter, std::move(source_handle), std::move(error_callback)); + mojo::ScopedDataPipeConsumerHandle output_handle; + if (!filter_wrapper->CreateOutputHandle(&output_handle)) + delete filter_wrapper; + return output_handle; +} + +} // namespace net_service diff --git a/libcef/browser/net_service/response_filter_wrapper.h b/libcef/browser/net_service/response_filter_wrapper.h new file mode 100644 index 000000000..241007f92 --- /dev/null +++ b/libcef/browser/net_service/response_filter_wrapper.h @@ -0,0 +1,26 @@ +// Copyright (c) 2019 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. + +#ifndef CEF_LIBCEF_BROWSER_NET_SERVICE_RESPONSE_FILTER_WRAPPER_H_ +#define CEF_LIBCEF_BROWSER_NET_SERVICE_RESPONSE_FILTER_WRAPPER_H_ + +#include "include/cef_response_filter.h" + +#include "mojo/public/cpp/system/data_pipe.h" + +namespace net_service { + +// Create a filter handler that will read from |source_handle| and pass the data +// through |filter|. If filtering cannot be initialized then |source_handle| +// will be returned, otherwise a new handle for retrieving the filtered output +// will be returned. If filtering fails after initialization then +// |error_callback| will be executed. +mojo::ScopedDataPipeConsumerHandle CreateResponseFilterHandler( + CefRefPtr filter, + mojo::ScopedDataPipeConsumerHandle source_handle, + base::OnceClosure error_callback); + +} // namespace net_service + +#endif // CEF_LIBCEF_BROWSER_NET_SERVICE_RESPONSE_FILTER_WRAPPER_H_ diff --git a/tests/cefclient/resources/response_filter.html b/tests/cefclient/resources/response_filter.html index cda5eef13..d67e4577f 100644 --- a/tests/cefclient/resources/response_filter.html +++ b/tests/cefclient/resources/response_filter.html @@ -3,7 +3,73 @@ Response Filter Test -

The text shown below in red has been replaced by the filter. This document is > 32kb in order to exceed the standard output buffer size.

+

The text shown below in red has been replaced by the filter. This document is > 64kb in order to exceed the standard output buffer size.

+

REPLACE_THIS_STRING

+

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

2. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

3. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

4. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

5. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

6. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

7. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

8. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

9. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

REPLACE_THIS_STRING

+

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

2. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

3. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

4. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

5. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

6. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

7. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

8. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

9. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

REPLACE_THIS_STRING

+

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

2. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

3. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

4. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

5. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

6. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

7. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

8. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

9. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

REPLACE_THIS_STRING

+

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

2. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

3. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

4. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

5. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

6. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

7. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

8. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

9. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

REPLACE_THIS_STRING

+

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

2. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

3. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

4. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

5. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

6. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

7. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

8. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

9. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

REPLACE_THIS_STRING

+

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

2. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

3. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

4. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

5. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

6. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

7. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

8. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

+

9. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

REPLACE_THIS_STRING

0. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

1. It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness, it was the epoch of belief, it was the epoch of incredulity, it was the season of Light, it was the season of Darkness, it was the spring of hope, it was the winter of despair, we had everything before us, we had nothing before us, we were all going direct to Heaven, we were all going direct the other way -- in short, the period was so far like the present period, that some of its noisiest authorities insisted on its being received, for good or for evil, in the superlative degree of comparison only.

diff --git a/tests/ceftests/request_unittest.cc b/tests/ceftests/request_unittest.cc index 517dceb3a..bfd70e497 100644 --- a/tests/ceftests/request_unittest.cc +++ b/tests/ceftests/request_unittest.cc @@ -342,12 +342,7 @@ class RequestSendRecvTestHandler : public TestHandler { EXPECT_TRUE(got_before_resource_load_); EXPECT_TRUE(got_resource_handler_); EXPECT_TRUE(got_resource_response_); - if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_FALSE(got_resource_response_filter_); - } else { - EXPECT_TRUE(got_resource_response_filter_); - } + EXPECT_TRUE(got_resource_response_filter_); EXPECT_TRUE(got_resource_load_complete_); TestHandler::DestroyTest(); diff --git a/tests/ceftests/resource_request_handler_unittest.cc b/tests/ceftests/resource_request_handler_unittest.cc index 1645614ae..a1c40506e 100644 --- a/tests/ceftests/resource_request_handler_unittest.cc +++ b/tests/ceftests/resource_request_handler_unittest.cc @@ -385,8 +385,11 @@ class BasicResponseTest : public TestHandler { EXPECT_EQ(1, get_resource_handler_ct_); EXPECT_EQ(0, on_resource_redirect_ct_); if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0, get_resource_response_filter_ct_); + // Unhandled requests won't see a call to GetResourceResponseFilter. + if (unhandled_) + EXPECT_EQ(0, get_resource_response_filter_ct_); + else + EXPECT_EQ(1, get_resource_response_filter_ct_); } else { EXPECT_EQ(1, get_resource_response_filter_ct_); } @@ -408,8 +411,11 @@ class BasicResponseTest : public TestHandler { EXPECT_EQ(2, get_resource_handler_ct_); EXPECT_EQ(0, on_resource_redirect_ct_); if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0, get_resource_response_filter_ct_); + // Unhandled requests won't see a call to GetResourceResponseFilter. + if (unhandled_) + EXPECT_EQ(0, get_resource_response_filter_ct_); + else + EXPECT_EQ(1, get_resource_response_filter_ct_); } else { EXPECT_EQ(2, get_resource_response_filter_ct_); } @@ -444,8 +450,11 @@ class BasicResponseTest : public TestHandler { } } if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0, get_resource_response_filter_ct_); + // Unhandled requests won't see a call to GetResourceResponseFilter. + if (unhandled_) + EXPECT_EQ(0, get_resource_response_filter_ct_); + else + EXPECT_EQ(1, get_resource_response_filter_ct_); } else { if (mode_ == REDIRECT_RESOURCE_RESPONSE) EXPECT_EQ(2, get_resource_response_filter_ct_); @@ -1285,8 +1294,11 @@ class SubresourceResponseTest : public RoutingTestHandler { EXPECT_EQ(1, get_resource_handler_ct_); EXPECT_EQ(0, on_resource_redirect_ct_); if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0, get_resource_response_filter_ct_); + // Unhandled requests won't see a call to GetResourceResponseFilter. + if (unhandled_) + EXPECT_EQ(0, get_resource_response_filter_ct_); + else + EXPECT_EQ(1, get_resource_response_filter_ct_); } else { EXPECT_EQ(1, get_resource_response_filter_ct_); } @@ -1309,8 +1321,11 @@ class SubresourceResponseTest : public RoutingTestHandler { EXPECT_EQ(2, get_resource_handler_ct_); EXPECT_EQ(0, on_resource_redirect_ct_); if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0, get_resource_response_filter_ct_); + // Unhandled requests won't see a call to GetResourceResponseFilter. + if (unhandled_) + EXPECT_EQ(0, get_resource_response_filter_ct_); + else + EXPECT_EQ(1, get_resource_response_filter_ct_); } else { EXPECT_EQ(2, get_resource_response_filter_ct_); } @@ -1341,8 +1356,11 @@ class SubresourceResponseTest : public RoutingTestHandler { } } if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0, get_resource_response_filter_ct_); + // Unhandled requests won't see a call to GetResourceResponseFilter. + if (unhandled_) + EXPECT_EQ(0, get_resource_response_filter_ct_); + else + EXPECT_EQ(1, get_resource_response_filter_ct_); } else { if (mode_ == REDIRECT_RESOURCE_RESPONSE) EXPECT_EQ(2, get_resource_response_filter_ct_); @@ -2000,8 +2018,8 @@ class RedirectResponseTest : public TestHandler { EXPECT_EQ(expected_resource_response_ct_, resource_response_ct_); EXPECT_EQ(expected_resource_response_ct_, get_resource_handler_ct_); if (IsNetworkServiceEnabled()) { - // TODO(network): Add support for GetResourceResponseFilter. - EXPECT_EQ(0U, get_resource_response_filter_ct_); + EXPECT_EQ(expected_resource_load_complete_ct_, + get_resource_response_filter_ct_); } else { EXPECT_EQ(expected_resource_response_ct_, get_resource_response_filter_ct_); @@ -2563,7 +2581,17 @@ namespace { // - Filter error. const char kResponseFilterTestUrl[] = "http://tests.com/response_filter.html"; -const size_t kResponseBufferSize = 1024 * 32; // 32kb + +size_t GetResponseBufferSize() { + if (IsNetworkServiceEnabled()) { + // Match the default |capacity_num_bytes| value from + // mojo::Core::CreateDataPipe. + return 64 * 1024; // 64kb + } else { + // Match |kBufferSize| from net/filter/filter_source_stream.cc. + return 32 * 1024; // 32kb + } +} const char kInputHeader[] = ""; const char kInputFooter[] = ""; @@ -2691,7 +2719,7 @@ class ResponseFilterPassThru : public ResponseFilterTestBase { } std::string GetInput() override { - input_ = CreateInput("FOOBAR ", kResponseBufferSize * 2U); + input_ = CreateInput("FOOBAR ", GetResponseBufferSize() * 2U + 1); return input_; } @@ -2702,12 +2730,12 @@ class ResponseFilterPassThru : public ResponseFilterTestBase { received_content); if (limit_read_) - // Expected to read 2 full buffers of kResponseBufferSize at 1kb - // increments (2 * 32) and one partial buffer. - EXPECT_EQ(2U * 32U + 1U, filter_count_); + // Expected to read 2 full buffers of GetResponseBufferSize() at 1kb + // increments and one partial buffer. + EXPECT_EQ(2U * (GetResponseBufferSize() / 1024) + 1U, filter_count_); else { - // Expected to read 2 full buffers of kResponseBufferSize and one partial - // buffer. + // Expected to read 2 full buffers of GetResponseBufferSize() and one + // partial buffer. EXPECT_EQ(3U, filter_count_); } EXPECT_STREQ(input_.c_str(), received_content.c_str()); @@ -2812,8 +2840,9 @@ class ResponseFilterNeedMore : public ResponseFilterTestBase { } std::string GetInput() override { - const std::string& input = CreateInput( - std::string(kFindString) + " ", kResponseBufferSize * 2U, &repeat_ct_); + const std::string& input = + CreateInput(std::string(kFindString) + " ", + GetResponseBufferSize() * 2U + 1, &repeat_ct_); input_size_ = input.size(); const size_t find_size = sizeof(kFindString) - 1; @@ -2842,8 +2871,8 @@ class ResponseFilterNeedMore : public ResponseFilterTestBase { // Filtered content length should be the output size. EXPECT_EQ(output.size(), received_content.size()); - // Expected to read 2 full buffers of kResponseBufferSize and one partial - // buffer, and then one additional call to drain the overflow. + // Expected to read 2 full buffers of GetResponseBufferSize() and one + // partial buffer, and then one additional call to drain the overflow. EXPECT_EQ(4U, filter_count_); }