jscript: Add Object.isExtensible implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7750753758
commit
7dadcaf819
|
@ -693,12 +693,34 @@ static HRESULT Object_preventExtensions(script_ctx_t *ctx, vdisp_t *jsthis, WORD
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT Object_isExtensible(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags, unsigned argc, jsval_t *argv, jsval_t *r)
|
||||||
|
{
|
||||||
|
jsdisp_t *obj;
|
||||||
|
|
||||||
|
if(!argc || !is_object_instance(argv[0]) || !get_object(argv[0])) {
|
||||||
|
WARN("argument is not an object\n");
|
||||||
|
return JS_E_OBJECT_EXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE("(%s)\n", debugstr_jsval(argv[0]));
|
||||||
|
|
||||||
|
obj = to_jsdisp(get_object(argv[0]));
|
||||||
|
if(!obj) {
|
||||||
|
FIXME("Non-JS object\n");
|
||||||
|
return E_NOTIMPL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(r) *r = jsval_bool(obj->extensible);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static const builtin_prop_t ObjectConstr_props[] = {
|
static const builtin_prop_t ObjectConstr_props[] = {
|
||||||
{L"create", Object_create, PROPF_ES5|PROPF_METHOD|2},
|
{L"create", Object_create, PROPF_ES5|PROPF_METHOD|2},
|
||||||
{L"defineProperties", Object_defineProperties, PROPF_ES5|PROPF_METHOD|2},
|
{L"defineProperties", Object_defineProperties, PROPF_ES5|PROPF_METHOD|2},
|
||||||
{L"defineProperty", Object_defineProperty, PROPF_ES5|PROPF_METHOD|2},
|
{L"defineProperty", Object_defineProperty, PROPF_ES5|PROPF_METHOD|2},
|
||||||
{L"getOwnPropertyDescriptor", Object_getOwnPropertyDescriptor, PROPF_ES5|PROPF_METHOD|2},
|
{L"getOwnPropertyDescriptor", Object_getOwnPropertyDescriptor, PROPF_ES5|PROPF_METHOD|2},
|
||||||
{L"getPrototypeOf", Object_getPrototypeOf, PROPF_ES5|PROPF_METHOD|1},
|
{L"getPrototypeOf", Object_getPrototypeOf, PROPF_ES5|PROPF_METHOD|1},
|
||||||
|
{L"isExtensible", Object_isExtensible, PROPF_ES5|PROPF_METHOD|1},
|
||||||
{L"keys", Object_keys, PROPF_ES5|PROPF_METHOD|1},
|
{L"keys", Object_keys, PROPF_ES5|PROPF_METHOD|1},
|
||||||
{L"preventExtensions", Object_preventExtensions, PROPF_ES5|PROPF_METHOD|1},
|
{L"preventExtensions", Object_preventExtensions, PROPF_ES5|PROPF_METHOD|1},
|
||||||
};
|
};
|
||||||
|
|
|
@ -958,6 +958,8 @@ sync_test("preventExtensions", function() {
|
||||||
|
|
||||||
r = Object.preventExtensions(o);
|
r = Object.preventExtensions(o);
|
||||||
ok(r === o, "r != o");
|
ok(r === o, "r != o");
|
||||||
|
r = Object.isExtensible(o);
|
||||||
|
ok(r === false, "isExtensible(o) returned " + r);
|
||||||
|
|
||||||
function Constr() {}
|
function Constr() {}
|
||||||
o = Object.preventExtensions(new Constr());
|
o = Object.preventExtensions(new Constr());
|
||||||
|
@ -965,8 +967,21 @@ sync_test("preventExtensions", function() {
|
||||||
ok(o.prop === 1, "o.prop = " + o.prop);
|
ok(o.prop === 1, "o.prop = " + o.prop);
|
||||||
o.prop = 2;
|
o.prop = 2;
|
||||||
ok(o.prop === 1, "o.prop = " + o.prop);
|
ok(o.prop === 1, "o.prop = " + o.prop);
|
||||||
|
r = Object.isExtensible(o);
|
||||||
|
ok(r === false, "isExtensible(o) returned " + r);
|
||||||
|
|
||||||
|
r = Object.isExtensible({});
|
||||||
|
ok(r === true, "isExtensible(o) returned " + r);
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object.isExtensible(1);
|
||||||
|
ok(false, "exception expected");
|
||||||
|
}catch(e) {
|
||||||
|
ok(e.name === "TypeError", "got " + e.name + " exception");
|
||||||
|
}
|
||||||
|
|
||||||
ok(Object.preventExtensions.length === 1, "Object.preventExtensions.length = " + Object.preventExtensions.length);
|
ok(Object.preventExtensions.length === 1, "Object.preventExtensions.length = " + Object.preventExtensions.length);
|
||||||
|
ok(Object.isExtensible.length === 1, "Object.isExtensible.length = " + Object.isExtensible.length);
|
||||||
});
|
});
|
||||||
|
|
||||||
sync_test("head_setter", function() {
|
sync_test("head_setter", function() {
|
||||||
|
|
Loading…
Reference in New Issue