#include <memory>
#include <string>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/test_future.h"
#include "base/time/time.h"
#include "base/values.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/service_worker_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/background_script_executor.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/script_executor.h"
#include "extensions/browser/script_result_queue.h"
#include "extensions/browser/service_worker/service_worker_task_queue.h"
#include "extensions/browser/service_worker/service_worker_test_utils.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/mojom/manifest.mojom.h"
#include "extensions/test/extension_background_page_waiter.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_extension_dir.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace extensions {
TestServiceWorkerTaskQueueObserver;
namespace {
constexpr char kNTPTestExtensionId[] = …;
enum class BackgroundType { … };
void CheckBooleanHistogramCounts(const char* histogram_name,
int true_count,
int false_count,
base::HistogramTester& histogram_tester) { … }
void CheckStatusCodeHistogramCounts(const char* histogram_name,
blink::ServiceWorkerStatusCode status,
int count,
base::HistogramTester& histogram_tester) { … }
GURL new_tab_url() { … }
class ExtensionRegistrationAndUnregistrationWaiter
: public ServiceWorkerTaskQueue::TestObserver { … };
}
class ServiceWorkerRegistrationApiTest : public ExtensionApiTest { … };
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
ServiceWorkerIsProperlyRegisteredAfterInstallation) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
UpdatingUnpackedExtensionUpdatesServiceWorker) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
AttemptInstallAndImmediateDisable) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
ImmediateUpdateWithNewTabPageOverrideActive) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
UpdatingPackedExtensionUpdatesServiceWorker) { … }
IN_PROC_BROWSER_TEST_F(
ServiceWorkerRegistrationApiTest,
DISABLED_DisablingOrUninstallingAnExtensionUnregistersTheServiceWorker) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
RegistrationCannotBeRemovedByBrowsingDataAPI) { … }
IN_PROC_BROWSER_TEST_F(ServiceWorkerRegistrationApiTest,
ModifyingLocalFilesForUnpackedExtensions) { … }
class ServiceWorkerExtensionUpdateOnBrowserRestartRegistrationApiTest
: public ServiceWorkerRegistrationApiTest { … };
IN_PROC_BROWSER_TEST_F(
ServiceWorkerExtensionUpdateOnBrowserRestartRegistrationApiTest,
PRE_NTPUpdateAcrossBrowserRestart) { … }
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_NTPUpdateAcrossBrowserRestart …
#else
#define MAYBE_NTPUpdateAcrossBrowserRestart …
#endif
IN_PROC_BROWSER_TEST_F(
ServiceWorkerExtensionUpdateOnBrowserRestartRegistrationApiTest,
MAYBE_NTPUpdateAcrossBrowserRestart) { … }
class ServiceWorkerManifestVersionBrowserTest
: public ExtensionBrowserTest,
public testing::WithParamInterface<int> { … };
ServiceWorkerRegistrationInstallMetricBrowserTest;
IN_PROC_BROWSER_TEST_P(ServiceWorkerRegistrationInstallMetricBrowserTest,
ExtensionInstall) { … }
class ServiceWorkerTaskQueueRegistrationObserver
: public ServiceWorkerTaskQueue::TestObserver { … };
IN_PROC_BROWSER_TEST_P(ServiceWorkerRegistrationInstallMetricBrowserTest,
ExtensionUninstall) { … }
ServiceWorkerRegistrationRestartMetricBrowserTest;
IN_PROC_BROWSER_TEST_P(ServiceWorkerRegistrationRestartMetricBrowserTest,
DISABLED_ExtensionRestart) { … }
class MV2BackgroundsToMV3WorkerRegistrationMetricBrowserTest
: public ServiceWorkerRegistrationApiTest,
public testing::WithParamInterface<BackgroundType> { … };
IN_PROC_BROWSER_TEST_P(MV2BackgroundsToMV3WorkerRegistrationMetricBrowserTest,
ExtensionUpdate) { … }
class WorkerBackgroundToWorkerBackgroundRegistrationMetricTest
: public ServiceWorkerRegistrationApiTest,
public testing::WithParamInterface<std::pair<int, int>> { … };
IN_PROC_BROWSER_TEST_P(WorkerBackgroundToWorkerBackgroundRegistrationMetricTest,
ExtensionUpdate) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
}