| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package org.mozilla.javascript.tests; |
| 6 |
|
| 7 |
import java.io.InputStreamReader; |
| 8 |
|
| 9 |
import junit.framework.TestCase; |
| 10 |
|
| 11 |
import org.mozilla.javascript.Context; |
| 12 |
import org.mozilla.javascript.Script; |
| 13 |
import org.mozilla.javascript.ScriptRuntime; |
| 14 |
import org.mozilla.javascript.Scriptable; |
| 15 |
|
| 16 |
public class Issue176Test extends TestCase { |
| 17 |
|
| 18 |
|
| 19 |
Context cx; |
| 20 |
Scriptable scope; |
| 21 |
|
| 22 |
public void testThrowing() throws Exception { |
| 23 |
cx = Context.enter(); |
| 24 |
try { |
| 25 |
Script script = cx.compileReader(new InputStreamReader( |
| 26 |
Bug482203Test.class.getResourceAsStream("Issue176.js")), |
| 27 |
"Issue176.js", 1, null); |
| 28 |
scope = cx.initStandardObjects(); |
| 29 |
scope.put("host", scope, this); |
| 30 |
script.exec(cx, scope); |
| 31 |
} finally { |
| 32 |
Context.exit(); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
public void throwError(String msg) { |
| 38 |
throw ScriptRuntime.throwError(cx, scope, msg); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
public void throwCustomError(String constr, String msg) { |
| 43 |
throw ScriptRuntime.throwCustomError(cx, scope, constr, msg); |
| 44 |
} |
| 45 |
|
| 46 |
} |