#include "chrome/browser/ui/views/page_info/page_info_bubble_view.h"
#include "base/files/file_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/metrics/user_action_tester.h"
#include "base/test/with_feature_override.h"
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/file_system_access/chrome_file_system_access_permission_context.h"
#include "chrome/browser/file_system_access/file_system_access_features.h"
#include "chrome/browser/file_system_access/file_system_access_permission_context_factory.h"
#include "chrome/browser/file_system_access/file_system_access_permission_request_manager.h"
#include "chrome/browser/interstitials/security_interstitial_page_test_utils.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service.h"
#include "chrome/browser/optimization_guide/optimization_guide_keyed_service_factory.h"
#include "chrome/browser/page_info/page_info_features.h"
#include "chrome/browser/privacy_sandbox/mock_privacy_sandbox_service.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h"
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service_factory.h"
#include "chrome/browser/safe_browsing/chrome_password_protection_service.h"
#include "chrome/browser/ssl/https_upgrades_interceptor.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/file_system_access/file_system_access_ui_helpers.h"
#include "chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h"
#include "chrome/browser/ui/hats/trust_safety_sentiment_service_factory.h"
#include "chrome/browser/ui/page_info/chrome_page_info_delegate.h"
#include "chrome/browser/ui/page_info/page_info_dialog.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/controls/rich_hover_button.h"
#include "chrome/browser/ui/views/file_system_access/file_system_access_test_utils.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_cookies_content_view.h"
#include "chrome/browser/ui/views/page_info/page_info_permission_content_view.h"
#include "chrome/browser/ui/views/page_info/page_info_view_factory.h"
#include "chrome/browser/ui/views/page_info/security_information_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "components/content_settings/core/common/features.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/optimization_guide/core/optimization_guide_switches.h"
#include "components/page_info/core/about_this_site_service.h"
#include "components/page_info/core/about_this_site_validation.h"
#include "components/page_info/core/features.h"
#include "components/page_info/core/proto/about_this_site_metadata.pb.h"
#include "components/page_info/page_info.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/permissions/features.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/safe_browsing/content/browser/password_protection/password_protection_test_util.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/security_state/content/security_state_tab_helper.h"
#include "components/strings/grit/components_strings.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/common/referrer.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/cert_test_util.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "net/test/test_certificate_data.h"
#include "net/test/test_data_directory.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/test/test_event.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/test/widget_test.h"
AboutThisSiteStatus;
AboutThisSiteInteraction;
namespace {
IsFalse;
IsTrue;
constexpr char kExpiredCertificateFile[] = …;
void PerformMouseClickOnView(views::View* view) { … }
void OpenPageInfoBubble(Browser* browser) { … }
views::View* GetView(int view_id) { … }
void ClickAndWaitForSettingsPageToOpen(views::View* site_settings_button) { … }
const GURL OpenSiteSettingsForUrl(Browser* browser, const GURL& url) { … }
void AddHintForTesting(Browser* browser,
const GURL& url,
page_info::proto::SiteInfo site_info) { … }
}
class PageInfoBubbleViewBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ShowBubble) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
StopShowingBubbleWhenWebContentsDestroyed) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ChromeURL) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ChromeExtensionURL) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ChromeDevtoolsURL) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, ViewSourceURL) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, SiteSettingsLink) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
SiteSettingsLinkWithNonAsciiUrl) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
SiteSettingsLinkWithNonDefaultPort) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
SiteSettingsLinkWithAboutBlankURL) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
VerifyEnterprisePasswordReusePageInfoBubble) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
VerifySavedPasswordReusePageInfoBubble) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
ClosesOnUserNavigateToSamePage) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
ClosesOnUserNavigateToDifferentPage) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
DoesntCloseOnSubframeNavigate) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
InteractedWithCookiesButton) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
InteractedWithFileSystemSubpage) { … }
class PageInfoBubbleViewBrowserTestWithAutoupgradesDisabled
: public PageInfoBubbleViewBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTestWithAutoupgradesDisabled,
UpdatesOnSecurityStateChange) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, BlockedAndInvalidCert) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, MalwareAndEvCert) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest,
SocialEngineeringStrings) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewBrowserTest, UnwantedSoftwareStrings) { … }
class PageInfoBubbleViewHttpsUpgradesBrowserTest
: public PageInfoBubbleViewBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewHttpsUpgradesBrowserTest,
ResetWarningDecisionsButtonCertWarningOnly) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewHttpsUpgradesBrowserTest,
ResetWarningDecisionsButtonCertAndMalwareWarnings) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewHttpsUpgradesBrowserTest,
ResetWarningDecisionsButtonHttpsFirstMode) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewHttpsUpgradesBrowserTest,
ResetWarningDecisionsButtonHttpsUpgrades) { … }
class PageInfoBubbleViewPrerenderBrowserTest
: public PageInfoBubbleViewBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewPrerenderBrowserTest,
DoesntCloseOnPrerenderNavigate) { … }
class PageInfoBubbleViewAboutThisSiteBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewAboutThisSiteBrowserTest,
AboutThisSite) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewAboutThisSiteBrowserTest,
AboutThisSiteInteraction) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewAboutThisSiteBrowserTest,
AboutThisSiteInteractionWithoutDescription) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewAboutThisSiteBrowserTest,
AboutThisSiteNotValid) { … }
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewAboutThisSiteBrowserTest,
AboutThisSiteNotSecure) { … }
class PageInfoBubbleViewAboutThisSiteDisabledBrowserTest
: public PageInfoBubbleViewAboutThisSiteBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewAboutThisSiteDisabledBrowserTest,
AboutThisSiteWithoutOptin) { … }
class PageInfoBubbleViewSiteSettingsBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PageInfoBubbleViewSiteSettingsBrowserTest,
SiteSettingsNotValid) { … }
class PageInfoBubbleViewBrowserTestCookiesSubpage
: public PageInfoBubbleViewBrowserTest,
public testing::WithParamInterface< bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(PageInfoBubbleViewBrowserTestCookiesSubpage,
ClickingCookieDialogButton) { … }
IN_PROC_BROWSER_TEST_P(PageInfoBubbleViewBrowserTestCookiesSubpage,
ClickingRwsButton) { … }
IN_PROC_BROWSER_TEST_P(PageInfoBubbleViewBrowserTestCookiesSubpage,
ToggleForBlockingThirdPartyCookies) { … }
IN_PROC_BROWSER_TEST_P(PageInfoBubbleViewBrowserTestCookiesSubpage,
LinkInDescriptionForCookiesSettings) { … }
class PageInfoBubbleViewBrowserTestTrackingProtectionSubpage
: public PageInfoBubbleViewBrowserTestCookiesSubpage { … };
IN_PROC_BROWSER_TEST_P(
PageInfoBubbleViewBrowserTestTrackingProtectionSubpage,
ToggleForBlockingThirdPartyCookiesUpdatesTrackingProtectionException) { … }
INSTANTIATE_TEST_SUITE_P(…);