mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-01 08:13:18 +00:00
jscript: Make global constants non-writable in ES5 mode.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4555828c57
commit
6b1e54a28e
2 changed files with 23 additions and 4 deletions
|
@ -1087,6 +1087,7 @@ static HRESULT init_constructors(script_ctx_t *ctx, jsdisp_t *object_prototype)
|
|||
|
||||
HRESULT init_global(script_ctx_t *ctx)
|
||||
{
|
||||
unsigned const_flags = ctx->version >= SCRIPTLANGUAGEVERSION_ES5 ? 0 : PROPF_WRITABLE;
|
||||
jsdisp_t *math, *object_prototype, *constr;
|
||||
HRESULT hres;
|
||||
|
||||
|
@ -1137,14 +1138,14 @@ HRESULT init_global(script_ctx_t *ctx)
|
|||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = jsdisp_propput_dontenum(ctx->global, undefinedW, jsval_undefined());
|
||||
hres = jsdisp_define_data_property(ctx->global, undefinedW, const_flags, jsval_undefined());
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = jsdisp_propput_dontenum(ctx->global, NaNW, jsval_number(NAN));
|
||||
hres = jsdisp_define_data_property(ctx->global, NaNW, const_flags, jsval_number(NAN));
|
||||
if(FAILED(hres))
|
||||
return hres;
|
||||
|
||||
hres = jsdisp_propput_dontenum(ctx->global, InfinityW, jsval_number(INFINITY));
|
||||
hres = jsdisp_define_data_property(ctx->global, InfinityW, const_flags, jsval_number(INFINITY));
|
||||
return hres;
|
||||
}
|
||||
|
|
|
@ -284,6 +284,23 @@ function test_defineProperty() {
|
|||
next_test();
|
||||
}
|
||||
|
||||
function test_global_properties() {
|
||||
var o;
|
||||
|
||||
/* Make sure that global properties are not writable. */
|
||||
o = NaN;
|
||||
NaN = 1;
|
||||
ok(isNaN(NaN), "NaN = " + NaN);
|
||||
o = undefined;
|
||||
undefined = 1;
|
||||
ok(undefined === o, "NaN = " + NaN);
|
||||
o = Infinity;
|
||||
Infinity = 1;
|
||||
ok(Infinity === o, "Infinity = " + NaN);
|
||||
|
||||
next_test();
|
||||
}
|
||||
|
||||
var tests = [
|
||||
test_date_now,
|
||||
test_toISOString,
|
||||
|
@ -291,5 +308,6 @@ var tests = [
|
|||
test_isArray,
|
||||
test_identifier_keywords,
|
||||
test_getOwnPropertyDescriptor,
|
||||
test_defineProperty
|
||||
test_defineProperty,
|
||||
test_global_properties
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue