#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/ui/views/permissions/permission_prompt_bubble_base_view.h"
#include "base/feature_list.h"
#include "base/functional/callback_helpers.h"
#include "base/ranges/algorithm.h"
#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 "build/chromeos_buildflags.h"
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/download/download_permission_request.h"
#include "chrome/browser/permissions/quiet_notification_permission_ui_config.h"
#include "chrome/browser/permissions/quiet_notification_permission_ui_state.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/permissions/chip/chip_controller.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_bubble_base_view.h"
#include "chrome/browser/ui/views/permissions/permission_prompt_chip.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/permissions/permission_request_manager_test_api.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/custom_handlers/protocol_handler_registry.h"
#include "components/custom_handlers/register_protocol_handler_permission_request.h"
#include "components/permissions/constants.h"
#include "components/permissions/features.h"
#include "components/permissions/permission_request.h"
#include "components/permissions/permission_ui_selector.h"
#include "components/permissions/permission_util.h"
#include "components/permissions/request_type.h"
#include "components/permissions/test/mock_permission_request.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_process_host_observer.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.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 "content/public/test/cursor_utils.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/events/base_event_utils.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/animation/animation_test_api.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/test/ax_event_counter.h"
#include "ui/views/test/button_test_api.h"
#include "url/gurl.h"
namespace {
class TestQuietNotificationPermissionUiSelector
: public permissions::PermissionUiSelector { … };
}
class PermissionPromptBubbleBaseViewBrowserTest : public DialogBrowserTest { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_AlertAccessibleEvent …
#else
#define MAYBE_AlertAccessibleEvent …
#endif
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
MAYBE_AlertAccessibleEvent) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
SwitchBetweenChipAndBubble) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_ActiveTabClosedAfterRendererCrashesWithPendingPermissionRequest …
#else
#define MAYBE_ActiveTabClosedAfterRendererCrashesWithPendingPermissionRequest …
#endif
IN_PROC_BROWSER_TEST_F(
PermissionPromptBubbleBaseViewBrowserTest,
MAYBE_ActiveTabClosedAfterRendererCrashesWithPendingPermissionRequest) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_geolocation) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_notifications) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_mic) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_camera) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_protocol_handlers) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_midi) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_storage_access) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_downloads) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_multiple) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
OpenHelpCenterLinkInNewTab) { … }
#if BUILDFLAG(IS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_protected_media) {
ShowAndVerifyUi();
}
#endif
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
DispositionNoAbusiveTest) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
AcceptedOnceDispositionNoAbusiveTest) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
PermissionPromptBubbleDisallowsCustomCursors) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
LoudChipOrAnchoredBubbleIsShownForNonAbusiveRequests) { … }
IN_PROC_BROWSER_TEST_F(PermissionPromptBubbleBaseViewBrowserTest,
QuietChipIsShownForAbusiveRequests) { … }
class PermissionPromptBubbleBaseViewAllowAlwaysFirstBrowserTest
: public PermissionPromptBubbleBaseViewBrowserTest { … };
IN_PROC_BROWSER_TEST_F(
PermissionPromptBubbleBaseViewAllowAlwaysFirstBrowserTest,
InvokeUi_geolocation) { … }
class PermissionPromptBubbleBaseViewAllowWhileVisitingFirstBrowserTest
: public PermissionPromptBubbleBaseViewBrowserTest { … };
IN_PROC_BROWSER_TEST_F(
PermissionPromptBubbleBaseViewAllowWhileVisitingFirstBrowserTest,
InvokeUi_geolocation) { … }
class LongOriginPermissionPromptBubbleBaseViewBrowserTest
: public PermissionPromptBubbleBaseViewBrowserTest { … };
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_geolocation) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_notifications) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_mic) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_camera) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_protocol_handlers) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_midi) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_storage_access) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_downloads) { … }
IN_PROC_BROWSER_TEST_F(LongOriginPermissionPromptBubbleBaseViewBrowserTest,
InvokeUi_multiple) { … }