Chromium Code Reviews| 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/chrome_switches.h" | 6 #include "chrome/common/chrome_switches.h" |
| 7 #include "chrome/common/extensions/extension.h" | 7 #include "chrome/common/extensions/extension.h" |
| 8 #include "chrome/common/extensions/extension_manifest_constants.h" | 8 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 9 #include "chrome/common/extensions/manifest.h" | 9 #include "chrome/common/extensions/manifest.h" |
| 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 11 #include "chrome/common/extensions/permissions/permissions_data.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 namespace errors = extension_manifest_errors; | 14 namespace errors = extension_manifest_errors; |
| 14 | 15 |
| 16 namespace extensions { | |
| 17 | |
| 15 TEST_F(ExtensionManifestTest, ChromeURLPermissionInvalid) { | 18 TEST_F(ExtensionManifestTest, ChromeURLPermissionInvalid) { |
| 16 LoadAndExpectError("permission_chrome_url_invalid.json", | 19 LoadAndExpectError("permission_chrome_url_invalid.json", |
| 17 errors::kInvalidPermissionScheme); | 20 errors::kInvalidPermissionScheme); |
| 18 } | 21 } |
| 19 | 22 |
| 20 TEST_F(ExtensionManifestTest, ChromeURLPermissionAllowedWithFlag) { | 23 TEST_F(ExtensionManifestTest, ChromeURLPermissionAllowedWithFlag) { |
| 21 CommandLine::ForCurrentProcess()->AppendSwitch( | 24 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 22 switches::kExtensionsOnChromeURLs); | 25 switches::kExtensionsOnChromeURLs); |
| 23 std::string error; | 26 std::string error; |
| 24 scoped_refptr<extensions::Extension> extension = | 27 scoped_refptr<Extension> extension = |
| 25 LoadAndExpectSuccess("permission_chrome_url_invalid.json"); | 28 LoadAndExpectSuccess("permission_chrome_url_invalid.json"); |
| 26 EXPECT_EQ("", error); | 29 EXPECT_EQ("", error); |
| 27 const GURL newtab_url("chrome://newtab/"); | 30 const GURL newtab_url("chrome://newtab/"); |
| 28 EXPECT_TRUE(extension->CanExecuteScriptOnPage(newtab_url, | 31 EXPECT_TRUE(PermissionsData::CanExecuteScriptOnPage( |
| 29 newtab_url, | 32 extension, newtab_url, newtab_url, 0, NULL, &error)) << error; |
| 30 0, | |
| 31 NULL, | |
| 32 &error)) << error; | |
| 33 } | 33 } |
| 34 | 34 |
| 35 TEST_F(ExtensionManifestTest, ChromeResourcesPermissionValidOnlyForComponents) { | 35 TEST_F(ExtensionManifestTest, ChromeResourcesPermissionValidOnlyForComponents) { |
| 36 LoadAndExpectError("permission_chrome_resources_url.json", | 36 LoadAndExpectError("permission_chrome_resources_url.json", |
| 37 errors::kInvalidPermissionScheme); | 37 errors::kInvalidPermissionScheme); |
| 38 std::string error; | 38 std::string error; |
| 39 LoadExtension(Manifest("permission_chrome_resources_url.json"), | 39 LoadExtension(Manifest("permission_chrome_resources_url.json"), |
| 40 &error, extensions::Manifest::COMPONENT, | 40 &error, |
| 41 extensions::Extension::NO_FLAGS); | 41 extensions::Manifest::COMPONENT, |
|
Yoyo Zhou
2013/05/11 00:57:04
nit: in extensions namespace
Devlin
2013/05/13 22:44:23
But there's also a ExtensionManifestTest::Manifest
| |
| 42 Extension::NO_FLAGS); | |
| 42 EXPECT_EQ("", error); | 43 EXPECT_EQ("", error); |
| 43 } | 44 } |
| 45 | |
| 46 } // namespace extensions | |
| OLD | NEW |