chromium/third_party/blink/renderer/modules/service_worker/service_worker_container_test.cc

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

#include "third_party/blink/renderer/modules/service_worker/service_worker_container.h"

#include <memory>
#include <utility>

#include "base/memory/raw_ref.h"
#include "base/test/bind.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/script/script_type.mojom-blink.h"
#include "third_party/blink/public/platform/modules/service_worker/web_service_worker_provider.h"
#include "third_party/blink/public/platform/web_url.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
#include "third_party/blink/renderer/bindings/core/v8/script_function.h"
#include "third_party/blink/renderer/bindings/core/v8/script_promise.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_dom_exception.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_gc_controller.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/dom_exception.h"
#include "third_party/blink/renderer/core/dom/events/event.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/testing/page_test_base.h"
#include "third_party/blink/renderer/core/testing/wait_for_event.h"
#include "third_party/blink/renderer/modules/service_worker/navigator_service_worker.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/thread_state.h"
#include "third_party/blink/renderer/platform/weborigin/kurl.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "v8/include/v8.h"

namespace blink {
namespace {

// Promise-related test support.

struct StubScriptFunction : public GarbageCollected<StubScriptFunction> {};

class ScriptValueTest {};

// Runs microtasks and expects |promise| to be rejected. Calls
// |valueTest| with the value passed to |reject|, if any.
void ExpectRejected(ScriptState* script_state,
                    ScriptPromiseUntyped& promise,
                    const ScriptValueTest& value_test) {}

// DOM-related test support.

// Matches a ScriptValue and a DOMException with a specific name and message.
class ExpectDOMException : public ScriptValueTest {};

// Matches a ScriptValue and a TypeError with a message.
class ExpectTypeError : public ScriptValueTest {};

// Service Worker-specific tests.

class NotReachedWebServiceWorkerProvider : public WebServiceWorkerProvider {};

class ServiceWorkerContainerTest : public PageTestBase {};

TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScriptIsRejected) {}

TEST_F(ServiceWorkerContainerTest, Register_UnsupportedSchemeIsRejected) {}

TEST_F(ServiceWorkerContainerTest, Register_CrossOriginScopeIsRejected) {}

TEST_F(ServiceWorkerContainerTest, GetRegistration_CrossOriginURLIsRejected) {}

class StubWebServiceWorkerProvider {};

TEST_F(ServiceWorkerContainerTest,
       RegisterUnregister_NonHttpsSecureOriginDelegatesToProvider) {}

TEST_F(ServiceWorkerContainerTest,
       GetRegistration_OmittedDocumentURLDefaultsToPageURL) {}

TEST_F(ServiceWorkerContainerTest,
       RegisterUnregister_UpdateViaCacheOptionDelegatesToProvider) {}

TEST_F(ServiceWorkerContainerTest, Register_TypeOptionDelegatesToProvider) {}

WebServiceWorkerObjectInfo MakeServiceWorkerObjectInfo() {}

TransferableMessage MakeTransferableMessage() {}

TEST_F(ServiceWorkerContainerTest, ReceiveMessage) {}

TEST_F(ServiceWorkerContainerTest, ReceiveMessageLockedToAgentCluster) {}

TEST_F(ServiceWorkerContainerTest, ReceiveMessageWhichCannotDeserialize) {}

}  // namespace
}  // namespace blink