chromium/third_party/blink/common/loader/throttling_url_loader_unittest.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/public/common/loader/throttling_url_loader.h"

#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/early_hints.mojom.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h"

namespace blink {
namespace {

GURL request_url =;
GURL redirect_url =;
RestartWithURLReset;

class TestURLLoaderFactory : public network::mojom::URLLoaderFactory,
                             public network::mojom::URLLoader {};

class TestURLLoaderClient : public network::mojom::URLLoaderClient {};

class TestURLLoaderThrottle : public blink::URLLoaderThrottle {};

class ThrottlingURLLoaderTest : public testing::Test {};

TEST_F(ThrottlingURLLoaderTest, CancelBeforeStart) {}

TEST_F(ThrottlingURLLoaderTest, DeleteBeforeStart) {}

TEST_F(ThrottlingURLLoaderTest, DeferBeforeStart) {}

TEST_F(ThrottlingURLLoaderTest, ModifyURLBeforeStart) {}

TEST_F(ThrottlingURLLoaderTest,
       CrossOriginRedirectBeforeStartWithIsolationInfo) {}

// Regression test for crbug.com/933538
TEST_F(ThrottlingURLLoaderTest, ModifyURLAndDeferRedirect) {}

// Regression test for crbug.com/1053700.
TEST_F(ThrottlingURLLoaderTest,
       RedirectCallbackShouldNotBeCalledAfterDestruction) {}

TEST_F(ThrottlingURLLoaderTest, CancelBeforeRedirect) {}

TEST_F(ThrottlingURLLoaderTest, DeleteBeforeRedirect) {}

TEST_F(ThrottlingURLLoaderTest, CancelBeforeWillRedirect) {}

TEST_F(ThrottlingURLLoaderTest, DeleteBeforeWillRedirect) {}

TEST_F(ThrottlingURLLoaderTest, DeferBeforeRedirect) {}

TEST_F(ThrottlingURLLoaderTest, ModifyHeadersBeforeRedirect) {}

TEST_F(ThrottlingURLLoaderTest, MultipleThrottlesModifyHeadersBeforeRedirect) {}

TEST_F(ThrottlingURLLoaderTest, CancelBeforeResponse) {}

TEST_F(ThrottlingURLLoaderTest, DeleteBeforeResponse) {}

TEST_F(ThrottlingURLLoaderTest, CancelBeforeWillProcessResponse) {}

TEST_F(ThrottlingURLLoaderTest, DeleteBeforeWillProcessResponse) {}

TEST_F(ThrottlingURLLoaderTest, DeferBeforeResponse) {}

TEST_F(ThrottlingURLLoaderTest, PipeClosure) {}

TEST_F(ThrottlingURLLoaderTest, ResumeNoOpIfNotDeferred) {}

TEST_F(ThrottlingURLLoaderTest, CancelNoOpIfAlreadyCanceled) {}

TEST_F(ThrottlingURLLoaderTest, ResumeNoOpIfAlreadyCanceled) {}

TEST_F(ThrottlingURLLoaderTest, MultipleThrottlesBasicSupport) {}

TEST_F(ThrottlingURLLoaderTest, BlockWithOneOfMultipleThrottles) {}

TEST_F(ThrottlingURLLoaderTest, BlockWithMultipleThrottles) {}

TEST_F(ThrottlingURLLoaderTest,
       DestroyingThrottlingURLLoaderInDelegateCall_Response) {}

// Regression test for crbug.com/833292.
TEST_F(ThrottlingURLLoaderTest,
       DestroyingThrottlingURLLoaderInDelegateCall_Redirect) {}

// Call RestartWithURLReset() from a single throttle while processing
// BeforeWillProcessResponse(), and verify that it restarts with the original
// URL.
TEST_F(ThrottlingURLLoaderTest, RestartWithURLReset) {}

// Call RestartWithURLReset() from multiple throttles while processing
// BeforeWillProcessResponse(). Ensures that the request is restarted exactly
// once with the original URL.
TEST_F(ThrottlingURLLoaderTest, MultipleRestartWithURLReset) {}

// Test restarts from "BeforeWillRedirectRequest".
TEST_F(ThrottlingURLLoaderTest, RestartWithURLResetBeforeWillRedirectRequest) {}

}  // namespace
}  // namespace blink