#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "content/browser/fenced_frame/fenced_frame.h"
#include "content/browser/renderer_host/navigation_controller_impl.h"
#include "content/browser/renderer_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/navigation_entry_restore_context_impl.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/webui/web_ui_controller_factory_registry.h"
#include "content/browser/webui/web_ui_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/web_ui_message_handler.h"
#include "content/public/browser/webui_config_map.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/isolated_world_ids.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/scoped_web_ui_controller_factory_registration.h"
#include "content/public/test/test_frame_navigation_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/web_ui_browsertest_util.h"
#include "content/shell/browser/shell.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "ui/events/base_event_utils.h"
#include "ui/webui/untrusted_web_ui_browsertest_util.h"
namespace content {
namespace {
WebUIImplBrowserTest;
#if !BUILDFLAG(IS_ANDROID)
const char kLoadSharedWorkerScript[] = …;
#endif
const char kLoadDedicatedWorkerScript[] = …;
class TestWebUIMessageHandler : public WebUIMessageHandler { … };
class WebUIRequiringGestureBrowserTest : public ContentBrowserTest { … };
}
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, ForceSwapOnDifferenteWebUITypes) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest,
ReuseInitialRenderFrameHostOnFirstNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest,
StartWebUINavigationWhileAboutBlankIsPendingCommit) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, NavigateFromCrashedAboutBlank) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest,
DoNotReuseInitialRenderFrameHostForDifferentTab) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest,
DoNotReuseInitialRenderFrameHostWithUsedProcess) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest,
ReuseInitialProcessSharedByMultipleTabs) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, ReuseProcessInClonedTab) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, ReuseInitialRFHInRestoredTab) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, ForceSwapOnFromChromeToUntrusted) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, ForceSwapOnFromUntrustedToChrome) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, SameDocumentNavigationsAndReload) { … }
IN_PROC_BROWSER_TEST_F(WebUIRequiringGestureBrowserTest,
MessageRequiringGestureIgnoredIfNoGesture) { … }
IN_PROC_BROWSER_TEST_F(WebUIRequiringGestureBrowserTest,
MessageRequiringGestureIgnoresRendererOnlyGesture) { … }
IN_PROC_BROWSER_TEST_F(WebUIRequiringGestureBrowserTest,
MessageRequiringGestureIgnoresNonInteractiveEvents) { … }
IN_PROC_BROWSER_TEST_F(
WebUIRequiringGestureBrowserTest,
DISABLED_MessageRequiringGestureAllowedWithInteractiveEvent) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, UntrustedSchemeLoads) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, DISABLED_NavigateWhileWebUISend) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest, CoopCoepPolicies) { … }
IN_PROC_BROWSER_TEST_F(WebUIImplBrowserTest,
SynchronousWebContentDeletionInUnload) { … }
class WebUIRequestSchemesTest : public ContentBrowserTest { … };
IN_PROC_BROWSER_TEST_F(WebUIRequestSchemesTest, DefaultSchemesCanBeRequested) { … }
IN_PROC_BROWSER_TEST_F(WebUIRequestSchemesTest,
AllowAdditionalSchemesToBeRequested) { … }
class WebUIWorkerTest : public ContentBrowserTest { … };
class WebUIDedicatedWorkerTest : public WebUIWorkerTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest, CanCreateWebUISharedWorkerForWebUI) { … }
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest,
CannotCreateWebUISharedWorkerForNonWebUI) { … }
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest,
CanCreateSharedWorkerFromUntrustedIframe) { … }
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest,
CanCreateUntrustedWebUISharedWorkerForUntrustedWebUI) { … }
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest,
CannotCreateUntrustedWebUISharedWorkerFromTrustedWebUI) { … }
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest,
CannotCreateUntrustedWebUISharedWorkerForWebURL) { … }
IN_PROC_BROWSER_TEST_F(WebUIWorkerTest,
CannotCreateWebUISharedWorkerForUntrustedPage) { … }
#endif
IN_PROC_BROWSER_TEST_P(WebUIDedicatedWorkerTest,
CanCreateWebUIDedicatedWorkerForWebUI) { … }
IN_PROC_BROWSER_TEST_P(WebUIDedicatedWorkerTest,
CannotCreateWebUIDedicatedWorkerForNonWebUI) { … }
IN_PROC_BROWSER_TEST_P(WebUIDedicatedWorkerTest,
CanCreateDedicatedWorkerFromUntrustedIframe) { … }
IN_PROC_BROWSER_TEST_P(
WebUIDedicatedWorkerTest,
CanCreateUntrustedWebUIDedicatedWorkerForUntrustedWebUI) { … }
IN_PROC_BROWSER_TEST_P(
WebUIDedicatedWorkerTest,
CannotCreateUntrustedWebUIDedicatedWorkerFromTrustedWebUI) { … }
IN_PROC_BROWSER_TEST_P(WebUIDedicatedWorkerTest,
CannotCreateUntrustedWebUIDedicatedWorkerForWebURL) { … }
IN_PROC_BROWSER_TEST_P(WebUIDedicatedWorkerTest,
CannotCreateWebUIDedicatedWorkerForUntrustedPage) { … }
}