Commit fdf9d6d3 authored by Takashi Toyoshima's avatar Takashi Toyoshima Committed by Commit Bot

OOR-CORS: Use net::ERR_ABORTED on OnConnectionError

Currently, some tests expect it does not complete, and others do
returning net::ERR_ABORTED. But it's really tough to realize the
same behavior when OutOfBlinkCORS is enabled because timing differs.

With this fix, CORSURLLoader is changed to return net::ERR_ABORTED
on OnConnectionError that happens when a client destructs a loader.

Existing tests that expect it does not complete are also modified
to check if it does not complete or it completes with the error.

This patch will make tests below pass even with OutOfBlinkCORS enabled.
- ResourceDispatcherHostTest.DataSentBeforeDetach
- ResourceDispatcherHostTest.Cancel
- ResourceDispatcherHostTest.DetachedResourceTimesOut
- ResourceDispatcherHostTest.TestBlockedRequestsProcessDies
- ResourceDispatcherHostTest.TestBlockingCancelingRequests

Bug: 872634, 870173
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I2f7f40de49d5820413eaf4e80debf747ba66632a
Reviewed-on: https://chromium-review.googlesource.com/1230039Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Takashi Toyoshima <toyoshim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593836}
parent 2ca919e5
...@@ -75,7 +75,11 @@ CORSURLLoader::CORSURLLoader( ...@@ -75,7 +75,11 @@ CORSURLLoader::CORSURLLoader(
SetCORSFlagIfNeeded(); SetCORSFlagIfNeeded();
} }
CORSURLLoader::~CORSURLLoader() = default; CORSURLLoader::~CORSURLLoader() {
// Close pipes first to ignore possible subsequent callback invocations
// cased by |network_loader_|
network_client_binding_.Close();
}
void CORSURLLoader::Start() { void CORSURLLoader::Start() {
if (fetch_cors_flag_ && if (fetch_cors_flag_ &&
...@@ -417,19 +421,12 @@ void CORSURLLoader::StartNetworkRequest( ...@@ -417,19 +421,12 @@ void CORSURLLoader::StartNetworkRequest(
void CORSURLLoader::HandleComplete(const URLLoaderCompletionStatus& status) { void CORSURLLoader::HandleComplete(const URLLoaderCompletionStatus& status) {
forwarding_client_->OnComplete(status); forwarding_client_->OnComplete(status);
// Close pipes to ignore possible subsequent callback invocations.
network_client_binding_.Close();
forwarding_client_.reset();
network_loader_.reset();
std::move(delete_callback_).Run(this); std::move(delete_callback_).Run(this);
// |this| is deleted here. // |this| is deleted here.
} }
void CORSURLLoader::OnConnectionError() { void CORSURLLoader::OnConnectionError() {
HandleComplete(URLLoaderCompletionStatus(net::ERR_FAILED)); HandleComplete(URLLoaderCompletionStatus(net::ERR_ABORTED));
} }
// This should be identical to CalculateCORSFlag defined in // This should be identical to CalculateCORSFlag defined in
......
...@@ -54,6 +54,9 @@ class TestURLLoaderClient final : public mojom::URLLoaderClient { ...@@ -54,6 +54,9 @@ class TestURLLoaderClient final : public mojom::URLLoaderClient {
return has_received_cached_metadata_; return has_received_cached_metadata_;
} }
bool has_received_completion() const { return has_received_completion_; } bool has_received_completion() const { return has_received_completion_; }
bool has_received_connection_error() const {
return has_received_connection_error_;
}
const ResourceResponseHead& response_head() const { return response_head_; } const ResourceResponseHead& response_head() const { return response_head_; }
const base::Optional<net::SSLInfo>& ssl_info() const { const base::Optional<net::SSLInfo>& ssl_info() const {
return response_head_.ssl_info; return response_head_.ssl_info;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment