diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 03:37:11 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 03:37:11 +0000 |
commit | ca77d3575f497bcf0d2ab16a026c78fef6b6ac7a (patch) | |
tree | 9e53dc92fca7d2d3d50cd555583b082697e343f4 /chrome/renderer/user_script_slave.cc | |
parent | 540ddbbc036e706a3c038418eba364a3422e835b (diff) | |
download | chromium_src-ca77d3575f497bcf0d2ab16a026c78fef6b6ac7a.zip chromium_src-ca77d3575f497bcf0d2ab16a026c78fef6b6ac7a.tar.gz chromium_src-ca77d3575f497bcf0d2ab16a026c78fef6b6ac7a.tar.bz2 |
TBR: Fix error line numbers.
There were two problems here:
a) We were adding an extra line number for the function
wrapper, but the wrapper didn't include a newline.
b) WebKit actually expects these to be one-based, not
zero-based.
So we were ending up two off.
Review URL: http://codereview.chromium.org/18199
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8273 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/user_script_slave.cc')
-rw-r--r-- | chrome/renderer/user_script_slave.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index d227d5e..a0877d9 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -13,7 +13,7 @@ // These two strings are injected before and after the Greasemonkey API and // user script to wrap it in an anonymous scope. -static const char kUserScriptHead[] = "(function (unsafeWindow) {"; +static const char kUserScriptHead[] = "(function (unsafeWindow) {\n"; static const char kUserScriptTail[] = "\n})(window);"; // UserScript @@ -73,8 +73,10 @@ UserScriptSlave::UserScriptSlave() pos++; } - // Add one more line to account for the function that wraps everything. - user_script_start_line_++; + // NOTE: There is actually one extra line in the injected script because the + // function header includes a newline as well. But WebKit expects the + // numbering to be one-based, not zero-based, so actually *not* accounting for + // this extra line ends us up with the right offset. } bool UserScriptSlave::UpdateScripts(base::SharedMemoryHandle shared_memory) { |