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 @@ ...@@ -17,15 +17,6 @@
namespace extensions { 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; using PermissionsParserTest = ChromeManifestTest;
TEST_F(PermissionsParserTest, RemoveOverlappingAPIPermissions) { TEST_F(PermissionsParserTest, RemoveOverlappingAPIPermissions) {
...@@ -123,14 +114,11 @@ TEST_F(PermissionsParserTest, OptionalHostPermissionsInvalidScheme) { ...@@ -123,14 +114,11 @@ TEST_F(PermissionsParserTest, OptionalHostPermissionsInvalidScheme) {
} }
TEST_F(PermissionsParserTest, HostPermissionsKey) { TEST_F(PermissionsParserTest, HostPermissionsKey) {
std::vector<std::string> expected_warnings; std::string expected_warning = ErrorUtils::FormatErrorMessage(
expected_warnings.push_back(ErrorUtils::FormatErrorMessage( manifest_errors::kPermissionUnknownOrMalformed, "https://google.com/*");
manifest_errors::kPermissionUnknownOrMalformed, "https://google.com/*"));
expected_warnings.push_back(kManifestVersionWarning);
scoped_refptr<Extension> extension( 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. // Expect that the host specified in |host_permissions| is parsed.
const URLPatternSet& required_hosts = const URLPatternSet& required_hosts =
...@@ -142,26 +130,20 @@ TEST_F(PermissionsParserTest, HostPermissionsKey) { ...@@ -142,26 +130,20 @@ TEST_F(PermissionsParserTest, HostPermissionsKey) {
} }
TEST_F(PermissionsParserTest, HostPermissionsKeyInvalidHosts) { TEST_F(PermissionsParserTest, HostPermissionsKeyInvalidHosts) {
std::vector<std::string> expected_warnings; std::string expected_warning = ErrorUtils::FormatErrorMessage(
expected_warnings.push_back(ErrorUtils::FormatErrorMessage( manifest_errors::kPermissionUnknownOrMalformed, "malformed_host");
manifest_errors::kPermissionUnknownOrMalformed, "malformed_host"));
expected_warnings.push_back(kManifestVersionWarning);
scoped_refptr<Extension> extension(LoadAndExpectWarnings( scoped_refptr<Extension> extension(LoadAndExpectWarning(
"host_permissions_key_invalid_hosts.json", expected_warnings)); "host_permissions_key_invalid_hosts.json", expected_warning));
} }
TEST_F(PermissionsParserTest, HostPermissionsKeyInvalidScheme) { TEST_F(PermissionsParserTest, HostPermissionsKeyInvalidScheme) {
std::vector<std::string> expected_warnings; std::string expected_warning = ErrorUtils::FormatErrorMessage(
expected_warnings.push_back(ErrorUtils::FormatErrorMessage(
manifest_errors::kInvalidPermissionScheme, manifest_errors::kInvalidPermissionScheme,
manifest_keys::kHostPermissions, "chrome://extensions/")); manifest_keys::kHostPermissions, "chrome://extensions/");
expected_warnings.push_back(kManifestVersionWarning); scoped_refptr<Extension> extension(LoadAndExpectWarning(
"host_permissions_key_invalid_scheme.json", expected_warning));
scoped_refptr<Extension> extension(LoadAndExpectWarnings(
"host_permissions_key_invalid_scheme.json", expected_warnings));
} }
// Tests that listing a permissions as optional when that permission cannot be // Tests that listing a permissions as optional when that permission cannot be
......
...@@ -84,7 +84,7 @@ bool IsManifestSupported(int manifest_version, ...@@ -84,7 +84,7 @@ bool IsManifestSupported(int manifest_version,
Manifest::Type type, Manifest::Type type,
int creation_flags, int creation_flags,
std::string* warning) { std::string* warning) {
static constexpr int kMaximumSupportedManifestVersion = 2; static constexpr int kMaximumSupportedManifestVersion = 3;
static_assert(kMaximumSupportedManifestVersion >= kModernManifestVersion, static_assert(kMaximumSupportedManifestVersion >= kModernManifestVersion,
"The modern manifest version must be supported."); "The modern manifest version must be supported.");
......
...@@ -107,7 +107,8 @@ TEST(ExtensionTest, ExtensionManifestVersions) { ...@@ -107,7 +107,8 @@ TEST(ExtensionTest, ExtensionManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_EXTENSION; const Manifest::Type kType = Manifest::TYPE_EXTENSION;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2)); 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 */)); true /* expect warning */));
// Manifest v1 is deprecated, and should not load. // Manifest v1 is deprecated, and should not load.
...@@ -156,8 +157,10 @@ TEST(ExtensionTest, PlatformAppManifestVersions) { ...@@ -156,8 +157,10 @@ TEST(ExtensionTest, PlatformAppManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_PLATFORM_APP; const Manifest::Type kType = Manifest::TYPE_PLATFORM_APP;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2)); 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 */)); true /* expect warning */));
// Omitting the key defaults to v2 for platform apps. // Omitting the key defaults to v2 for platform apps.
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(base::nullopt), kType, 2)); EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(base::nullopt), kType, 2));
...@@ -194,7 +197,8 @@ TEST(ExtensionTest, HostedAppManifestVersions) { ...@@ -194,7 +197,8 @@ TEST(ExtensionTest, HostedAppManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_HOSTED_APP; const Manifest::Type kType = Manifest::TYPE_HOSTED_APP;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2)); 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 */)); true /* expect warning */));
// Manifest v1 is deprecated, but should still load for hosted apps. // Manifest v1 is deprecated, but should still load for hosted apps.
...@@ -221,7 +225,8 @@ TEST(ExtensionTest, UserScriptManifestVersions) { ...@@ -221,7 +225,8 @@ TEST(ExtensionTest, UserScriptManifestVersions) {
const Manifest::Type kType = Manifest::TYPE_USER_SCRIPT; const Manifest::Type kType = Manifest::TYPE_USER_SCRIPT;
EXPECT_TRUE(RunManifestVersionSuccess(get_manifest(2), kType, 2)); 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 */)); true /* expect warning */));
// Manifest v1 is deprecated, but should still load for user scripts. // Manifest v1 is deprecated, but should still load for user scripts.
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
namespace extensions { namespace extensions {
using ManifestV3PermissionsTest = ManifestTest; 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) { TEST_F(ManifestV3PermissionsTest, WebRequestBlockingPermissionsTest) {
const std::string kPermissionRequiresV2OrLower = const std::string kPermissionRequiresV2OrLower =
...@@ -22,17 +19,16 @@ TEST_F(ManifestV3PermissionsTest, WebRequestBlockingPermissionsTest) { ...@@ -22,17 +19,16 @@ TEST_F(ManifestV3PermissionsTest, WebRequestBlockingPermissionsTest) {
// Manifest V3 extension that is not policy installed. This should trigger a // Manifest V3 extension that is not policy installed. This should trigger a
// warning that manifest V3 is not currently supported and that the // warning that manifest V3 is not currently supported and that the
// webRequestBlocking permission requires a lower manifest version. // webRequestBlocking permission requires a lower manifest version.
scoped_refptr<Extension> extension(LoadAndExpectWarnings( scoped_refptr<Extension> extension(LoadAndExpectWarning(
"web_request_blocking_v3.json", "web_request_blocking_v3.json", kPermissionRequiresV2OrLower,
{kManifestV3NotSupported, kPermissionRequiresV2OrLower},
extensions::Manifest::Location::UNPACKED)); extensions::Manifest::Location::UNPACKED));
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
} }
{ {
// Manifest V3 extension that is policy extension. This should only trigger // Manifest V3 extension that is policy extension. This should only trigger
// a warning that manifest V3 is not supported currently. // a warning that manifest V3 is not supported currently.
scoped_refptr<Extension> extension(LoadAndExpectWarnings( scoped_refptr<Extension> extension(
"web_request_blocking_v3.json", {kManifestV3NotSupported}, LoadAndExpectSuccess("web_request_blocking_v3.json",
extensions::Manifest::Location::EXTERNAL_POLICY)); extensions::Manifest::Location::EXTERNAL_POLICY));
ASSERT_TRUE(extension); ASSERT_TRUE(extension);
} }
...@@ -53,9 +49,8 @@ TEST_F(ManifestV3PermissionsTest, DisallowNaClTest) { ...@@ -53,9 +49,8 @@ TEST_F(ManifestV3PermissionsTest, DisallowNaClTest) {
// Unpacked Manifest V3 extension should trigger a warning that // Unpacked Manifest V3 extension should trigger a warning that
// manifest V3 is not currently supported and that 'nacl_modules' requires a // manifest V3 is not currently supported and that 'nacl_modules' requires a
// lower manifest version. // lower manifest version.
scoped_refptr<Extension> extension(LoadAndExpectWarnings( scoped_refptr<Extension> extension(LoadAndExpectWarning(
"nacl_module_v3.json", "nacl_module_v3.json", kPermissionRequiresV2OrLower,
{kManifestV3NotSupported, kPermissionRequiresV2OrLower},
extensions::Manifest::Location::UNPACKED)); extensions::Manifest::Location::UNPACKED));
ASSERT_TRUE(extension); 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