jscript: Throw error when accessing arguments prop of bind functions.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
This commit is contained in:
Gabriel Ivăncescu 2023-06-22 16:19:01 +03:00 committed by Alexandre Julliard
parent 426f4bb3ea
commit a4c2f6ab72
2 changed files with 15 additions and 1 deletions

View file

@ -912,13 +912,18 @@ HRESULT create_source_function(script_ctx_t *ctx, bytecode_t *code, function_cod
return S_OK;
}
static HRESULT BindFunction_get_arguments(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
return JS_E_INVALID_ACTION;
}
static HRESULT BindFunction_get_caller(script_ctx_t *ctx, jsdisp_t *jsthis, jsval_t *r)
{
return JS_E_INVALID_ACTION;
}
static const builtin_prop_t BindFunction_props[] = {
{L"arguments", NULL, 0, Function_get_arguments},
{L"arguments", NULL, 0, BindFunction_get_arguments},
{L"caller", NULL, 0, BindFunction_get_caller},
{L"length", NULL, 0, Function_get_length}
};

View file

@ -532,8 +532,10 @@ sync_test("getOwnPropertyDescriptor", function() {
test_own_data_prop_desc(String, "prototype", false, false, false);
test_own_data_prop_desc(function(){}, "prototype", true, false, false);
test_own_data_prop_desc(function(){}, "caller", false, false, false);
test_own_data_prop_desc(function(){}, "arguments", false, false, false);
test_own_data_prop_desc(Function, "prototype", false, false, false);
test_own_data_prop_desc(Function.prototype, "caller", false, false, false);
test_own_data_prop_desc(Function.prototype, "arguments", false, false, false);
test_own_data_prop_desc(String.prototype, "constructor", true, false, true);
try {
@ -1140,6 +1142,13 @@ sync_test("bind", function() {
r = f.call(o2);
ok(r === 1, "r = " + r);
try {
f.arguments;
ok(false, "expected exception getting f.arguments");
}catch(ex) {
var n = ex.number >>> 0;
ok(n === JS_E_INVALID_ACTION, "f.arguments threw " + n);
}
try {
f.caller;
ok(false, "expected exception getting f.caller");