#include "content/public/browser/service_worker_context.h"
#include <stdint.h>
#include <memory>
#include "base/containers/contains.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/time/time.h"
#include "content/browser/service_worker/embedded_worker_test_helper.h"
#include "content/browser/service_worker/fake_embedded_worker_instance_client.h"
#include "content/browser/service_worker/service_worker_client.h"
#include "content/browser/service_worker/service_worker_context_core.h"
#include "content/browser/service_worker/service_worker_context_core_observer.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_host.h"
#include "content/browser/service_worker/service_worker_metrics.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/public/browser/service_worker_context_observer.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/service_worker/service_worker_types.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_event_status.mojom.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 {
void SaveResponseCallback(bool* called,
int64_t* store_registration_id,
blink::ServiceWorkerStatusCode status,
const std::string& status_message,
int64_t registration_id) { … }
ServiceWorkerContextCore::RegistrationCallback MakeRegisteredCallback(
bool* called,
int64_t* store_registration_id) { … }
void RegisteredCallback(base::OnceClosure quit_closure,
blink::ServiceWorkerStatusCode status,
const std::string& status_message,
int64_t registration_id) { … }
void CallCompletedCallback(bool* called, blink::ServiceWorkerStatusCode) { … }
ServiceWorkerContextCore::UnregistrationCallback MakeUnregisteredCallback(
bool* called) { … }
void ExpectRegisteredWorkers(
blink::ServiceWorkerStatusCode expect_status,
bool expect_waiting,
bool expect_active,
blink::ServiceWorkerStatusCode status,
scoped_refptr<ServiceWorkerRegistration> registration) { … }
class InstallActivateWorker : public FakeServiceWorker { … };
enum NotificationType { … };
struct NotificationLog { … };
}
class ServiceWorkerContextTest : public ServiceWorkerContextCoreObserver,
public testing::Test { … };
class RecordableEmbeddedWorkerInstanceClient
: public FakeEmbeddedWorkerInstanceClient { … };
class TestServiceWorkerContextObserver : public ServiceWorkerContextObserver { … };
TEST_F(ServiceWorkerContextTest, RegistrationCompletedObserver) { … }
TEST_F(ServiceWorkerContextTest, Observer_ControlleeEvents) { … }
TEST_F(ServiceWorkerContextTest, VersionActivatedObserver) { … }
TEST_F(ServiceWorkerContextTest, VersionRedundantObserver) { … }
TEST_F(ServiceWorkerContextTest, OnVersionRunningStatusChangedObserver) { … }
TEST_F(ServiceWorkerContextTest, OnDestructObserver) { … }
TEST_F(ServiceWorkerContextTest, Register) { … }
TEST_F(ServiceWorkerContextTest, Register_RejectInstall) { … }
TEST_F(ServiceWorkerContextTest, Register_RejectActivate) { … }
TEST_F(ServiceWorkerContextTest, Unregister) { … }
TEST_F(ServiceWorkerContextTest, UnregisterMultiple) { … }
TEST_F(ServiceWorkerContextTest, RegisterNewScript) { … }
TEST_F(ServiceWorkerContextTest, RegisterDuplicateScript) { … }
TEST_F(ServiceWorkerContextTest, ContainerHostIterator) { … }
class ServiceWorkerContextRecoveryTest
: public ServiceWorkerContextTest,
public testing::WithParamInterface<bool > { … };
TEST_P(ServiceWorkerContextRecoveryTest, DeleteAndStartOver) { … }
INSTANTIATE_TEST_SUITE_P(…);
}