chromium/components/custom_handlers/protocol_handler_registry_unittest.cc

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

#include "components/custom_handlers/protocol_handler_registry.h"

#include <stddef.h>

#include <memory>
#include <set>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/custom_handlers/pref_names.h"
#include "components/custom_handlers/protocol_handler.h"
#include "components/custom_handlers/test_protocol_handler_registry_delegate.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "components/user_prefs/user_prefs.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_renderer_host.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/security/protocol_handler_security_level.h"
#include "url/url_features.h"

BrowserThread;

namespace custom_handlers {

base::Value::Dict GetProtocolHandlerValue(const std::string& protocol,
                                          const std::string& url) {}

base::Value::Dict GetProtocolHandlerValueWithDefault(
    const std::string& protocol,
    const std::string& url,
    bool is_default) {}

class ProtocolHandlerChangeListener : public ProtocolHandlerRegistry::Observer {};

class QueryProtocolHandlerOnChange : public ProtocolHandlerRegistry::Observer {};

class ProtocolHandlerRegistryTest : public testing::Test {};

TEST_F(ProtocolHandlerRegistryTest, AcceptProtocolHandlerHandlesProtocol) {}

TEST_F(ProtocolHandlerRegistryTest, DeniedProtocolIsntHandledUntilAccepted) {}

TEST_F(ProtocolHandlerRegistryTest, ClearDefaultMakesProtocolNotHandled) {}

TEST_F(ProtocolHandlerRegistryTest, DisableDeregistersProtocolHandlers) {}

TEST_F(ProtocolHandlerRegistryTest, IgnoreProtocolHandler) {}

TEST_F(ProtocolHandlerRegistryTest, IgnoreEquivalentProtocolHandler) {}

TEST_F(ProtocolHandlerRegistryTest, SaveAndLoad) {}

TEST_F(ProtocolHandlerRegistryTest, Encode) {}

TEST_F(ProtocolHandlerRegistryTest, GetHandlersBetween) {}

TEST_F(ProtocolHandlerRegistryTest, ClearHandlersBetween) {}

TEST_F(ProtocolHandlerRegistryTest, TestEnabledDisabled) {}

TEST_F(ProtocolHandlerRegistryTest,
       DisallowRegisteringExternallyHandledProtocols) {}

TEST_F(ProtocolHandlerRegistryTest, RemovingHandlerMeansItCanBeAddedAgain) {}

TEST_F(ProtocolHandlerRegistryTest, TestStartsAsDefault) {}

TEST_F(ProtocolHandlerRegistryTest, TestClearDefault) {}

TEST_F(ProtocolHandlerRegistryTest, TestGetHandlerFor) {}

TEST_F(ProtocolHandlerRegistryTest, TestMostRecentHandlerIsDefault) {}

TEST_F(ProtocolHandlerRegistryTest, TestOnAcceptRegisterProtocolHandler) {}

TEST_F(ProtocolHandlerRegistryTest, TestDefaultSaveLoad) {}

TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandler) {}

TEST_F(ProtocolHandlerRegistryTest, TestIsRegistered) {}

TEST_F(ProtocolHandlerRegistryTest, TestIsEquivalentRegistered) {}

TEST_F(ProtocolHandlerRegistryTest, TestSilentlyRegisterHandler) {}

TEST_F(ProtocolHandlerRegistryTest, TestRemoveHandlerRemovesDefault) {}

TEST_F(ProtocolHandlerRegistryTest, TestGetHandlersFor) {}

TEST_F(ProtocolHandlerRegistryTest, TestGetRegisteredProtocols) {}

TEST_F(ProtocolHandlerRegistryTest, TestIsHandledProtocol) {}

TEST_F(ProtocolHandlerRegistryTest, TestObserver) {}

TEST_F(ProtocolHandlerRegistryTest, TestReentrantObserver) {}

TEST_F(ProtocolHandlerRegistryTest, TestProtocolsWithNoDefaultAreHandled) {}

TEST_F(ProtocolHandlerRegistryTest, TestDisablePreventsHandling) {}

TEST_F(ProtocolHandlerRegistryTest, TestOSRegistration) {}

#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
// TODO(benwells): When Linux support is more reliable and
// http://crbug.com/88255 is fixed this test will pass.
#define MAYBE_TestOSRegistrationFailure
#else
#define MAYBE_TestOSRegistrationFailure
#endif

TEST_F(ProtocolHandlerRegistryTest, MAYBE_TestOSRegistrationFailure) {}

TEST_F(ProtocolHandlerRegistryTest, TestRemovingDefaultFallsBackToOldDefault) {}

TEST_F(ProtocolHandlerRegistryTest, TestRemovingDefaultDoesntChangeHandlers) {}

TEST_F(ProtocolHandlerRegistryTest, TestReplaceHandler) {}

TEST_F(ProtocolHandlerRegistryTest, TestReplaceNonDefaultHandler) {}

TEST_F(ProtocolHandlerRegistryTest, TestReplaceRemovesStaleHandlers) {}

TEST_F(ProtocolHandlerRegistryTest, TestIsSameOrigin) {}

TEST_F(ProtocolHandlerRegistryTest, TestInstallDefaultHandler) {}

// Non-special URLs behavior is affected by the
// StandardCompliantNonSpecialSchemeURLParsing feature.
// See https://crbug.com/40063064 for details.
class ProtocolHandlerRegistryParamTest
    : public ProtocolHandlerRegistryTest,
      public ::testing::WithParamInterface<bool> {};

#define URL_p1u1
#define URL_p1u2
#define URL_p1u3
#define URL_p2u1
#define URL_p2u2
#define URL_p3u1

TEST_F(ProtocolHandlerRegistryTest, TestPrefPolicyOverlapRegister) {}

TEST_F(ProtocolHandlerRegistryTest, TestPrefPolicyOverlapIgnore) {}

TEST_P(ProtocolHandlerRegistryParamTest, TestURIPercentEncoding) {}

TEST_F(ProtocolHandlerRegistryTest, TestMultiplePlaceholders) {}

TEST_F(ProtocolHandlerRegistryTest, InvalidHandlers) {}

// See
// https://html.spec.whatwg.org/multipage/system-state.html#normalize-protocol-handler-parameters
TEST_F(ProtocolHandlerRegistryTest, WebPlusPrefix) {}

TEST_F(ProtocolHandlerRegistryTest, ProtocolHandlerSecurityLevels) {}

namespace {

enum class ProtocolTestMode {};

}  // namespace

class ProtocolHandlerRegistrySchemeTest
    : public ProtocolHandlerRegistryTest,
      public ::testing::WithParamInterface<ProtocolTestMode> {};
INSTANTIATE_TEST_SUITE_P();
// See
// https://html.spec.whatwg.org/multipage/system-state.html#safelisted-scheme
TEST_P(ProtocolHandlerRegistrySchemeTest, SafelistedSchemes) {}

namespace {

enum class CredentialsTestMode {};

}  // namespace

class ProtocolHandlerRegistryCredentialsTest
    : public ProtocolHandlerRegistryTest,
      public ::testing::WithParamInterface<CredentialsTestMode> {};
INSTANTIATE_TEST_SUITE_P();

// See
// https://html.spec.whatwg.org/multipage/system-state.html#security-and-privacy
// guidance on mitigating credential leaks.
TEST_P(ProtocolHandlerRegistryCredentialsTest,
       NoCredentialsForStandardSchemes) {}

TEST_P(ProtocolHandlerRegistryParamTest, CredentialsForNonStandardSchemes) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace custom_handlers