diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 20:42:31 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-11 20:42:31 +0000 |
commit | 60f0c4072e004002b87a25f6e5681557848d3060 (patch) | |
tree | 78214e53483388daafd818499f710fd656861290 /chrome/browser/extensions/user_script_master_unittest.cc | |
parent | cc70801856ea67a98ac0ff0b9064a6b56e67288d (diff) | |
download | chromium_src-60f0c4072e004002b87a25f6e5681557848d3060.zip chromium_src-60f0c4072e004002b87a25f6e5681557848d3060.tar.gz chromium_src-60f0c4072e004002b87a25f6e5681557848d3060.tar.bz2 |
Fix a bug where we don't recognize user script declarations
if they aren't at the beginning of a line. Greasemonkey
allows this.
BUG=31076
TEST=Install http://userscripts.org/scripts/review/29876. The
install dialog should say 'Sans-serif default', not
29876.user.js.
Review URL: http://codereview.chromium.org/545002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35938 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/user_script_master_unittest.cc')
-rw-r--r-- | chrome/browser/extensions/user_script_master_unittest.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/chrome/browser/extensions/user_script_master_unittest.cc b/chrome/browser/extensions/user_script_master_unittest.cc index 562f4cf..ef5ac2f 100644 --- a/chrome/browser/extensions/user_script_master_unittest.cc +++ b/chrome/browser/extensions/user_script_master_unittest.cc @@ -240,3 +240,22 @@ TEST_F(UserScriptMasterTest, Parse7) { EXPECT_EQ("http://*.mail.google.com/*", script.url_patterns()[0].GetAsString()); } + +TEST_F(UserScriptMasterTest, Parse8) { + // Greasemonkey allows there to be any leading text before the comment marker. + const std::string text( + "// ==UserScript==\n" + "adsasdfasf// @name hello\n" + " // @description\twiggity woo\n" + "\t// @match \t http://mail.yahoo.com/*\n" + "// ==/UserScript==\n"); + + UserScript script; + EXPECT_TRUE(UserScriptMaster::ScriptReloader::ParseMetadataHeader( + text, &script)); + ASSERT_EQ("hello", script.name()); + ASSERT_EQ("wiggity woo", script.description()); + ASSERT_EQ(1U, script.url_patterns().size()); + EXPECT_EQ("http://mail.yahoo.com/*", + script.url_patterns()[0].GetAsString()); +} |