diff --git a/src/org/mozilla/javascript/AbstractEcmaObjectOperations.java b/src/org/mozilla/javascript/AbstractEcmaObjectOperations.java index 717d81fa00..7993935b6f 100644 --- a/src/org/mozilla/javascript/AbstractEcmaObjectOperations.java +++ b/src/org/mozilla/javascript/AbstractEcmaObjectOperations.java @@ -34,7 +34,7 @@ enum INTEGRITY_LEVEL { * @see */ static boolean hasOwnProperty(Context cx, Object o, Object property) { - ScriptableObject obj = ScriptableObject.ensureScriptableObject(o); + Scriptable obj = ScriptableObject.ensureScriptable(o); boolean result; if (property instanceof Symbol) { result = ScriptableObject.ensureSymbolScriptable(o).has((Symbol) property, obj); diff --git a/testsrc/org/mozilla/javascript/tests/NativeObjectTest.java b/testsrc/org/mozilla/javascript/tests/NativeObjectTest.java index a8e4122799..c9710d7dce 100644 --- a/testsrc/org/mozilla/javascript/tests/NativeObjectTest.java +++ b/testsrc/org/mozilla/javascript/tests/NativeObjectTest.java @@ -4,10 +4,13 @@ package org.mozilla.javascript.tests; +import static org.junit.Assert.assertTrue; + import org.junit.Assert; import org.junit.Test; import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; +import org.mozilla.javascript.ScriptableObject; public class NativeObjectTest { @@ -83,4 +86,22 @@ public void getOwnPropertyDescriptorAttributes_captureStackTrace() throws Except Assert.assertEquals("true true false", result); Context.exit(); } + + public static class JavaObj { + public String name = "test"; + } + + @Test + public void testNativeJavaObject_hasOwnProperty() { + Context cx = Context.enter(); + try { + Scriptable scope = cx.initStandardObjects(); + ScriptableObject.putProperty(scope, "javaObj", Context.javaToJS(new JavaObj(), scope)); + Object result = cx.evaluateString(scope, "Object.prototype.hasOwnProperty.call(javaObj, \"name\");", "", 1, + null); + assertTrue((Boolean) result); + } finally { + Context.exit(); + } + } }