diff --git a/js/rhino/org/mozilla/javascript/NativeGlobal.java b/js/rhino/org/mozilla/javascript/NativeGlobal.java index 9c3f1d68459..02a1cd9fe61 100644 --- a/js/rhino/org/mozilla/javascript/NativeGlobal.java +++ b/js/rhino/org/mozilla/javascript/NativeGlobal.java @@ -79,7 +79,8 @@ public class NativeGlobal { global.defineProperty("undefined", Undefined.instance, ScriptableObject.DONTENUM); - String[] errorMethods = { "EvalError", + String[] errorMethods = { "ConversionError", + "EvalError", "RangeError", "ReferenceError", "SyntaxError", diff --git a/js/rhino/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/org/mozilla/javascript/ScriptRuntime.java index 68d9307cc8b..2357a156faa 100644 --- a/js/rhino/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/org/mozilla/javascript/ScriptRuntime.java @@ -766,10 +766,12 @@ public class ScriptRuntime { catch (ClassCastException e) { start = toObject(scope, obj); } - if (start == null) { + if (start == null || start == Undefined.instance) { + String msg = start == null ? "msg.null.to.object" + : "msg.undefined"; throw NativeGlobal.constructError( - Context.getContext(), "TypeError", - ScriptRuntime.getMessage("msg.null.to.object", null), + Context.getContext(), "ConversionError", + ScriptRuntime.getMessage(msg, null), scope); } Scriptable m = start; diff --git a/js/rhino/src/org/mozilla/javascript/NativeGlobal.java b/js/rhino/src/org/mozilla/javascript/NativeGlobal.java index 9c3f1d68459..02a1cd9fe61 100644 --- a/js/rhino/src/org/mozilla/javascript/NativeGlobal.java +++ b/js/rhino/src/org/mozilla/javascript/NativeGlobal.java @@ -79,7 +79,8 @@ public class NativeGlobal { global.defineProperty("undefined", Undefined.instance, ScriptableObject.DONTENUM); - String[] errorMethods = { "EvalError", + String[] errorMethods = { "ConversionError", + "EvalError", "RangeError", "ReferenceError", "SyntaxError", diff --git a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java index 68d9307cc8b..2357a156faa 100644 --- a/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java +++ b/js/rhino/src/org/mozilla/javascript/ScriptRuntime.java @@ -766,10 +766,12 @@ public class ScriptRuntime { catch (ClassCastException e) { start = toObject(scope, obj); } - if (start == null) { + if (start == null || start == Undefined.instance) { + String msg = start == null ? "msg.null.to.object" + : "msg.undefined"; throw NativeGlobal.constructError( - Context.getContext(), "TypeError", - ScriptRuntime.getMessage("msg.null.to.object", null), + Context.getContext(), "ConversionError", + ScriptRuntime.getMessage(msg, null), scope); } Scriptable m = start;