chromium/chrome/browser/ui/views/page_info/page_info_bubble_view_interactive_uitest.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 "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "chrome/browser/ui/views/location_bar/location_icon_view.h"
#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "chrome/browser/ui/views/page_info/page_info_main_view.h"
#include "chrome/browser/ui/views/page_info/permission_toggle_row_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "ui/events/test/test_event.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/interaction/interaction_test_util_views.h"

namespace {

DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
const char kFirstPermissionRow[] =;

// Clicks the location icon to open the page info bubble.
void OpenPageInfoBubble(Browser* browser) {}

// Tracks focus of an arbitrary UI element.
class FocusTracker {};

// Watches a WebContents for focus changes.
class WebContentsFocusTracker : public FocusTracker,
                                public content::WebContentsObserver {};

// Watches a View for focus changes.
class ViewFocusTracker : public FocusTracker, public views::ViewObserver {};

}  // namespace

class PageInfoBubbleViewFocusInteractiveUiTest : public InProcessBrowserTest {};

#if BUILDFLAG(IS_MAC)
// https://crbug.com/1029882
#define MAYBE_FocusReturnsToContentOnClose
#else
#define MAYBE_FocusReturnsToContentOnClose
#endif

// Test that when the PageInfo bubble is closed, focus is returned to the web
// contents pane.
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewFocusInteractiveUiTest,
                       MAYBE_FocusReturnsToContentOnClose) {}

#if BUILDFLAG(IS_MAC)
// https://crbug.com/1029882
#define MAYBE_FocusDoesNotReturnToContentsOnReloadPrompt
#else
#define MAYBE_FocusDoesNotReturnToContentsOnReloadPrompt
#endif

// Test that when the PageInfo bubble is closed and a reload prompt is
// displayed, focus is NOT returned to the web contents pane, but rather returns
// to the location bar so accessibility users must tab through the reload prompt
// before getting back to web contents (see https://crbug.com/910067).
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewFocusInteractiveUiTest,
                       MAYBE_FocusDoesNotReturnToContentsOnReloadPrompt) {}

class PageInfoBubbleViewInteractiveUiTest : public InteractiveBrowserTest {};

IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewInteractiveUiTest,
                       ToggleTest_DefaultAsk) {}

IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewInteractiveUiTest,
                       ToggleTest_DefaultBlock) {}

IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewInteractiveUiTest,
                       BroadExceptionToggleTest_DefaultAllow) {}

IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewInteractiveUiTest,
                       BroadExceptionToggleTest_DefaultBlock) {}