#include "content/renderer/service_worker/service_worker_subresource_loader.h"
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "content/common/features.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_task_environment.h"
#include "content/renderer/service_worker/controller_service_worker_connector.h"
#include "content/test/fake_network_url_loader_factory.h"
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/url_request.h"
#include "services/network/public/cpp/wrapper_shared_url_loader_factory.h"
#include "services/network/test/test_data_pipe_getter.h"
#include "services/network/test/test_url_loader_client.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/service_worker/service_worker_router_rule.h"
#include "third_party/blink/public/mojom/blob/blob.mojom.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_response.mojom.h"
#include "third_party/blink/public/mojom/loader/fetch_client_settings_object.mojom.h"
#include "third_party/blink/public/mojom/service_worker/dispatch_fetch_event_params.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_container.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_fetch_handler_bypass_option.mojom-shared.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration_options.mojom.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_stream_handle.mojom.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "url/origin.h"
namespace content {
namespace service_worker_subresource_loader_unittest {
class FakeBlob final : public blink::mojom::Blob { … };
class FakeControllerServiceWorker
: public blink::mojom::ControllerServiceWorker { … };
class FakeServiceWorkerContainerHost
: public blink::mojom::ServiceWorkerContainerHost { … };
network::mojom::URLResponseHeadPtr CreateResponseInfoFromServiceWorker() { … }
bool LoaderRecordsTimingMetrics() { … }
const char kHistogramSubresourceFetchEvent[] = …;
class ServiceWorkerSubresourceLoaderTest : public ::testing::Test { … };
TEST_F(ServiceWorkerSubresourceLoaderTest, Basic) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, Abort) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, DropController) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, NoController) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, DropController_RestartFetchEvent) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, DropController_TooManyRestart) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest,
DropController_RestartFetchEvent_RaceNetworkRequest) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, StreamResponse) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, StreamResponse_Abort) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, BlobResponse) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, BlobResponseWithoutMetadata) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, BlobResponseNonScript) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, FallbackResponse) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, ErrorResponse) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, RedirectResponse) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, TooManyRedirects) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, FollowNonexistentRedirect) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, FallbackWithRequestBody_String) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, FallbackWithRequestBody_DataPipe) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, RangeRequest_200Response) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest, RangeRequest_206Response) { … }
TEST_F(ServiceWorkerSubresourceLoaderTest,
RangeRequest_UnboundedRight_206Response) { … }
}
}