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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
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/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 script.url_patterns().begin()->GetAsString()); | 75 script.url_patterns().begin()->GetAsString()); |
76 ASSERT_EQ(1u, script.exclude_url_patterns().patterns().size()); | 76 ASSERT_EQ(1u, script.exclude_url_patterns().patterns().size()); |
77 EXPECT_EQ("http://www.google.com/foo*", | 77 EXPECT_EQ("http://www.google.com/foo*", |
78 script.exclude_url_patterns().begin()->GetAsString()); | 78 script.exclude_url_patterns().begin()->GetAsString()); |
79 EXPECT_TRUE(script.emulate_greasemonkey()); | 79 EXPECT_TRUE(script.emulate_greasemonkey()); |
80 | 80 |
81 // Make sure the files actually exist on disk. | 81 // Make sure the files actually exist on disk. |
82 EXPECT_TRUE(base::PathExists( | 82 EXPECT_TRUE(base::PathExists( |
83 extension->path().Append(script.js_scripts()[0].relative_path()))); | 83 extension->path().Append(script.js_scripts()[0].relative_path()))); |
84 EXPECT_TRUE(base::PathExists( | 84 EXPECT_TRUE(base::PathExists( |
85 extension->path().Append(kManifestFilename))); | 85 extension->path().Append(filenames::kManifestFilename))); |
86 } | 86 } |
87 | 87 |
88 TEST_F(ExtensionFromUserScript, NoMetadata) { | 88 TEST_F(ExtensionFromUserScript, NoMetadata) { |
89 base::ScopedTempDir extensions_dir; | 89 base::ScopedTempDir extensions_dir; |
90 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); | 90 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); |
91 | 91 |
92 base::FilePath test_file; | 92 base::FilePath test_file; |
93 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file)); | 93 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file)); |
94 test_file = test_file.AppendASCII("extensions") | 94 test_file = test_file.AppendASCII("extensions") |
95 .AppendASCII("user_script_no_metadata.user.js"); | 95 .AppendASCII("user_script_no_metadata.user.js"); |
(...skipping 28 matching lines...) Expand all Loading... |
124 | 124 |
125 URLPatternSet expected; | 125 URLPatternSet expected; |
126 AddPattern(&expected, "http://*/*"); | 126 AddPattern(&expected, "http://*/*"); |
127 AddPattern(&expected, "https://*/*"); | 127 AddPattern(&expected, "https://*/*"); |
128 EXPECT_EQ(expected, script.url_patterns()); | 128 EXPECT_EQ(expected, script.url_patterns()); |
129 | 129 |
130 // Make sure the files actually exist on disk. | 130 // Make sure the files actually exist on disk. |
131 EXPECT_TRUE(base::PathExists( | 131 EXPECT_TRUE(base::PathExists( |
132 extension->path().Append(script.js_scripts()[0].relative_path()))); | 132 extension->path().Append(script.js_scripts()[0].relative_path()))); |
133 EXPECT_TRUE(base::PathExists( | 133 EXPECT_TRUE(base::PathExists( |
134 extension->path().Append(kManifestFilename))); | 134 extension->path().Append(filenames::kManifestFilename))); |
135 } | 135 } |
136 | 136 |
137 TEST_F(ExtensionFromUserScript, NotUTF8) { | 137 TEST_F(ExtensionFromUserScript, NotUTF8) { |
138 base::ScopedTempDir extensions_dir; | 138 base::ScopedTempDir extensions_dir; |
139 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); | 139 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); |
140 | 140 |
141 base::FilePath test_file; | 141 base::FilePath test_file; |
142 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file)); | 142 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file)); |
143 test_file = test_file.AppendASCII("extensions") | 143 test_file = test_file.AppendASCII("extensions") |
144 .AppendASCII("user_script_not_utf8.user.js"); | 144 .AppendASCII("user_script_not_utf8.user.js"); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 EXPECT_EQ(Manifest::TYPE_USER_SCRIPT, extension->GetType()); | 252 EXPECT_EQ(Manifest::TYPE_USER_SCRIPT, extension->GetType()); |
253 | 253 |
254 // Validate run location. | 254 // Validate run location. |
255 ASSERT_EQ(1u, ContentScriptsInfo::GetContentScripts(extension.get()).size()); | 255 ASSERT_EQ(1u, ContentScriptsInfo::GetContentScripts(extension.get()).size()); |
256 const UserScript& script = | 256 const UserScript& script = |
257 ContentScriptsInfo::GetContentScripts(extension.get())[0]; | 257 ContentScriptsInfo::GetContentScripts(extension.get())[0]; |
258 EXPECT_EQ(UserScript::DOCUMENT_IDLE, script.run_location()); | 258 EXPECT_EQ(UserScript::DOCUMENT_IDLE, script.run_location()); |
259 } | 259 } |
260 | 260 |
261 } // namespace extensions | 261 } // namespace extensions |
OLD | NEW |