jscript: Add Object.preventExtensions semi-stub implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-06-05 18:26:39 +02:00 committed by Alexandre Julliard
parent fe0bd340cd
commit 2e767e81cc
2 changed files with 45 additions and 2 deletions

View File

@ -671,13 +671,35 @@ static HRESULT Object_keys(script_ctx_t *ctx, vdisp_t *jsthis, WORD flags,
return hres;
}
static HRESULT Object_preventExtensions(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])) {
FIXME("invalid arguments\n");
return E_NOTIMPL;
}
FIXME("(%s) semi-stub\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_obj(jsdisp_addref(obj));
return S_OK;
}
static const builtin_prop_t ObjectConstr_props[] = {
{L"create", Object_create, PROPF_ES5|PROPF_METHOD|2},
{L"defineProperties", Object_defineProperties, PROPF_ES5|PROPF_METHOD|2},
{L"defineProperty", Object_defineProperty, PROPF_ES5|PROPF_METHOD|2},
{L"getOwnPropertyDescriptor", Object_getOwnPropertyDescriptor, PROPF_ES5|PROPF_METHOD|2},
{L"getPrototypeOf", Object_getPrototypeOf, 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},
};
static const builtin_info_t ObjectConstr_info = {

View File

@ -924,7 +924,28 @@ sync_test("reduce", function() {
try {
[].reduce(function(a) { return 0; });
ok(false, "expected exception");
}catch(e) {trace(e.message);}
}catch(e) {}
ok(Array.prototype.reduce.length === 1, "Array.prototype.reduce.length = " + Array.prototype.reduce.length);
});
sync_test("preventExtensions", function() {
var o = {};
var r = Object.preventExtensions(o);
ok(r === o, "r != o");
o.x = 1;
todo_wine.
ok(!("x" in o), "x property added to o");
try {
Object.defineProperty(o, "y", { value: true });
todo_wine.
ok(false, "expected exception");
}catch(e) {
ok(e.name === "TypeError", "got " + e.name + " exception");
}
r = Object.preventExtensions(o);
ok(r === o, "r != o");
ok(Object.preventExtensions.length === 1, "Object.preventExtensions.length = " + Object.preventExtensions.length);
});