#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/hash/hash.h"
#include "base/memory/ref_counted_memory.h"
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/threading/thread_restrictions.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/process_lock.h"
#include "content/browser/renderer_host/frame_tree_node.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/webui/web_ui_controller_factory_registry.h"
#include "content/common/content_navigation_policy.h"
#include "content/public/browser/site_isolation_policy.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_controller.h"
#include "content/public/browser/web_ui_data_source.h"
#include "content/public/browser/webui_config_map.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/content_paths.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/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.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 "net/base/url_util.h"
#include "ui/webui/untrusted_web_ui_browsertest_util.h"
#include "url/gurl.h"
namespace content {
class WebUISecurityTest : public ContentBrowserTest { … };
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, UntrustedNoBindings) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, NoBindings) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIBindings) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, MojoBindings) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIAndMojoBindings) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIReuse) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUISameSiteSubframe) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUICrossSiteSubframe) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIReuseInSubframe) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WindowOpenWebUI) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIFailedNavigation) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
DisallowResourceRequestToChromeUntrusted) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, DisallowWebRequestToSharedResources) { … }
namespace {
class UntrustedSourceWithCorsSupport : public URLDataSource { … };
enum FetchMode { … };
EvalJsResult PerformFetch(Shell* shell,
const GURL& fetch_url,
FetchMode fetch_mode = FetchMode::CORS) { … }
}
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
DisallowWebPageFetchRequestToChromeUntrusted) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, ChromeUntrustedFetchRequestToSelf) { … }
IN_PROC_BROWSER_TEST_F(
WebUISecurityTest,
DisallowCrossOriginFetchRequestToChromeUntrustedByDefault) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
CrossOriginFetchRequestToChromeUntrusted) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
DisallowChromeUntrustedFetchRequestToChrome) { … }
namespace {
EvalJsResult PerformXHRRequest(Shell* shell, const GURL& xhr_url) { … }
}
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
DisallowWebPageXHRRequestToChromeUntrusted) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
AllowChromeUntrustedXHRRequestToSelf) { … }
IN_PROC_BROWSER_TEST_F(
WebUISecurityTest,
DisallowCrossOriginXHRRequestToChromeUntrustedByDefault) { … }
IN_PROC_BROWSER_TEST_F(
WebUISecurityTest,
CrossOriginXHRRequestToChromeUntrustedIfContenSecurityPolicyAllowsIt) { … }
IN_PROC_BROWSER_TEST_F(WebUISecurityTest,
DisallowChromeUntrustedXHRRequestToChrome) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_ReuseRVHWithWebUI …
#else
#define MAYBE_ReuseRVHWithWebUI …
#endif
IN_PROC_BROWSER_TEST_F(WebUISecurityTest, MAYBE_ReuseRVHWithWebUI) { … }
class WebUIBrowserSideSecurityTest : public WebUISecurityTest { … };
IN_PROC_BROWSER_TEST_F(WebUIBrowserSideSecurityTest,
DenyWebAccessToSharedResources) { … }
class WebUISecurityTestSiteIsolationDisabled : public WebUISecurityTest { … };
IN_PROC_BROWSER_TEST_F(WebUISecurityTestSiteIsolationDisabled,
EnsureProcessLockWithoutSiteIsolation) { … }
}