#include "extensions/browser/guest_view/web_view/web_view_apitest.h"
#include <memory>
#include <string>
#include <utility>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/scoped_refptr.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
#include "components/guest_view/browser/guest_view_base.h"
#include "components/guest_view/browser/guest_view_histogram_value.h"
#include "components/guest_view/browser/guest_view_manager.h"
#include "components/guest_view/browser/guest_view_manager_delegate.h"
#include "components/guest_view/browser/guest_view_manager_factory.h"
#include "components/guest_view/browser/test_guest_view_manager.h"
#include "content/public/browser/browser_context.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_observer.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/context_menu_interceptor.h"
#include "content/public/test/hit_test_region_observer.h"
#include "content/public/test/mock_client_hints_controller_delegate.h"
#include "content/public/test/no_renderer_crashes_assertion.h"
#include "content/public/test/test_renderer_host.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/api/test/test_api.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/switches.h"
#include "extensions/shell/browser/desktop_controller.h"
#include "extensions/shell/browser/shell_browser_context.h"
#include "extensions/shell/browser/shell_content_browser_client.h"
#include "extensions/shell/browser/shell_extension_system.h"
#include "extensions/shell/test/shell_test.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "net/base/filename_util.h"
#include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/embedded_test_server/http_request.h"
#include "net/test/embedded_test_server/http_response.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/public/common/user_agent/user_agent_metadata.h"
#include "ui/display/display_switches.h"
#if defined(USE_AURA)
#include "third_party/blink/public/common/input/web_mouse_event.h"
#endif
GuestViewManager;
TestGuestViewManager;
namespace {
const char kEmptyResponsePath[] = …;
const char kRedirectResponsePath[] = …;
const char kRedirectResponseFullPath[] = …;
const char kUserAgentRedirectResponsePath[] = …;
const char kTestServerPort[] = …;
const char kExpectUserAgentPath[] = …;
static std::unique_ptr<net::test_server::HttpResponse>
UserAgentRedirectResponseHandler(const std::string& path,
const GURL& redirect_target,
const net::test_server::HttpRequest& request) { … }
static std::unique_ptr<net::test_server::HttpResponse>
ExpectUserAgentResponseHandler(const std::string& path,
const net::test_server::HttpRequest& request) { … }
class WebContentsHiddenObserver : public content::WebContentsObserver { … };
std::unique_ptr<net::test_server::HttpResponse> RedirectResponseHandler(
const std::string& path,
const GURL& redirect_target,
const net::test_server::HttpRequest& request) { … }
std::unique_ptr<net::test_server::HttpResponse> EmptyResponseHandler(
const std::string& path,
const net::test_server::HttpRequest& request) { … }
class RenderWidgetHostVisibilityObserver
: public content::RenderWidgetHostObserver { … };
}
namespace extensions {
WebViewAPITest::WebViewAPITest() = default;
void WebViewAPITest::LaunchApp(const std::string& app_location) { … }
content::WebContents* WebViewAPITest::GetFirstAppWindowWebContents() { … }
void WebViewAPITest::RunTest(const std::string& test_name,
const std::string& app_location,
bool ad_hoc_framework) { … }
void WebViewAPITest::SetUpCommandLine(base::CommandLine* command_line) { … }
void WebViewAPITest::SetUpOnMainThread() { … }
void WebViewAPITest::StartTestServer(const std::string& app_location) { … }
void WebViewAPITest::StopTestServer() { … }
void WebViewAPITest::TearDownOnMainThread() { … }
void WebViewAPITest::SendMessageToEmbedder(const std::string& message) { … }
content::WebContents* WebViewAPITest::GetEmbedderWebContents() { … }
TestGuestViewManager* WebViewAPITest::GetGuestViewManager() { … }
void WebViewDPIAPITest::SetUp() { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, EmbedderVisibilityChanged) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, DisplayNoneSetSrc) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, GuestVisibilityChanged) { … }
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
#define MAYBE_CloseOnLoadcommit …
#else
#define MAYBE_CloseOnLoadcommit …
#endif
IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_CloseOnLoadcommit) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, ReloadEmbedder) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAllowTransparencyAttribute) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAPIMethodExistence) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCustomElementCallbacksInaccessible) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAssignSrcAfterCrash) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeAfterNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeBeforeNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeBeforeNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeHeight) { … }
IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeHeight) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestAutosizeRemoveAttributes) { … }
IN_PROC_BROWSER_TEST_F(WebViewDPIAPITest, TestAutosizeRemoveAttributes) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
DISABLED_TestAutosizeWithPartialAttributes) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCannotMutateEventName) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestChromeExtensionRelativePath) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestChromeExtensionURL) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestContentLoadEvent) { … }
#if defined(USE_AURA)
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestContextMenu) { … }
#endif
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDeclarativeWebRequestAPI) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
TestDeclarativeWebRequestAPISendMessage) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDestroyOnEventListener) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogAlert) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirm) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmCancel) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmDefaultCancel) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogConfirmDefaultGCCancel) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDialogPrompt) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestDisplayNoneWebviewLoad) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
DISABLED_TestDisplayNoneWebviewRemoveChild) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestEventName) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestExecuteScript) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestExecuteScriptFail) { … }
IN_PROC_BROWSER_TEST_F(
WebViewAPITest,
DISABLED_TestExecuteScriptIsAbortedWhenWebViewSourceIsChanged) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestFindAPI) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestFindAPI_findupdate) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestGetProcessId) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestHiddenBeforeNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
TestInlineScriptFromAccessibleResources) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestInvalidChromeExtensionURL) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
TestLoadAbortChromeExtensionURLWrongPartition) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortEmptyResponse) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalChromeURL) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalFileURL) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortIllegalJavaScriptURL) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortInvalidNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortNonWebSafeScheme) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadAbortUnknownScheme) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadProgressEvent) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestCanGoBack) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestLoadStartLoadRedirect …
#else
#define MAYBE_TestLoadStartLoadRedirect …
#endif
IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_TestLoadStartLoadRedirect) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavigateAfterResize) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
TestContentInitiatedNavigationToDataUrlBlocked) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
TestNavOnConsecutiveSrcAttributeChanges) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNavOnSrcAttributeChange) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadCommitUrlsWithIframe) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindow) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowNoPreventDefault) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowNoReferrerLink) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNewWindowTwoListeners) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestOnEventProperty) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestPartitionChangeAfterNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest,
TestPartitionRemovalAfterNavigationFails) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReassignSrcAttribute) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveWebviewOnExit) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReload) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestReloadAfterTerminate) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveSrcAttribute) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestRemoveWebviewAfterNavigation) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestResizeWebviewResizesContent …
#else
#define MAYBE_TestResizeWebviewResizesContent …
#endif
IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_TestResizeWebviewResizesContent) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestTerminateAfterExit) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPI) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_TestWebRequestAPIWithHeaders …
#else
#define MAYBE_TestWebRequestAPIWithHeaders …
#endif
IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_TestWebRequestAPIWithHeaders) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIWithExtraHeaders) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestLoadEventsSameDocumentNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIExistence) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebRequestAPIGoogleProperty) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestWebViewInsideFrame) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_TestCaptureVisibleRegion …
#else
#define MAYBE_TestCaptureVisibleRegion …
#endif
IN_PROC_BROWSER_TEST_F(WebViewAPITest, MAYBE_TestCaptureVisibleRegion) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNoUserCodeCreate) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNoUserCodeSetOnEventProperty) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNoUserCodeGetSetAttributes) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNoUserCodeBackForward) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestNoUserCodeFocus) { … }
IN_PROC_BROWSER_TEST_F(WebViewAPITest, TestClosedShadowRoot) { … }
class WebViewAPITestUserAgentOverride
: public WebViewAPITest { … };
IN_PROC_BROWSER_TEST_F(WebViewAPITestUserAgentOverride, TestSetUserAgentOverride) { … }
}