#include "third_party/blink/renderer/core/page/context_menu_controller.h"
#include <algorithm>
#include <limits>
#include <memory>
#include <optional>
#include <utility>
#include "base/run_loop.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "services/network/public/mojom/attribution.mojom-blink.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/context_menu_data/context_menu_data.h"
#include "third_party/blink/public/common/context_menu_data/edit_flags.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
#include "third_party/blink/public/common/input/web_menu_source_type.h"
#include "third_party/blink/public/mojom/context_menu/context_menu.mojom-blink.h"
#include "third_party/blink/public/web/web_plugin.h"
#include "third_party/blink/renderer/core/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/dom/xml_document.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.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/exported/web_plugin_container_impl.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_document.h"
#include "third_party/blink/renderer/core/html/html_embed_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/input/context_menu_allowed_scope.h"
#include "third_party/blink/renderer/core/layout/layout_embedded_content.h"
#include "third_party/blink/renderer/core/page/focus_controller.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/core/testing/fake_web_plugin.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_component.h"
#include "third_party/blink/renderer/platform/mediastream/media_stream_descriptor.h"
#include "third_party/blink/renderer/platform/testing/empty_web_media_player.h"
#include "third_party/blink/renderer/platform/testing/scoped_mocked_url.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_loader_mock.h"
#include "third_party/blink/renderer/platform/testing/url_loader_mock_factory_impl.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
#include "ui/gfx/geometry/rect.h"
Return;
namespace blink {
namespace {
constexpr char kTestResourceFilename[] = …;
constexpr char kTestResourceMimeType[] = …;
class MockWebMediaPlayerForContextMenu : public EmptyWebMediaPlayer { … };
class ContextMenuControllerTestPlugin : public FakeWebPlugin { … };
class TestWebFrameClientImpl : public frame_test_helpers::TestWebFrameClient { … };
void RegisterMockedImageURLLoad(const String& url) { … }
}
template <>
struct DowncastTraits<ContextMenuControllerTestPlugin> { … };
class ContextMenuControllerTest : public testing::Test { … };
TEST_F(ContextMenuControllerTest, CopyFromPlugin) { … }
TEST_F(ContextMenuControllerTest, VideoNotLoaded) { … }
TEST_F(ContextMenuControllerTest, VideoWithAudioOnly) { … }
TEST_F(ContextMenuControllerTest, PictureInPictureEnabledVideoLoaded) { … }
TEST_F(ContextMenuControllerTest, PictureInPictureDisabledVideoLoaded) { … }
TEST_F(ContextMenuControllerTest, MediaStreamVideoLoaded) { … }
TEST_F(ContextMenuControllerTest, InfiniteDurationVideoLoaded) { … }
TEST_F(ContextMenuControllerTest, HitTestVideoChildElements) { … }
TEST_F(ContextMenuControllerTest, EditingActionsEnabledInSVGDocument) { … }
TEST_F(ContextMenuControllerTest, EditingActionsEnabledInXMLDocument) { … }
TEST_F(ContextMenuControllerTest, ShowNonLocatedContextMenuEvent) { … }
#if !BUILDFLAG(IS_MAC)
TEST_F(ContextMenuControllerTest,
ValidateNonLocatedContextMenuOnLargeImageElement) { … }
#endif
TEST_F(ContextMenuControllerTest, ContextMenuImageHitTestSVGImageElement) { … }
TEST_F(ContextMenuControllerTest, SelectionRectClipped) { … }
class MockEventListener final : public NativeEventListener { … };
TEST_F(ContextMenuControllerTest,
ContextMenuImageHitTestStandardImageSelection) { … }
TEST_F(ContextMenuControllerTest, ContextMenuImageHitTestSucceededPenetrating) { … }
TEST_F(ContextMenuControllerTest, ContextMenuImageHitTestStandardCanvas) { … }
TEST_F(ContextMenuControllerTest, ContextMenuImageHitTestOpaqueNodeBlocking) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageHitTestContextMenuListenerAboveImageBlocking) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageHitTestContextMenuListenerOnImageBlocking) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageHitTestNonBlockingNonContextMenuListenerOnImage) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageHitTestStandardContextMenuListenerAncestorNonBlocking) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageHitTestContextMenuListenerAncestorBlocking) { … }
TEST_F(ContextMenuControllerTest, ContextMenuImageRetrievalCachedImageFound) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageRetrievalCachedImageNotFound) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageRetrievalAfterCachedImageReset) { … }
TEST_F(ContextMenuControllerTest,
ContextMenuImageRetrievalCachedImageCrossFrame) { … }
TEST_F(ContextMenuControllerTest, OpenedFromHighlight) { … }
TEST_F(ContextMenuControllerTest,
KeyboardTriggeredContextMenuPreservesSelection) { … }
TEST_F(ContextMenuControllerTest, CheckRendererIdFromContextMenuOnTextField) { … }
TEST_F(ContextMenuControllerTest, AttributionSrc) { … }
TEST_F(ContextMenuControllerTest, SelectUnselectableContent) { … }
class ContextMenuControllerRemoteParentFrameTest : public testing::Test { … };
TEST_F(ContextMenuControllerRemoteParentFrameTest, ShowContextMenuInChild) { … }
TEST_F(ContextMenuControllerTest, IsPasswordTypeByHeuristic) { … }
TEST_F(ContextMenuControllerTest, HasBeenPasswordHeuristic) { … }
}