| Index: chrome/common/extensions/extension_file_util_unittest.cc
|
| diff --git a/chrome/common/extensions/extension_file_util_unittest.cc b/chrome/common/extensions/extension_file_util_unittest.cc
|
| index 3271595e6189d735099c96874d07d30c0b1d6e9e..143c5befc77fa28210e60d50836b47cadeb7c18b 100644
|
| --- a/chrome/common/extensions/extension_file_util_unittest.cc
|
| +++ b/chrome/common/extensions/extension_file_util_unittest.cc
|
| @@ -233,115 +233,6 @@ TEST_F(ExtensionFileUtilTest, FailLoadingNonUTF8Scripts) {
|
| error.c_str());
|
| }
|
|
|
| -TEST_F(ExtensionFileUtilTest, ExtensionURLToRelativeFilePath) {
|
| -#define URL_PREFIX "chrome-extension://extension-id/"
|
| - struct TestCase {
|
| - const char* url;
|
| - const char* expected_relative_path;
|
| - } test_cases[] = {
|
| - { URL_PREFIX "simple.html",
|
| - "simple.html" },
|
| - { URL_PREFIX "directory/to/file.html",
|
| - "directory/to/file.html" },
|
| - { URL_PREFIX "escape%20spaces.html",
|
| - "escape spaces.html" },
|
| - { URL_PREFIX "%C3%9Cber.html",
|
| - "\xC3\x9C" "ber.html" },
|
| -#if defined(OS_WIN)
|
| - { URL_PREFIX "C%3A/simple.html",
|
| - "" },
|
| -#endif
|
| - { URL_PREFIX "////simple.html",
|
| - "simple.html" },
|
| - { URL_PREFIX "/simple.html",
|
| - "simple.html" },
|
| - { URL_PREFIX "\\simple.html",
|
| - "simple.html" },
|
| - { URL_PREFIX "\\\\foo\\simple.html",
|
| - "foo/simple.html" },
|
| - };
|
| -#undef URL_PREFIX
|
| -
|
| - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
| - GURL url(test_cases[i].url);
|
| - base::FilePath expected_path =
|
| - base::FilePath::FromUTF8Unsafe(test_cases[i].expected_relative_path);
|
| - base::FilePath actual_path =
|
| - extension_file_util::ExtensionURLToRelativeFilePath(url);
|
| - EXPECT_FALSE(actual_path.IsAbsolute()) <<
|
| - " For the path " << actual_path.value();
|
| - EXPECT_EQ(expected_path.value(), actual_path.value()) <<
|
| - " For the path " << url;
|
| - }
|
| -}
|
| -
|
| -TEST_F(ExtensionFileUtilTest, ExtensionResourceURLToFilePath) {
|
| - // Setup filesystem for testing.
|
| - base::FilePath root_path;
|
| - ASSERT_TRUE(file_util::CreateNewTempDirectory(
|
| - base::FilePath::StringType(), &root_path));
|
| - root_path = base::MakeAbsoluteFilePath(root_path);
|
| - ASSERT_FALSE(root_path.empty());
|
| -
|
| - base::FilePath api_path = root_path.Append(FILE_PATH_LITERAL("apiname"));
|
| - ASSERT_TRUE(file_util::CreateDirectory(api_path));
|
| -
|
| - const char data[] = "Test Data";
|
| - base::FilePath resource_path = api_path.Append(FILE_PATH_LITERAL("test.js"));
|
| - ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data)));
|
| - resource_path = api_path.Append(FILE_PATH_LITERAL("escape spaces.js"));
|
| - ASSERT_TRUE(file_util::WriteFile(resource_path, data, sizeof(data)));
|
| -
|
| -#ifdef FILE_PATH_USES_WIN_SEPARATORS
|
| -#define SEP "\\"
|
| -#else
|
| -#define SEP "/"
|
| -#endif
|
| -#define URL_PREFIX "chrome-extension-resource://"
|
| - struct TestCase {
|
| - const char* url;
|
| - const base::FilePath::CharType* expected_path;
|
| - } test_cases[] = {
|
| - { URL_PREFIX "apiname/test.js",
|
| - FILE_PATH_LITERAL("test.js") },
|
| - { URL_PREFIX "/apiname/test.js",
|
| - FILE_PATH_LITERAL("test.js") },
|
| - // Test % escape
|
| - { URL_PREFIX "apiname/%74%65st.js",
|
| - FILE_PATH_LITERAL("test.js") },
|
| - { URL_PREFIX "apiname/escape%20spaces.js",
|
| - FILE_PATH_LITERAL("escape spaces.js") },
|
| - // Test file does not exist.
|
| - { URL_PREFIX "apiname/directory/to/file.js",
|
| - NULL },
|
| - // Test apiname/../../test.js
|
| - { URL_PREFIX "apiname/../../test.js",
|
| - FILE_PATH_LITERAL("test.js") },
|
| - { URL_PREFIX "apiname/..%2F../test.js",
|
| - NULL },
|
| - { URL_PREFIX "apiname/f/../../../test.js",
|
| - FILE_PATH_LITERAL("test.js") },
|
| - { URL_PREFIX "apiname/f%2F..%2F..%2F../test.js",
|
| - NULL },
|
| - };
|
| -#undef SEP
|
| -#undef URL_PREFIX
|
| -
|
| - for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) {
|
| - GURL url(test_cases[i].url);
|
| - base::FilePath expected_path;
|
| - if (test_cases[i].expected_path)
|
| - expected_path = root_path.Append(FILE_PATH_LITERAL("apiname")).Append(
|
| - test_cases[i].expected_path);
|
| - base::FilePath actual_path =
|
| - extension_file_util::ExtensionResourceURLToFilePath(url, root_path);
|
| - EXPECT_EQ(expected_path.value(), actual_path.value()) <<
|
| - " For the path " << url;
|
| - }
|
| - // Remove temp files.
|
| - ASSERT_TRUE(base::DeleteFile(root_path, true));
|
| -}
|
| -
|
| static scoped_refptr<Extension> LoadExtensionManifest(
|
| base::DictionaryValue* manifest,
|
| const base::FilePath& manifest_dir,
|
|
|