chromium/content/browser/accessibility/accessibility_action_browsertest.cc

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

#include <string>

#include "base/check.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/escape.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/run_until.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/test/accessibility_notification_waiter.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/context_menu_interceptor.h"
#include "content/public/test/scoped_accessibility_mode_override.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "net/base/data_url.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features_generated.h"
#include "ui/accessibility/accessibility_switches.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_position.h"
#include "ui/accessibility/mojom/ax_tree_data.mojom-shared-internal.h"
#include "ui/accessibility/platform/browser_accessibility.h"
#include "ui/accessibility/platform/browser_accessibility_manager.h"
#include "ui/gfx/codec/png_codec.h"
#include "url/gurl.h"

namespace content {

namespace {

class AccessibilityActionBrowserTest : public ContentBrowserTest {};

}  // namespace

// Canvas tests rely on the harness producing pixel output in order to read back
// pixels from a canvas element. So we have to override the setup function.
class AccessibilityCanvasActionBrowserTest
    : public AccessibilityActionBrowserTest {};

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, DoDefaultAction) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       DoDefaultActionOnObjectWithRole) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, FocusAction) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, BlurAction) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       IncrementDecrementActions) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, VerticalScroll) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, HorizontalScroll) {}

// Flaky on Mac https://crbug.com/1337760.
#if BUILDFLAG(IS_MAC)
#define MAYBE_CanvasGetImage
#else
#define MAYBE_CanvasGetImage
#endif
IN_PROC_BROWSER_TEST_F(AccessibilityCanvasActionBrowserTest,
                       MAYBE_CanvasGetImage) {}

// Flaky on Mac https://crbug.com/1337760.
#if BUILDFLAG(IS_MAC)
#define MAYBE_CanvasGetImageScale
#else
#define MAYBE_CanvasGetImageScale
#endif
IN_PROC_BROWSER_TEST_F(AccessibilityCanvasActionBrowserTest,
                       MAYBE_CanvasGetImageScale) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, ImgElementGetImage) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       DoDefaultActionFocusesContentEditable) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, InputSetValue) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, TextareaSetValue) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       ContenteditableSetValue) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, ShowContextMenu) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       ShowContextMenuOnMultilineElement) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       ShowContextMenuOnOffscreenElement) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       ShowContextMenuOnObscuredElement) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       AriaGridSelectedChangedEvent) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       AriaControlsChangedEvent) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, FocusLostOnDeletedNode) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       FocusLostOnDeletedNodeInInnerWebContents) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       InnerWebContentsFocusPlaceholder) {}

// Action::kScrollToMakeVisible does not seem reliable on Android and we are
// currently only using it for desktop screen readers.
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, ScrollIntoView) {}
#endif  // !BUILDFLAG(IS_ANDROID)

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, StitchChildTree) {}

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, ClickSVG) {}

// TODO(crbug.com/40928581) Disabled due to flakiness.
IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest,
                       DISABLED_ClickAXNodeGeneratedFromCSSContent) {}

// Only run this test on platforms where Blink expands and draws a popup.
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_IOS)
IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, OpenSelectPopup) {}
#endif  // !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_MAC) && !(BUILDFLAG(IS_IOS)

IN_PROC_BROWSER_TEST_F(AccessibilityActionBrowserTest, FocusPermissionElement) {}

}  // namespace content