Paul Gofman : jscript: Also add function name to its detached scope in ES5 mode.

Alexandre Julliard julliard at winehq.org
Mon Aug 9 16:21:43 CDT 2021


Module: wine
Branch: master
Commit: c6a75d49369f7ae262ffbb054c9b27525f5bc406
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c6a75d49369f7ae262ffbb054c9b27525f5bc406

Author: Paul Gofman <pgofman at codeweavers.com>
Date:   Mon Aug  9 16:55:41 2021 +0300

jscript: Also add function name to its detached scope in ES5 mode.

Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/jscript/engine.c    |  4 ++++
 dlls/mshtml/tests/es5.js | 29 +++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c
index cb9ea5cd9ac..47b4e56e8e4 100644
--- a/dlls/jscript/engine.c
+++ b/dlls/jscript/engine.c
@@ -573,6 +573,7 @@ HRESULT jsval_strict_equal(jsval_t lval, jsval_t rval, BOOL *ret)
 
 static HRESULT detach_scope(script_ctx_t *ctx, call_frame_t *frame, scope_chain_t *scope)
 {
+    function_code_t *func = frame->function;
     unsigned int i, index;
     HRESULT hres;
 
@@ -591,6 +592,9 @@ static HRESULT detach_scope(script_ctx_t *ctx, call_frame_t *frame, scope_chain_
         scope->obj = to_disp(scope->jsobj);
     }
 
+    if (scope == frame->base_scope && func->name && ctx->version >= SCRIPTLANGUAGEVERSION_ES5)
+        jsdisp_propput_name(scope->jsobj, func->name, jsval_obj(jsdisp_addref(frame->function_instance)));
+
     index = scope->scope_index;
     for(i = 0; i < frame->function->local_scopes[index].locals_cnt; i++)
     {
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js
index e57aed5ca35..81c06a4145e 100644
--- a/dlls/mshtml/tests/es5.js
+++ b/dlls/mshtml/tests/es5.js
@@ -1447,6 +1447,35 @@ sync_test("functions scope", function() {
     val = with_function();
     ok(val == 8, "val != 8");
     ok(w == 9, "w != 9");
+
+    var func, func_outer, ret;
+    var o = new Object();
+
+    func_outer = function e()
+    {
+        function func_inner()
+        {
+            ok(typeof e == "function", "typeof e == " + typeof e);
+            ret = e
+        }
+        func = func_inner
+    }
+    func_outer();
+    func();
+    ok(ret === func_outer, "ret != func_outer");
+
+    func_outer = function f(f)
+    {
+        function func_inner()
+        {
+            ok(typeof f == "object", "typeof f == " + typeof f);
+            ret = f
+        }
+        func = func_inner
+    }
+    func_outer(o);
+    func();
+    ok(ret === o, "ret != o");
 });
 
 sync_test("console", function() {




More information about the wine-cvs mailing list