#include "content/browser/service_worker/service_worker_new_script_loader.h"
#include <map>
#include <memory>
#include <string>
#include <utility>
#include "base/containers/span.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/service_worker_consts.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/url_loader_interceptor.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/data_pipe_utils.h"
#include "net/base/features.h"
#include "net/base/load_flags.h"
#include "net/base/test_completion_callback.h"
#include "net/http/http_util.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
#include "net/url_request/redirect_info.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/parsed_headers.mojom.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_loader_factory.mojom.h"
#include "services/network/test/test_url_loader_client.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/storage_key/storage_key.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 "url/origin.h"
namespace content {
namespace service_worker_new_script_loader_unittest {
const char kNormalScriptURL[] = …;
const char kNormalImportedScriptURL[] = …;
const char kHistogramWriteResponseResult[] = …;
class MockHTTPServer { … };
class MockNetwork { … };
class ServiceWorkerNewScriptLoaderTest : public testing::Test { … };
TEST_F(ServiceWorkerNewScriptLoaderTest, Success) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Success_EmptyBody) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Success_LargeBody) { … }
namespace {
class BodyDataPipeTestURLLoaderFactory final
: public network::mojom::URLLoaderFactory { … };
}
TEST_F(ServiceWorkerNewScriptLoaderTest, Success_ClientConsumeBodyLater) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_404) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_Redirect) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_CertificateError) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_NoMimeType) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_BadMimeType) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Success_PathRestriction) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest,
Fail_ModuleServiceWorker_PathRestriction) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_PathRestriction) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, Error_RedundantWorker) { … }
TEST_F(ServiceWorkerNewScriptLoaderTest, AccessedNetwork) { … }
}
}