#include "headless/public/headless_browser.h"
#include <memory>
#include <string>
#include <tuple>
#include <vector>
#include "base/command_line.h"
#include "base/files/file_enumerator.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/build_config.h"
#include "components/devtools/simple_devtools_protocol_client/simple_devtools_protocol_client.h"
#include "components/headless/select_file_dialog/headless_select_file_dialog.h"
#include "components/infobars/content/content_infobar_manager.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobars_switches.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/permission_controller_delegate.h"
#include "content/public/browser/ssl_status.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/no_renderer_crashes_assertion.h"
#include "content/public/test/test_navigation_observer.h"
#include "headless/lib/browser/headless_browser_context_impl.h"
#include "headless/lib/browser/headless_browser_impl.h"
#include "headless/lib/browser/headless_web_contents_impl.h"
#include "headless/public/headless_web_contents.h"
#include "headless/public/switches.h"
#include "headless/test/headless_browser_test.h"
#include "headless/test/headless_browser_test_utils.h"
#include "net/base/net_errors.h"
#include "net/cert/cert_status_flags.h"
#include "net/ssl/ssl_server_config.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "storage/browser/file_system/external_mount_points.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/chrome_debug_urls.h"
#include "third_party/blink/public/common/permissions/permission_utils.h"
#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom.h"
#include "third_party/blink/public/resources/grit/blink_resources.h"
#include "third_party/blink/public/strings/grit/blink_strings.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/base/clipboard/clipboard_non_backed.h"
#include "ui/base/clipboard/scoped_clipboard_writer.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/size.h"
#include "ui/shell_dialogs/select_file_dialog.h"
#if !BUILDFLAG(IS_FUCHSIA)
#include "third_party/crashpad/crashpad/client/crash_report_database.h"
#endif
#if BUILDFLAG(IS_APPLE)
#include "base/mac/mac_util.h"
#endif
SimpleDevToolsProtocolClient;
UnorderedElementsAre;
namespace headless {
namespace {
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, CreateAndDestroyBrowserContext) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest,
CreateAndDoNotDestroyBrowserContext) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, CreateAndDestroyWebContents) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest,
WebContentsAreDestroyedWithContext) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, CreateAndDoNotDestroyWebContents) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DestroyAndCreateTwoWebContents) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, CreateWithBadURL) { … }
class HeadlessBrowserTestWithProxy : public HeadlessBrowserTest { … };
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_SetProxyConfig …
#else
#define MAYBE_SetProxyConfig …
#endif
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTestWithProxy, MAYBE_SetProxyConfig) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, WebGLSupported) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, ClipboardCopyPasteText) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DefaultSizes) { … }
class HeadlessBrowserWindowSizeTest : public HeadlessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(HeadlessBrowserWindowSizeTest, WindowSize) { … }
#if BUILDFLAG(IS_POSIX)
class HeadlessBrowserRendererCommandPrefixTest : public HeadlessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(HeadlessBrowserRendererCommandPrefixTest, Prefix) { … }
#endif
class CrashReporterTest : public HeadlessBrowserTest,
public HeadlessWebContents::Observer { … };
#if !BUILDFLAG(IS_FUCHSIA) && !BUILDFLAG(IS_WIN)
IN_PROC_BROWSER_TEST_F(CrashReporterTest, GenerateMinidump) { … }
#endif
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, PermissionManagerAlwaysASK) { … }
class BrowserTargetTracingTest : public HeadlessBrowserTest { … };
#if BUILDFLAG(IS_WIN)
#define MAYBE_BrowserTargetTracing …
#else
#define MAYBE_BrowserTargetTracing …
#endif
IN_PROC_BROWSER_TEST_F(BrowserTargetTracingTest, MAYBE_BrowserTargetTracing) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, WindowPrint) { … }
class HeadlessBrowserAllowInsecureLocalhostTest : public HeadlessBrowserTest { … };
IN_PROC_BROWSER_TEST_F(HeadlessBrowserAllowInsecureLocalhostTest,
AllowInsecureLocalhostFlag) { … }
#if BUILDFLAG(IS_FUCHSIA)
#define MAYBE_ServerWantsClientCertificate …
#else
#define MAYBE_ServerWantsClientCertificate …
#endif
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest,
MAYBE_ServerWantsClientCertificate) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, AIAFetching) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, BadgingAPI) { … }
class HeadlessBrowserTestWithExplicitlyAllowedPorts
: public HeadlessBrowserTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(HeadlessBrowserTestWithExplicitlyAllowedPorts,
AllowedPort) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, LocalizedResources) { … }
class SelectFileDialogHeadlessBrowserTest
: public HeadlessBrowserTest,
public testing::WithParamInterface<
std::tuple<const char*, ui::SelectFileDialog::Type>> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(SelectFileDialogHeadlessBrowserTest, SelectFileDialog) { … }
IN_PROC_BROWSER_TEST_F(HeadlessBrowserTest, DISABLED_NetworkServiceCrash) { … }
class TestInfoBarDelegate : public ConfirmInfoBarDelegate { … };
class HeadlessInfobarBrowserTest : public HeadlessBrowserTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(HeadlessInfobarBrowserTest, InfoBarsCanBeDisabled) { … }
}
}