summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 20:38:43 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-20 20:38:43 +0000
commite66de89ab98e011edcda88974421417eec153f9a (patch)
treeb080787323749397a19008b0d6fdaf5db1c84d94
parent3be0198c07fd435236c9482fc6c5bc3c00ac8ba6 (diff)
downloadchromium_src-e66de89ab98e011edcda88974421417eec153f9a.zip
chromium_src-e66de89ab98e011edcda88974421417eec153f9a.tar.gz
chromium_src-e66de89ab98e011edcda88974421417eec153f9a.tar.bz2
Allow multiple js files per content script. Thanks to georged for making this so easy.
Review URL: http://codereview.chromium.org/42438 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12210 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extension.cc11
-rw-r--r--chrome/browser/extensions/extension.h1
-rw-r--r--chrome/browser/extensions/extension_unittest.cc7
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc13
-rw-r--r--chrome/test/data/extensions/good/extension1/1/manifest.json6
-rw-r--r--chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json6
6 files changed, 8 insertions, 36 deletions
diff --git a/chrome/browser/extensions/extension.cc b/chrome/browser/extensions/extension.cc
index 924c4ed..bb5ec23 100644
--- a/chrome/browser/extensions/extension.cc
+++ b/chrome/browser/extensions/extension.cc
@@ -50,9 +50,6 @@ const char* Extension::kInvalidFormatVersionError =
"Required value 'format_version' is missing or invalid.";
const char* Extension::kInvalidIdError =
"Required value 'id' is missing or invalid.";
-const char* Extension::kInvalidJsCountError =
- "Invalid value for 'content_scripts[*].js. Only one js file is currently "
- "supported per-content script.";
const char* Extension::kInvalidJsError =
"Invalid value for 'content_scripts[*].js[*]'.";
const char* Extension::kInvalidJsListError =
@@ -274,14 +271,6 @@ bool Extension::LoadUserScriptHelper(const DictionaryValue* content_script,
return false;
}
- // NOTE: Only one js file is supported for now.
- // TODO(aa): Add support for multiple js files.
- if (js && js->GetSize() != 1) {
- *error = FormatErrorMessage(kInvalidJsCountError,
- IntToString(definition_index));
- return false;
- }
-
if (js) {
for (size_t script_index = 0; script_index < js->GetSize();
++script_index) {
diff --git a/chrome/browser/extensions/extension.h b/chrome/browser/extensions/extension.h
index fafe33a..7a7d8ae 100644
--- a/chrome/browser/extensions/extension.h
+++ b/chrome/browser/extensions/extension.h
@@ -57,7 +57,6 @@ class Extension {
static const char* kInvalidDescriptionError;
static const char* kInvalidFormatVersionError;
static const char* kInvalidIdError;
- static const char* kInvalidJsCountError;
static const char* kInvalidJsError;
static const char* kInvalidJsListError;
static const char* kInvalidManifestError;
diff --git a/chrome/browser/extensions/extension_unittest.cc b/chrome/browser/extensions/extension_unittest.cc
index 646a0f4..e78e9d2 100644
--- a/chrome/browser/extensions/extension_unittest.cc
+++ b/chrome/browser/extensions/extension_unittest.cc
@@ -158,13 +158,6 @@ TEST(ExtensionTest, InitFromValueInvalid) {
EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsError));
- // Test too many file elements (more than one not yet supported)
- files->Set(0, Value::CreateStringValue("foo.js"));
- files->Set(1, Value::CreateStringValue("bar.js"));
- EXPECT_FALSE(extension.InitFromValue(*input_value, &error));
- EXPECT_TRUE(MatchPattern(error, Extension::kInvalidJsCountError));
-
- // Remove all script files
user_script->Remove(Extension::kJsKey, NULL);
// Test the css element
user_script->Set(Extension::kCssKey, Value::CreateIntegerValue(42));
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index 493551c3..c253848 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -169,22 +169,21 @@ TEST_F(ExtensionsServiceTest, LoadAllExtensionsFromDirectorySuccess) {
Extension* extension = frontend->extensions()->at(0);
const UserScriptList& scripts = extension->content_scripts();
- ASSERT_EQ(3u, scripts.size());
+ ASSERT_EQ(2u, scripts.size());
EXPECT_EQ(2u, scripts[0].url_patterns().size());
EXPECT_EQ("http://*.google.com/*",
scripts[0].url_patterns()[0].GetAsString());
EXPECT_EQ("https://*.google.com/*",
scripts[0].url_patterns()[1].GetAsString());
+ EXPECT_EQ(2u, scripts[0].js_scripts().size());
EXPECT_EQ(extension->path().AppendASCII("script1.js").value(),
scripts[0].js_scripts()[0].path().value());
- EXPECT_EQ(1u, scripts[1].url_patterns().size());
- EXPECT_EQ("http://*.yahoo.com/*", scripts[1].url_patterns()[0].GetAsString());
EXPECT_EQ(extension->path().AppendASCII("script2.js").value(),
- scripts[1].js_scripts()[0].path().value());
- EXPECT_EQ(1u, scripts[2].url_patterns().size());
- EXPECT_EQ("http://*.news.com/*", scripts[2].url_patterns()[0].GetAsString());
+ scripts[0].js_scripts()[1].path().value());
+ EXPECT_EQ(1u, scripts[1].url_patterns().size());
+ EXPECT_EQ("http://*.news.com/*", scripts[1].url_patterns()[0].GetAsString());
EXPECT_EQ(extension->path().AppendASCII("js_files").AppendASCII("script3.js")
- .value(), scripts[2].js_scripts()[0].path().value());
+ .value(), scripts[1].js_scripts()[0].path().value());
EXPECT_EQ(std::string("10123456789abcdef0123456789abcdef0123456"),
frontend->extensions()->at(1)->id());
diff --git a/chrome/test/data/extensions/good/extension1/1/manifest.json b/chrome/test/data/extensions/good/extension1/1/manifest.json
index e64b1d0..16f7d6b 100644
--- a/chrome/test/data/extensions/good/extension1/1/manifest.json
+++ b/chrome/test/data/extensions/good/extension1/1/manifest.json
@@ -8,14 +8,10 @@
"content_scripts": [
{
"matches": ["http://*.google.com/*", "https://*.google.com/*"],
- "js": ["script1.js"],
+ "js": ["script1.js", "script2.js"],
"css": ["style1.css", "style2.css", "style2.css"]
},
{
- "matches": ["http://*.yahoo.com/*"],
- "js": ["script2.js"]
- },
- {
"matches": ["http://*.news.com/*"],
"js": ["js_files/script3.js"]
}
diff --git a/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json b/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json
index e4e4b4d..712ca55 100644
--- a/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json
+++ b/chrome/test/data/extensions/ui/create_extension_detail_value_expected_output/good-extension1.json
@@ -5,14 +5,10 @@
"content_scripts": [
{
"matches": ["http://*.google.com/*", "https://*.google.com/*"],
- "js": ["script1.js"],
+ "js": ["script1.js", "script2.js"],
"css": ["style1.css", "style2.css", "style2.css"]
},
{
- "matches": ["http://*.yahoo.com/*"],
- "js": ["script2.js"]
- },
- {
"matches": ["http://*.news.com/*"],
"js": ["js_files/script3.js"]
}