Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/common/extensions/extension_unittest.cc

Issue 10384072: Update to handle absolute-looking paths in manifests and still produce nice-looking URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #include "base/format_macros.h" 7 #include "base/format_macros.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 "empty.json"); 169 "empty.json");
170 EXPECT_TRUE(extension.get()); 170 EXPECT_TRUE(extension.get());
171 171
172 EXPECT_EQ(extension->url().spec() + "bar/baz.js", 172 EXPECT_EQ(extension->url().spec() + "bar/baz.js",
173 Extension::GetResourceURL(extension->url(), "bar/baz.js").spec()); 173 Extension::GetResourceURL(extension->url(), "bar/baz.js").spec());
174 EXPECT_EQ(extension->url().spec() + "baz.js", 174 EXPECT_EQ(extension->url().spec() + "baz.js",
175 Extension::GetResourceURL(extension->url(), 175 Extension::GetResourceURL(extension->url(),
176 "bar/../baz.js").spec()); 176 "bar/../baz.js").spec());
177 EXPECT_EQ(extension->url().spec() + "baz.js", 177 EXPECT_EQ(extension->url().spec() + "baz.js",
178 Extension::GetResourceURL(extension->url(), "../baz.js").spec()); 178 Extension::GetResourceURL(extension->url(), "../baz.js").spec());
179
180 // Test that absolute-looking paths ("/"-prefixed) are pasted correctly.
181 EXPECT_EQ(extension->url().spec() + "test.html",
182 extension->GetResourceURL("/test.html").spec());
179 } 183 }
180 184
181 TEST(ExtensionTest, GetAbsolutePathNoError) { 185 TEST(ExtensionTest, GetAbsolutePathNoError) {
182 scoped_refptr<Extension> extension = LoadManifestStrict("absolute_path", 186 scoped_refptr<Extension> extension = LoadManifestStrict("absolute_path",
183 "absolute.json"); 187 "absolute.json");
184 EXPECT_TRUE(extension.get()); 188 EXPECT_TRUE(extension.get());
185 std::string err; 189 std::string err;
186 EXPECT_TRUE(extension_file_util::ValidateExtension(extension.get(), &err)); 190 EXPECT_TRUE(extension_file_util::ValidateExtension(extension.get(), &err));
187 191
188 EXPECT_EQ(extension->path().AppendASCII("test.html").value(), 192 EXPECT_EQ(extension->path().AppendASCII("test.html").value(),
189 extension->GetResource("test.html").GetFilePath().value()); 193 extension->GetResource("test.html").GetFilePath().value());
190 EXPECT_EQ(extension->path().AppendASCII("test.js").value(), 194 EXPECT_EQ(extension->path().AppendASCII("test.js").value(),
191 extension->GetResource("test.js").GetFilePath().value()); 195 extension->GetResource("test.js").GetFilePath().value());
196
Aaron Boodman 2012/05/10 16:49:08 Remove spurious change.
Greg Billock 2012/05/14 16:09:55 Done.
192 } 197 }
193 198
194 TEST(ExtensionTest, LoadPageActionHelper) { 199 TEST(ExtensionTest, LoadPageActionHelper) {
195 scoped_ptr<ExtensionAction> action; 200 scoped_ptr<ExtensionAction> action;
196 201
197 // First try with an empty dictionary. 202 // First try with an empty dictionary.
198 action.reset(LoadAction("page_action_empty.json")); 203 action.reset(LoadAction("page_action_empty.json"));
199 ASSERT_TRUE(action != NULL); 204 ASSERT_TRUE(action != NULL);
200 205
201 // Now setup some values to use in the action. 206 // Now setup some values to use in the action.
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 } 964 }
960 965
961 TEST(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) { 966 TEST(ExtensionTest, GetSyncTypeExtensionWithTwoPlugins) {
962 scoped_refptr<Extension> extension( 967 scoped_refptr<Extension> extension(
963 MakeSyncTestExtension(EXTENSION, GURL(), GURL(), 968 MakeSyncTestExtension(EXTENSION, GURL(), GURL(),
964 Extension::INTERNAL, 2, FilePath())); 969 Extension::INTERNAL, 2, FilePath()));
965 if (extension) 970 if (extension)
966 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE); 971 EXPECT_EQ(extension->GetSyncType(), Extension::SYNC_TYPE_NONE);
967 } 972 }
968 #endif // !defined(OS_CHROMEOS) 973 #endif // !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698