Jacek Caban : jscript: Make global constants non-writable in ES5 mode.
Alexandre Julliard
julliard at winehq.org
Fri May 11 13:22:28 CDT 2018
Module: wine
Branch: master
Commit: 6b1e54a28efb8cf2475ff2dedb4b158a16020850
URL: https://source.winehq.org/git/wine.git/?a=commit;h=6b1e54a28efb8cf2475ff2dedb4b158a16020850
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri May 11 14:43:40 2018 +0200
jscript: Make global constants non-writable in ES5 mode.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/jscript/global.c | 7 ++++---
dlls/mshtml/tests/es5.js | 20 +++++++++++++++++++-
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/dlls/jscript/global.c b/dlls/jscript/global.c
index 6cd5ee9..732b020 100644
--- a/dlls/jscript/global.c
+++ b/dlls/jscript/global.c
@@ -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;
}
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js
index 92024cf..c2e3e9f 100644
--- a/dlls/mshtml/tests/es5.js
+++ b/dlls/mshtml/tests/es5.js
@@ -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
];
More information about the wine-cvs
mailing list