#include "chrome/browser/extensions/extension_action_runner.h"
#include <stddef.h>
#include <memory>
#include <utility>
#include <vector>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/extensions/browsertest_util.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.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 "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/permissions_manager.h"
#include "extensions/common/extension_features.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/permissions_manager_waiter.h"
#include "extensions/test/test_extension_dir.h"
#include "net/dns/mock_host_resolver.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
namespace {
UserSiteAccess;
UserSiteSetting;
constexpr char kAllHostsScheme[] = …;
constexpr char kExplicitHostsScheme[] = …;
constexpr char kBackgroundScript[] = …;
constexpr char kBackgroundScriptSource[] = …;
constexpr char kContentScriptSource[] = …;
constexpr char kInjectSucceeded[] = …;
enum InjectionType { … };
enum HostType { … };
enum RequiresConsent { … };
enum WithholdPermissions { … };
bool RunAllPendingInRenderer(content::WebContents* web_contents) { … }
bool DidInjectScript(content::WebContents& web_contents) { … }
}
ContextType;
class ExtensionActionRunnerBrowserTest : public ExtensionBrowserTest { … };
void ExtensionActionRunnerBrowserTest::TearDownOnMainThread() { … }
const Extension* ExtensionActionRunnerBrowserTest::CreateExtension(
HostType host_type,
InjectionType injection_type,
WithholdPermissions withhold_permissions) { … }
void ExtensionActionRunnerBrowserTest::RunActiveScriptsTest(
const std::string& name,
HostType host_type,
InjectionType injection_type,
WithholdPermissions withhold_permissions,
RequiresConsent requires_consent) { … }
class ExtensionActionRunnerBrowserTestWithContextType
: public ExtensionActionRunnerBrowserTest,
public testing::WithParamInterface<ContextType> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(
ExtensionActionRunnerBrowserTestWithContextType,
ActiveScriptsAreDisplayedAndDelayExecution_ExecuteScripts_AllHosts) { … }
IN_PROC_BROWSER_TEST_P(
ExtensionActionRunnerBrowserTestWithContextType,
ActiveScriptsAreDisplayedAndDelayExecution_ExecuteScripts_ExplicitHosts) { … }
IN_PROC_BROWSER_TEST_F(
ExtensionActionRunnerBrowserTest,
ActiveScriptsAreDisplayedAndDelayExecution_ContentScripts_AllHosts) { … }
IN_PROC_BROWSER_TEST_F(
ExtensionActionRunnerBrowserTest,
ActiveScriptsAreDisplayedAndDelayExecution_ContentScripts_ExplicitHosts) { … }
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest,
RemoveExtensionWithPendingInjections) { … }
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest,
GrantExtensionAllUrlsPermission) { … }
class ExtensionActionRunnerRunActionBubbleBrowserTest
: public ExtensionActionRunnerBrowserTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ExtensionActionRunnerRunActionBubbleBrowserTest,
RunAction) { … }
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest, RunBlockedActions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest,
ScriptsExecuteWhenNoPermissionsWithheld_ContentScripts) { … }
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerBrowserTest,
ScriptsExecuteWhenNoPermissionsWithheld_ExecuteScripts) { … }
class ExtensionActionRunnerFencedFrameBrowserTest
: public ExtensionActionRunnerBrowserTest { … };
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerFencedFrameBrowserTest,
FencedFrameDoesNotClearActiveExtensions) { … }
IN_PROC_BROWSER_TEST_F(ExtensionActionRunnerFencedFrameBrowserTest,
DoNotResetExtensionActionRunner) { … }
}