Commit 288c423b authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions] Bump the supported manifest version

Increment to 3; update tests.

Bug: 1147355
Change-Id: I8469f30b6bb25f2ecc56217c83bb73c81521bafc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2528614Reviewed-by: default avatarKelvin Jiang <kelvinjiang@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827336}
parent d240c2b1
......@@ -17,15 +17,6 @@
namespace extensions {
namespace {
// Install warning for tests running Manifest v3. The current highest
// supported manifest version is 2.
constexpr char kManifestVersionWarning[] =
"The maximum currently-supported manifest version is 2, but this is 3. "
"Certain features may not work as expected.";
} // namespace
using PermissionsParserTest = ChromeManifestTest;
TEST_F(PermissionsParserTest, RemoveOverlappingAPIPermissions) {
......@@ -123,14 +114,11 @@ TEST_F(PermissionsParserTest, OptionalHostPermissionsInvalidScheme) {
}
TEST_F(PermissionsParserTest, HostPermissionsKey) {
std::vector<std::string> expected_warnings;
expected_warnings.push_back(ErrorUtils::FormatErrorMessage(
manifest_errors::kPermissionUnknownOrMalformed, "https://google.com/*"));
expected_warnings.push_back(kManifestVersionWarning);
std::string expected_warning = ErrorUtils::FormatErrorMessage(
manifest_errors::kPermissionUnknownOrMalformed, "https://google.com/*");
scoped_refptr<Extension> extension(
LoadAndExpectWarnings("host_permissions_key.json", expected_warnings));
LoadAndExpectWarning("host_permissions_key.json", expected_warning));
// Expect that the host specified in |host_permissions| is parsed.
const URLPatternSet& required_hosts =
......@@ -142,26 +130,20 @@ TEST_F(PermissionsParserTest, HostPermissionsKey) {
}
TEST_F(PermissionsParserTest, HostPermissionsKeyInvalidHosts) {
std::vector<std::string> expected_warnings;
expected_warnings.push_back(ErrorUtils::FormatErrorMessage(
manifest_errors::kPermissionUnknownOrMalformed, "malformed_host"));
expected_warnings.push_back(kManifestVersionWarning);
std::string expected_warning = ErrorUtils::FormatErrorMessage(
manifest_errors::kPermissionUnknownOrMalformed, "malformed_host");
scoped_refptr<Extension> extension(LoadAndExpectWarnings(
"host_permissions_key_invalid_hosts.json", expected_warnings));
scoped_refptr<Extension> extension(LoadAndExpectWarning(
"host_permissions_key_invalid_hosts.json", expected_warning));
}
TEST_F(PermissionsParserTest, HostPermissionsKeyInvalidScheme) {
std::vector<std::string> expected_warnings;
expected_warnings.push_back(ErrorUtils::FormatErrorMessage(
std::string expected_warning = ErrorUtils::FormatErrorMessage(
manifest_errors::kInvalidPermissionScheme,
manifest_keys::kHostPermissions, "chrome://extensions/"));
manifest_keys::kHostPermissions, "chrome://extensions/");
expected_warnings.push_back(kManifestVersionWarning);
scoped_refptr<Extension> extension(LoadAndExpectWarnings(
"host_permissions_key_invalid_scheme.json", expected_warnings));
scoped_refptr<Extension> extension(LoadAndExpectWarning(
"host_permissions_key_invalid_scheme.json", expected_warning));
}
// Tests that listing a permissions as optional when that permission cannot be
......
......@@ -84,7 +84,7 @@ bool IsManifestSupported(int manifest_version,
Manifest::Type type,
int creation_flags,
std::string* warning) {
static constexpr int kMaximumSupportedManifestVersion = 2;
static constexpr int kMaximumSupportedManifestVersion = 3;
static_assert(kMaximumSupportedManifestVersion >= kModernManifestVersion,
"The modern manifest version must be supported.");
......
......@@ -107,7 +107,8 @@ TEST(ExtensionTest, ExtensionManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_EXTENSION;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3,
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(4), kType, 4,
true /* expect warning */));
// Manifest v1 is deprecated, and should not load.
......@@ -156,8 +157,10 @@ TEST(ExtensionTest, PlatformAppManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_PLATFORM_APP;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3,
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(4), kType, 4,
true /* expect warning */));
// Omitting the key defaults to v2 for platform apps.
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(base::nullopt), kType, 2));
......@@ -194,7 +197,8 @@ TEST(ExtensionTest, HostedAppManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_HOSTED_APP;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3,
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(4), kType, 4,
true /* expect warning */));
// Manifest v1 is deprecated, but should still load for hosted apps.
......@@ -221,7 +225,8 @@ TEST(ExtensionTest, UserScriptManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_USER_SCRIPT;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3,
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(3), kType, 3));
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(4), kType, 4,
true /* expect warning */));
// Manifest v1 is deprecated, but should still load for user scripts.
......
......@@ -11,9 +11,6 @@
namespace extensions {
using ManifestV3PermissionsTest = ManifestTest;
const char* kManifestV3NotSupported =
"The maximum currently-supported manifest version is 2, but this is 3. "
"Certain features may not work as expected.";
TEST_F(ManifestV3PermissionsTest, WebRequestBlockingPermissionsTest) {
const std::string kPermissionRequiresV2OrLower =
......@@ -22,18 +19,17 @@ TEST_F(ManifestV3PermissionsTest, WebRequestBlockingPermissionsTest) {
// Manifest V3 extension that is not policy installed. This should trigger a
// warning that manifest V3 is not currently supported and that the
// webRequestBlocking permission requires a lower manifest version.
scoped_refptr<Extension> extension(LoadAndExpectWarnings(
"web_request_blocking_v3.json",
{kManifestV3NotSupported, kPermissionRequiresV2OrLower},
scoped_refptr<Extension> extension(LoadAndExpectWarning(
"web_request_blocking_v3.json", kPermissionRequiresV2OrLower,
extensions::Manifest::Location::UNPACKED));
ASSERT_TRUE(extension);
}
{
// Manifest V3 extension that is policy extension. This should only trigger
// a warning that manifest V3 is not supported currently.
scoped_refptr<Extension> extension(LoadAndExpectWarnings(
"web_request_blocking_v3.json", {kManifestV3NotSupported},
extensions::Manifest::Location::EXTERNAL_POLICY));
scoped_refptr<Extension> extension(
LoadAndExpectSuccess("web_request_blocking_v3.json",
extensions::Manifest::Location::EXTERNAL_POLICY));
ASSERT_TRUE(extension);
}
{
......@@ -53,9 +49,8 @@ TEST_F(ManifestV3PermissionsTest, DisallowNaClTest) {
// Unpacked Manifest V3 extension should trigger a warning that
// manifest V3 is not currently supported and that 'nacl_modules' requires a
// lower manifest version.
scoped_refptr<Extension> extension(LoadAndExpectWarnings(
"nacl_module_v3.json",
{kManifestV3NotSupported, kPermissionRequiresV2OrLower},
scoped_refptr<Extension> extension(LoadAndExpectWarning(
"nacl_module_v3.json", kPermissionRequiresV2OrLower,
extensions::Manifest::Location::UNPACKED));
ASSERT_TRUE(extension);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment