| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 287 |
| 288 // Forbid options page with non-(http|https) scheme in hosted app. | 288 // Forbid options page with non-(http|https) scheme in hosted app. |
| 289 LoadAndExpectError("hosted_app_file_options.json", | 289 LoadAndExpectError("hosted_app_file_options.json", |
| 290 errors::kInvalidOptionsPageInHostedApp); | 290 errors::kInvalidOptionsPageInHostedApp); |
| 291 | 291 |
| 292 // Forbid absolute URL for options page in packaged apps. | 292 // Forbid absolute URL for options page in packaged apps. |
| 293 LoadAndExpectError("packaged_app_absolute_options.json", | 293 LoadAndExpectError("packaged_app_absolute_options.json", |
| 294 errors::kInvalidOptionsPageExpectUrlInPackage); | 294 errors::kInvalidOptionsPageExpectUrlInPackage); |
| 295 } | 295 } |
| 296 | 296 |
| 297 TEST_F(ExtensionManifestTest, DisallowExtensionPermissions) { | 297 TEST_F(ExtensionManifestTest, AllowUnrecognizedPermissions) { |
| 298 std::string error; | 298 std::string error; |
| 299 scoped_ptr<DictionaryValue> manifest( | 299 scoped_ptr<DictionaryValue> manifest( |
| 300 LoadManifestFile("valid_app.json", &error)); | 300 LoadManifestFile("valid_app.json", &error)); |
| 301 ASSERT_TRUE(manifest.get()); | 301 ASSERT_TRUE(manifest.get()); |
| 302 | 302 |
| 303 ListValue *permissions = new ListValue(); | 303 ListValue *permissions = new ListValue(); |
| 304 manifest->Set(keys::kPermissions, permissions); | 304 manifest->Set(keys::kPermissions, permissions); |
| 305 for (size_t i = 0; i < Extension::kNumPermissions; i++) { | 305 for (size_t i = 0; i < Extension::kNumPermissions; i++) { |
| 306 const char* name = Extension::kPermissions[i].name; | 306 const char* name = Extension::kPermissions[i].name; |
| 307 StringValue* p = new StringValue(name); | 307 StringValue* p = new StringValue(name); |
| 308 permissions->Clear(); | 308 permissions->Clear(); |
| 309 permissions->Append(p); | 309 permissions->Append(p); |
| 310 std::string message_name = base::StringPrintf("permission-%s", name); | 310 std::string message_name = base::StringPrintf("permission-%s", name); |
| 311 if (Extension::IsHostedAppPermission(name)) { | 311 |
| 312 scoped_refptr<Extension> extension; | 312 // Extensions are allowed to contain unrecognized API permissions, |
| 313 extension = LoadAndExpectSuccess(manifest.get(), message_name); | 313 // so there shouldn't be any errors. |
| 314 } else { | 314 scoped_refptr<Extension> extension; |
| 315 LoadAndExpectError(manifest.get(), message_name, | 315 extension = LoadAndExpectSuccess(manifest.get(), message_name); |
| 316 errors::kInvalidPermission); | |
| 317 } | |
| 318 } | 316 } |
| 319 } | 317 } |
| 320 | 318 |
| 321 TEST_F(ExtensionManifestTest, NormalizeIconPaths) { | 319 TEST_F(ExtensionManifestTest, NormalizeIconPaths) { |
| 322 scoped_refptr<Extension> extension( | 320 scoped_refptr<Extension> extension( |
| 323 LoadAndExpectSuccess("normalize_icon_paths.json")); | 321 LoadAndExpectSuccess("normalize_icon_paths.json")); |
| 324 EXPECT_EQ("16.png", | 322 EXPECT_EQ("16.png", |
| 325 extension->icons().Get(16, ExtensionIconSet::MATCH_EXACTLY)); | 323 extension->icons().Get(16, ExtensionIconSet::MATCH_EXACTLY)); |
| 326 EXPECT_EQ("48.png", | 324 EXPECT_EQ("48.png", |
| 327 extension->icons().Get(48, ExtensionIconSet::MATCH_EXACTLY)); | 325 extension->icons().Get(48, ExtensionIconSet::MATCH_EXACTLY)); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 358 |
| 361 TEST_F(ExtensionManifestTest, DefaultPathForExtent) { | 359 TEST_F(ExtensionManifestTest, DefaultPathForExtent) { |
| 362 scoped_refptr<Extension> extension( | 360 scoped_refptr<Extension> extension( |
| 363 LoadAndExpectSuccess("default_path_for_extent.json")); | 361 LoadAndExpectSuccess("default_path_for_extent.json")); |
| 364 | 362 |
| 365 ASSERT_EQ(1u, extension->web_extent().patterns().size()); | 363 ASSERT_EQ(1u, extension->web_extent().patterns().size()); |
| 366 EXPECT_EQ("/*", extension->web_extent().patterns()[0].path()); | 364 EXPECT_EQ("/*", extension->web_extent().patterns()[0].path()); |
| 367 EXPECT_TRUE(extension->web_extent().ContainsURL( | 365 EXPECT_TRUE(extension->web_extent().ContainsURL( |
| 368 GURL("http://www.google.com/monkey"))); | 366 GURL("http://www.google.com/monkey"))); |
| 369 } | 367 } |
| OLD | NEW |