#include <stdint.h>
#include <tuple>
#include <utility>
#include "base/check.h"
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_future.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/download/public/common/download_url_parameters.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/media/audio_stream_monitor.h"
#include "content/browser/media/media_web_contents_observer.h"
#include "content/browser/renderer_host/navigation_entry_impl.h"
#include "content/browser/renderer_host/navigator.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/render_frame_proxy_host.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/site_instance_impl.h"
#include "content/browser/storage_partition_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/common/frame.mojom.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/global_request_id.h"
#include "content/public/browser/javascript_dialog_manager.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/ssl_host_state_delegate.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_constants.h"
#include "content/public/common/content_features.h"
#include "content/public/common/url_constants.h"
#include "content/public/common/url_utils.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/fake_local_frame.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/navigation_simulator.h"
#include "content/public/test/scoped_web_ui_controller_factory_registration.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_utils.h"
#include "content/test/navigation_simulator_impl.h"
#include "content/test/test_content_browser_client.h"
#include "content/test/test_content_client.h"
#include "content/test/test_page_broadcast.h"
#include "content/test/test_render_frame_host.h"
#include "content/test/test_render_view_host.h"
#include "content/test/test_web_contents.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver.h"
#include "net/base/network_handle.h"
#include "net/test/cert_test_util.h"
#include "net/test/test_data_directory.h"
#include "services/network/public/cpp/web_sandbox_flags.h"
#include "services/network/test/test_network_context.h"
#include "skia/ext/skia_utils_base.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/input/synthetic_web_input_event_builders.h"
#include "third_party/blink/public/common/security/protocol_handler_security_level.h"
#include "third_party/blink/public/mojom/frame/fullscreen.mojom.h"
#include "third_party/blink/public/mojom/image_downloader/image_downloader.mojom.h"
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
#include "third_party/blink/public/mojom/page/page_visibility_state.mojom.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "url/gurl.h"
#include "url/url_constants.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chromeos/lacros/lacros_test_helper.h"
#endif
namespace content {
namespace {
class WebContentsImplTest : public RenderViewHostImplTestHarness { … };
class TestWebContentsObserver : public WebContentsObserver { … };
class MockWebContentsDelegate : public WebContentsDelegate { … };
class FakeFullscreenDelegate : public WebContentsDelegate { … };
class FakeWebContentsDelegate : public WebContentsDelegate { … };
class FakeImageDownloader : public blink::mojom::ImageDownloader { … };
class MockPageBroadcast : public TestPageBroadcast { … };
class TestColorProviderSource : public ui::ColorProviderSource { … };
class MockNetworkContext : public network::TestNetworkContext { … };
}
TEST_F(WebContentsImplTest, SetMainFrameMimeType) { … }
TEST_F(WebContentsImplTest, UpdateTitle) { … }
TEST_F(WebContentsImplTest, UpdateTitleBeforeFirstNavigation) { … }
TEST_F(WebContentsImplTest, UpdateTitleWhileFirstNavigationIsPending) { … }
TEST_F(WebContentsImplTest, DontUsePendingEntryUrlAsTitle) { … }
TEST_F(WebContentsImplTest, UpdateAndUseTitleFromFirstNavigationPendingEntry) { … }
TEST_F(WebContentsImplTest,
UpdateAndDontUseTitleFromPendingEntryForSecondNavigation) { … }
class EnableViewSourceLocalFrame : public content::FakeLocalFrame,
public WebContentsObserver { … };
TEST_F(WebContentsImplTest, DirectNavigationToViewSourceWebUI) { … }
TEST_F(WebContentsImplTest, SimpleNavigation) { … }
TEST_F(WebContentsImplTest, NavigateToExcessivelyLongURL) { … }
TEST_F(WebContentsImplTest, NavigateToInvalidURL) { … }
TEST_F(WebContentsImplTest, NavigateToViewSourceRendererDebugURL) { … }
TEST_F(WebContentsImplTest, CrossSiteBoundaries) { … }
TEST_F(WebContentsImplTest, CrossSiteBoundariesAfterCrash) { … }
TEST_F(WebContentsImplTest, NavigateTwoTabsCrossSite) { … }
TEST_F(WebContentsImplTest, NavigateFromSitelessUrl) { … }
TEST_F(WebContentsImplTest, NavigateFromRestoredSitelessUrl) { … }
TEST_F(WebContentsImplTest, NavigateFromRestoredRegularUrl) { … }
TEST_F(WebContentsImplTest, FindOpenerRVHWhenPending) { … }
TEST_F(WebContentsImplTest, CrossSiteComparesAgainstCurrentPage) { … }
TEST_F(WebContentsImplTest, CrossSiteUnloadHandlers) { … }
TEST_F(WebContentsImplTest, CrossSiteNavigationPreempted) { … }
TEST_F(WebContentsImplTest, CrossSiteNavigationBackOldNavigationIgnored) { … }
TEST_F(WebContentsImplTest, CrossSiteNavigationNotPreemptedByFrame) { … }
TEST_F(WebContentsImplTest, CrossSiteNotPreemptedDuringBeforeUnload) { … }
TEST_F(WebContentsImplTest, NavigationEntryContentState) { … }
TEST_F(WebContentsImplTest, NavigationEntryContentStateNewWindow) { … }
namespace {
void ExpectTrue(bool value) { … }
void ExpectFalse(bool value) { … }
}
TEST_F(WebContentsImplTest, NavigationExitsFullscreen) { … }
TEST_F(WebContentsImplTest, HistoryNavigationExitsFullscreen) { … }
TEST_F(WebContentsImplTest, CrashExitsFullscreen) { … }
TEST_F(WebContentsImplTest,
FailEnterFullscreenWhenNoUserActivationNoOrientationChange) { … }
TEST_F(WebContentsImplTest, FilterURLs) { … }
TEST_F(WebContentsImplTest, PendingContentsDestroyed) { … }
TEST_F(WebContentsImplTest, PendingContentsShown) { … }
TEST_F(WebContentsImplTest, CaptureHoldsWakeLock) { … }
TEST_F(WebContentsImplTest, CapturerOverridesPreferredSize) { … }
TEST_F(WebContentsImplTest, UpdateWebContentsVisibility) { … }
TEST_F(WebContentsImplTest, VideoPictureInPictureStaysVisibleIfHidden) { … }
TEST_F(WebContentsImplTest, VisibilityIsUpdatedIfVideoPictureInPictureChanges) { … }
TEST_F(WebContentsImplTest, DocumentPictureInPictureStaysVisibleIfHidden) { … }
TEST_F(WebContentsImplTest,
VisibilityIsUpdatedIfDocumentPictureInPictureChanges) { … }
namespace {
void HideOrOccludeWithCapturerTest(WebContentsImpl* contents,
Visibility hidden_or_occluded) { … }
}
TEST_F(WebContentsImplTest, HideWithCapturer) { … }
TEST_F(WebContentsImplTest, OccludeWithCapturer) { … }
TEST_F(WebContentsImplTest, HiddenCapture) { … }
TEST_F(WebContentsImplTest, NonActivityCaptureDoesNotCountAsActivity) { … }
TEST_F(WebContentsImplTest, GetLastActiveTimeTicks) { … }
class ContentsZoomChangedDelegate : public WebContentsDelegate { … };
TEST_F(WebContentsImplTest, HandleWheelEvent) { … }
TEST_F(WebContentsImplTest, ActiveContentsCountBasic) { … }
TEST_F(WebContentsImplTest, ActiveContentsCountNavigate) { … }
TEST_F(WebContentsImplTest, ActiveContentsCountChangeBrowsingInstance) { … }
class LoadingWebContentsObserver : public WebContentsObserver { … };
class WebContentsImplTestWithSiteIsolation : public WebContentsImplTest { … };
TEST_F(WebContentsImplTestWithSiteIsolation, StartStopEventsBalance) { … }
TEST_F(WebContentsImplTestWithSiteIsolation, ShouldShowLoadingUI) { … }
TEST_F(WebContentsImplTest, DISABLED_NoEarlyStop) { … }
TEST_F(WebContentsImplTest, MediaWakeLock) { … }
TEST_F(WebContentsImplTest, OnTextCopiedToClipboard) { … }
TEST_F(WebContentsImplTest, ThemeColorChangeDependingOnFirstVisiblePaint) { … }
TEST_F(WebContentsImplTest, ParseDownloadHeaders) { … }
TEST_F(WebContentsImplTest, DidLoadResourceFromMemoryCache_NavigationCheck) { … }
TEST_F(WebContentsImplTest,
DidLoadResourceFromMemoryCache_BypassNavigationCheck) { … }
namespace {
class TestJavaScriptDialogManager : public JavaScriptDialogManager { … };
}
TEST_F(WebContentsImplTest, ResetJavaScriptDialogOnUserNavigate) { … }
TEST_F(WebContentsImplTest, StartingSandboxFlags) { … }
TEST_F(WebContentsImplTest, DidFirstVisuallyNonEmptyPaint) { … }
TEST_F(WebContentsImplTest, DidChangeVerticalScrollDirection) { … }
TEST_F(WebContentsImplTest, HandleContextMenuDelegate) { … }
TEST_F(WebContentsImplTest, RegisterProtocolHandlerDifferentOrigin) { … }
TEST_F(WebContentsImplTest, RegisterProtocolHandlerDataURL) { … }
TEST_F(WebContentsImplTest, RegisterProtocolHandlerInvalidURLSyntax) { … }
TEST_F(WebContentsImplTest, Bluetooth) { … }
TEST_F(WebContentsImplTest, BadDownloadImageResponseFromRenderer) { … }
TEST_F(WebContentsImplTest,
GetCaptureHandleConfigBeforeSetIsCalledReturnsEmptyConfig) { … }
TEST_F(WebContentsImplTest, SetAndGetCaptureHandleConfig) { … }
TEST_F(WebContentsImplTest, NoOnCaptureHandleConfigUpdateCallIfResettingEmpty) { … }
TEST_F(WebContentsImplTest,
OnCaptureHandleConfigUpdateCalledWhenHandleChanges) { … }
TEST_F(WebContentsImplTest,
OnCaptureHandleConfigUpdateNotCalledWhenResettingAnIdenticalHandle) { … }
TEST_F(WebContentsImplTest,
OnCaptureHandleConfigUpdateCalledWhenClearingTheConfig) { … }
TEST_F(WebContentsImplTest,
CrossDocumentMainPageNavigationClearsCaptureHandleConfig) { … }
TEST_F(WebContentsImplTest,
SameDocumentMainPageNavigationDoesNotClearCaptureHandleConfig) { … }
TEST_F(WebContentsImplTest,
CrossDocumentChildPageNavigationDoesNotClearCaptureHandleConfig) { … }
class TestCanonicalUrlLocalFrame : public content::FakeLocalFrame,
public WebContentsObserver { … };
TEST_F(WebContentsImplTest, CanonicalUrlSchemeHttpsIsAllowed) { … }
TEST_F(WebContentsImplTest, CanonicalUrlSchemeChromeIsNotAllowed) { … }
TEST_F(WebContentsImplTest, RequestMediaAccessPermissionNoDelegate) { … }
TEST_F(WebContentsImplTest, IgnoreInputEvents) { … }
TEST_F(WebContentsImplTest, OnColorProviderChangedTriggersPageBroadcast) { … }
TEST_F(WebContentsImplTest, InvalidNetworkHandleAsDefault) { … }
TEST_F(WebContentsImplTest, CreateWebContentsWithNetworkHandle) { … }
TEST_F(WebContentsImplTest, CreateWebContentsWithOpenerAndNetworkHandle) { … }
TEST_F(WebContentsImplTest, BadDownloadImageFromAXNodeId) { … }
}