Fix construction of Arguments object: add handler for 'caller' property that throws TypeError upon read or write access.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan 2015-06-29 22:30:47 +03:00
parent ec02ace0e9
commit 71bac03d51
2 changed files with 21 additions and 2 deletions

View File

@ -268,16 +268,22 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
}
ecma_string_t *callee_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE);
ecma_string_t *caller_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLER);
completion = ecma_op_object_define_own_property (obj_p,
callee_magic_string_p,
&prop_desc,
false);
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
ecma_deref_ecma_string (callee_magic_string_p);
ecma_string_t *caller_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CALLER);
completion = ecma_op_object_define_own_property (obj_p,
caller_magic_string_p,
&prop_desc,
false);
JERRY_ASSERT (ecma_is_completion_value_normal_true (completion));
ecma_deref_ecma_string (caller_magic_string_p);
ecma_deref_object (thrower_p);
}

View File

@ -109,6 +109,19 @@ fn_expr = function (a, b, c)
assert (arguments[0] === 'new value');
assert (arguments[1] === 'p');
assert (arguments[2] === 'q');
function check_type_error_for_property (obj, prop) {
try {
var v = obj[prop];
assert (false);
}
catch (e) {
assert (e instanceof TypeError);
}
}
check_type_error_for_property (arguments, 'caller');
check_type_error_for_property (arguments, 'callee');
}
fn_expr (1);