therubyrhino 1.73.4 → 1.73.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ gemspec
4
4
 
5
5
  # NOTE: some specs might be excluded @see #spec/spec_helper.rb
6
6
  gem 'redjs', :git => 'git://github.com/cowboyd/redjs.git', :group => :test,
7
- :ref => "8656639e99d52b8d5414250db2e27db4bb531506"
7
+ :ref => "b212e50ad347c0d32e53f28d0d627df6b8077e68"
@@ -1,3 +1,10 @@
1
+ === 1.73.5 2012-07-25
2
+
3
+ * #to_s functionName typo fix for org.mozilla.javascript.ScriptStackElement
4
+ * make sure thrown values are correctly raised from inside JS functions
5
+ * a better #inspect for native rhino objects
6
+ * correct JavaScript error handling for Function#apply
7
+
1
8
  === 1.73.4 2012-05-21
2
9
 
3
10
  * allow rhino.jar path overrides with Rhino::JAR_PATH
@@ -85,6 +85,13 @@ class Java::OrgMozillaJavascript::ScriptableObject
85
85
  to_h.to_json(*args)
86
86
  end
87
87
 
88
+ # make sure inspect prints the same as to_s (on --1.8)
89
+ # otherwise JRuby might play it a little smart e.g. :
90
+ # "#<#<Class:0xd790a8>:0x557c15>" instead of "Error: bar"
91
+ def inspect
92
+ toString
93
+ end
94
+
88
95
  # Delegate methods to JS object if possible when called from Ruby.
89
96
  def method_missing(name, *args)
90
97
  name_str = name.to_s
@@ -159,6 +166,8 @@ class Java::OrgMozillaJavascript::BaseFunction
159
166
  # TODO can't pass Undefined.instance as this - it's not a Scriptable !?
160
167
  this = Rhino::JS::ScriptRuntime.getGlobal(context)
161
168
  __call__(context, scope, this, Rhino.args_to_javascript(args, scope))
169
+ rescue Rhino::JS::JavaScriptException => e
170
+ raise Rhino::JSError.new(e)
162
171
  ensure
163
172
  Rhino::JS::Context.exit
164
173
  end
@@ -176,6 +185,8 @@ class Java::OrgMozillaJavascript::BaseFunction
176
185
  def new(*args)
177
186
  context = Rhino::JS::Context.enter; scope = current_scope(context)
178
187
  construct(context, scope, Rhino.args_to_javascript(args, scope))
188
+ rescue Rhino::JS::JavaScriptException => e
189
+ raise Rhino::JSError.new(e)
179
190
  ensure
180
191
  Rhino::JS::Context.exit
181
192
  end
@@ -189,6 +200,8 @@ class Java::OrgMozillaJavascript::BaseFunction
189
200
  context = Rhino::JS::Context.enter; scope = current_scope(context)
190
201
  args = Rhino.args_to_javascript(args, scope)
191
202
  __call__(context, scope, Rhino.to_javascript(this), args)
203
+ rescue Rhino::JS::JavaScriptException => e
204
+ raise Rhino::JSError.new(e)
192
205
  ensure
193
206
  Rhino::JS::Context.exit
194
207
  end
@@ -205,7 +218,7 @@ class Java::OrgMozillaJavascript::ScriptStackElement
205
218
  def to_s
206
219
  str = "at #{fileName}"
207
220
  str << ':' << lineNumber.to_s if lineNumber > -1
208
- str << " (#{funcionName})" if functionName
221
+ str << " (#{functionName})" if functionName
209
222
  str
210
223
  end
211
224
 
@@ -1,4 +1,3 @@
1
-
2
1
  module Rhino
3
- VERSION = "1.73.4"
2
+ VERSION = "1.73.5"
4
3
  end
@@ -93,6 +93,18 @@ describe Rhino::JSError do
93
93
  end
94
94
  end
95
95
 
96
+ it "contains function name in javascript backtrace" do
97
+ begin
98
+ Rhino::Context.eval "function fortyTwo() { throw 42 }\n fortyTwo()"
99
+ rescue => e
100
+ e.javascript_backtrace.size.should == 2
101
+ e.javascript_backtrace[0].should == "at <eval>:1 (fortyTwo)"
102
+ e.javascript_backtrace[1].should == "at <eval>:2"
103
+ else
104
+ fail "expected to rescue"
105
+ end
106
+ end
107
+
96
108
  it "backtrace starts with the javascript part" do
97
109
  begin
98
110
  Rhino::Context.eval "throw 42"
@@ -115,5 +127,18 @@ describe Rhino::JSError do
115
127
  fail "expected to rescue"
116
128
  end
117
129
  end
130
+
131
+ it "raises correct error from function#apply" do
132
+ begin
133
+ context = Rhino::Context.new
134
+ context.eval "function foo() { throw 'bar' }"
135
+ context['foo'].apply(nil)
136
+ rescue => e
137
+ e.should be_a Rhino::JSError
138
+ e.value.should == 'bar'
139
+ else
140
+ fail "expected to rescue"
141
+ end
142
+ end
118
143
 
119
144
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: therubyrhino
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.73.4
5
+ version: 1.73.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Charles Lowell
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-05-21 00:00:00 Z
13
+ date: 2012-07-25 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake