chromium/content/browser/service_worker/service_worker_internals_ui_browsertest.cc

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

#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_registration.h"
#include "content/browser/service_worker/service_worker_test_utils.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_base.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "net/base/features.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/service_worker/service_worker_status_code.h"
#include "third_party/blink/public/common/storage_key/storage_key.h"
#include "third_party/blink/public/mojom/service_worker/service_worker_registration_options.mojom.h"

namespace content {
namespace {
const char kServiceWorkerInternalsUrl[] =;
const char kServiceWorkerSetupPage[] =;
const char kServiceWorkerUrl[] =;
const char kServiceWorkerScope[] =;

void ExpectRegisterResultAndRun(blink::ServiceWorkerStatusCode expected,
                                base::RepeatingClosure continuation,
                                blink::ServiceWorkerStatusCode actual) {}

void ExpectUnregisterResultAndRun(
    blink::ServiceWorkerStatusCode expected_status,
    base::RepeatingClosure continuation,
    blink::ServiceWorkerStatusCode actual_status) {}

class ServiceWorkerObserver : public ServiceWorkerContextCoreObserver {};

class SWStateObserver : public ServiceWorkerObserver,
                        public base::RefCountedThreadSafe<SWStateObserver> {};

class SWOnStoppedObserver
    : public ServiceWorkerObserver,
      public base::RefCountedThreadSafe<SWOnStoppedObserver> {};

class SWOnStartedObserver
    : public ServiceWorkerObserver,
      public base::RefCountedThreadSafe<SWOnStartedObserver> {};
class SWOnRegistrationDeletedObserver
    : public ServiceWorkerObserver,
      public base::RefCountedThreadSafe<SWOnRegistrationDeletedObserver> {};

}  // namespace

class ServiceWorkerInternalsUIBrowserTest : public ContentBrowserTest {};

// Tests
IN_PROC_BROWSER_TEST_F(ServiceWorkerInternalsUIBrowserTest,
                       NoRegisteredServiceWorker) {}

IN_PROC_BROWSER_TEST_F(ServiceWorkerInternalsUIBrowserTest,
                       RegisteredSWReflectedOnInternalUI) {}

// The test is flaky on Mac and Linux. crbug.com/1324856
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
#define MAYBE_StopStartSWReflectedOnInternalUI
#else
#define MAYBE_StopStartSWReflectedOnInternalUI
#endif
IN_PROC_BROWSER_TEST_F(ServiceWorkerInternalsUIBrowserTest,
                       MAYBE_StopStartSWReflectedOnInternalUI) {}

IN_PROC_BROWSER_TEST_F(ServiceWorkerInternalsUIBrowserTest, InternalUIOptions) {}

class ServiceWorkerInternalsUIBrowserTestWithStoragePartitioning
    : public ServiceWorkerInternalsUIBrowserTest {};

IN_PROC_BROWSER_TEST_F(
    ServiceWorkerInternalsUIBrowserTestWithStoragePartitioning,
    RegisteredSWReflectedOnInternalUI) {}

}  // namespace content