#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include <string>
#include <vector>
#include "base/functional/callback.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/test_future.h"
#include "components/services/storage/service_worker/service_worker_storage_control_impl.h"
#include "content/browser/loader/reconnectable_url_loader_factory.h"
#include "content/browser/loader/url_loader_factory_utils.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/policy_container_utils.h"
#include "content/public/test/test_browser_context.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "services/network/public/cpp/url_loader_factory_builder.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "storage/browser/test/mock_special_storage_policy.h"
#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
namespace content {
namespace {
void CreateURLLoaderFactory(
mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { … }
}
EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
const base::FilePath& user_data_directory)
: … { … }
EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
const base::FilePath& user_data_directory,
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy)
: … { … }
EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
const base::FilePath& user_data_directory,
std::unique_ptr<BrowserContext> browser_context)
: … { … }
EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
const base::FilePath& user_data_directory,
scoped_refptr<storage::SpecialStoragePolicy> special_storage_policy,
std::unique_ptr<BrowserContext> browser_context)
: … { … }
void EmbeddedWorkerTestHelper::AddPendingInstanceClient(
std::unique_ptr<FakeEmbeddedWorkerInstanceClient> client) { … }
void EmbeddedWorkerTestHelper::AddPendingServiceWorker(
std::unique_ptr<FakeServiceWorker> service_worker) { … }
void EmbeddedWorkerTestHelper::OnInstanceClientReceiver(
mojo::PendingReceiver<blink::mojom::EmbeddedWorkerInstanceClient>
receiver) { … }
void EmbeddedWorkerTestHelper::OnInstanceClientRequest(
mojo::ScopedMessagePipeHandle request_handle) { … }
void EmbeddedWorkerTestHelper::OnServiceWorkerRequest(
mojo::PendingReceiver<blink::mojom::ServiceWorker> receiver) { … }
void EmbeddedWorkerTestHelper::OnServiceWorkerReceiver(
mojo::PendingReceiver<blink::mojom::ServiceWorker> receiver) { … }
void EmbeddedWorkerTestHelper::RemoveInstanceClient(
FakeEmbeddedWorkerInstanceClient* instance_client) { … }
void EmbeddedWorkerTestHelper::RemoveServiceWorker(
FakeServiceWorker* service_worker) { … }
EmbeddedWorkerTestHelper::~EmbeddedWorkerTestHelper() { … }
ServiceWorkerContextCore* EmbeddedWorkerTestHelper::context() { … }
void EmbeddedWorkerTestHelper::ShutdownContext() { … }
void EmbeddedWorkerTestHelper::SimulateStorageRestartForTesting() { … }
std::unique_ptr<ServiceWorkerVersion::MainScriptResponse>
EmbeddedWorkerTestHelper::CreateMainScriptResponse() { … }
scoped_refptr<network::SharedURLLoaderFactory>
EmbeddedWorkerTestHelper::GetNetworkFactory() { … }
void EmbeddedWorkerTestHelper::PopulateScriptCacheMap(
int64_t version_id,
base::OnceClosure callback) { … }
std::unique_ptr<FakeEmbeddedWorkerInstanceClient>
EmbeddedWorkerTestHelper::CreateInstanceClient() { … }
std::unique_ptr<FakeServiceWorker>
EmbeddedWorkerTestHelper::CreateServiceWorker() { … }
void EmbeddedWorkerTestHelper::BindStorageControl(
mojo::PendingReceiver<storage::mojom::ServiceWorkerStorageControl>
receiver) { … }
EmbeddedWorkerTestHelper::RegistrationAndVersionPair
EmbeddedWorkerTestHelper::PrepareRegistrationAndVersion(
const GURL& scope,
const GURL& script_url) { … }
void EmbeddedWorkerTestHelper::StartWorkerUntilStartSent(
EmbeddedWorkerInstance* worker,
blink::mojom::EmbeddedWorkerStartParamsPtr params) { … }
void EmbeddedWorkerTestHelper::StartWorker(
EmbeddedWorkerInstance* worker,
blink::mojom::EmbeddedWorkerStartParamsPtr params) { … }
blink::mojom::EmbeddedWorkerStartParamsPtr
EmbeddedWorkerTestHelper::CreateStartParams(
scoped_refptr<ServiceWorkerVersion> version) { … }
blink::mojom::ServiceWorkerProviderInfoForStartWorkerPtr
EmbeddedWorkerTestHelper::CreateProviderInfo(
scoped_refptr<ServiceWorkerVersion> version) { … }
mojo::PendingReceiver<blink::mojom::ServiceWorker>
EmbeddedWorkerTestHelper::CreateServiceWorker(
scoped_refptr<ServiceWorkerVersion> version) { … }
mojo::PendingReceiver<blink::mojom::ControllerServiceWorker>
EmbeddedWorkerTestHelper::CreateController() { … }
blink::mojom::ServiceWorkerInstalledScriptsInfoPtr
EmbeddedWorkerTestHelper::GetInstalledScriptsInfoPtr() { … }
}