Don't let Undefined prototype be assigned to new objects, revert to Object
instead. Also, detect Undefined prototype in hasInstance and bail. git-svn-id: svn://10.0.0.236/trunk@55123 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
498dc1681d
commit
9abcd79da8
@ -114,16 +114,20 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
FlattenedObject flat = new FlattenedObject(this);
|
||||
|
||||
Object protoProp = flat.getProperty("prototype");
|
||||
|
||||
try {
|
||||
protoProp = ((FlattenedObject)protoProp).getObject();
|
||||
} catch (ClassCastException e) {
|
||||
Object[] args = { names[0] };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.instanceof.bad.prototype", args));
|
||||
|
||||
if ((protoProp instanceof Scriptable)
|
||||
&& (protoProp != Undefined.instance)) {
|
||||
try {
|
||||
protoProp = ((FlattenedObject)protoProp).getObject();
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
} catch (ClassCastException e) { }
|
||||
}
|
||||
Object[] args = { names[0] };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.instanceof.bad.prototype", args),
|
||||
instance);
|
||||
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +142,9 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
|
||||
protected Scriptable getClassPrototype() {
|
||||
Object protoVal = get("prototype", this);
|
||||
if (protoVal == null || !(protoVal instanceof Scriptable))
|
||||
if (protoVal == null
|
||||
|| !(protoVal instanceof Scriptable)
|
||||
|| (protoVal == Undefined.instance))
|
||||
protoVal = getClassPrototype(this, "Object");
|
||||
return (Scriptable) protoVal;
|
||||
}
|
||||
|
||||
@ -114,16 +114,20 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
FlattenedObject flat = new FlattenedObject(this);
|
||||
|
||||
Object protoProp = flat.getProperty("prototype");
|
||||
|
||||
try {
|
||||
protoProp = ((FlattenedObject)protoProp).getObject();
|
||||
} catch (ClassCastException e) {
|
||||
Object[] args = { names[0] };
|
||||
throw Context.reportRuntimeError(Context.getMessage
|
||||
("msg.instanceof.bad.prototype", args));
|
||||
|
||||
if ((protoProp instanceof Scriptable)
|
||||
&& (protoProp != Undefined.instance)) {
|
||||
try {
|
||||
protoProp = ((FlattenedObject)protoProp).getObject();
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
} catch (ClassCastException e) { }
|
||||
}
|
||||
Object[] args = { names[0] };
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "TypeError",
|
||||
ScriptRuntime.getMessage("msg.instanceof.bad.prototype", args),
|
||||
instance);
|
||||
|
||||
return ScriptRuntime.jsDelegatesTo(instance, (Scriptable)protoProp);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -138,7 +142,9 @@ public class NativeFunction extends ScriptableObject implements Function {
|
||||
|
||||
protected Scriptable getClassPrototype() {
|
||||
Object protoVal = get("prototype", this);
|
||||
if (protoVal == null || !(protoVal instanceof Scriptable))
|
||||
if (protoVal == null
|
||||
|| !(protoVal instanceof Scriptable)
|
||||
|| (protoVal == Undefined.instance))
|
||||
protoVal = getClassPrototype(this, "Object");
|
||||
return (Scriptable) protoVal;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user