chromium/third_party/blink/renderer/platform/weborigin/kurl_test.cc

/*
 * Copyright (C) 2010 Google Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

// Basic tests that verify our KURL's interface behaves the same as the
// original KURL's.

#include "third_party/blink/renderer/platform/weborigin/kurl.h"

#include <stdint.h>

#include <string_view>

#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/scheduler/public/non_main_thread.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "url/gurl.h"
#include "url/gurl_abstract_tests.h"
#include "url/url_features.h"
#include "url/url_util.h"

namespace blink {

TEST(KURLTest, Getters) {}

TEST(KURLTest, Setters) {}

// Tests that KURL::decodeURLEscapeSequences works as expected
TEST(KURLTest, DecodeURLEscapeSequences) {}

TEST(KURLTest, EncodeWithURLEscapeSequences) {}

TEST(KURLTest, AbsoluteRemoveWhitespace) {}

TEST(KURLTest, RelativeRemoveWhitespace) {}

TEST(KURLTest, AbsolutePotentiallyDanglingMarkup) {}

TEST(KURLTest, PotentiallyDanglingMarkupAfterFragmentRemoval) {}

TEST(KURLTest, ResolveEmpty) {}

// WebKit will make empty URLs and set components on them. kurl doesn't allow
// replacements on invalid URLs, but here we do.
TEST(KURLTest, ReplaceInvalid) {}

TEST(KURLTest, Valid_HTTP_FTP_URLsHaveHosts) {}

TEST(KURLTest, Path) {}

// Test that setting the query to different things works. Thq query is handled
// a littler differently than some of the other components.
TEST(KURLTest, Query) {}

TEST(KURLTest, Ref) {}

TEST(KURLTest, Empty) {}

TEST(KURLTest, UserPass) {}

TEST(KURLTest, Offsets) {}

TEST(KURLTest, DeepCopyInnerURL) {}

TEST(KURLTest, LastPathComponent) {}

TEST(KURLTest, IsHierarchical) {}

TEST(KURLTest, PathAfterLastSlash) {}

TEST(KURLTest, ProtocolIsInHTTPFamily) {}

TEST(KURLTest, ProtocolIs) {}

TEST(KURLTest, urlStrippedForUseAsReferrer) {}

TEST(KURLTest, urlStrippedForUseAsReferrerRespectsReferrerScheme) {}

TEST(KURLTest, strippedForUseAsReferrer) {}

TEST(KURLTest, ThreadSafesStaticKurlGetters) {}

// Setting protocol to "file" should not work if the URL has credentials or a
// port.
TEST(KURLTest, FailToSetProtocolToFile) {}

// If the source URL is invalid, then it behaves like it has an empty
// protocol, so the conversion to a file URL can go ahead.
TEST(KURL, SetProtocolToFileFromInvalidURL) {}

TEST(KURLTest, SetProtocolToFromFile) {}

TEST(KURLTest, FailToSetProtocolFromFile) {}

// According to the URL standard https://url.spec.whatwg.org/#scheme-state
// switching between special and non-special schemes shouldn't work, but for now
// we are retaining it for backwards-compatibility.
// TODO(ricea): Change these tests if we change the behaviour.
TEST(KURLTest, SetFileProtocolFromNonSpecial) {}

TEST(KURLTest, SetFileProtocolToNonSpecial) {}

TEST(KURLTest, InvalidKURLToGURL) {}

TEST(KURLTest, HasIDNA2008DeviationCharacters) {}

TEST(KURLTest, IPv4EmbeddedIPv6Address) {}

// Regression test for https://crbug.com/362674372.
TEST(KURLTest, SetQueryTwice) {}

enum class PortIsValid {};

struct PortTestCase {};

// port used if SetHostAndPort/SetPort is a no-op
constexpr int kNoopPort =;

// The tested behaviour matches the implementation. It doesn't necessarily match
// the URL Standard.
const PortTestCase port_test_cases[] =;

void PrintTo(const PortTestCase& port_test_case, ::std::ostream* os) {}

class KURLPortTest : public ::testing::TestWithParam<PortTestCase> {};

TEST_P(KURLPortTest, Construct) {}

TEST_P(KURLPortTest, ConstructRelative) {}

TEST_P(KURLPortTest, SetPort) {}

TEST_P(KURLPortTest, SetHostAndPort) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace blink

// Apparently INSTANTIATE_TYPED_TEST_SUITE_P needs to be used in the same
// namespace as where the typed test suite was defined.
namespace url {

class KURLTestTraits {};

INSTANTIATE_TYPED_TEST_SUITE_P();

}  // namespace url