#include <stdint.h>
#include "base/command_line.h"
#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/history/history_test_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/location_bar/location_bar.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/test/web_app_browsertest_util.h"
#include "chrome/browser/web_applications/os_integration/os_integration_manager.h"
#include "chrome/browser/web_applications/test/os_integration_test_override_impl.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/search_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/back_forward_cache/back_forward_cache_disable.h"
#include "components/blocked_content/list_item_position.h"
#include "components/blocked_content/popup_blocker_tab_helper.h"
#include "components/content_settings/browser/page_specific_content_settings.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/embedder_support/switches.h"
#include "components/javascript_dialogs/app_modal_dialog_controller.h"
#include "components/javascript_dialogs/app_modal_dialog_manager.h"
#include "components/javascript_dialogs/app_modal_dialog_view.h"
#include "components/javascript_dialogs/tab_modal_dialog_manager.h"
#include "components/omnibox/browser/autocomplete_match.h"
#include "components/omnibox/browser/autocomplete_result.h"
#include "components/omnibox/browser/omnibox_edit_model.h"
#include "components/omnibox/browser/omnibox_view.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.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/common/content_features.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "printing/buildflags/buildflags.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/mojom/frame/fullscreen.mojom.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)
#include "third_party/blink/public/common/switches.h"
#endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#include "chrome/browser/printing/print_preview_dialog_controller.h"
#endif
WebContents;
_;
Return;
namespace {
class CloseObserver : public content::WebContentsObserver { … };
class PopupBlockerBrowserTest : public InProcessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, BlockWebContentsCreation) { … }
#if (BUILDFLAG(IS_MAC) && defined(ADDRESS_SANITIZER)) || \
BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_BlockWebContentsCreationIncognito …
#else
#define MAYBE_BlockWebContentsCreationIncognito …
#endif
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
MAYBE_BlockWebContentsCreationIncognito) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupBlockedFakeClickOnAnchor) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
PopupBlockedFakeClickOnAnchorNoTarget) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupMetrics) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, MultiplePopups) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
AllowPopupThroughContentSetting) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
AllowPopupThroughContentSettingIFrame) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, NoPopupsLaunchWhenTabIsClosed) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
PopupsAllowedWhenPopupBlockingIsDisabled) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
UnblockedPopupShowsInHistoryAndOmnibox) { … }
#if defined(USE_AURA) && \
(BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_WIN))
#define MAYBE_WindowFeatures …
#else
#define MAYBE_WindowFeatures …
#endif
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, MAYBE_WindowFeatures) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, CorrectReferrer) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, CorrectFrameName) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, WindowFeaturesBarProps) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, SessionStorage) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, Opener) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ClosableAfterNavigation) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, OpenerSuppressed) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ShiftClick) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, WebUI) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, DenialOfService) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, Regress427477) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ModalPopUnder) { … }
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
#if BUILDFLAG(IS_MAC)
#define MAYBE_PrintPreviewPopUnder …
#else
#define MAYBE_PrintPreviewPopUnder …
#endif
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, MAYBE_PrintPreviewPopUnder) { … }
#endif
class PopupBlockerBrowserTestWithWebApps : public PopupBlockerBrowserTest { … };
#if BUILDFLAG(IS_MAC)
#define MAYBE_CloseFullscreenStandaloneWebApp …
#else
#define MAYBE_CloseFullscreenStandaloneWebApp …
#endif
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTestWithWebApps,
MAYBE_CloseFullscreenStandaloneWebApp) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, DISABLED_CtrlEnterKey) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_TapGestureWithCtrlKey …
#else
#define MAYBE_TapGestureWithCtrlKey …
#endif
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, MAYBE_TapGestureWithCtrlKey) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, MultiplePopupsViaPostMessage) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, OpenInNewForegroundTab) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, OpenInNewBackgroundTab) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, OpenInNewWindow) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, PopupsDisableBackForwardCache) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
#define MAYBE_PopupTriggeredFromDifferentWebContents …
#else
#define MAYBE_PopupTriggeredFromDifferentWebContents …
#endif
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
MAYBE_PopupTriggeredFromDifferentWebContents) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest,
DocumentPictureInPictureIsNotConsideredForBlocking) { … }
class PopupBlockerFencedFrameTest : public PopupBlockerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(PopupBlockerFencedFrameTest,
AllowPopupThroughContentSettingFencedFrame) { … }
IN_PROC_BROWSER_TEST_F(PopupBlockerFencedFrameTest,
BlockPopupThroughContentSettingFencedFrame) { … }
}