From c267edf74b5e8fba75e2191dc70aeb11f11edce0 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 13 Dec 2012 01:15:44 +0100 Subject: [PATCH] Fix Object.prototype.isPrototypeOf() Implement the method according to spec (15.2.4.6) Change-Id: I84b943366dcb1048966d4ae2f60bcbf01c99e7ea Reviewed-by: Simon Hausmann --- qv4ecmaobjects.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qv4ecmaobjects.cpp b/qv4ecmaobjects.cpp index daee93a..bb3cd5f 100644 --- a/qv4ecmaobjects.cpp +++ b/qv4ecmaobjects.cpp @@ -823,9 +823,14 @@ Value ObjectPrototype::method_isPrototypeOf(ExecutionContext *ctx) if (! V.isObject()) return Value::fromBoolean(false); - Value O = ctx->thisObject.toObject(ctx); + Object *O = ctx->thisObject.toObject(ctx).objectValue(); Object *proto = V.objectValue()->prototype; - return Value::fromBoolean(proto && O.objectValue() == proto); + while (proto) { + if (O == proto) + return Value::fromBoolean(true); + proto = proto->prototype; + } + return Value::fromBoolean(false); } Value ObjectPrototype::method_propertyIsEnumerable(ExecutionContext *ctx) -- 2.7.4