jscript: Implement Object.prototype.isPrototypeOf method.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6c8500d05e
commit
87ac636cbb
|
@ -196,8 +196,24 @@ static HRESULT Object_propertyIsEnumerable(script_ctx_t *ctx, vdisp_t *jsthis, W
|
||||||
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
static HRESULT Object_isPrototypeOf(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv,
|
||||||
jsval_t *r)
|
jsval_t *r)
|
||||||
{
|
{
|
||||||
FIXME("\n");
|
jsdisp_t *jsdisp;
|
||||||
return E_NOTIMPL;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
if(!r)
|
||||||
|
return S_OK;
|
||||||
|
|
||||||
|
if(argc && is_jsdisp(jsthis) && is_object_instance(argv[0]) && (jsdisp = to_jsdisp(get_object(argv[0])))) {
|
||||||
|
while(jsdisp->prototype) {
|
||||||
|
if(jsdisp->prototype == jsthis->u.jsdisp) {
|
||||||
|
ret = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
jsdisp = jsdisp->prototype;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*r = jsval_bool(ret);
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static HRESULT Object_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
static HRESULT Object_get_value(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
|
||||||
|
|
|
@ -1679,14 +1679,28 @@ tmp = new instanceOfTest();
|
||||||
ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
|
ok((tmp instanceof instanceOfTest) === true, "tmp is not instance of instanceOfTest");
|
||||||
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
||||||
ok((tmp instanceof String) === false, "tmp is instance of String");
|
ok((tmp instanceof String) === false, "tmp is instance of String");
|
||||||
|
ok(instanceOfTest.isPrototypeOf(tmp) === false, "instanceOfTest is prototype of tmp");
|
||||||
|
ok(instanceOfTest.prototype.isPrototypeOf(tmp) === true, "instanceOfTest.prototype is not prototype of tmp");
|
||||||
|
ok(Object.prototype.isPrototypeOf(tmp) === true, "Object.prototype is not prototype of tmp");
|
||||||
|
|
||||||
instanceOfTest.prototype = new Object();
|
instanceOfTest.prototype = new Object();
|
||||||
ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
|
ok((tmp instanceof instanceOfTest) === false, "tmp is instance of instanceOfTest");
|
||||||
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
ok((tmp instanceof Object) === true, "tmp is not instance of Object");
|
||||||
|
ok(instanceOfTest.prototype.isPrototypeOf(tmp) === false, "instanceOfTest.prototype is prototype of tmp");
|
||||||
|
|
||||||
ok((1 instanceof Object) === false, "1 is instance of Object");
|
ok((1 instanceof Object) === false, "1 is instance of Object");
|
||||||
ok((false instanceof Boolean) === false, "false is instance of Boolean");
|
ok((false instanceof Boolean) === false, "false is instance of Boolean");
|
||||||
ok(("" instanceof Object) === false, "'' is instance of Object");
|
ok(("" instanceof Object) === false, "'' is instance of Object");
|
||||||
|
ok(Number.prototype.isPrototypeOf(1) === false, "Number.prototype is prototype of 1");
|
||||||
|
ok(String.prototype.isPrototypeOf("") === false, "String.prototype is prototype of ''");
|
||||||
|
|
||||||
|
ok(tmp.isPrototypeOf(null) === false, "tmp is prototype of null");
|
||||||
|
ok(tmp.isPrototypeOf(undefined) === false, "tmp is prototype of undefined");
|
||||||
|
ok(Object.prototype.isPrototypeOf.call(tmp) === false, "tmp is prototype of no argument");
|
||||||
|
ok(Object.prototype.isPrototypeOf.call(test, Object) === false, "test is prototype of Object");
|
||||||
|
ok(Object.prototype.isPrototypeOf.call(testObj, Object) === false, "testObj is prototype of Object");
|
||||||
|
ok(Object.prototype.isPrototypeOf(test) === false, "Object.prototype is prototype of test");
|
||||||
|
ok(Object.prototype.isPrototypeOf(testObj) === false, "Object.prototype is prototype of testObj");
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
ok((arguments instanceof Object) === true, "argument is not instance of Object");
|
ok((arguments instanceof Object) === true, "argument is not instance of Object");
|
||||||
|
|
Loading…
Reference in New Issue