#include <memory>
#include "base/files/file_path.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/content_verifier/content_verifier.h"
#include "extensions/browser/content_verifier/content_verifier_utils.h"
#include "extensions/browser/content_verifier/test_utils.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extensions_test.h"
#include "extensions/common/api/content_scripts.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/extension_paths.h"
#include "extensions/common/extensions_client.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/background_info.h"
#include "extensions/common/manifest_handlers/content_scripts_handler.h"
#include "extensions/common/scoped_testing_manifest_handler_registry.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
namespace {
enum class BackgroundManifestType { … };
const std::string kDotSpaceSuffixList[] = …;
base::FilePath kBackgroundScriptPath(FILE_PATH_LITERAL("foo/bg.txt"));
base::FilePath kContentScriptPath(FILE_PATH_LITERAL("foo/content.txt"));
base::FilePath kBackgroundPagePath(FILE_PATH_LITERAL("foo/page.txt"));
base::FilePath kScriptFilePath(FILE_PATH_LITERAL("bar/code.js"));
base::FilePath kUnknownTypeFilePath(FILE_PATH_LITERAL("bar/code.txt"));
base::FilePath kHTMLFilePath(FILE_PATH_LITERAL("bar/page.html"));
base::FilePath kHTMFilePath(FILE_PATH_LITERAL("bar/page.htm"));
base::FilePath kIconPath(FILE_PATH_LITERAL("bar/16.png"));
base::FilePath ToUppercasePath(const base::FilePath& path) { … }
base::FilePath ToFirstLetterUppercasePath(const base::FilePath& path) { … }
base::FilePath AppendSuffix(const base::FilePath& path,
const std::string& suffix) { … }
class TestContentVerifierDelegate : public MockContentVerifierDelegate { … };
std::set<base::FilePath> TestContentVerifierDelegate::GetBrowserImagePaths(
const extensions::Extension* extension) { … }
void TestContentVerifierDelegate::SetBrowserImagePaths(
std::set<base::FilePath> paths) { … }
struct FilePathVariants { … };
}
class ContentVerifierTest : public ExtensionsTest { … };
class ContentVerifierTestWithBackgroundType
: public ContentVerifierTest,
public testing::WithParamInterface<BackgroundManifestType> { … };
TEST_P(ContentVerifierTestWithBackgroundType, BrowserImagesShouldBeVerified) { … }
INSTANTIATE_TEST_SUITE_P(…);
TEST_F(ContentVerifierTest, NormalizeRelativePath) { … }
TEST_F(ContentVerifierTest, JSAndHTMLAlwaysVerified) { … }
TEST_F(ContentVerifierTest, AlwaysVerifiedPathsWithVariants) { … }
TEST_F(ContentVerifierTest, NeverVerifiedPaths) { … }
}