chromium/content/browser/service_worker/service_worker_offline_capability_check_browsertest.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 <optional>

#include "base/barrier_closure.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/scoped_refptr.h"
#include "base/task/task_traits.h"
#include "base/test/bind.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "content/browser/service_worker/service_worker_context_wrapper.h"
#include "content/browser/service_worker/service_worker_fetch_dispatcher.h"
#include "content/browser/service_worker/service_worker_version.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.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/shell/browser/shell.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "services/network/public/mojom/fetch_api.mojom.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 "url/gurl.h"
#include "url/origin.h"

namespace content {

namespace {

struct FetchResult {};

class FetchEventTestHelper {};

}  // namespace

class ServiceWorkerOfflineCapabilityCheckBrowserTest
    : public ContentBrowserTest {};

IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       DispatchOfflineCapabilityCheckFetchEvent) {}

IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       DispatchOfflineCapabilityCheckFetchEventMoreThanOnce) {}

// Sites without a service worker are identified as having no offline capability
// support.
IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       CheckOfflineCapabilityForNoServiceWorker) {}

// Sites with a no-fetch-handler service worker are identified as having no
// offline capability support.
IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       CheckOfflineCapabilityForNoFetchHandler) {}

// Sites with a service worker are identified as supporting offline capability
// only when it returns a valid response in the offline mode.

// TODO(crbug.com/40866226): Flaky on all platforms.
IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       DISABLED_CheckOfflineCapability) {}

// Sites with a service worker which is not activated yet are identified as
// having no offline capability support.
IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       CheckOfflineCapabilityForInstallingServiceWorker) {}

// Sites with a service worker that enable navigation preload are identified
// as supporting offline capability only when they return a valid response in
// offline mode.
IN_PROC_BROWSER_TEST_F(ServiceWorkerOfflineCapabilityCheckBrowserTest,
                       CheckOfflineCapabilityForNavigationPreload) {}

}  // namespace content