chromium/content/browser/service_worker/service_worker_registration_unittest.cc

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/browser/service_worker/service_worker_registration.h"

#include <stdint.h>

#include <optional>
#include <utility>

#include "base/compiler_specific.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/run_loop.h"
#include "base/test/bind.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/test_simple_task_runner.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/fake_service_worker.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_register_job.h"
#include "content/browser/service_worker/service_worker_registration_object_host.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/browser/service_worker/test_service_worker_observer.h"
#include "content/browser/storage_partition_impl.h"
#include "content/public/common/content_client.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/url_loader_interceptor.h"
#include "content/test/fake_network.h"
#include "content/test/storage_partition_test_helpers.h"
#include "content/test/test_content_browser_client.h"
#include "mojo/public/cpp/bindings/associated_receiver.h"
#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
#include "mojo/public/cpp/system/functions.h"
#include "net/cookies/site_for_cookies.h"
#include "testing/gtest/include/gtest/gtest.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_object.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/gurl.h"
#include "url/origin.h"

namespace content {

namespace {

// From service_worker_registration.cc.
constexpr base::TimeDelta kMaxLameDuckTime =;

int CreateInflightRequest(ServiceWorkerVersion* version) {}

void SaveStatusCallback(bool* called,
                        blink::ServiceWorkerStatusCode* out,
                        blink::ServiceWorkerStatusCode status) {}

}  // namespace

class ServiceWorkerTestContentBrowserClient : public TestContentBrowserClient {};

void RequestTermination(
    mojo::AssociatedRemote<blink::mojom::EmbeddedWorkerInstanceHost>* host) {}

class MockServiceWorkerRegistrationObject
    : public blink::mojom::ServiceWorkerRegistrationObject {};

class ServiceWorkerRegistrationTest : public testing::Test {};

TEST_F(ServiceWorkerRegistrationTest, SetAndUnsetVersions) {}

TEST_F(ServiceWorkerRegistrationTest, FailedRegistrationNoCrash) {}

TEST_F(ServiceWorkerRegistrationTest, NavigationPreload) {}

// Sets up a registration with a waiting worker, and an active worker
// with a controllee and an inflight request.
class ServiceWorkerActivationTest : public ServiceWorkerRegistrationTest,
                                    public testing::WithParamInterface<bool> {};

// Test activation triggered by finishing all requests.
TEST_P(ServiceWorkerActivationTest, NoInflightRequest) {}

// Test activation triggered by skipWaiting and finishing requests.
TEST_P(ServiceWorkerActivationTest, SkipWaitingWithInflightRequest) {}

// Test activation triggered by skipWaiting.
TEST_P(ServiceWorkerActivationTest, SkipWaiting) {}

TEST_P(ServiceWorkerActivationTest, TimeSinceSkipWaiting_Installing) {}

// Test lame duck timer triggered by skip waiting.
TEST_P(ServiceWorkerActivationTest, LameDuckTime_SkipWaiting) {}

// Test lame duck timer triggered by loss of controllee.
TEST_P(ServiceWorkerActivationTest, LameDuckTime_NoControllee) {}

INSTANTIATE_TEST_SUITE_P();

// Sets up a registration with a ServiceWorkerRegistrationObjectHost to hold it.
class ServiceWorkerRegistrationObjectHostTest
    : public ServiceWorkerRegistrationTest {};

class ServiceWorkerRegistrationObjectHostUpdateTest
    : public ServiceWorkerRegistrationObjectHostTest,
      public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

TEST_F(ServiceWorkerRegistrationObjectHostTest, BreakConnection_Destroy) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest, Update_Success) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest,
       Update_CrossOriginShouldFail) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest,
       Update_ContentSettingsDisallowsServiceWorker) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest,
       Update_NoDelayFromControllee) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest,
       Update_DelayFromWorkerWithoutControllee) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest,
       Update_NoDelayFromWorkerWithControllee) {}

TEST_F(ServiceWorkerRegistrationObjectHostTest, Unregister_Success) {}

TEST_F(ServiceWorkerRegistrationObjectHostTest,
       Unregister_CrossOriginShouldFail) {}

TEST_F(ServiceWorkerRegistrationObjectHostTest,
       Unregister_ContentSettingsDisallowsServiceWorker) {}

TEST_F(ServiceWorkerRegistrationObjectHostTest, SetVersionAttributes) {}

TEST_F(ServiceWorkerRegistrationObjectHostTest, SetUpdateViaCache) {}

TEST_P(ServiceWorkerRegistrationObjectHostUpdateTest, UpdateFound) {}

}  // namespace content