| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/common/features/api_feature.h" | 5 #include "extensions/common/features/api_feature.h" |
| 6 #include "extensions/common/features/complex_feature.h" | 6 #include "extensions/common/features/complex_feature.h" |
| 7 #include "extensions/common/features/feature.h" | 7 #include "extensions/common/features/feature.h" |
| 8 #include "extensions/common/features/simple_feature.h" | 8 #include "extensions/common/features/simple_feature.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "tools/json_schema_compiler/test/features_compiler_test.h" | 10 #include "tools/json_schema_compiler/test/features_compiler_test.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 }; | 99 }; |
| 100 | 100 |
| 101 // Check some simple features for accuracy. | 101 // Check some simple features for accuracy. |
| 102 { | 102 { |
| 103 APIFeature* feature = GetAPIFeature("alpha"); | 103 APIFeature* feature = GetAPIFeature("alpha"); |
| 104 FeatureComparator comparator("alpha"); | 104 FeatureComparator comparator("alpha"); |
| 105 comparator.dependencies = {"permission:alpha"}; | 105 comparator.dependencies = {"permission:alpha"}; |
| 106 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; | 106 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; |
| 107 comparator.channel.reset( | 107 comparator.channel.reset( |
| 108 new version_info::Channel(version_info::Channel::STABLE)); | 108 new version_info::Channel(version_info::Channel::STABLE)); |
| 109 comparator.max_manifest_version = 1; |
| 109 comparator.CompareFeature(feature); | 110 comparator.CompareFeature(feature); |
| 110 } | 111 } |
| 111 { | 112 { |
| 112 APIFeature* feature = GetAPIFeature("beta"); | 113 APIFeature* feature = GetAPIFeature("beta"); |
| 113 FeatureComparator comparator("beta"); | 114 FeatureComparator comparator("beta"); |
| 114 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; | 115 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; |
| 115 comparator.channel.reset( | 116 comparator.channel.reset( |
| 116 new version_info::Channel(version_info::Channel::DEV)); | 117 new version_info::Channel(version_info::Channel::DEV)); |
| 117 comparator.extension_types = {Manifest::TYPE_EXTENSION, | 118 comparator.extension_types = {Manifest::TYPE_EXTENSION, |
| 118 Manifest::TYPE_PLATFORM_APP}; | 119 Manifest::TYPE_PLATFORM_APP}; |
| 120 comparator.location = SimpleFeature::COMPONENT_LOCATION; |
| 119 comparator.whitelist = {"aaa", "bbb"}; | 121 comparator.whitelist = {"aaa", "bbb"}; |
| 120 comparator.blacklist = {"zzz", "yyy"}; | 122 comparator.blacklist = {"zzz", "yyy"}; |
| 121 comparator.component_extensions_auto_granted = false; | 123 comparator.component_extensions_auto_granted = false; |
| 122 comparator.CompareFeature(feature); | 124 comparator.CompareFeature(feature); |
| 123 } | 125 } |
| 124 { | 126 { |
| 125 APIFeature* feature = GetAPIFeature("gamma"); | 127 APIFeature* feature = GetAPIFeature("gamma"); |
| 126 FeatureComparator comparator("gamma"); | 128 FeatureComparator comparator("gamma"); |
| 127 comparator.channel.reset( | 129 comparator.channel.reset( |
| 128 new version_info::Channel(version_info::Channel::BETA)); | 130 new version_info::Channel(version_info::Channel::BETA)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 } | 169 } |
| 168 { | 170 { |
| 169 APIFeature* feature = GetAPIFeature("delta"); | 171 APIFeature* feature = GetAPIFeature("delta"); |
| 170 FeatureComparator comparator("delta"); | 172 FeatureComparator comparator("delta"); |
| 171 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT, | 173 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT, |
| 172 Feature::WEBUI_CONTEXT}; | 174 Feature::WEBUI_CONTEXT}; |
| 173 comparator.channel.reset( | 175 comparator.channel.reset( |
| 174 new version_info::Channel(version_info::Channel::DEV)); | 176 new version_info::Channel(version_info::Channel::DEV)); |
| 175 comparator.matches.AddPattern( | 177 comparator.matches.AddPattern( |
| 176 URLPattern(URLPattern::SCHEME_ALL, "*://example.com/*")); | 178 URLPattern(URLPattern::SCHEME_ALL, "*://example.com/*")); |
| 179 comparator.min_manifest_version = 2; |
| 177 comparator.CompareFeature(feature); | 180 comparator.CompareFeature(feature); |
| 178 } | 181 } |
| 179 { | 182 { |
| 183 APIFeature* feature = GetAPIFeature("allEnum"); |
| 184 FeatureComparator comparator("allEnum"); |
| 185 comparator.contexts = { |
| 186 Feature::BLESSED_EXTENSION_CONTEXT, Feature::BLESSED_WEB_PAGE_CONTEXT, |
| 187 Feature::CONTENT_SCRIPT_CONTEXT, Feature::SERVICE_WORKER_CONTEXT, |
| 188 Feature::WEB_PAGE_CONTEXT, Feature::WEBUI_CONTEXT, |
| 189 Feature::UNBLESSED_EXTENSION_CONTEXT}; |
| 190 comparator.extension_types = { |
| 191 Manifest::TYPE_EXTENSION, Manifest::TYPE_HOSTED_APP, |
| 192 Manifest::TYPE_LEGACY_PACKAGED_APP, Manifest::TYPE_PLATFORM_APP, |
| 193 Manifest::TYPE_SHARED_MODULE, Manifest::TYPE_THEME}; |
| 194 comparator.channel.reset( |
| 195 new version_info::Channel(version_info::Channel::BETA)); |
| 196 comparator.CompareFeature(feature); |
| 197 } |
| 198 { |
| 180 // Omega is imported from a second .json file. | 199 // Omega is imported from a second .json file. |
| 181 APIFeature* feature = GetAPIFeature("omega"); | 200 APIFeature* feature = GetAPIFeature("omega"); |
| 182 FeatureComparator comparator("omega"); | 201 FeatureComparator comparator("omega"); |
| 183 comparator.contexts = {Feature::WEB_PAGE_CONTEXT}; | 202 comparator.contexts = {Feature::WEB_PAGE_CONTEXT}; |
| 184 comparator.channel.reset( | 203 comparator.channel.reset( |
| 185 new version_info::Channel(version_info::Channel::DEV)); | 204 new version_info::Channel(version_info::Channel::DEV)); |
| 186 comparator.min_manifest_version = 2; | 205 comparator.min_manifest_version = 2; |
| 187 comparator.CompareFeature(feature); | 206 comparator.CompareFeature(feature); |
| 188 } | 207 } |
| 189 { | 208 { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 new version_info::Channel(version_info::Channel::BETA)); | 258 new version_info::Channel(version_info::Channel::BETA)); |
| 240 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; | 259 comparator.contexts = {Feature::BLESSED_EXTENSION_CONTEXT}; |
| 241 comparator.extension_types = {Manifest::TYPE_EXTENSION}; | 260 comparator.extension_types = {Manifest::TYPE_EXTENSION}; |
| 242 comparator.whitelist = {"aaa"}; | 261 comparator.whitelist = {"aaa"}; |
| 243 comparator.CompareFeature(other_parent); | 262 comparator.CompareFeature(other_parent); |
| 244 } | 263 } |
| 245 } | 264 } |
| 246 } | 265 } |
| 247 | 266 |
| 248 } // namespace extensions | 267 } // namespace extensions |
| OLD | NEW |