#include "third_party/blink/renderer/platform/loader/fetch/url_loader/resource_request_sender.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/run_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/thread_pool.h"
#include "base/test/bind.h"
#include "base/test/task_environment.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/base/request_priority.h"
#include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/url_loader_completion_status.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_loader.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/features.h"
#include "third_party/blink/public/common/loader/referrer_utils.h"
#include "third_party/blink/public/mojom/loader/code_cache.mojom-blink.h"
#include "third_party/blink/public/platform/resource_load_info_notifier_wrapper.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/public/platform/web_url_request_extra_data.h"
#include "third_party/blink/public/platform/web_url_request_util.h"
#include "third_party/blink/renderer/platform/loader/fetch/code_cache_host.h"
#include "third_party/blink/renderer/platform/loader/fetch/url_loader/resource_request_client.h"
#include "third_party/blink/renderer/platform/loader/fetch/url_loader/sync_load_response.h"
#include "third_party/blink/renderer/platform/loader/testing/fake_url_loader_factory_for_background_thread.h"
#include "third_party/blink/renderer/platform/testing/testing_platform_support.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "third_party/blink/renderer/platform/wtf/threading.h"
#include "url/gurl.h"
namespace blink {
namespace {
RefCountedURLLoaderClientRemote;
static constexpr char kTestPageUrl[] = …;
static constexpr char kDifferentUrl[] = …;
static constexpr char kRedirectedUrl[] = …;
static constexpr char kTestUrlForCodeCacheWithHashing[] = …;
static constexpr char kTestData[] = …;
constexpr size_t kDataPipeCapacity = …;
std::string ReadOneChunk(mojo::ScopedDataPipeConsumerHandle* handle) { … }
base::TimeTicks TicksFromMicroseconds(int64_t micros) { … }
std::unique_ptr<network::ResourceRequest> CreateResourceRequest() { … }
std::unique_ptr<network::ResourceRequest> CreateSyncResourceRequest() { … }
mojo::ScopedDataPipeConsumerHandle CreateDataPipeConsumerHandleFilledWithString(
const std::string& string) { … }
class TestPlatformForRedirects final : public TestingPlatformSupport { … };
void RegisterURLSchemeAsCodeCacheWithHashing() { … }
class MockRequestClient : public ResourceRequestClient { … };
class MockLoader : public network::mojom::URLLoader { … };
FetchCachedCodeCallback;
ProcessCodeCacheRequestCallback;
class DummyCodeCacheHost final : public mojom::blink::CodeCacheHost { … };
class ResourceRequestSenderTest : public testing::Test,
public network::mojom::URLLoaderFactory { … };
TEST_F(ResourceRequestSenderTest, MakeRequestID) { … }
TEST_F(ResourceRequestSenderTest, RedirectSyncFollow) { … }
TEST_F(ResourceRequestSenderTest, RedirectSyncFollowWithRemovedHeaders) { … }
TEST_F(ResourceRequestSenderTest, RedirectSyncFollowWithModifiedHeaders) { … }
TEST_F(ResourceRequestSenderTest, RedirectSyncCancel) { … }
TEST_F(ResourceRequestSenderTest, RedirectAsyncFollow) { … }
TEST_F(ResourceRequestSenderTest, RedirectAsyncFollowWithRemovedHeaders) { … }
TEST_F(ResourceRequestSenderTest, RedirectAsyncFollowWithModifiedHeaders) { … }
TEST_F(ResourceRequestSenderTest, RedirectAsyncFollowAfterCancel) { … }
TEST_F(ResourceRequestSenderTest, ReceiveResponseWithoutMetadata) { … }
TEST_F(ResourceRequestSenderTest, ReceiveResponseWithMetadata) { … }
TEST_F(ResourceRequestSenderTest, EmptyCodeCacheThenReceiveResponse) { … }
TEST_F(ResourceRequestSenderTest, ReceiveCodeCacheThenReceiveResponse) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveTimeMismatchCodeCacheThenReceiveResponse) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveEmptyCodeCacheThenReceiveResponseWithMetadata) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveCodeCacheThenReceiveResponseWithMetadata) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveResponseWithMetadataThenReceiveCodeCache) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveResponseWithMetadataThenReceiveEmptyCodeCache) { … }
TEST_F(ResourceRequestSenderTest, SlowCodeCache) { … }
TEST_F(ResourceRequestSenderTest, ReceiveCodeCacheWhileFrozen) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveCodeCacheThenReceiveSyntheticResponseFromServiceWorker) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveCodeCacheThenReceivePassThroughResponseFromServiceWorker) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveCodeCacheThenReceiveDifferentUrlResponseFromServiceWorker) { … }
TEST_F(ResourceRequestSenderTest,
ReceiveCodeCacheThenReceiveResponseFromCacheStorageViaServiceWorker) { … }
TEST_F(ResourceRequestSenderTest, CodeCacheWithHashingEmptyCodeCache) { … }
TEST_F(ResourceRequestSenderTest, CodeCacheWithHashingWithCodeCache) { … }
TEST_F(ResourceRequestSenderTest,
CodeCacheWithHashingWithCodeCacheAfterRedirectedToDifferentScheme) { … }
TEST_F(ResourceRequestSenderTest, WebAssemblyCodeCacheRequest) { … }
TEST_F(ResourceRequestSenderTest, KeepaliveRequest) { … }
class ResourceRequestSenderSyncTest : public testing::Test { … };
TEST_F(ResourceRequestSenderSyncTest, SendSyncRequest) { … }
TEST_F(ResourceRequestSenderSyncTest, SendSyncRedirect) { … }
TEST_F(ResourceRequestSenderSyncTest, SendSyncRedirectWithRemovedHeaders) { … }
TEST_F(ResourceRequestSenderSyncTest, SendSyncRedirectWithModifiedHeaders) { … }
TEST_F(ResourceRequestSenderSyncTest, SendSyncRedirectCancel) { … }
class TimeConversionTest : public ResourceRequestSenderTest { … };
TEST_F(TimeConversionTest, ProperlyInitialized) { … }
TEST_F(TimeConversionTest, PartiallyInitialized) { … }
TEST_F(TimeConversionTest, NotInitialized) { … }
class CompletionTimeConversionTest : public ResourceRequestSenderTest { … };
TEST_F(CompletionTimeConversionTest, NullCompletionTimestamp) { … }
TEST_F(CompletionTimeConversionTest, RemoteRequestStartIsUnavailable) { … }
TEST_F(CompletionTimeConversionTest, Convert) { … }
}
}