Commit 6b1e54a2 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

jscript: Make global constants non-writable in ES5 mode.

parent 4555828c
......@@ -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
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment