chromium/content/browser/service_worker/service_worker_context_wrapper_unittest.cc

// Copyright 2019 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_context_wrapper.h"

#include <memory>
#include <vector>

#include "base/files/scoped_temp_dir.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "components/services/storage/service_worker/service_worker_storage_control_impl.h"
#include "content/browser/service_worker/service_worker_context_core.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/browser/storage_partition_impl.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "net/base/features.h"
#include "net/base/schemeful_site.h"
#include "testing/gtest/include/gtest/gtest.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 "url/origin.h"

namespace content {

// Fixture for the ServiceWorkerContextWrapper test. It uses a disk user data
// directory in order to test starting the browser with a registration already
// written to storage.
class ServiceWorkerContextWrapperTest : public testing::Test {};

// Test that the UI thread knows which origins have registrations upon
// browser startup. Regression test for https://crbug.com/991143.
TEST_F(ServiceWorkerContextWrapperTest, HasRegistration) {}

// This test involves storing two registrations for the same key to storage
// and deleting one of them to check that MaybeHasRegistrationForStorageKey
// still correctly returns TRUE since there is still one registration for the
// key, and should only return FALSE when ALL registrations for that key
// have been deleted from storage.
TEST_F(ServiceWorkerContextWrapperTest, DeleteRegistrationsForSameKey) {}

// This tests installs two registrations with the same origin but different
// top-level site, then deletes one, then confirms that the other still appears
// for MaybeHasRegistrationForStorageKey().
TEST_F(ServiceWorkerContextWrapperTest, DeleteRegistrationsForPartitionedKeys) {}

// This tests deleting registrations from storage and checking that even if live
// registrations may exist, MaybeHasRegistrationForStorageKey correctly returns
// FALSE since the registrations do not exist in storage.
TEST_F(ServiceWorkerContextWrapperTest, DeleteRegistration) {}

}  // namespace content