| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/common/extensions/extension_unittest.h" | 5 #include "chrome/common/extensions/extension_unittest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // actual crx files that we test other parts of the system with. | 226 // actual crx files that we test other parts of the system with. |
| 227 TEST_F(ExtensionTest, MimeTypeSniffing) { | 227 TEST_F(ExtensionTest, MimeTypeSniffing) { |
| 228 base::FilePath path; | 228 base::FilePath path; |
| 229 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); | 229 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &path)); |
| 230 path = path.AppendASCII("extensions").AppendASCII("good.crx"); | 230 path = path.AppendASCII("extensions").AppendASCII("good.crx"); |
| 231 | 231 |
| 232 std::string data; | 232 std::string data; |
| 233 ASSERT_TRUE(file_util::ReadFileToString(path, &data)); | 233 ASSERT_TRUE(file_util::ReadFileToString(path, &data)); |
| 234 | 234 |
| 235 std::string result; | 235 std::string result; |
| 236 EXPECT_TRUE(net::SniffMimeType(data.c_str(), data.size(), | 236 EXPECT_TRUE(net::SniffMimeType(data.c_str(), |
| 237 GURL("http://www.example.com/foo.crx"), "", &result)); | 237 data.size(), |
| 238 GURL("http://www.example.com/foo.crx"), |
| 239 std::string(), |
| 240 &result)); |
| 238 EXPECT_EQ(std::string(Extension::kMimeType), result); | 241 EXPECT_EQ(std::string(Extension::kMimeType), result); |
| 239 | 242 |
| 240 data.clear(); | 243 data.clear(); |
| 241 result.clear(); | 244 result.clear(); |
| 242 path = path.DirName().AppendASCII("bad_magic.crx"); | 245 path = path.DirName().AppendASCII("bad_magic.crx"); |
| 243 ASSERT_TRUE(file_util::ReadFileToString(path, &data)); | 246 ASSERT_TRUE(file_util::ReadFileToString(path, &data)); |
| 244 EXPECT_TRUE(net::SniffMimeType(data.c_str(), data.size(), | 247 EXPECT_TRUE(net::SniffMimeType(data.c_str(), |
| 245 GURL("http://www.example.com/foo.crx"), "", &result)); | 248 data.size(), |
| 249 GURL("http://www.example.com/foo.crx"), |
| 250 std::string(), |
| 251 &result)); |
| 246 EXPECT_EQ("application/octet-stream", result); | 252 EXPECT_EQ("application/octet-stream", result); |
| 247 } | 253 } |
| 248 | 254 |
| 249 TEST_F(ExtensionTest, EffectiveHostPermissions) { | 255 TEST_F(ExtensionTest, EffectiveHostPermissions) { |
| 250 (new ContentScriptsHandler)->Register(); | 256 (new ContentScriptsHandler)->Register(); |
| 251 scoped_refptr<Extension> extension; | 257 scoped_refptr<Extension> extension; |
| 252 URLPatternSet hosts; | 258 URLPatternSet hosts; |
| 253 | 259 |
| 254 extension = LoadManifest("effective_host_permissions", "empty.json"); | 260 extension = LoadManifest("effective_host_permissions", "empty.json"); |
| 255 EXPECT_EQ(0u, extension->GetEffectiveHostPermissions().patterns().size()); | 261 EXPECT_EQ(0u, extension->GetEffectiveHostPermissions().patterns().size()); |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 error.clear(); | 947 error.clear(); |
| 942 extension = LoadManifestUnchecked("optional_only_permission", | 948 extension = LoadManifestUnchecked("optional_only_permission", |
| 943 "manifest2.json", | 949 "manifest2.json", |
| 944 Manifest::INTERNAL, Extension::NO_FLAGS, | 950 Manifest::INTERNAL, Extension::NO_FLAGS, |
| 945 &error); | 951 &error); |
| 946 EXPECT_TRUE(extension != NULL); | 952 EXPECT_TRUE(extension != NULL); |
| 947 EXPECT_TRUE(error.empty()); | 953 EXPECT_TRUE(error.empty()); |
| 948 } | 954 } |
| 949 | 955 |
| 950 } // namespace extensions | 956 } // namespace extensions |
| OLD | NEW |