chromium/third_party/blink/renderer/core/fragment_directive/text_fragment_handler_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 "third_party/blink/renderer/core/fragment_directive/text_fragment_handler.h"

#include <gtest/gtest.h>

#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "components/shared_highlighting/core/common/shared_highlighting_features.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_font_face_descriptors.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_mouse_event_init.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_union_arraybuffer_arraybufferview_string.h"
#include "third_party/blink/renderer/core/css/css_font_face.h"
#include "third_party/blink/renderer/core/css/font_face_set_document.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/visible_units.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/location.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/loader/document_loader.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/scheduler/public/main_thread_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/public/thread_scheduler.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"

namespace blink {

RunPendingTasks;

class TextFragmentHandlerTest : public SimTest {};

TEST_F(TextFragmentHandlerTest, RemoveTextFragments) {}

TEST_F(TextFragmentHandlerTest,
       ExtractTextFragmentWithWithMultipleTextFragments) {}

TEST_F(TextFragmentHandlerTest, ExtractTextFragmentWithNoMatch) {}

TEST_F(TextFragmentHandlerTest, ExtractTextFragmentWithRange) {}

TEST_F(TextFragmentHandlerTest, ExtractTextFragmentWithRangeAndContext) {}

TEST_F(TextFragmentHandlerTest, ExtractFirstTextFragmentRect) {}

TEST_F(TextFragmentHandlerTest, ExtractFirstTextFragmentRectScroll) {}

TEST_F(TextFragmentHandlerTest, ExtractFirstTextFragmentRectMultipleHighlight) {}

TEST_F(TextFragmentHandlerTest,
       ExtractFirstTextFragmentRectMultipleHighlightWithNoFoundText) {}

TEST_F(TextFragmentHandlerTest, RejectExtractFirstTextFragmentRect) {}

// Checks that the selector is preemptively generated.
TEST_F(TextFragmentHandlerTest, CheckPreemptiveGeneration) {}

// When URL is blocklisted, the selector shouldn't be preemptively generated.
TEST_F(TextFragmentHandlerTest, CheckNoPreemptiveGenerationBlocklist) {}

// Check that selector is not generated for editable text.
TEST_F(TextFragmentHandlerTest, CheckNoPreemptiveGenerationEditable) {}

// TODO(crbug.com/1192047): Update the test to better reflect the real repro
// steps. Test case for crash in crbug.com/1190137. When selector is requested
// after callback is set and unused.
TEST_F(TextFragmentHandlerTest, SecondGenerationCrash) {}

// Verifies metrics for preemptive generation are correctly recorded when the
// selector is successfully generated.
TEST_F(TextFragmentHandlerTest, CheckMetrics_Success) {}

// Verifies metrics for preemptive generation are correctly recorded when the
// selector request fails, in this case, because the context limit is reached.
TEST_F(TextFragmentHandlerTest, CheckMetrics_Failure) {}

TEST_F(TextFragmentHandlerTest,
       ShouldCreateTextFragmentHandlerAndRemoveHighlightForIframes) {}

TEST_F(TextFragmentHandlerTest, NonMatchingTextDirectiveCreatesHandler) {}

TEST_F(TextFragmentHandlerTest, MatchingTextDirectiveCreatesHandler) {}

TEST_F(TextFragmentHandlerTest,
       ShouldCreateTextFragmentHandlerAndRemoveHighlight) {}

TEST_F(TextFragmentHandlerTest,
       ShouldCreateTextFragmentHandlerAndRequestSelector) {}

// Verify that removing a shared highlight removes document markers and the
// text directive from the URL, for both main frame and subframe.
TEST_F(TextFragmentHandlerTest,
       ShouldRemoveFromMainFrameAndIframeWhenBothHaveHighlights) {}

// crbug.com/1266937 Even if |TextFragmentSelectorGenerator| gets reset between
// generation completion and selector request we should record the correct error
// code.
// TODO(https://crbug.com/338340754): It's not clear how useful this behavior is
// and it prevents us from clearing the TextFragmentHandler and
// TextFragmentSelectorGenerator entirely between navigations.
TEST_F(TextFragmentHandlerTest, IfGeneratorResetShouldRecordCorrectError) {}

// crbug.com/1301794 If generation didn't start requesting selector shouldn't
// crash.
TEST_F(TextFragmentHandlerTest, NotGenerated) {}

TEST_F(TextFragmentHandlerTest, InvalidateOverflowOnRemoval) {}

}  // namespace blink