#include "extensions/browser/script_injection_tracker.h"
#include <string>
#include <string_view>
#include <vector>
#include "base/files/file_path.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/bind.h"
#include "build/buildflag.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/permissions/permissions_test_util.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/version_info/channel.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/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/commit_message_delayer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/browsertest_util.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/script_executor.h"
#include "extensions/browser/user_script_manager.h"
#include "extensions/common/features/feature_channel.h"
#include "extensions/common/manifest_handlers/permissions_parser.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "extensions/test/test_content_script_load_waiter.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
namespace extensions {
void ExecuteProgrammaticContentScriptNoWait(content::WebContents* web_contents,
const ExtensionId& extension_id,
const std::string& content_script,
const char* message) { … }
void ExecuteProgrammaticContentScript(content::WebContents* web_contents,
const ExtensionId& extension_id,
const std::string& content_script) { … }
void ExecuteUserScript(content::WebContents& web_contents,
const ExtensionId& extension_id,
const std::string& script) { … }
class ScriptInjectionTrackerBrowserTest : public ExtensionBrowserTest { … };
class ContentScriptExecuterBeforeDidCommit { … };
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerBrowserTest,
ProgrammaticContentScript) { … }
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerBrowserTest,
ProgrammaticUserScript) { … }
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerBrowserTest,
ProgrammaticInjectionRacingWithDidCommit) { … }
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerBrowserTest,
ContentScriptDeclarationInExtensionManifest) { … }
IN_PROC_BROWSER_TEST_F(
ScriptInjectionTrackerBrowserTest,
AboutBlankNavigationAfterLoadingExtensionMidwayThroughTest) { … }
IN_PROC_BROWSER_TEST_F(
ScriptInjectionTrackerBrowserTest,
ContentScriptDeclarationInExtensionManifest_DataUrlIframe) { … }
IN_PROC_BROWSER_TEST_F(
ScriptInjectionTrackerBrowserTest,
ContentScriptDeclarationInExtensionManifest_AboutBlankPopup) { … }
IN_PROC_BROWSER_TEST_F(
ScriptInjectionTrackerBrowserTest,
ContentScriptDeclarationInExtensionManifest_SubframeWithInitialEmptyDoc) { … }
IN_PROC_BROWSER_TEST_F(
ScriptInjectionTrackerBrowserTest,
ContentScriptDeclarationInExtensionManifest_ScriptLoadRacesWithDidCommit) { … }
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerBrowserTest,
ContentScriptViaDeclarativeContentApi) { … }
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerBrowserTest, HistoryPushState) { … }
class DynamicScriptsTrackerBrowserTest
: public ScriptInjectionTrackerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(DynamicScriptsTrackerBrowserTest,
ContentScriptViaScriptingApi) { … }
IN_PROC_BROWSER_TEST_F(DynamicScriptsTrackerBrowserTest,
ContentScriptViaScriptingApi_HostPermissions) { … }
IN_PROC_BROWSER_TEST_F(DynamicScriptsTrackerBrowserTest,
ContentScriptViaScriptingApiWhileIdle) { … }
IN_PROC_BROWSER_TEST_F(DynamicScriptsTrackerBrowserTest,
UpdateHostPermissions) { … }
#if BUILDFLAG(IS_LINUX)
#define MAYBE_UpdateHostPermissions_RaceCondition …
#else
#define MAYBE_UpdateHostPermissions_RaceCondition …
#endif
IN_PROC_BROWSER_TEST_F(DynamicScriptsTrackerBrowserTest,
MAYBE_UpdateHostPermissions_RaceCondition) { … }
IN_PROC_BROWSER_TEST_F(DynamicScriptsTrackerBrowserTest, ActiveTabGranted) { … }
class UserScriptTrackerBrowserTest : public ScriptInjectionTrackerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(UserScriptTrackerBrowserTest,
UserScriptViaUserScriptsApi) { … }
IN_PROC_BROWSER_TEST_F(UserScriptTrackerBrowserTest,
UserScriptViaUserScriptsApi_HostPermissions) { … }
class ScriptInjectionTrackerAppBrowserTest : public PlatformAppBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerAppBrowserTest,
WebViewContentScript) { … }
IN_PROC_BROWSER_TEST_F(ScriptInjectionTrackerAppBrowserTest,
WebViewContentScriptForLateAboutBlank) { … }
}