OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/extensions/manifest_tests/chrome_manifest_test.h" | 6 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
7 #include "chrome/common/url_constants.h" | 7 #include "chrome/common/url_constants.h" |
8 #include "extensions/common/error_utils.h" | 8 #include "extensions/common/error_utils.h" |
9 #include "extensions/common/extension.h" | 9 #include "extensions/common/extension.h" |
10 #include "extensions/common/manifest.h" | 10 #include "extensions/common/manifest.h" |
11 #include "extensions/common/manifest_constants.h" | 11 #include "extensions/common/manifest_constants.h" |
12 #include "extensions/common/permissions/permissions_data.h" | 12 #include "extensions/common/permissions/permissions_data.h" |
13 #include "extensions/common/switches.h" | 13 #include "extensions/common/switches.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 | 17 |
18 namespace errors = manifest_errors; | 18 namespace errors = manifest_errors; |
19 | 19 |
20 typedef ChromeManifestTest ChromePermissionManifestTest; | 20 TEST_F(ExtensionManifestTest, ChromeURLPermissionInvalid) { |
21 | |
22 TEST_F(ChromePermissionManifestTest, ChromeURLPermissionInvalid) { | |
23 LoadAndExpectWarning("permission_chrome_url_invalid.json", | 21 LoadAndExpectWarning("permission_chrome_url_invalid.json", |
24 ErrorUtils::FormatErrorMessage( | 22 ErrorUtils::FormatErrorMessage( |
25 errors::kInvalidPermissionScheme, | 23 errors::kInvalidPermissionScheme, |
26 chrome::kChromeUINewTabURL)); | 24 chrome::kChromeUINewTabURL)); |
27 } | 25 } |
28 | 26 |
29 TEST_F(ChromePermissionManifestTest, ChromeURLPermissionAllowedWithFlag) { | 27 TEST_F(ExtensionManifestTest, ChromeURLPermissionAllowedWithFlag) { |
30 // Ignore the policy delegate for this test. | 28 // Ignore the policy delegate for this test. |
31 PermissionsData::SetPolicyDelegate(NULL); | 29 PermissionsData::SetPolicyDelegate(NULL); |
32 CommandLine::ForCurrentProcess()->AppendSwitch( | 30 CommandLine::ForCurrentProcess()->AppendSwitch( |
33 switches::kExtensionsOnChromeURLs); | 31 switches::kExtensionsOnChromeURLs); |
34 std::string error; | 32 std::string error; |
35 scoped_refptr<Extension> extension = | 33 scoped_refptr<Extension> extension = |
36 LoadAndExpectSuccess("permission_chrome_url_invalid.json"); | 34 LoadAndExpectSuccess("permission_chrome_url_invalid.json"); |
37 EXPECT_EQ("", error); | 35 EXPECT_EQ("", error); |
38 const GURL newtab_url(chrome::kChromeUINewTabURL); | 36 const GURL newtab_url(chrome::kChromeUINewTabURL); |
39 EXPECT_TRUE(extension->permissions_data()->CanAccessPage( | 37 EXPECT_TRUE(extension->permissions_data()->CanAccessPage( |
40 extension.get(), newtab_url, newtab_url, 0, -1, &error)) | 38 extension.get(), newtab_url, newtab_url, 0, -1, &error)) |
41 << error; | 39 << error; |
42 } | 40 } |
43 | 41 |
44 TEST_F(ChromePermissionManifestTest, | 42 TEST_F(ExtensionManifestTest, ChromeResourcesPermissionValidOnlyForComponents) { |
45 ChromeResourcesPermissionValidOnlyForComponents) { | |
46 LoadAndExpectWarning("permission_chrome_resources_url.json", | 43 LoadAndExpectWarning("permission_chrome_resources_url.json", |
47 ErrorUtils::FormatErrorMessage( | 44 ErrorUtils::FormatErrorMessage( |
48 errors::kInvalidPermissionScheme, | 45 errors::kInvalidPermissionScheme, |
49 "chrome://resources/")); | 46 "chrome://resources/")); |
50 std::string error; | 47 std::string error; |
51 LoadExtension(ManifestData("permission_chrome_resources_url.json"), | 48 LoadExtension(Manifest("permission_chrome_resources_url.json"), |
52 &error, | 49 &error, |
53 extensions::Manifest::COMPONENT, | 50 extensions::Manifest::COMPONENT, |
54 Extension::NO_FLAGS); | 51 Extension::NO_FLAGS); |
55 EXPECT_EQ("", error); | 52 EXPECT_EQ("", error); |
56 } | 53 } |
57 | 54 |
58 } // namespace extensions | 55 } // namespace extensions |
OLD | NEW |