mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-03-08 07:48:32 +01:00
Remove renderer process CefURLRequest support
The CefFrame::CreateURLRequest method is no longer supported in the renderer process. Usage of this method was already limited to same-origin requests due to renderer process CORS restrictions, and the underlying Blink API has now been removed in https://crbug.com/1413912 (M112+). Existing alternatives include CefURLRequest usage in the browser process, or JavaScript XMLHttpRequest/fetch API usage in the renderer process.
This commit is contained in:
parent
276423dcfb
commit
3c85154faf
2
BUILD.gn
2
BUILD.gn
@ -933,8 +933,6 @@ source_set("libcef_static") {
|
||||
"libcef/renderer/render_frame_util.h",
|
||||
"libcef/renderer/render_manager.cc",
|
||||
"libcef/renderer/render_manager.h",
|
||||
"libcef/renderer/render_urlrequest_impl.cc",
|
||||
"libcef/renderer/render_urlrequest_impl.h",
|
||||
"libcef/renderer/thread_util.h",
|
||||
"libcef/renderer/v8_impl.cc",
|
||||
"libcef/renderer/v8_impl.h",
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=b9b1308311999efcfd2aa678472f934ca783492c$
|
||||
// $hash=5bed8359f09a821f4b5ec8ebfad0aa5720bf39f9$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
|
||||
@ -216,24 +216,16 @@ typedef struct _cef_frame_t {
|
||||
|
||||
///
|
||||
/// Create a new URL request that will be treated as originating from this
|
||||
/// frame and the associated browser. This request may be intercepted by the
|
||||
/// client via cef_resource_request_handler_t or cef_scheme_handler_factory_t.
|
||||
/// Use cef_urlrequest_t::Create instead if you do not want the request to
|
||||
/// have this association, in which case it may be handled differently (see
|
||||
/// documentation on that function). Requests may originate from both the
|
||||
/// browser process and the render process.
|
||||
///
|
||||
/// For requests originating from the browser process:
|
||||
/// frame and the associated browser. Use cef_urlrequest_t::Create instead if
|
||||
/// you do not want the request to have this association, in which case it may
|
||||
/// be handled differently (see documentation on that function). A request
|
||||
/// created with this function may only originate from the browser process,
|
||||
/// and will behave as follows:
|
||||
/// - It may be intercepted by the client via CefResourceRequestHandler or
|
||||
/// CefSchemeHandlerFactory.
|
||||
/// - POST data may only contain a single element of type PDE_TYPE_FILE or
|
||||
/// PDE_TYPE_BYTES.
|
||||
///
|
||||
/// For requests originating from the render process:
|
||||
/// - POST data may only contain a single element of type PDE_TYPE_BYTES.
|
||||
/// - If the response contains Content-Disposition or Mime-Type header
|
||||
/// values that would not normally be rendered then the response may
|
||||
/// receive special handling inside the browser (for example, via the
|
||||
/// file download code path instead of the URL request code path).
|
||||
///
|
||||
/// The |request| object will be marked as read-only after calling this
|
||||
/// function.
|
||||
///
|
||||
|
@ -221,24 +221,16 @@ class CefFrame : public virtual CefBaseRefCounted {
|
||||
|
||||
///
|
||||
/// Create a new URL request that will be treated as originating from this
|
||||
/// frame and the associated browser. This request may be intercepted by the
|
||||
/// client via CefResourceRequestHandler or CefSchemeHandlerFactory. Use
|
||||
/// CefURLRequest::Create instead if you do not want the request to have this
|
||||
/// association, in which case it may be handled differently (see
|
||||
/// documentation on that method). Requests may originate from both the
|
||||
/// browser process and the render process.
|
||||
///
|
||||
/// For requests originating from the browser process:
|
||||
/// frame and the associated browser. Use CefURLRequest::Create instead if you
|
||||
/// do not want the request to have this association, in which case it may be
|
||||
/// handled differently (see documentation on that method). A request created
|
||||
/// with this method may only originate from the browser process, and will
|
||||
/// behave as follows:
|
||||
/// - It may be intercepted by the client via CefResourceRequestHandler or
|
||||
/// CefSchemeHandlerFactory.
|
||||
/// - POST data may only contain a single element of type PDE_TYPE_FILE or
|
||||
/// PDE_TYPE_BYTES.
|
||||
///
|
||||
/// For requests originating from the render process:
|
||||
/// - POST data may only contain a single element of type PDE_TYPE_BYTES.
|
||||
/// - If the response contains Content-Disposition or Mime-Type header
|
||||
/// values that would not normally be rendered then the response may
|
||||
/// receive special handling inside the browser (for example, via the
|
||||
/// file download code path instead of the URL request code path).
|
||||
///
|
||||
/// The |request| object will be marked as read-only after calling this
|
||||
/// method.
|
||||
///
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "libcef/renderer/blink_glue.h"
|
||||
|
||||
#include "third_party/blink/public/mojom/v8_cache_options.mojom-blink.h"
|
||||
#include "third_party/blink/public/platform/scheduler/web_resource_loading_task_runner_handle.h"
|
||||
#include "third_party/blink/public/platform/web_string.h"
|
||||
#include "third_party/blink/public/platform/web_url_response.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
@ -37,8 +36,6 @@
|
||||
#include "third_party/blink/renderer/platform/bindings/v8_binding.h"
|
||||
#include "third_party/blink/renderer/platform/loader/fetch/resource_response.h"
|
||||
#include "third_party/blink/renderer/platform/loader/fetch/script_fetch_options.h"
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h"
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/page_scheduler.h"
|
||||
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
|
||||
#undef LOG
|
||||
|
||||
@ -318,21 +315,4 @@ void StartNavigation(blink::WebLocalFrame* frame,
|
||||
.StartNavigation(frame_load_request, blink::WebFrameLoadType::kStandard);
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
|
||||
CreateResourceLoadingTaskRunnerHandle(blink::WebLocalFrame* frame) {
|
||||
blink::Frame* core_frame = blink::WebFrame::ToCoreFrame(*frame);
|
||||
return blink::To<blink::LocalFrame>(core_frame)
|
||||
->GetFrameScheduler()
|
||||
->CreateResourceLoadingTaskRunnerHandle();
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
|
||||
CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle(
|
||||
blink::WebLocalFrame* frame) {
|
||||
blink::Frame* core_frame = blink::WebFrame::ToCoreFrame(*frame);
|
||||
return blink::To<blink::LocalFrame>(core_frame)
|
||||
->GetFrameScheduler()
|
||||
->CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle();
|
||||
}
|
||||
|
||||
} // namespace blink_glue
|
||||
|
@ -25,10 +25,6 @@ class WebString;
|
||||
class WebURLRequest;
|
||||
class WebURLResponse;
|
||||
class WebView;
|
||||
|
||||
namespace scheduler {
|
||||
class WebResourceLoadingTaskRunnerHandle;
|
||||
}
|
||||
} // namespace blink
|
||||
|
||||
namespace blink_glue {
|
||||
@ -128,15 +124,6 @@ BLINK_EXPORT bool HasPluginFrameOwner(blink::WebLocalFrame* frame);
|
||||
BLINK_EXPORT void StartNavigation(blink::WebLocalFrame* frame,
|
||||
const blink::WebURLRequest& request);
|
||||
|
||||
// Used by CefFrameImpl::CreateURLLoader.
|
||||
BLINK_EXPORT
|
||||
std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
|
||||
CreateResourceLoadingTaskRunnerHandle(blink::WebLocalFrame* frame);
|
||||
BLINK_EXPORT
|
||||
std::unique_ptr<blink::scheduler::WebResourceLoadingTaskRunnerHandle>
|
||||
CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle(
|
||||
blink::WebLocalFrame* frame);
|
||||
|
||||
} // namespace blink_glue
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_BLINK_GLUE_H_
|
||||
|
@ -17,6 +17,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "include/cef_urlrequest.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/frame_util.h"
|
||||
#include "libcef/common/net/http_header_utils.h"
|
||||
@ -28,7 +29,6 @@
|
||||
#include "libcef/renderer/browser_impl.h"
|
||||
#include "libcef/renderer/dom_document_impl.h"
|
||||
#include "libcef/renderer/render_frame_util.h"
|
||||
#include "libcef/renderer/render_urlrequest_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
#include "libcef/renderer/v8_impl.h"
|
||||
|
||||
@ -37,11 +37,9 @@
|
||||
#include "content/renderer/render_frame_impl.h"
|
||||
#include "third_party/blink/public/mojom/frame/frame.mojom-blink.h"
|
||||
#include "third_party/blink/public/mojom/frame/lifecycle.mojom-blink.h"
|
||||
#include "third_party/blink/public/platform/web_back_forward_cache_loader_helper.h"
|
||||
#include "third_party/blink/public/platform/web_data.h"
|
||||
#include "third_party/blink/public/platform/web_string.h"
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
#include "third_party/blink/public/platform/web_url_loader.h"
|
||||
#include "third_party/blink/public/web/blink.h"
|
||||
#include "third_party/blink/public/web/web_document.h"
|
||||
#include "third_party/blink/public/web/web_document_loader.h"
|
||||
@ -260,17 +258,7 @@ void CefFrameImpl::VisitDOM(CefRefPtr<CefDOMVisitor> visitor) {
|
||||
CefRefPtr<CefURLRequest> CefFrameImpl::CreateURLRequest(
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
CEF_REQUIRE_RT_RETURN(nullptr);
|
||||
|
||||
if (!request || !client || !frame_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CefRefPtr<CefRenderURLRequest> impl =
|
||||
new CefRenderURLRequest(this, request, client);
|
||||
if (impl->Start()) {
|
||||
return impl.get();
|
||||
}
|
||||
NOTREACHED() << "CreateURLRequest cannot be called from the render process";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -309,42 +297,6 @@ void CefFrameImpl::SendProcessMessage(CefProcessId target_process,
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::WebURLLoader> CefFrameImpl::CreateURLLoader() {
|
||||
CEF_REQUIRE_RT();
|
||||
if (!frame_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!url_loader_factory_) {
|
||||
auto render_frame = content::RenderFrameImpl::FromWebFrame(frame_);
|
||||
if (render_frame) {
|
||||
url_loader_factory_ = render_frame->CreateURLLoaderFactory();
|
||||
}
|
||||
}
|
||||
if (!url_loader_factory_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return url_loader_factory_->CreateURLLoader(
|
||||
blink::WebURLRequest(),
|
||||
blink_glue::CreateResourceLoadingTaskRunnerHandle(frame_),
|
||||
blink_glue::CreateResourceLoadingMaybeUnfreezableTaskRunnerHandle(frame_),
|
||||
/*keep_alive_handle=*/mojo::NullRemote(),
|
||||
blink::WebBackForwardCacheLoaderHelper());
|
||||
}
|
||||
|
||||
std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper>
|
||||
CefFrameImpl::CreateResourceLoadInfoNotifierWrapper() {
|
||||
CEF_REQUIRE_RT();
|
||||
if (frame_) {
|
||||
auto render_frame = content::RenderFrameImpl::FromWebFrame(frame_);
|
||||
if (render_frame) {
|
||||
return render_frame->CreateResourceLoadInfoNotifierWrapper();
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CefFrameImpl::OnAttached() {
|
||||
// Called indirectly from RenderFrameCreated.
|
||||
ConnectBrowserFrame(ConnectReason::RENDER_FRAME_CREATED);
|
||||
@ -461,7 +413,6 @@ void CefFrameImpl::OnDetached() {
|
||||
OnDisconnect(DisconnectReason::DETACHED);
|
||||
|
||||
browser_ = nullptr;
|
||||
url_loader_factory_.reset();
|
||||
|
||||
// In case we never attached.
|
||||
while (!queued_browser_actions_.empty()) {
|
||||
|
@ -27,8 +27,6 @@ class ListValue;
|
||||
namespace blink {
|
||||
class ResourceLoadInfoNotifierWrapper;
|
||||
class WebLocalFrame;
|
||||
class WebURLLoader;
|
||||
class WebURLLoaderFactory;
|
||||
} // namespace blink
|
||||
|
||||
class GURL;
|
||||
@ -84,11 +82,6 @@ class CefFrameImpl
|
||||
void SendProcessMessage(CefProcessId target_process,
|
||||
CefRefPtr<CefProcessMessage> message) override;
|
||||
|
||||
// Used by CefRenderURLRequest.
|
||||
std::unique_ptr<blink::WebURLLoader> CreateURLLoader();
|
||||
std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper>
|
||||
CreateResourceLoadInfoNotifierWrapper();
|
||||
|
||||
// Forwarded from CefRenderFrameObserver.
|
||||
void OnAttached();
|
||||
void OnWasShown();
|
||||
@ -197,8 +190,6 @@ class CefFrameImpl
|
||||
std::queue<std::pair<std::string, BrowserFrameAction>>
|
||||
queued_browser_actions_;
|
||||
|
||||
std::unique_ptr<blink::WebURLLoaderFactory> url_loader_factory_;
|
||||
|
||||
mojo::Receiver<cef::mojom::RenderFrame> receiver_{this};
|
||||
|
||||
mojo::Remote<cef::mojom::BrowserFrame> browser_frame_;
|
||||
|
@ -1,501 +0,0 @@
|
||||
// Copyright (c) 2012 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/renderer/render_urlrequest_impl.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "libcef/common/request_impl.h"
|
||||
#include "libcef/common/response_impl.h"
|
||||
#include "libcef/renderer/blink_glue.h"
|
||||
#include "libcef/renderer/frame_impl.h"
|
||||
#include "libcef/renderer/thread_util.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "net/base/request_priority.h"
|
||||
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom.h"
|
||||
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h"
|
||||
#include "third_party/blink/public/platform/resource_load_info_notifier_wrapper.h"
|
||||
#include "third_party/blink/public/platform/web_security_origin.h"
|
||||
#include "third_party/blink/public/platform/web_string.h"
|
||||
#include "third_party/blink/public/platform/web_url.h"
|
||||
#include "third_party/blink/public/platform/web_url_error.h"
|
||||
#include "third_party/blink/public/platform/web_url_loader.h"
|
||||
#include "third_party/blink/public/platform/web_url_loader_client.h"
|
||||
#include "third_party/blink/public/platform/web_url_request.h"
|
||||
#include "third_party/blink/public/platform/web_url_request_extra_data.h"
|
||||
#include "third_party/blink/public/platform/web_url_response.h"
|
||||
|
||||
using blink::WebString;
|
||||
using blink::WebURL;
|
||||
using blink::WebURLError;
|
||||
using blink::WebURLLoader;
|
||||
using blink::WebURLRequest;
|
||||
using blink::WebURLResponse;
|
||||
|
||||
namespace {
|
||||
|
||||
class CefWebURLLoaderClient : public blink::WebURLLoaderClient {
|
||||
public:
|
||||
CefWebURLLoaderClient(CefRenderURLRequest::Context* context,
|
||||
int request_flags);
|
||||
~CefWebURLLoaderClient() override;
|
||||
|
||||
// blink::WebURLLoaderClient methods.
|
||||
void DidSendData(uint64_t bytes_sent,
|
||||
uint64_t total_bytes_to_be_sent) override;
|
||||
void DidReceiveResponse(const WebURLResponse& response) override;
|
||||
void DidReceiveData(const char* data, int dataLength) override;
|
||||
void DidFinishLoading(
|
||||
base::TimeTicks finish_time,
|
||||
int64_t total_encoded_data_length,
|
||||
uint64_t total_encoded_body_length,
|
||||
int64_t total_decoded_body_length,
|
||||
bool should_report_corb_blocking,
|
||||
absl::optional<bool> pervasive_payload_requested) override;
|
||||
void DidFail(const WebURLError&,
|
||||
base::TimeTicks finish_time,
|
||||
int64_t total_encoded_data_length,
|
||||
uint64_t total_encoded_body_length,
|
||||
int64_t total_decoded_body_length) override;
|
||||
void DidStartLoadingResponseBody(
|
||||
mojo::ScopedDataPipeConsumerHandle response_body) override;
|
||||
bool WillFollowRedirect(const WebURL& new_url,
|
||||
const net::SiteForCookies& new_site_for_cookies,
|
||||
const WebString& new_referrer,
|
||||
network::mojom::ReferrerPolicy new_referrer_policy,
|
||||
const WebString& new_method,
|
||||
const WebURLResponse& passed_redirect_response,
|
||||
bool& report_raw_headers,
|
||||
std::vector<std::string>* removed_headers,
|
||||
bool insecure_scheme_was_upgraded) override;
|
||||
|
||||
protected:
|
||||
// The context_ pointer will outlive this object.
|
||||
CefRenderURLRequest::Context* context_;
|
||||
int request_flags_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// CefRenderURLRequest::Context -----------------------------------------------
|
||||
|
||||
class CefRenderURLRequest::Context
|
||||
: public base::RefCountedThreadSafe<CefRenderURLRequest::Context> {
|
||||
public:
|
||||
Context(CefRefPtr<CefRenderURLRequest> url_request,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client)
|
||||
: url_request_(url_request),
|
||||
frame_(frame),
|
||||
request_(request),
|
||||
client_(client),
|
||||
status_(UR_IO_PENDING),
|
||||
error_code_(ERR_NONE),
|
||||
body_watcher_(FROM_HERE, mojo::SimpleWatcher::ArmingPolicy::MANUAL),
|
||||
response_was_cached_(false),
|
||||
upload_data_size_(0),
|
||||
got_upload_progress_complete_(false),
|
||||
download_data_received_(0),
|
||||
download_data_total_(-1) {
|
||||
// Mark the request as read-only.
|
||||
static_cast<CefRequestImpl*>(request_.get())->SetReadOnly(true);
|
||||
}
|
||||
|
||||
bool Start() {
|
||||
GURL url = GURL(request_->GetURL().ToString());
|
||||
if (!url.is_valid()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
url_client_.reset(new CefWebURLLoaderClient(this, request_->GetFlags()));
|
||||
|
||||
std::unique_ptr<network::ResourceRequest> resource_request =
|
||||
std::make_unique<network::ResourceRequest>();
|
||||
static_cast<CefRequestImpl*>(request_.get())
|
||||
->Get(resource_request.get(), false);
|
||||
resource_request->priority = net::MEDIUM;
|
||||
|
||||
// Behave the same as a subresource load.
|
||||
resource_request->resource_type =
|
||||
static_cast<int>(blink::mojom::ResourceType::kSubResource);
|
||||
|
||||
// Need load timing info for WebURLLoaderImpl::PopulateURLResponse to
|
||||
// properly set cached status.
|
||||
resource_request->enable_load_timing = true;
|
||||
|
||||
// Set the origin to match the request. The requirement for an origin is
|
||||
// DCHECK'd in ResourceDispatcherHostImpl::ContinuePendingBeginRequest.
|
||||
resource_request->request_initiator = url::Origin::Create(url);
|
||||
|
||||
if (request_->GetFlags() & UR_FLAG_ALLOW_STORED_CREDENTIALS) {
|
||||
// Include SameSite cookies.
|
||||
resource_request->site_for_cookies =
|
||||
net::SiteForCookies::FromOrigin(*resource_request->request_initiator);
|
||||
}
|
||||
|
||||
if (resource_request->request_body) {
|
||||
const auto& elements = *resource_request->request_body->elements();
|
||||
if (elements.size() > 0) {
|
||||
const auto& element = elements[0];
|
||||
if (element.type() == network::DataElement::Tag::kBytes) {
|
||||
const auto& bytes_element = element.As<network::DataElementBytes>();
|
||||
upload_data_size_ = bytes_element.bytes().size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto frame_impl = static_cast<CefFrameImpl*>(frame_.get());
|
||||
loader_ = frame_impl->CreateURLLoader();
|
||||
loader_->LoadAsynchronously(
|
||||
std::move(resource_request), /*extra_data=*/nullptr,
|
||||
/*no_mime_sniffing=*/false,
|
||||
frame_impl->CreateResourceLoadInfoNotifierWrapper(), url_client_.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
// The request may already be complete.
|
||||
if (!loader_.get() || status_ != UR_IO_PENDING) {
|
||||
return;
|
||||
}
|
||||
|
||||
status_ = UR_CANCELED;
|
||||
error_code_ = ERR_ABORTED;
|
||||
|
||||
// Will result in a call to OnError().
|
||||
loader_->Cancel();
|
||||
}
|
||||
|
||||
void OnStopRedirect(const WebURL& redirect_url,
|
||||
const WebURLResponse& response) {
|
||||
response_was_cached_ = blink_glue::ResponseWasCached(response);
|
||||
response_ = CefResponse::Create();
|
||||
CefResponseImpl* responseImpl =
|
||||
static_cast<CefResponseImpl*>(response_.get());
|
||||
|
||||
// In case of StopOnRedirect we only set these fields. Everything else is
|
||||
// left blank. This also replicates the behaviour of the browser urlrequest
|
||||
// fetcher.
|
||||
responseImpl->SetStatus(response.HttpStatusCode());
|
||||
responseImpl->SetURL(redirect_url.GetString().Utf16());
|
||||
responseImpl->SetReadOnly(true);
|
||||
|
||||
status_ = UR_CANCELED;
|
||||
error_code_ = ERR_ABORTED;
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
void OnResponse(const WebURLResponse& response) {
|
||||
response_was_cached_ = blink_glue::ResponseWasCached(response);
|
||||
response_ = CefResponse::Create();
|
||||
CefResponseImpl* responseImpl =
|
||||
static_cast<CefResponseImpl*>(response_.get());
|
||||
responseImpl->Set(response);
|
||||
responseImpl->SetReadOnly(true);
|
||||
|
||||
download_data_total_ = response.ExpectedContentLength();
|
||||
}
|
||||
|
||||
void OnError(const WebURLError& error) {
|
||||
if (status_ == UR_IO_PENDING) {
|
||||
status_ = UR_FAILED;
|
||||
error_code_ = static_cast<cef_errorcode_t>(error.reason());
|
||||
}
|
||||
|
||||
OnComplete();
|
||||
}
|
||||
|
||||
void OnComplete() {
|
||||
if (body_handle_.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (status_ == UR_IO_PENDING) {
|
||||
status_ = UR_SUCCESS;
|
||||
NotifyUploadProgressIfNecessary();
|
||||
}
|
||||
|
||||
if (loader_.get()) {
|
||||
loader_.reset(nullptr);
|
||||
}
|
||||
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnRequestComplete(url_request_.get());
|
||||
|
||||
// This may result in the Context object being deleted.
|
||||
url_request_ = nullptr;
|
||||
}
|
||||
|
||||
void OnBodyReadable(MojoResult, const mojo::HandleSignalsState&) {
|
||||
const void* buffer = nullptr;
|
||||
uint32_t read_bytes = 0;
|
||||
MojoResult result = body_handle_->BeginReadData(&buffer, &read_bytes,
|
||||
MOJO_READ_DATA_FLAG_NONE);
|
||||
if (result == MOJO_RESULT_SHOULD_WAIT) {
|
||||
body_watcher_.ArmOrNotify();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result == MOJO_RESULT_FAILED_PRECONDITION) {
|
||||
// Whole body has been read.
|
||||
body_handle_.reset();
|
||||
body_watcher_.Cancel();
|
||||
OnComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
if (result != MOJO_RESULT_OK) {
|
||||
// Something went wrong.
|
||||
body_handle_.reset();
|
||||
body_watcher_.Cancel();
|
||||
OnComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
download_data_received_ += read_bytes;
|
||||
|
||||
client_->OnDownloadProgress(url_request_.get(), download_data_received_,
|
||||
download_data_total_);
|
||||
|
||||
if (!(request_->GetFlags() & UR_FLAG_NO_DOWNLOAD_DATA)) {
|
||||
client_->OnDownloadData(url_request_.get(), buffer, read_bytes);
|
||||
}
|
||||
|
||||
body_handle_->EndReadData(read_bytes);
|
||||
body_watcher_.ArmOrNotify();
|
||||
}
|
||||
|
||||
void OnStartLoadingResponseBody(
|
||||
mojo::ScopedDataPipeConsumerHandle response_body) {
|
||||
DCHECK(response_body);
|
||||
DCHECK(!body_handle_);
|
||||
body_handle_ = std::move(response_body);
|
||||
|
||||
body_watcher_.Watch(
|
||||
body_handle_.get(),
|
||||
MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_PEER_CLOSED,
|
||||
MOJO_TRIGGER_CONDITION_SIGNALS_SATISFIED,
|
||||
base::BindRepeating(&CefRenderURLRequest::Context::OnBodyReadable,
|
||||
base::Unretained(this)));
|
||||
body_watcher_.ArmOrNotify();
|
||||
}
|
||||
|
||||
void OnDownloadProgress(int64_t current) {
|
||||
DCHECK(url_request_.get());
|
||||
|
||||
NotifyUploadProgressIfNecessary();
|
||||
|
||||
download_data_received_ += current;
|
||||
client_->OnDownloadProgress(url_request_.get(), download_data_received_,
|
||||
download_data_total_);
|
||||
}
|
||||
|
||||
void OnDownloadData(const char* data, int dataLength) {
|
||||
DCHECK(url_request_.get());
|
||||
client_->OnDownloadData(url_request_.get(), data, dataLength);
|
||||
}
|
||||
|
||||
void OnUploadProgress(int64_t current, int64_t total) {
|
||||
DCHECK(url_request_.get());
|
||||
if (current == total) {
|
||||
got_upload_progress_complete_ = true;
|
||||
}
|
||||
client_->OnUploadProgress(url_request_.get(), current, total);
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> request() const { return request_; }
|
||||
CefRefPtr<CefURLRequestClient> client() const { return client_; }
|
||||
CefURLRequest::Status status() const { return status_; }
|
||||
CefURLRequest::ErrorCode error_code() const { return error_code_; }
|
||||
CefRefPtr<CefResponse> response() const { return response_; }
|
||||
bool response_was_cached() const { return response_was_cached_; }
|
||||
|
||||
private:
|
||||
friend class base::RefCountedThreadSafe<CefRenderURLRequest::Context>;
|
||||
|
||||
virtual ~Context() {}
|
||||
|
||||
void NotifyUploadProgressIfNecessary() {
|
||||
if (!got_upload_progress_complete_ && upload_data_size_ > 0) {
|
||||
// Upload notifications are sent using a timer and may not occur if the
|
||||
// request completes too quickly. We therefore send the notification here
|
||||
// if necessary.
|
||||
url_client_->DidSendData(upload_data_size_, upload_data_size_);
|
||||
got_upload_progress_complete_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Members only accessed on the initialization thread.
|
||||
CefRefPtr<CefRenderURLRequest> url_request_;
|
||||
CefRefPtr<CefFrame> frame_;
|
||||
CefRefPtr<CefRequest> request_;
|
||||
CefRefPtr<CefURLRequestClient> client_;
|
||||
CefURLRequest::Status status_;
|
||||
CefURLRequest::ErrorCode error_code_;
|
||||
CefRefPtr<CefResponse> response_;
|
||||
mojo::ScopedDataPipeConsumerHandle body_handle_;
|
||||
mojo::SimpleWatcher body_watcher_;
|
||||
bool response_was_cached_;
|
||||
std::unique_ptr<blink::WebURLLoader> loader_;
|
||||
std::unique_ptr<CefWebURLLoaderClient> url_client_;
|
||||
int64_t upload_data_size_;
|
||||
bool got_upload_progress_complete_;
|
||||
int64_t download_data_received_;
|
||||
int64_t download_data_total_;
|
||||
};
|
||||
|
||||
// CefWebURLLoaderClient --------------------------------------------------
|
||||
|
||||
namespace {
|
||||
|
||||
CefWebURLLoaderClient::CefWebURLLoaderClient(
|
||||
CefRenderURLRequest::Context* context,
|
||||
int request_flags)
|
||||
: context_(context), request_flags_(request_flags) {}
|
||||
|
||||
CefWebURLLoaderClient::~CefWebURLLoaderClient() {}
|
||||
|
||||
void CefWebURLLoaderClient::DidSendData(uint64_t bytes_sent,
|
||||
uint64_t total_bytes_to_be_sent) {
|
||||
if (request_flags_ & UR_FLAG_REPORT_UPLOAD_PROGRESS) {
|
||||
context_->OnUploadProgress(bytes_sent, total_bytes_to_be_sent);
|
||||
}
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidReceiveResponse(const WebURLResponse& response) {
|
||||
context_->OnResponse(response);
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidReceiveData(const char* data, int dataLength) {
|
||||
context_->OnDownloadProgress(dataLength);
|
||||
|
||||
if (!(request_flags_ & UR_FLAG_NO_DOWNLOAD_DATA)) {
|
||||
context_->OnDownloadData(data, dataLength);
|
||||
}
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidFinishLoading(
|
||||
base::TimeTicks finish_time,
|
||||
int64_t total_encoded_data_length,
|
||||
uint64_t total_encoded_body_length,
|
||||
int64_t total_decoded_body_length,
|
||||
bool should_report_corb_blocking,
|
||||
absl::optional<bool> pervasive_payload_requested) {
|
||||
context_->OnComplete();
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidFail(const WebURLError& error,
|
||||
base::TimeTicks finish_time,
|
||||
int64_t total_encoded_data_length,
|
||||
uint64_t total_encoded_body_length,
|
||||
int64_t total_decoded_body_length) {
|
||||
context_->OnError(error);
|
||||
}
|
||||
|
||||
void CefWebURLLoaderClient::DidStartLoadingResponseBody(
|
||||
mojo::ScopedDataPipeConsumerHandle response_body) {
|
||||
context_->OnStartLoadingResponseBody(std::move(response_body));
|
||||
}
|
||||
|
||||
bool CefWebURLLoaderClient::WillFollowRedirect(
|
||||
const WebURL& new_url,
|
||||
const net::SiteForCookies& new_site_for_cookies,
|
||||
const WebString& new_referrer,
|
||||
network::mojom::ReferrerPolicy new_referrer_policy,
|
||||
const WebString& new_method,
|
||||
const WebURLResponse& passed_redirect_response,
|
||||
bool& report_raw_headers,
|
||||
std::vector<std::string>* removed_headers,
|
||||
bool insecure_scheme_was_upgraded) {
|
||||
if (request_flags_ & UR_FLAG_STOP_ON_REDIRECT) {
|
||||
context_->OnStopRedirect(new_url, passed_redirect_response);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// CefRenderURLRequest --------------------------------------------------------
|
||||
|
||||
CefRenderURLRequest::CefRenderURLRequest(
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client) {
|
||||
DCHECK(frame);
|
||||
DCHECK(request);
|
||||
DCHECK(client);
|
||||
context_ = new Context(this, frame, request, client);
|
||||
}
|
||||
|
||||
CefRenderURLRequest::~CefRenderURLRequest() {}
|
||||
|
||||
bool CefRenderURLRequest::Start() {
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
return context_->Start();
|
||||
}
|
||||
|
||||
CefRefPtr<CefRequest> CefRenderURLRequest::GetRequest() {
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->request();
|
||||
}
|
||||
|
||||
CefRefPtr<CefURLRequestClient> CefRenderURLRequest::GetClient() {
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->client();
|
||||
}
|
||||
|
||||
CefURLRequest::Status CefRenderURLRequest::GetRequestStatus() {
|
||||
if (!VerifyContext()) {
|
||||
return UR_UNKNOWN;
|
||||
}
|
||||
return context_->status();
|
||||
}
|
||||
|
||||
CefURLRequest::ErrorCode CefRenderURLRequest::GetRequestError() {
|
||||
if (!VerifyContext()) {
|
||||
return ERR_NONE;
|
||||
}
|
||||
return context_->error_code();
|
||||
}
|
||||
|
||||
CefRefPtr<CefResponse> CefRenderURLRequest::GetResponse() {
|
||||
if (!VerifyContext()) {
|
||||
return nullptr;
|
||||
}
|
||||
return context_->response();
|
||||
}
|
||||
|
||||
bool CefRenderURLRequest::ResponseWasCached() {
|
||||
if (!VerifyContext()) {
|
||||
return false;
|
||||
}
|
||||
return context_->response_was_cached();
|
||||
}
|
||||
|
||||
void CefRenderURLRequest::Cancel() {
|
||||
if (!VerifyContext()) {
|
||||
return;
|
||||
}
|
||||
return context_->Cancel();
|
||||
}
|
||||
|
||||
bool CefRenderURLRequest::VerifyContext() {
|
||||
DCHECK(context_.get());
|
||||
if (!CEF_CURRENTLY_ON_RT()) {
|
||||
NOTREACHED() << "called on invalid thread";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
// Copyright (c) 2012 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_RENDERER_RENDER_URLREQUEST_IMPL_H_
|
||||
#define CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_
|
||||
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/cef_urlrequest.h"
|
||||
|
||||
#include "base/memory/ref_counted.h"
|
||||
|
||||
class CefRenderURLRequest : public CefURLRequest {
|
||||
public:
|
||||
class Context;
|
||||
|
||||
// If |frame| is nullptr the default URLLoaderFactory will be used. That
|
||||
// factory only supports http(s) and blob requests that cannot be
|
||||
// intercepted in the browser process.
|
||||
CefRenderURLRequest(CefRefPtr<CefFrame> frame,
|
||||
CefRefPtr<CefRequest> request,
|
||||
CefRefPtr<CefURLRequestClient> client);
|
||||
~CefRenderURLRequest() override;
|
||||
|
||||
bool Start();
|
||||
|
||||
// CefURLRequest methods.
|
||||
CefRefPtr<CefRequest> GetRequest() override;
|
||||
CefRefPtr<CefURLRequestClient> GetClient() override;
|
||||
Status GetRequestStatus() override;
|
||||
ErrorCode GetRequestError() override;
|
||||
CefRefPtr<CefResponse> GetResponse() override;
|
||||
bool ResponseWasCached() override;
|
||||
void Cancel() override;
|
||||
|
||||
private:
|
||||
bool VerifyContext();
|
||||
|
||||
scoped_refptr<Context> context_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(CefRenderURLRequest);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_RENDERER_RENDER_URLREQUEST_IMPL_H_
|
@ -471,11 +471,6 @@ patches = [
|
||||
# http://crrev.com/3955c9f9eb
|
||||
'name': 'set_resize_background_color',
|
||||
},
|
||||
{
|
||||
# Restore WebUrlLoader Cancel method.
|
||||
# https://chromium-review.googlesource.com/c/chromium/src/+/1617042
|
||||
'name': 'web_url_loader_cancel_1617042',
|
||||
},
|
||||
{
|
||||
# Avoid a shutdown crash with multi-threaded message loop caused by
|
||||
# |g_browser_task_executor->browser_ui_thread_scheduler_| being null when
|
||||
|
@ -1,21 +0,0 @@
|
||||
diff --git third_party/blink/public/platform/web_url_loader.h third_party/blink/public/platform/web_url_loader.h
|
||||
index 31054cf2795a4..d5082be28ea54 100644
|
||||
--- third_party/blink/public/platform/web_url_loader.h
|
||||
+++ third_party/blink/public/platform/web_url_loader.h
|
||||
@@ -143,12 +143,14 @@ class BLINK_PLATFORM_EXPORT WebURLLoader {
|
||||
void SetResourceRequestSenderForTesting(
|
||||
std::unique_ptr<WebResourceRequestSender> resource_request_sender);
|
||||
|
||||
+ // Cancels an asynchronous load. This will appear as a load error to
|
||||
+ // the client.
|
||||
+ void Cancel();
|
||||
+
|
||||
private:
|
||||
class Context;
|
||||
class RequestPeerImpl;
|
||||
|
||||
- void Cancel();
|
||||
-
|
||||
scoped_refptr<Context> context_;
|
||||
};
|
||||
|
@ -79,11 +79,6 @@ void CreateRenderDelegates(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates);
|
||||
CreateThreadRendererTests(delegates);
|
||||
|
||||
// Bring in the URLRequest tests.
|
||||
extern void CreateURLRequestRendererTests(ClientAppRenderer::DelegateSet &
|
||||
delegates);
|
||||
CreateURLRequestRendererTests(delegates);
|
||||
|
||||
// Bring in the V8 tests.
|
||||
extern void CreateV8RendererTests(ClientAppRenderer::DelegateSet & delegates);
|
||||
CreateV8RendererTests(delegates);
|
||||
|
@ -26,9 +26,6 @@
|
||||
#include "tests/shared/browser/client_app_browser.h"
|
||||
#include "tests/shared/browser/file_util.h"
|
||||
#include "tests/shared/common/string_util.h"
|
||||
#include "tests/shared/renderer/client_app_renderer.h"
|
||||
|
||||
using client::ClientAppRenderer;
|
||||
|
||||
// How to add a new test:
|
||||
// 1. Add a new value to the RequestTestMode enumeration.
|
||||
@ -60,18 +57,13 @@ class URLRequestBrowserTest : public client::ClientAppBrowser::Delegate {
|
||||
IMPLEMENT_REFCOUNTING(URLRequestBrowserTest);
|
||||
};
|
||||
|
||||
// Unique values for URLRequest tests.
|
||||
const char kRequestTestMsg[] = "URLRequestTest.Test";
|
||||
const char kIncompleteRequestTestMsg[] = "URLRequestTest.IncompleteRequestTest";
|
||||
|
||||
// TEST DATA
|
||||
|
||||
// Custom scheme handler backend.
|
||||
const char kRequestSchemeCustom[] = "urcustom";
|
||||
const char kRequestHostCustom[] = "test";
|
||||
|
||||
// Server backend. These values are hard-coded because they're used in both the
|
||||
// browser and renderer processes.
|
||||
// Server backend.
|
||||
const char* kRequestAddressServer = test_server::kHttpServerAddress;
|
||||
const uint16 kRequestPortServer = test_server::kHttpServerPort;
|
||||
const char kRequestSchemeServer[] = "http";
|
||||
@ -1442,15 +1434,11 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
public:
|
||||
using TestCallback = base::RepeatingCallback<void(base::OnceClosure)>;
|
||||
|
||||
RequestTestRunner(bool is_browser_process,
|
||||
bool is_server_backend,
|
||||
RequestTestRunner(bool is_server_backend,
|
||||
bool use_frame_method,
|
||||
bool run_in_browser_process,
|
||||
base::OnceClosure incomplete_request_callback)
|
||||
: is_browser_process_(is_browser_process),
|
||||
is_server_backend_(is_server_backend),
|
||||
: is_server_backend_(is_server_backend),
|
||||
use_frame_method_(use_frame_method),
|
||||
run_in_browser_process_(run_in_browser_process),
|
||||
incomplete_request_callback_(std::move(incomplete_request_callback)) {
|
||||
owner_task_runner_ = CefTaskRunner::GetForCurrentThread();
|
||||
EXPECT_TRUE(owner_task_runner_.get());
|
||||
@ -1527,7 +1515,7 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
return request_context_;
|
||||
}
|
||||
|
||||
// Called in both the browser and render process to setup the test.
|
||||
// Called to setup the test.
|
||||
void SetupTest(RequestTestMode test_mode,
|
||||
base::OnceClosure complete_callback) {
|
||||
EXPECT_TRUE(owner_task_runner_->BelongsToCurrentThread());
|
||||
@ -1547,7 +1535,7 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
}
|
||||
}
|
||||
|
||||
// Called in either the browser or render process to run the test.
|
||||
// Called to run the test.
|
||||
void RunTest(RequestTestMode test_mode,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
base::OnceClosure complete_callback) {
|
||||
@ -1568,7 +1556,7 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
}
|
||||
}
|
||||
|
||||
// Called in both the browser and render process to shut down the test.
|
||||
// Called to shut down the test.
|
||||
void ShutdownTest(base::OnceClosure complete_callback) {
|
||||
EXPECT_TRUE(owner_task_runner_->BelongsToCurrentThread());
|
||||
|
||||
@ -1577,7 +1565,6 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
std::move(complete_callback));
|
||||
|
||||
if (!post_file_tmpdir_.IsEmpty()) {
|
||||
EXPECT_TRUE(is_browser_process_);
|
||||
CefPostTask(TID_FILE_USER_VISIBLE,
|
||||
base::BindOnce(&RequestTestRunner::RunDeleteTempDirectory,
|
||||
this, std::move(safe_complete_callback)));
|
||||
@ -1598,16 +1585,11 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_browser_process_) {
|
||||
SetupTestBackend(std::move(complete_callback));
|
||||
} else {
|
||||
std::move(complete_callback).Run();
|
||||
}
|
||||
SetupTestBackend(std::move(complete_callback));
|
||||
}
|
||||
|
||||
std::string GetTestPath(const std::string& name) {
|
||||
return std::string(run_in_browser_process_ ? "/Browser" : "/Renderer") +
|
||||
name;
|
||||
return std::string("/Browser") + name;
|
||||
}
|
||||
|
||||
std::string GetTestURL(const std::string& name) {
|
||||
@ -1704,9 +1686,7 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
// on stop redirects.
|
||||
settings_.response = CefResponse::Create();
|
||||
settings_.response->SetStatus(302);
|
||||
if (is_browser_process_) {
|
||||
settings_.response->SetStatusText("Found");
|
||||
}
|
||||
settings_.response->SetStatusText("Found");
|
||||
|
||||
// Add a redirect request.
|
||||
settings_.redirect_request = CefRequest::Create();
|
||||
@ -1816,9 +1796,6 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
}
|
||||
|
||||
void SetupPostFileTest(base::OnceClosure complete_callback) {
|
||||
// This test is only supported in the browser process.
|
||||
EXPECT_TRUE(is_browser_process_);
|
||||
|
||||
settings_.request = CefRequest::Create();
|
||||
settings_.request->SetURL(GetTestURL("PostFileTest.html"));
|
||||
settings_.request->SetMethod("POST");
|
||||
@ -2298,10 +2275,7 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
settings_.response_data = test_server::kIncompleteDoNotSendData;
|
||||
settings_.expected_error_code = ERR_ABORTED;
|
||||
settings_.expected_status = UR_FAILED;
|
||||
// TODO(network): Download progress notifications are sent for incomplete
|
||||
// (with no data sent) requests in the browser process but not the renderer
|
||||
// process. Consider standardizing this behavior.
|
||||
settings_.expect_download_progress = is_browser_process_;
|
||||
settings_.expect_download_progress = true;
|
||||
settings_.expect_download_data = false;
|
||||
|
||||
std::move(complete_callback).Run();
|
||||
@ -2309,11 +2283,6 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
|
||||
// Send a request. |complete_callback| will be executed on request completion.
|
||||
void SendRequest(test_request::RequestDoneCallback done_callback) {
|
||||
if (!is_browser_process_) {
|
||||
// Render process requests must use CefFrame::CreateURLRequest.
|
||||
EXPECT_TRUE(use_frame_method_);
|
||||
}
|
||||
|
||||
test_request::SendConfig config;
|
||||
|
||||
if (settings_.redirect_request) {
|
||||
@ -2503,18 +2472,11 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_browser_process_) {
|
||||
ShutdownTestBackend(std::move(complete_callback));
|
||||
} else {
|
||||
std::move(complete_callback).Run();
|
||||
}
|
||||
ShutdownTestBackend(std::move(complete_callback));
|
||||
}
|
||||
|
||||
// Create the backend for the current test. Called during test setup.
|
||||
void SetupTestBackend(base::OnceClosure complete_callback) {
|
||||
// Backends are only created in the browser process.
|
||||
EXPECT_TRUE(is_browser_process_);
|
||||
|
||||
EXPECT_TRUE(settings_.request.get());
|
||||
EXPECT_TRUE(settings_.response.get() ||
|
||||
settings_.expected_status == UR_FAILED);
|
||||
@ -2559,8 +2521,6 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
|
||||
// Shutdown the backend for the current test. Called during test shutdown.
|
||||
void ShutdownTestBackend(base::OnceClosure complete_callback) {
|
||||
// Backends are only created in the browser process.
|
||||
EXPECT_TRUE(is_browser_process_);
|
||||
if (is_server_backend_) {
|
||||
ShutdownServer(std::move(complete_callback));
|
||||
} else {
|
||||
@ -2586,17 +2546,13 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
scheme_factory_ = nullptr;
|
||||
}
|
||||
|
||||
const bool is_browser_process_;
|
||||
const bool is_server_backend_;
|
||||
const bool use_frame_method_;
|
||||
const bool run_in_browser_process_;
|
||||
|
||||
// Used with incomplete request tests.
|
||||
base::OnceClosure incomplete_request_callback_;
|
||||
|
||||
// Primary thread runner for the object that owns us. In the browser process
|
||||
// this will be the UI thread and in the renderer process this will be the
|
||||
// RENDERER thread.
|
||||
// Primary thread runner (UI thread) for the object that owns us.
|
||||
CefRefPtr<CefTaskRunner> owner_task_runner_;
|
||||
|
||||
CefRefPtr<CefRequestContext> request_context_;
|
||||
@ -2624,137 +2580,16 @@ class RequestTestRunner : public base::RefCountedThreadSafe<RequestTestRunner> {
|
||||
RequestRunSettings settings_;
|
||||
};
|
||||
|
||||
// RENDERER-SIDE TEST HARNESS
|
||||
|
||||
class RequestRendererTest : public ClientAppRenderer::Delegate {
|
||||
public:
|
||||
RequestRendererTest() {}
|
||||
|
||||
bool OnProcessMessageReceived(CefRefPtr<ClientAppRenderer> app,
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
if (message->GetName() == kRequestTestMsg) {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_RENDERER));
|
||||
EXPECT_TRUE(frame->IsMain());
|
||||
|
||||
app_ = app;
|
||||
browser_ = browser;
|
||||
frame_ = nullptr;
|
||||
|
||||
CefRefPtr<CefListValue> args = message->GetArgumentList();
|
||||
|
||||
const bool use_frame_method = args->GetBool(2);
|
||||
if (use_frame_method) {
|
||||
frame_ = frame;
|
||||
}
|
||||
|
||||
test_mode_ = static_cast<RequestTestMode>(args->GetInt(0));
|
||||
test_runner_ = new RequestTestRunner(
|
||||
false, args->GetBool(1), use_frame_method, false,
|
||||
base::BindOnce(&RequestRendererTest::OnIncompleteRequest, this));
|
||||
test_runner_->Initialize();
|
||||
|
||||
// Setup the test. This will create the objects that we test against but
|
||||
// not register any backend (because we're in the render process).
|
||||
test_runner_->SetupTest(
|
||||
test_mode_,
|
||||
base::BindOnce(&RequestRendererTest::OnSetupComplete, this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Message not handled.
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
void OnSetupComplete() {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_RENDERER));
|
||||
|
||||
// Run the test.
|
||||
test_runner_->RunTest(
|
||||
test_mode_, frame_,
|
||||
base::BindOnce(&RequestRendererTest::OnRunComplete, this));
|
||||
}
|
||||
|
||||
void OnRunComplete() {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_RENDERER));
|
||||
|
||||
// Shutdown the test.
|
||||
test_runner_->ShutdownTest(
|
||||
base::BindOnce(&RequestRendererTest::OnShutdownComplete, this));
|
||||
}
|
||||
|
||||
void OnIncompleteRequest() {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_RENDERER));
|
||||
|
||||
// This method will only be called for incomplete requests.
|
||||
EXPECT_NE(test_runner_->settings_.incomplete_type,
|
||||
RequestRunSettings::INCOMPLETE_NONE);
|
||||
|
||||
// Check if the test has failed.
|
||||
bool result = !TestFailed();
|
||||
|
||||
// The browser will be closed to abort in-progress requests.
|
||||
CefRefPtr<CefProcessMessage> return_msg =
|
||||
CefProcessMessage::Create(kIncompleteRequestTestMsg);
|
||||
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
||||
browser_->GetMainFrame()->SendProcessMessage(PID_BROWSER, return_msg);
|
||||
}
|
||||
|
||||
void OnShutdownComplete() {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_RENDERER));
|
||||
|
||||
if (test_runner_->settings_.incomplete_type !=
|
||||
RequestRunSettings::INCOMPLETE_NONE) {
|
||||
// For incomplete tests there's a race between process destruction due to
|
||||
// the browser closing, and the test possibly completing due to request
|
||||
// cancellation. We therefore ignore test completion in this case.
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the test has failed.
|
||||
bool result = !TestFailed();
|
||||
|
||||
// Return the result to the browser process.
|
||||
CefRefPtr<CefProcessMessage> return_msg =
|
||||
CefProcessMessage::Create(kRequestTestMsg);
|
||||
EXPECT_TRUE(return_msg->GetArgumentList()->SetBool(0, result));
|
||||
browser_->GetMainFrame()->SendProcessMessage(PID_BROWSER, return_msg);
|
||||
|
||||
app_ = nullptr;
|
||||
browser_ = nullptr;
|
||||
}
|
||||
|
||||
CefRefPtr<ClientAppRenderer> app_;
|
||||
CefRefPtr<CefBrowser> browser_;
|
||||
CefRefPtr<CefFrame> frame_;
|
||||
RequestTestMode test_mode_;
|
||||
|
||||
scoped_refptr<RequestTestRunner> test_runner_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(RequestRendererTest);
|
||||
};
|
||||
|
||||
// BROWSER-SIDE TEST HARNESS
|
||||
|
||||
class RequestTestHandler : public TestHandler {
|
||||
public:
|
||||
RequestTestHandler(RequestTestMode test_mode,
|
||||
ContextTestMode context_mode,
|
||||
bool test_in_browser,
|
||||
bool test_server_backend,
|
||||
bool test_frame_method)
|
||||
: test_mode_(test_mode),
|
||||
context_mode_(context_mode),
|
||||
test_in_browser_(test_in_browser),
|
||||
test_server_backend_(test_server_backend),
|
||||
test_frame_method_(test_frame_method),
|
||||
// Must use the request origin to avoid failures in
|
||||
// CorsURLLoaderFactory::IsSane for requests originating from the
|
||||
// renderer process.
|
||||
test_url_(GetRequestOrigin(test_server_backend) +
|
||||
"/URLRequestTest.Test") {}
|
||||
|
||||
@ -2789,7 +2624,7 @@ class RequestTestHandler : public TestHandler {
|
||||
EXPECT_TRUE(CefCurrentlyOn(TID_UI));
|
||||
|
||||
test_runner_ = new RequestTestRunner(
|
||||
true, test_server_backend_, test_frame_method_, test_in_browser_,
|
||||
test_server_backend_, test_frame_method_,
|
||||
base::BindOnce(&RequestTestHandler::OnIncompleteRequest, this));
|
||||
test_runner_->Initialize();
|
||||
|
||||
@ -2858,25 +2693,18 @@ class RequestTestHandler : public TestHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (test_in_browser_) {
|
||||
if (test_frame_method_) {
|
||||
AddResource(test_url_, "<html><body>TEST</body></html>", "text/html");
|
||||
|
||||
// Create the browser who's main frame will be the initiator for the
|
||||
// request.
|
||||
CreateBrowser(test_url_, test_runner_->GetRequestContext());
|
||||
} else {
|
||||
// Run the test now.
|
||||
test_running_ = true;
|
||||
test_runner_->RunTest(
|
||||
test_mode_, nullptr /* frame */,
|
||||
base::BindOnce(&RequestTestHandler::OnRunComplete, this));
|
||||
}
|
||||
} else {
|
||||
if (test_frame_method_) {
|
||||
AddResource(test_url_, "<html><body>TEST</body></html>", "text/html");
|
||||
|
||||
// Create a browser to run the test in the renderer process.
|
||||
// Create the browser who's main frame will be the initiator for the
|
||||
// request.
|
||||
CreateBrowser(test_url_, test_runner_->GetRequestContext());
|
||||
} else {
|
||||
// Run the test now.
|
||||
test_running_ = true;
|
||||
test_runner_->RunTest(
|
||||
test_mode_, nullptr /* frame */,
|
||||
base::BindOnce(&RequestTestHandler::OnRunComplete, this));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2901,7 +2729,6 @@ class RequestTestHandler : public TestHandler {
|
||||
const CefString& realm,
|
||||
const CefString& scheme,
|
||||
CefRefPtr<CefAuthCallback> callback) override {
|
||||
EXPECT_TRUE(test_in_browser_);
|
||||
EXPECT_TRUE(test_frame_method_);
|
||||
auth_credentials_ct_++;
|
||||
if (test_runner_->settings_.expect_authentication) {
|
||||
@ -2915,7 +2742,7 @@ class RequestTestHandler : public TestHandler {
|
||||
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
int httpStatusCode) override {
|
||||
if (test_in_browser_ && test_frame_method_) {
|
||||
if (test_frame_method_) {
|
||||
// Run the test now.
|
||||
test_frame_ = frame;
|
||||
test_running_ = true;
|
||||
@ -2924,66 +2751,6 @@ class RequestTestHandler : public TestHandler {
|
||||
base::BindOnce(&RequestTestHandler::OnRunComplete, this));
|
||||
return;
|
||||
}
|
||||
|
||||
EXPECT_FALSE(test_in_browser_);
|
||||
if (frame->IsMain()) {
|
||||
CefRefPtr<CefProcessMessage> test_message =
|
||||
CefProcessMessage::Create(kRequestTestMsg);
|
||||
CefRefPtr<CefListValue> args = test_message->GetArgumentList();
|
||||
EXPECT_TRUE(args->SetInt(0, test_mode_));
|
||||
EXPECT_TRUE(args->SetBool(1, test_server_backend_));
|
||||
EXPECT_TRUE(args->SetBool(2, test_frame_method_));
|
||||
|
||||
if (test_frame_method_) {
|
||||
test_frame_ = frame;
|
||||
}
|
||||
test_running_ = true;
|
||||
|
||||
// Send a message to the renderer process to run the test.
|
||||
frame->SendProcessMessage(PID_RENDERER, test_message);
|
||||
}
|
||||
}
|
||||
|
||||
bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefFrame> frame,
|
||||
CefProcessId source_process,
|
||||
CefRefPtr<CefProcessMessage> message) override {
|
||||
EXPECT_TRUE(browser.get());
|
||||
EXPECT_TRUE(frame.get());
|
||||
EXPECT_EQ(PID_RENDERER, source_process);
|
||||
EXPECT_TRUE(message.get());
|
||||
EXPECT_TRUE(message->IsReadOnly());
|
||||
EXPECT_FALSE(test_in_browser_);
|
||||
|
||||
EXPECT_FALSE(got_message_);
|
||||
got_message_.yes();
|
||||
|
||||
if (message->GetArgumentList()->GetBool(0)) {
|
||||
got_success_.yes();
|
||||
}
|
||||
|
||||
const std::string& message_name = message->GetName();
|
||||
if (message_name == kRequestTestMsg) {
|
||||
// Renderer process test is complete.
|
||||
OnRunComplete();
|
||||
} else if (message_name == kIncompleteRequestTestMsg) {
|
||||
// Incomplete renderer tests will not complete normally. Instead, trigger
|
||||
// browser close and then signal completion from OnBeforeClose.
|
||||
OnIncompleteRequest();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnBeforeClose(CefRefPtr<CefBrowser> browser) override {
|
||||
if (!test_in_browser_ && test_runner_->settings_.incomplete_type !=
|
||||
RequestRunSettings::INCOMPLETE_NONE) {
|
||||
// Incomplete tests running in the renderer process will never recieve the
|
||||
// test complete process message, so call the method here.
|
||||
OnRunComplete();
|
||||
}
|
||||
|
||||
TestHandler::OnBeforeClose(browser);
|
||||
}
|
||||
|
||||
// Incomplete tests will not complete normally. Instead, we trigger a browser
|
||||
@ -3007,7 +2774,7 @@ class RequestTestHandler : public TestHandler {
|
||||
1000);
|
||||
}
|
||||
|
||||
// Test run is complete. It ran in either the browser or render process.
|
||||
// Test run is complete.
|
||||
void OnRunComplete() {
|
||||
GetTestCookie(test_runner_->GetRequestContext(), test_server_backend_,
|
||||
base::BindOnce(&RequestTestHandler::PostRunComplete, this));
|
||||
@ -3042,11 +2809,6 @@ class RequestTestHandler : public TestHandler {
|
||||
}
|
||||
|
||||
void DestroyTest() override {
|
||||
if (!test_in_browser_) {
|
||||
EXPECT_TRUE(got_message_);
|
||||
EXPECT_TRUE(got_success_);
|
||||
}
|
||||
|
||||
if (test_frame_method_) {
|
||||
// Expect at least 1 call to OnBeforeResourceLoad for every test.
|
||||
// Redirect tests may get multiple calls.
|
||||
@ -3056,8 +2818,7 @@ class RequestTestHandler : public TestHandler {
|
||||
// CefRequestHandler::GetAuthCredentials should be called after
|
||||
// CefURLRequestClient::GetAuthCredentials when the request has an
|
||||
// associated frame.
|
||||
if (test_in_browser_ && test_frame_method_ &&
|
||||
test_runner_->settings_.expect_authentication) {
|
||||
if (test_frame_method_ && test_runner_->settings_.expect_authentication) {
|
||||
EXPECT_EQ(1, auth_credentials_ct_);
|
||||
} else {
|
||||
EXPECT_EQ(0, auth_credentials_ct_);
|
||||
@ -3069,7 +2830,7 @@ class RequestTestHandler : public TestHandler {
|
||||
// RequestContextHandler is destroyed.
|
||||
bool call_test_complete = false;
|
||||
if (context_mode_ == CONTEXT_GLOBAL) {
|
||||
if (test_in_browser_ && !test_frame_method_) {
|
||||
if (!test_frame_method_) {
|
||||
// These tests don't create a browser that would signal implicitly.
|
||||
call_test_complete = true;
|
||||
} else if (!SignalCompletionWhenAllBrowsersClose()) {
|
||||
@ -3127,7 +2888,6 @@ class RequestTestHandler : public TestHandler {
|
||||
|
||||
const RequestTestMode test_mode_;
|
||||
const ContextTestMode context_mode_;
|
||||
const bool test_in_browser_;
|
||||
const bool test_server_backend_;
|
||||
const bool test_frame_method_;
|
||||
const std::string test_url_;
|
||||
@ -3143,37 +2903,14 @@ class RequestTestHandler : public TestHandler {
|
||||
CefString context_tmpdir_path_;
|
||||
|
||||
public:
|
||||
// Only used when the test runs in the render process.
|
||||
TrackCallback got_message_;
|
||||
TrackCallback got_success_;
|
||||
|
||||
int auth_credentials_ct_ = 0;
|
||||
TrackCallback got_on_test_complete_;
|
||||
|
||||
IMPLEMENT_REFCOUNTING(RequestTestHandler);
|
||||
};
|
||||
|
||||
bool IsTestSupported(RequestTestMode test_mode,
|
||||
ContextTestMode context_mode,
|
||||
bool test_in_browser,
|
||||
bool test_server_backend,
|
||||
bool test_frame_method) {
|
||||
if (!test_in_browser && !test_frame_method) {
|
||||
// Render process requests must use CefFrame::CreateURLRequest.
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// Entry point for creating URLRequest renderer test objects.
|
||||
// Called from client_app_delegates.cc.
|
||||
void CreateURLRequestRendererTests(ClientAppRenderer::DelegateSet& delegates) {
|
||||
delegates.insert(new RequestRendererTest);
|
||||
}
|
||||
|
||||
// Entry point for registering custom schemes.
|
||||
// Called from client_app_delegates.cc.
|
||||
void RegisterURLRequestCustomSchemes(CefRawPtr<CefSchemeRegistrar> registrar) {
|
||||
@ -3191,79 +2928,45 @@ void RegisterURLRequestCookieableSchemes(
|
||||
}
|
||||
|
||||
// Helpers for defining URLRequest tests.
|
||||
#define REQ_TEST_EX(name, test_mode, context_mode, test_in_browser, \
|
||||
test_server_backend, test_frame_method) \
|
||||
TEST(URLRequestTest, name) { \
|
||||
if (!IsTestSupported(test_mode, context_mode, test_in_browser, \
|
||||
test_server_backend, test_frame_method)) { \
|
||||
return; \
|
||||
} \
|
||||
CefRefPtr<RequestTestHandler> handler = \
|
||||
new RequestTestHandler(test_mode, context_mode, test_in_browser, \
|
||||
test_server_backend, test_frame_method); \
|
||||
handler->ExecuteTest(); \
|
||||
ReleaseAndWaitForDestructor(handler); \
|
||||
#define REQ_TEST(name, test_mode, context_mode, test_server_backend, \
|
||||
test_frame_method) \
|
||||
TEST(URLRequestTest, name) { \
|
||||
CefRefPtr<RequestTestHandler> handler = new RequestTestHandler( \
|
||||
test_mode, context_mode, test_server_backend, test_frame_method); \
|
||||
handler->ExecuteTest(); \
|
||||
ReleaseAndWaitForDestructor(handler); \
|
||||
}
|
||||
|
||||
#define REQ_TEST(name, test_mode, context_mode, test_in_browser, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST_EX(name, test_mode, context_mode, test_in_browser, \
|
||||
test_server_backend, test_frame_method)
|
||||
|
||||
// Define the tests.
|
||||
#define REQ_TEST_SET_EX(suffix, context_mode, test_server_backend, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGET##suffix, REQTEST_GET, context_mode, true, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETNoData##suffix, REQTEST_GET_NODATA, context_mode, true, \
|
||||
REQ_TEST(BrowserGET##suffix, REQTEST_GET, context_mode, test_server_backend, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETNoData##suffix, REQTEST_GET_NODATA, context_mode, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETPartialContent##suffix, REQTEST_GET_PARTIAL_CONTENT, \
|
||||
context_mode, true, test_server_backend, test_frame_method) \
|
||||
context_mode, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETAllowCookies##suffix, REQTEST_GET_ALLOWCOOKIES, \
|
||||
context_mode, true, test_server_backend, test_frame_method) \
|
||||
context_mode, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETRedirect##suffix, REQTEST_GET_REDIRECT, context_mode, \
|
||||
true, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETRedirectStop##suffix, REQTEST_GET_REDIRECT_STOP, \
|
||||
context_mode, true, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETRedirectLocation##suffix, REQTEST_GET_REDIRECT_LOCATION, \
|
||||
context_mode, true, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETReferrer##suffix, REQTEST_GET_REFERRER, context_mode, \
|
||||
true, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOST##suffix, REQTEST_POST, context_mode, true, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOSTFile##suffix, REQTEST_POST_FILE, context_mode, true, \
|
||||
REQ_TEST(BrowserGETRedirectStop##suffix, REQTEST_GET_REDIRECT_STOP, \
|
||||
context_mode, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETRedirectLocation##suffix, REQTEST_GET_REDIRECT_LOCATION, \
|
||||
context_mode, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserGETReferrer##suffix, REQTEST_GET_REFERRER, context_mode, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOST##suffix, REQTEST_POST, context_mode, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOSTFile##suffix, REQTEST_POST_FILE, context_mode, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOSTWithProgress##suffix, REQTEST_POST_WITHPROGRESS, \
|
||||
context_mode, true, test_server_backend, test_frame_method) \
|
||||
context_mode, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOSTRedirect##suffix, REQTEST_POST_REDIRECT, context_mode, \
|
||||
true, test_server_backend, test_frame_method) \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserPOSTRedirectToGET##suffix, REQTEST_POST_REDIRECT_TOGET, \
|
||||
context_mode, true, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserHEAD##suffix, REQTEST_HEAD, context_mode, true, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGET##suffix, REQTEST_GET, context_mode, false, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGETNoData##suffix, REQTEST_GET_NODATA, context_mode, false, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGETAllowCookies##suffix, REQTEST_GET_ALLOWCOOKIES, \
|
||||
context_mode, false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGETRedirect##suffix, REQTEST_GET_REDIRECT, context_mode, \
|
||||
false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGETRedirectStop##suffix, REQTEST_GET_REDIRECT_STOP, \
|
||||
context_mode, false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGETRedirectLocation##suffix, REQTEST_GET_REDIRECT_LOCATION, \
|
||||
context_mode, false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererGETReferrer##suffix, REQTEST_GET_REFERRER, context_mode, \
|
||||
false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererPOST##suffix, REQTEST_POST, context_mode, false, \
|
||||
test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererPOSTWithProgress##suffix, REQTEST_POST_WITHPROGRESS, \
|
||||
context_mode, false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererPOSTRedirect##suffix, REQTEST_POST_REDIRECT, context_mode, \
|
||||
false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererPOSTRedirectToGET##suffix, REQTEST_POST_REDIRECT_TOGET, \
|
||||
context_mode, false, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(RendererHEAD##suffix, REQTEST_HEAD, context_mode, false, \
|
||||
context_mode, test_server_backend, test_frame_method) \
|
||||
REQ_TEST(BrowserHEAD##suffix, REQTEST_HEAD, context_mode, \
|
||||
test_server_backend, test_frame_method)
|
||||
|
||||
#define REQ_TEST_SET(suffix, test_frame_method) \
|
||||
@ -3286,16 +2989,10 @@ REQ_TEST_SET(WithFrame, true)
|
||||
// Define tests that can only run with a frame.
|
||||
#define REQ_TEST_FRAME_SET_EX(suffix, context_mode, test_server_backend) \
|
||||
REQ_TEST(BrowserIncompleteProcessRequest##suffix, \
|
||||
REQTEST_INCOMPLETE_PROCESS_REQUEST, context_mode, true, \
|
||||
REQTEST_INCOMPLETE_PROCESS_REQUEST, context_mode, \
|
||||
test_server_backend, true) \
|
||||
REQ_TEST(BrowserIncompleteReadResponse##suffix, \
|
||||
REQTEST_INCOMPLETE_READ_RESPONSE, context_mode, true, \
|
||||
test_server_backend, true) \
|
||||
REQ_TEST(RendererIncompleteProcessRequest##suffix, \
|
||||
REQTEST_INCOMPLETE_PROCESS_REQUEST, context_mode, false, \
|
||||
test_server_backend, true) \
|
||||
REQ_TEST(RendererIncompleteReadResponse##suffix, \
|
||||
REQTEST_INCOMPLETE_READ_RESPONSE, context_mode, false, \
|
||||
REQTEST_INCOMPLETE_READ_RESPONSE, context_mode, \
|
||||
test_server_backend, true)
|
||||
|
||||
#define REQ_TEST_FRAME_SET() \
|
||||
@ -3313,57 +3010,31 @@ REQ_TEST_FRAME_SET()
|
||||
// Cache and authentication tests can only be run with the server backend.
|
||||
#define REQ_TEST_CACHE_SET_EX(suffix, context_mode, test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheWithControl##suffix, REQTEST_CACHE_WITH_CONTROL, \
|
||||
context_mode, true, true, test_frame_method) \
|
||||
context_mode, true, test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheWithoutControl##suffix, \
|
||||
REQTEST_CACHE_WITHOUT_CONTROL, context_mode, true, true, \
|
||||
REQTEST_CACHE_WITHOUT_CONTROL, context_mode, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheSkipFlag##suffix, REQTEST_CACHE_SKIP_FLAG, \
|
||||
context_mode, true, true, test_frame_method) \
|
||||
context_mode, true, test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheSkipHeader##suffix, REQTEST_CACHE_SKIP_HEADER, \
|
||||
context_mode, true, true, test_frame_method) \
|
||||
context_mode, true, test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheOnlyFailureFlag##suffix, \
|
||||
REQTEST_CACHE_ONLY_FAILURE_FLAG, context_mode, true, true, \
|
||||
REQTEST_CACHE_ONLY_FAILURE_FLAG, context_mode, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheOnlyFailureHeader##suffix, \
|
||||
REQTEST_CACHE_ONLY_FAILURE_HEADER, context_mode, true, true, \
|
||||
REQTEST_CACHE_ONLY_FAILURE_HEADER, context_mode, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheOnlySuccessFlag##suffix, \
|
||||
REQTEST_CACHE_ONLY_SUCCESS_FLAG, context_mode, true, true, \
|
||||
REQTEST_CACHE_ONLY_SUCCESS_FLAG, context_mode, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheOnlySuccessHeader##suffix, \
|
||||
REQTEST_CACHE_ONLY_SUCCESS_HEADER, context_mode, true, true, \
|
||||
REQTEST_CACHE_ONLY_SUCCESS_HEADER, context_mode, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheDisableFlag##suffix, REQTEST_CACHE_DISABLE_FLAG, \
|
||||
context_mode, true, true, test_frame_method) \
|
||||
context_mode, true, test_frame_method) \
|
||||
REQ_TEST(BrowserGETCacheDisableHeader##suffix, REQTEST_CACHE_DISABLE_HEADER, \
|
||||
context_mode, true, true, test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheWithControl##suffix, REQTEST_CACHE_WITH_CONTROL, \
|
||||
context_mode, false, true, test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheWithoutControl##suffix, \
|
||||
REQTEST_CACHE_WITHOUT_CONTROL, context_mode, false, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(BrowserGETAuth##suffix, REQTEST_GET_AUTH, context_mode, true, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheSkipFlag##suffix, REQTEST_CACHE_SKIP_FLAG, \
|
||||
context_mode, false, true, test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheSkipHeader##suffix, REQTEST_CACHE_SKIP_HEADER, \
|
||||
context_mode, false, true, test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheOnlyFailureFlag##suffix, \
|
||||
REQTEST_CACHE_ONLY_FAILURE_FLAG, context_mode, false, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheOnlyFailureHeader##suffix, \
|
||||
REQTEST_CACHE_ONLY_FAILURE_HEADER, context_mode, false, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheOnlySuccessFlag##suffix, \
|
||||
REQTEST_CACHE_ONLY_SUCCESS_FLAG, context_mode, false, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheOnlySuccessHeader##suffix, \
|
||||
REQTEST_CACHE_ONLY_SUCCESS_HEADER, context_mode, false, true, \
|
||||
test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheDisableFlag##suffix, REQTEST_CACHE_DISABLE_FLAG, \
|
||||
context_mode, false, true, test_frame_method) \
|
||||
REQ_TEST(RendererGETCacheDisableHeader##suffix, \
|
||||
REQTEST_CACHE_DISABLE_HEADER, context_mode, false, true, \
|
||||
context_mode, true, test_frame_method) \
|
||||
REQ_TEST(BrowserGETAuth##suffix, REQTEST_GET_AUTH, context_mode, true, \
|
||||
test_frame_method)
|
||||
|
||||
#define REQ_TEST_CACHE_SET(suffix, test_frame_method) \
|
||||
|
Loading…
x
Reference in New Issue
Block a user