#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include <stddef.h>
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sharing_hub/sharing_hub_features.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/find_bar/find_bar_host_unittest_util.h"
#include "chrome/browser/ui/frame/window_frame_util.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/chrome_test_utils.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/omnibox/browser/autocomplete_match_type.h"
#include "components/omnibox/browser/omnibox_client.h"
#include "components/omnibox/browser/omnibox_controller.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/focus_changed_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/switches.h"
#include "ui/base/test/ui_controls.h"
#include "ui/base/ui_base_features.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/test/widget_activation_waiter.h"
#include "ui/views/widget/widget.h"
#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_CHROMEOS_LACROS)
#include "base/test/scoped_feature_list.h"
#endif
namespace {
constexpr char kGetFocusedElementJS[] = …;
class FocusChangeObserver : public views::FocusChangeListener,
public content::WebContentsObserver { … };
}
namespace base {
template <>
struct ScopedObservationTraits<views::FocusManager, FocusChangeObserver> { … };
}
namespace {
RenderViewHost;
WebContents;
#if BUILDFLAG(IS_POSIX)
const int kActionDelayMs = …;
#endif
const char kSimplePage[] = …;
const char kStealFocusPage[] = …;
const char kTypicalPage[] = …;
class BrowserFocusBasicTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BrowserFocusBasicTest, BrowserFocusedOnCreation) { … }
class BrowserFocusTest : public InProcessBrowserTest { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_ClickingMovesFocus …
#else
#define MAYBE_ClickingMovesFocus …
#endif
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_ClickingMovesFocus) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BrowsersRememberFocus) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocusFindInPage) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, LocationBarLockFocus) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_FindFocusTest …
#else
#define MAYBE_FindFocusTest …
#endif
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FindFocusTest) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabInitialFocus) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusOnReload) { … }
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX)
#define MAYBE_FocusOnReloadCrashedTab …
#else
#define MAYBE_FocusOnReloadCrashedTab …
#endif
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusOnReloadCrashedTab) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusAfterCrashedTab) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, NavigateFromOmnibox) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, NavigateFromOmniboxIntoNewTab) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_FocusOnNavigate) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, AboutBlankNavigationLocationTest) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, NoFocusForBackgroundNTP) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, DISABLED_PopupLocationBar) { … }
IN_PROC_BROWSER_TEST_F(BrowserFocusTest, AppLocationBar) { … }
}