#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/extensions/chrome_extension_test_notification_observer.h"
#include "chrome/browser/extensions/chrome_test_extension_loader.h"
#include "chrome/browser/extensions/extension_action_test_util.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/bookmarks/common/bookmark_metrics.h"
#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "extensions/browser/api/declarative/rules_registry.h"
#include "extensions/browser/api/declarative/rules_registry_service.h"
#include "extensions/browser/api/declarative_webrequest/webrequest_constants.h"
#include "extensions/browser/browsertest_util.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/api/extension_action/action_info.h"
#include "extensions/common/api/extension_action/action_info_test_util.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/test_extension_dir.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace extensions {
namespace {
static constexpr char kDeclarativeContentManifest[] = …;
constexpr char kIncognitoSpecificBackground[] = …;
constexpr char kBackgroundHelpers[] = …;
ContextType;
class DeclarativeContentApiTest : public ExtensionApiTest { … };
std::string DeclarativeContentApiTest::FormatManifest(IncognitoMode mode) { … }
void DeclarativeContentApiTest::CheckIncognito(IncognitoMode mode,
bool is_enabled_in_incognito) { … }
void DeclarativeContentApiTest::CheckBookmarkEvents(bool match_is_bookmarked) { … }
class DeclarativeContentApiTestWithContextType
: public DeclarativeContentApiTest,
public testing::WithParamInterface<ContextType> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest, Overview) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
ReusedActionInstance) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
RulesEvaluatedOnAddRemove) { … }
struct ShowActionParams { … };
class ParameterizedShowActionDeclarativeContentApiTest
: public DeclarativeContentApiTest,
public testing::WithParamInterface<ShowActionParams> { … };
void ParameterizedShowActionDeclarativeContentApiTest::TestShowAction(
std::optional<ActionInfo::Type> action_type) { … }
IN_PROC_BROWSER_TEST_P(ParameterizedShowActionDeclarativeContentApiTest,
NoActionInManifest) { … }
IN_PROC_BROWSER_TEST_P(ParameterizedShowActionDeclarativeContentApiTest,
PageActionInManifest) { … }
IN_PROC_BROWSER_TEST_P(ParameterizedShowActionDeclarativeContentApiTest,
BrowserActionInManifest) { … }
IN_PROC_BROWSER_TEST_P(ParameterizedShowActionDeclarativeContentApiTest,
ActionInManifest) { … }
IN_PROC_BROWSER_TEST_P(ParameterizedShowActionDeclarativeContentApiTest,
RulesAddedFromManifest) { … }
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
DisabledForSpanningIncognito) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
EnabledForSpanningIncognito) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
DisabledForSplitIncognito) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
EnabledForSplitIncognito) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
RulesEvaluatedForExistingIncognitoTab) { … }
constexpr char kRulesExtensionName[] = …;
#if (BUILDFLAG(IS_WIN) && defined(NDEBUG)) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_PRE_RulesPersistence …
#else
#define MAYBE_PRE_RulesPersistence …
#endif
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
MAYBE_PRE_RulesPersistence) { … }
#if (BUILDFLAG(IS_WIN) && defined(NDEBUG)) || BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_RulesPersistence …
#else
#define MAYBE_RulesPersistence …
#endif
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
MAYBE_RulesPersistence) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
UninstallWhileActivePageAction) { … }
IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
AddExtensionMatchingExistingTabWithDeadFrames) { … }
IN_PROC_BROWSER_TEST_F(DeclarativeContentApiTest,
CanonicalizesPageStateMatcherCss) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
IsBookmarkedRulesEvaluatedOnBookmarkEvents) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
NotBookmarkedRulesEvaluatedOnBookmarkEvents) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
WebContentsWithoutTabAddedNotificationAtOnLoaded) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
PendingWebContentsClearedOnRemoveRules) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
RemoveAllRulesAfterExtensionUninstall) { … }
IN_PROC_BROWSER_TEST_P(DeclarativeContentApiTestWithContextType,
RequestContentScriptRule) { … }
}
}