| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 URLPattern(URLPattern::SCHEME_HTTP, "http://yahoo.com/*")); | 70 URLPattern(URLPattern::SCHEME_HTTP, "http://yahoo.com/*")); |
| 71 | 71 |
| 72 EXPECT_EQ(expected, scriptable_hosts); | 72 EXPECT_EQ(expected, scriptable_hosts); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(ContentScriptsManifestTest, ContentScriptIds) { | 75 TEST_F(ContentScriptsManifestTest, ContentScriptIds) { |
| 76 scoped_refptr<Extension> extension1 = | 76 scoped_refptr<Extension> extension1 = |
| 77 LoadAndExpectSuccess("content_script_yahoo.json"); | 77 LoadAndExpectSuccess("content_script_yahoo.json"); |
| 78 scoped_refptr<Extension> extension2 = | 78 scoped_refptr<Extension> extension2 = |
| 79 LoadAndExpectSuccess("content_script_yahoo.json"); | 79 LoadAndExpectSuccess("content_script_yahoo.json"); |
| 80 const UserScriptList& user_scripts1 = | 80 const ScriptMetadataList& user_scripts1 = |
| 81 ContentScriptsInfo::GetContentScripts(extension1.get()); | 81 ContentScriptsInfo::GetContentScripts(extension1.get()); |
| 82 ASSERT_EQ(1u, user_scripts1.size()); | 82 ASSERT_EQ(1u, user_scripts1.size()); |
| 83 int id = user_scripts1[0].id(); | 83 int id = user_scripts1[0]->id(); |
| 84 const UserScriptList& user_scripts2 = | 84 const ScriptMetadataList& user_scripts2 = |
| 85 ContentScriptsInfo::GetContentScripts(extension2.get()); | 85 ContentScriptsInfo::GetContentScripts(extension2.get()); |
| 86 ASSERT_EQ(1u, user_scripts2.size()); | 86 ASSERT_EQ(1u, user_scripts2.size()); |
| 87 // The id of the content script should be one higher than the previous. | 87 // The id of the content script should be one higher than the previous. |
| 88 EXPECT_EQ(id + 1, user_scripts2[0].id()); | 88 EXPECT_EQ(id + 1, user_scripts2[0]->id()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(ContentScriptsManifestTest, FailLoadingNonUTF8Scripts) { | 91 TEST_F(ContentScriptsManifestTest, FailLoadingNonUTF8Scripts) { |
| 92 base::FilePath install_dir; | 92 base::FilePath install_dir; |
| 93 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); | 93 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir)); |
| 94 install_dir = install_dir.AppendASCII("extensions") | 94 install_dir = install_dir.AppendASCII("extensions") |
| 95 .AppendASCII("bad") | 95 .AppendASCII("bad") |
| 96 .AppendASCII("bad_encoding"); | 96 .AppendASCII("bad_encoding"); |
| 97 | 97 |
| 98 std::string error; | 98 std::string error; |
| 99 scoped_refptr<Extension> extension(file_util::LoadExtension( | 99 scoped_refptr<Extension> extension(file_util::LoadExtension( |
| 100 install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); | 100 install_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); |
| 101 ASSERT_TRUE(extension.get() == NULL); | 101 ASSERT_TRUE(extension.get() == NULL); |
| 102 ASSERT_STREQ( | 102 ASSERT_STREQ( |
| 103 "Could not load file 'bad_encoding.js' for content script. " | 103 "Could not load file 'bad_encoding.js' for content script. " |
| 104 "It isn't UTF-8 encoded.", | 104 "It isn't UTF-8 encoded.", |
| 105 error.c_str()); | 105 error.c_str()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace extensions | 108 } // namespace extensions |
| OLD | NEW |