Commit da209031 authored by Yutaka Hirano's avatar Yutaka Hirano Committed by Commit Bot

[OOR-CORS] Implement redirect logic in CORSURLLoader

This CL adds redirect logic to CORSURLLoader. There are some TODOs and
I'll address them later.

Bug: 736308
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_mojo
Change-Id: I8db4eccb6c5bb453882f6a469d4185487848773a
Reviewed-on: https://chromium-review.googlesource.com/1088715Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarAdam Rice <ricea@chromium.org>
Commit-Queue: Yutaka Hirano <yhirano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#566751}
parent a275018e
This diff is collapsed.
...@@ -29,7 +29,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader ...@@ -29,7 +29,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
public mojom::URLLoaderClient { public mojom::URLLoaderClient {
public: public:
// Assumes network_loader_factory outlives this loader. // Assumes network_loader_factory outlives this loader.
// TODO(yhirano): Remove |preflight_finalizer| when the network service is // TODO(yhirano): Remove |request_finalizer| when the network service is
// fully enabled. // fully enabled.
CORSURLLoader( CORSURLLoader(
int32_t routing_id, int32_t routing_id,
...@@ -39,7 +39,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader ...@@ -39,7 +39,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
mojom::URLLoaderClientPtr client, mojom::URLLoaderClientPtr client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation, const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
mojom::URLLoaderFactory* network_loader_factory, mojom::URLLoaderFactory* network_loader_factory,
const base::RepeatingCallback<void(int)>& preflight_finalizer); const base::RepeatingCallback<void(int)>& request_finalizer);
~CORSURLLoader() override; ~CORSURLLoader() override;
...@@ -68,12 +68,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader ...@@ -68,12 +68,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
void OnComplete(const URLLoaderCompletionStatus& status) override; void OnComplete(const URLLoaderCompletionStatus& status) override;
private: private:
void StartNetworkRequest( void StartRequest();
int32_t routing_id, void StartNetworkRequest(base::Optional<CORSErrorStatus> status);
int32_t request_id,
uint32_t options,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation,
base::Optional<CORSErrorStatus> status);
// Called when there is a connection error on the upstream pipe used for the // Called when there is a connection error on the upstream pipe used for the
// actual request. // actual request.
...@@ -82,6 +78,11 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader ...@@ -82,6 +78,11 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
// Handles OnComplete() callback. // Handles OnComplete() callback.
void HandleComplete(const URLLoaderCompletionStatus& status); void HandleComplete(const URLLoaderCompletionStatus& status);
// We need to save these for redirect.
const int32_t routing_id_;
const int32_t request_id_;
const uint32_t options_;
// This raw URLLoaderFactory pointer is shared with the CORSURLLoaderFactory // This raw URLLoaderFactory pointer is shared with the CORSURLLoaderFactory
// that created and owns this object. // that created and owns this object.
mojom::URLLoaderFactory* network_loader_factory_; mojom::URLLoaderFactory* network_loader_factory_;
...@@ -105,6 +106,21 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader ...@@ -105,6 +106,21 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CORSURLLoader
// Corresponds to the Fetch spec, https://fetch.spec.whatwg.org/. // Corresponds to the Fetch spec, https://fetch.spec.whatwg.org/.
bool fetch_cors_flag_; bool fetch_cors_flag_;
net::RedirectInfo redirect_info_;
// https://fetch.spec.whatwg.org/#concept-request-tainted-origin
bool tainted_ = false;
// https://fetch.spec.whatwg.org/#concept-request-redirect-count
int redirect_count_ = 0;
// Used to finalize preflight / redirect requests.
// TODO(yhirano): Remove this once the network service is fully enabled.
base::RepeatingCallback<void(int)> request_finalizer_;
// We need to save this for redirect.
net::MutableNetworkTrafficAnnotationTag traffic_annotation_;
// Used to run asynchronous class instance bound callbacks safely. // Used to run asynchronous class instance bound callbacks safely.
base::WeakPtrFactory<CORSURLLoader> weak_factory_; base::WeakPtrFactory<CORSURLLoader> weak_factory_;
......
...@@ -61,7 +61,8 @@ std::string CreateAccessControlRequestHeadersHeader( ...@@ -61,7 +61,8 @@ std::string CreateAccessControlRequestHeadersHeader(
} }
std::unique_ptr<ResourceRequest> CreatePreflightRequest( std::unique_ptr<ResourceRequest> CreatePreflightRequest(
const ResourceRequest& request) { const ResourceRequest& request,
bool tainted) {
DCHECK(!request.url.has_username()); DCHECK(!request.url.has_username());
DCHECK(!request.url.has_password()); DCHECK(!request.url.has_password());
...@@ -98,8 +99,9 @@ std::unique_ptr<ResourceRequest> CreatePreflightRequest( ...@@ -98,8 +99,9 @@ std::unique_ptr<ResourceRequest> CreatePreflightRequest(
DCHECK(request.request_initiator); DCHECK(request.request_initiator);
preflight_request->request_initiator = request.request_initiator; preflight_request->request_initiator = request.request_initiator;
preflight_request->headers.SetHeader(net::HttpRequestHeaders::kOrigin, preflight_request->headers.SetHeader(
request.request_initiator->Serialize()); net::HttpRequestHeaders::kOrigin,
(tainted ? url::Origin() : *request.request_initiator).Serialize());
// TODO(toyoshim): Remove the following line once the network service is // TODO(toyoshim): Remove the following line once the network service is
// enabled by default. // enabled by default.
...@@ -116,6 +118,7 @@ std::unique_ptr<PreflightResult> CreatePreflightResult( ...@@ -116,6 +118,7 @@ std::unique_ptr<PreflightResult> CreatePreflightResult(
const GURL& final_url, const GURL& final_url,
const ResourceResponseHead& head, const ResourceResponseHead& head,
const ResourceRequest& original_request, const ResourceRequest& original_request,
bool tainted,
base::Optional<mojom::CORSError>* detected_error) { base::Optional<mojom::CORSError>* detected_error) {
DCHECK(detected_error); DCHECK(detected_error);
...@@ -127,7 +130,8 @@ std::unique_ptr<PreflightResult> CreatePreflightResult( ...@@ -127,7 +130,8 @@ std::unique_ptr<PreflightResult> CreatePreflightResult(
GetHeaderString(head.headers, GetHeaderString(head.headers,
cors::header_names::kAccessControlAllowCredentials), cors::header_names::kAccessControlAllowCredentials),
original_request.fetch_credentials_mode, original_request.fetch_credentials_mode,
*original_request.request_initiator, false /* allow_file_origin */); tainted ? url::Origin() : *original_request.request_initiator,
false /* allow_file_origin */);
if (*detected_error) if (*detected_error)
return nullptr; return nullptr;
...@@ -225,13 +229,15 @@ class PreflightController::PreflightLoader final { ...@@ -225,13 +229,15 @@ class PreflightController::PreflightLoader final {
PreflightLoader(PreflightController* controller, PreflightLoader(PreflightController* controller,
CompletionCallback completion_callback, CompletionCallback completion_callback,
const ResourceRequest& request, const ResourceRequest& request,
bool tainted,
const net::NetworkTrafficAnnotationTag& annotation_tag, const net::NetworkTrafficAnnotationTag& annotation_tag,
base::OnceCallback<void()> preflight_finalizer) base::OnceCallback<void()> preflight_finalizer)
: controller_(controller), : controller_(controller),
completion_callback_(std::move(completion_callback)), completion_callback_(std::move(completion_callback)),
original_request_(request), original_request_(request),
tainted_(tainted),
preflight_finalizer_(std::move(preflight_finalizer)) { preflight_finalizer_(std::move(preflight_finalizer)) {
loader_ = SimpleURLLoader::Create(CreatePreflightRequest(request), loader_ = SimpleURLLoader::Create(CreatePreflightRequest(request, tainted),
annotation_tag); annotation_tag);
} }
...@@ -275,7 +281,7 @@ class PreflightController::PreflightLoader final { ...@@ -275,7 +281,7 @@ class PreflightController::PreflightLoader final {
base::Optional<mojom::CORSError> detected_error; base::Optional<mojom::CORSError> detected_error;
std::unique_ptr<PreflightResult> result = CreatePreflightResult( std::unique_ptr<PreflightResult> result = CreatePreflightResult(
final_url, head, original_request_, &detected_error); final_url, head, original_request_, tainted_, &detected_error);
base::Optional<CORSErrorStatus> detected_error_status; base::Optional<CORSErrorStatus> detected_error_status;
if (result) { if (result) {
...@@ -331,6 +337,8 @@ class PreflightController::PreflightLoader final { ...@@ -331,6 +337,8 @@ class PreflightController::PreflightLoader final {
PreflightController::CompletionCallback completion_callback_; PreflightController::CompletionCallback completion_callback_;
const ResourceRequest original_request_; const ResourceRequest original_request_;
const bool tainted_;
// This is needed because we sometimes need to cancel the preflight loader // This is needed because we sometimes need to cancel the preflight loader
// synchronously. // synchronously.
// TODO(yhirano): Remove this when the network service is fully enabled. // TODO(yhirano): Remove this when the network service is fully enabled.
...@@ -342,8 +350,9 @@ class PreflightController::PreflightLoader final { ...@@ -342,8 +350,9 @@ class PreflightController::PreflightLoader final {
// static // static
std::unique_ptr<ResourceRequest> std::unique_ptr<ResourceRequest>
PreflightController::CreatePreflightRequestForTesting( PreflightController::CreatePreflightRequestForTesting(
const ResourceRequest& request) { const ResourceRequest& request,
return CreatePreflightRequest(request); bool tainted) {
return CreatePreflightRequest(request, tainted);
} }
// static // static
...@@ -360,6 +369,7 @@ void PreflightController::PerformPreflightCheck( ...@@ -360,6 +369,7 @@ void PreflightController::PerformPreflightCheck(
CompletionCallback callback, CompletionCallback callback,
int32_t request_id, int32_t request_id,
const ResourceRequest& request, const ResourceRequest& request,
bool tainted,
const net::NetworkTrafficAnnotationTag& annotation_tag, const net::NetworkTrafficAnnotationTag& annotation_tag,
mojom::URLLoaderFactory* loader_factory, mojom::URLLoaderFactory* loader_factory,
base::OnceCallback<void()> preflight_finalizer) { base::OnceCallback<void()> preflight_finalizer) {
...@@ -374,7 +384,7 @@ void PreflightController::PerformPreflightCheck( ...@@ -374,7 +384,7 @@ void PreflightController::PerformPreflightCheck(
} }
auto emplaced_pair = loaders_.emplace(std::make_unique<PreflightLoader>( auto emplaced_pair = loaders_.emplace(std::make_unique<PreflightLoader>(
this, std::move(callback), request, annotation_tag, this, std::move(callback), request, tainted, annotation_tag,
std::move(preflight_finalizer))); std::move(preflight_finalizer)));
(*emplaced_pair.first)->Request(loader_factory, request_id); (*emplaced_pair.first)->Request(loader_factory, request_id);
} }
......
...@@ -37,7 +37,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) PreflightController final { ...@@ -37,7 +37,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) PreflightController final {
// Creates a CORS-preflight ResourceRequest for a specified |request| for a // Creates a CORS-preflight ResourceRequest for a specified |request| for a
// URL that is originally requested. // URL that is originally requested.
static std::unique_ptr<ResourceRequest> CreatePreflightRequestForTesting( static std::unique_ptr<ResourceRequest> CreatePreflightRequestForTesting(
const ResourceRequest& request); const ResourceRequest& request,
bool tainted = false);
// Obtains the shared default controller instance. // Obtains the shared default controller instance.
// TODO(toyoshim): Find a right owner rather than a single design. // TODO(toyoshim): Find a right owner rather than a single design.
...@@ -61,6 +62,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) PreflightController final { ...@@ -61,6 +62,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) PreflightController final {
CompletionCallback callback, CompletionCallback callback,
int32_t request_id, int32_t request_id,
const ResourceRequest& resource_request, const ResourceRequest& resource_request,
bool tainted,
const net::NetworkTrafficAnnotationTag& traffic_annotation, const net::NetworkTrafficAnnotationTag& traffic_annotation,
mojom::URLLoaderFactory* loader_factory, mojom::URLLoaderFactory* loader_factory,
base::OnceCallback<void()> preflight_finalizer); base::OnceCallback<void()> preflight_finalizer);
......
...@@ -130,6 +130,19 @@ TEST(PreflightControllerCreatePreflightRequestTest, ExcludeForbiddenHeaders) { ...@@ -130,6 +130,19 @@ TEST(PreflightControllerCreatePreflightRequestTest, ExcludeForbiddenHeaders) {
cors::header_names::kAccessControlRequestHeaders, &header)); cors::header_names::kAccessControlRequestHeaders, &header));
} }
TEST(PreflightControllerCreatePreflightRequestTest, Tainted) {
ResourceRequest request;
request.request_initiator = url::Origin::Create(GURL("https://example.com"));
std::unique_ptr<ResourceRequest> preflight =
PreflightController::CreatePreflightRequestForTesting(request, true);
std::string header;
EXPECT_TRUE(
preflight->headers.GetHeader(net::HttpRequestHeaders::kOrigin, &header));
EXPECT_EQ(header, "null");
}
class PreflightControllerTest : public testing::Test { class PreflightControllerTest : public testing::Test {
public: public:
PreflightControllerTest() PreflightControllerTest()
...@@ -161,13 +174,14 @@ class PreflightControllerTest : public testing::Test { ...@@ -161,13 +174,14 @@ class PreflightControllerTest : public testing::Test {
GURL GetURL(const std::string& path) { return test_server_.GetURL(path); } GURL GetURL(const std::string& path) { return test_server_.GetURL(path); }
void PerformPreflightCheck(const ResourceRequest& request) { void PerformPreflightCheck(const ResourceRequest& request,
bool tainted = false) {
DCHECK(preflight_controller_); DCHECK(preflight_controller_);
run_loop_ = std::make_unique<base::RunLoop>(); run_loop_ = std::make_unique<base::RunLoop>();
preflight_controller_->PerformPreflightCheck( preflight_controller_->PerformPreflightCheck(
base::BindOnce(&PreflightControllerTest::HandleRequestCompletion, base::BindOnce(&PreflightControllerTest::HandleRequestCompletion,
base::Unretained(this)), base::Unretained(this)),
0 /* request_id */, request, TRAFFIC_ANNOTATION_FOR_TESTS, 0 /* request_id */, request, tainted, TRAFFIC_ANNOTATION_FOR_TESTS,
url_loader_factory_ptr_.get(), url_loader_factory_ptr_.get(),
base::BindOnce(&PreflightControllerTest::CancelPreflight, base::BindOnce(&PreflightControllerTest::CancelPreflight,
base::Unretained(this))); base::Unretained(this)));
...@@ -198,11 +212,15 @@ class PreflightControllerTest : public testing::Test { ...@@ -198,11 +212,15 @@ class PreflightControllerTest : public testing::Test {
response = std::make_unique<net::test_server::BasicHttpResponse>(); response = std::make_unique<net::test_server::BasicHttpResponse>();
if (net::test_server::ShouldHandle(request, "/404") || if (net::test_server::ShouldHandle(request, "/404") ||
net::test_server::ShouldHandle(request, "/allow")) { net::test_server::ShouldHandle(request, "/allow") ||
net::test_server::ShouldHandle(request, "/tainted")) {
response->set_code(net::test_server::ShouldHandle(request, "/404") response->set_code(net::test_server::ShouldHandle(request, "/404")
? net::HTTP_NOT_FOUND ? net::HTTP_NOT_FOUND
: net::HTTP_OK); : net::HTTP_OK);
url::Origin origin = url::Origin::Create(test_server_.base_url()); const url::Origin origin =
net::test_server::ShouldHandle(request, "/tainted")
? url::Origin()
: url::Origin::Create(test_server_.base_url());
response->AddCustomHeader(cors::header_names::kAccessControlAllowOrigin, response->AddCustomHeader(cors::header_names::kAccessControlAllowOrigin,
origin.Serialize()); origin.Serialize());
response->AddCustomHeader(header_names::kAccessControlAllowMethods, response->AddCustomHeader(header_names::kAccessControlAllowMethods,
...@@ -257,6 +275,16 @@ TEST_F(PreflightControllerTest, CheckValidRequest) { ...@@ -257,6 +275,16 @@ TEST_F(PreflightControllerTest, CheckValidRequest) {
EXPECT_EQ(1u, access_count()); // Should be from the preflight cache. EXPECT_EQ(1u, access_count()); // Should be from the preflight cache.
} }
TEST_F(PreflightControllerTest, CheckTaintedRequest) {
ResourceRequest request;
request.url = GetURL("/tainted");
request.request_initiator = url::Origin::Create(request.url);
PerformPreflightCheck(request, true /* tainted */);
ASSERT_FALSE(status());
EXPECT_EQ(1u, access_count());
}
// TODO(yhirano): Remove this test case when the network service is fully // TODO(yhirano): Remove this test case when the network service is fully
// enabled. // enabled.
TEST_F(PreflightControllerTest, CancelPreflightIsCalled) { TEST_F(PreflightControllerTest, CancelPreflightIsCalled) {
......
...@@ -1786,10 +1786,6 @@ crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/simple-cross- ...@@ -1786,10 +1786,6 @@ crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/simple-cross-
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/workers/cross-origin-unsupported-url.html [ Timeout ] crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/workers/cross-origin-unsupported-url.html [ Timeout ]
# Failing tests in dictionary order. # Failing tests in dictionary order.
crbug.com/736308 virtual/outofblink-cors/external/wpt/fetch/api/cors/cors-redirect-preflight.any.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/external/wpt/fetch/api/cors/cors-redirect-preflight.any.worker.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/external/wpt/fetch/api/cors/cors-redirect.any.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/external/wpt/fetch/api/cors/cors-redirect.any.worker.html [ Failure ]
crbug.com/802835 virtual/outofblink-cors/external/wpt/fetch/corb/img-mime-types-coverage.tentative.sub.html [ Failure ] crbug.com/802835 virtual/outofblink-cors/external/wpt/fetch/corb/img-mime-types-coverage.tentative.sub.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/external/wpt/service-workers/service-worker/fetch-canvas-tainting-image-cache.https.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/external/wpt/service-workers/service-worker/fetch-canvas-tainting-image-cache.https.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/external/wpt/service-workers/service-worker/fetch-canvas-tainting-image.https.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/external/wpt/service-workers/service-worker/fetch-canvas-tainting-image.https.html [ Failure ]
...@@ -1849,7 +1845,6 @@ crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-exact- ...@@ -1849,7 +1845,6 @@ crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-exact-
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-exact-matching/46.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-exact-matching/46.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-exact-matching/47.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-exact-matching/47.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-whitelisting-ip-addresses.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/origin-whitelisting-ip-addresses.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/redirect-cors-origin-null.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/workers/xmlhttprequest-allowed-with-disabled-web-security.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/workers/xmlhttprequest-allowed-with-disabled-web-security.html [ Failure ]
crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/xmlhttprequest-allowed-with-disabled-web-security.html [ Failure ] crbug.com/736308 virtual/outofblink-cors/http/tests/xmlhttprequest/xmlhttprequest-allowed-with-disabled-web-security.html [ Failure ]
# ====== Out of Blink CORS related tests END ====== # ====== Out of Blink CORS related tests END ======
......
This is a testharness.js-based test.
PASS Set cookies
PASS Testing credentials after cross-origin redirection with CORS and no preflight
FAIL Testing credentials after cross-origin redirection with CORS and preflight promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch"
PASS Clean cookies
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Set cookies
PASS Testing credentials after cross-origin redirection with CORS and no preflight
FAIL Testing credentials after cross-origin redirection with CORS and preflight promise_test: Unhandled rejection with value: object "TypeError: Failed to fetch"
PASS Clean cookies
Harness: the test ran to completion.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
CONSOLE ERROR: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
XMLHttpRequest doesn't crash even when open() is invoked synchronously to handling of a redirect response to a cross-origin request.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS successfullyParsed is true
TEST COMPLETE
CONSOLE WARNING: line 25: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
CONSOLE ERROR: line 26: Failed to load http://localhost:8000/xmlhttprequest/resources/redirect.php?url=/xmlhttprequest/resources/reply.xml: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:8000' is therefore not allowed access.
Test that a cross-origin chain of redirects to a server that responds is indistinguishable from one that does not. Should say PASS:
PASS
...@@ -604,6 +604,7 @@ bool DocumentThreadableLoader::RedirectReceived( ...@@ -604,6 +604,7 @@ bool DocumentThreadableLoader::RedirectReceived(
const KURL& original_url = redirect_response.Url(); const KURL& original_url = redirect_response.Url();
if (!actual_request_.IsNull()) { if (!actual_request_.IsNull()) {
DCHECK(!out_of_blink_cors_);
ReportResponseReceived(resource->Identifier(), redirect_response); ReportResponseReceived(resource->Identifier(), redirect_response);
HandlePreflightFailure( HandlePreflightFailure(
...@@ -643,6 +644,15 @@ bool DocumentThreadableLoader::RedirectReceived( ...@@ -643,6 +644,15 @@ bool DocumentThreadableLoader::RedirectReceived(
return false; return false;
} }
if (out_of_blink_cors_) {
client_->DidReceiveRedirectTo(new_url);
if (client_->IsDocumentThreadableLoaderClient()) {
return static_cast<DocumentThreadableLoaderClient*>(client_)
->WillFollowRedirect(new_url, redirect_response);
}
return true;
}
// Allow same origin requests to continue after allowing clients to audit the // Allow same origin requests to continue after allowing clients to audit the
// redirect. // redirect.
if (IsAllowedRedirect(new_request.GetFetchRequestMode(), new_url)) { if (IsAllowedRedirect(new_request.GetFetchRequestMode(), new_url)) {
......
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