chromium/third_party/blink/renderer/core/fragment_directive/css_selector_fragment_anchor_test.cc

// Copyright 2021 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/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/web/web_script_source.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_core.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_style_declaration.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/layout/layout_object.h"
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/page/scrolling/element_fragment_anchor.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/svg/graphics/svg_image.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

namespace blink {

RunPendingTasks;

class CssSelectorFragmentAnchorTest : public SimTest {};

// Make sure we find the element and set it as the CSS target.
TEST_F(CssSelectorFragmentAnchorTest, BasicTest) {}

// When more than one CssSelector Fragments are present, set the first one as
// the CSS target (which will be outlined accordingly)
TEST_F(CssSelectorFragmentAnchorTest, TwoCssSelectorFragmentsOutlineFirst) {}

// If the first CssSelector Fragment is not found, look for the second one
// and set that as the CSS target
TEST_F(CssSelectorFragmentAnchorTest, TwoCssSelectorFragmentsFirstNotFound) {}

// If both CssSelectorFragment and ElementFragment present,
// prioritize CssSelectorFragment
TEST_F(CssSelectorFragmentAnchorTest,
       PrioritizeCssSelectorFragmentOverElementFragment) {}

// TODO(crbug/1253707): Enable after fixing!
// Don't do anything if attribute selector is not allowed according to spec
// https://github.com/WICG/scroll-to-text-fragment/blob/main/EXTENSIONS.md#proposed-solution
TEST_F(CssSelectorFragmentAnchorTest, DISABLED_CheckCssSelectorRestrictions) {}

// Make sure fragment is not dismissed after user clicks
TEST_F(CssSelectorFragmentAnchorTest, FragmentStaysAfterUserClicks) {}

// Although parsed correctly, the element is not found, hence no CSS target
// should be set
TEST_F(CssSelectorFragmentAnchorTest, ParsedCorrectlyButElementNotFound) {}

// value= part should be encoded/decoded
TEST_F(CssSelectorFragmentAnchorTest, ValuePartHasCommaAndIsEncoded) {}

// What if value= part is not encoded, and it contains a comma,
// Should not crash and no CSS target should be set
TEST_F(CssSelectorFragmentAnchorTest, ValuePartHasCommaButIsNotEncoded) {}

TEST_F(CssSelectorFragmentAnchorTest,
       TargetElementIsNotHighlightedWithElementFragment) {}

TEST_F(CssSelectorFragmentAnchorTest,
       TargetElementIsNotHighlightedWithTextFragment) {}

// Simulate an anchor link navigation and check that the style is removed.
TEST_F(CssSelectorFragmentAnchorTest, SelectorFragmentTargetOutline) {}

}  // namespace blink