Jacek Caban : jscript: Support undefined context value in Array.prototype.map.

Alexandre Julliard julliard at winehq.org
Wed Mar 20 17:09:12 CDT 2019


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Mar 20 17:41:31 2019 +0100

jscript: Support undefined context value in Array.prototype.map.

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

---

 dlls/jscript/array.c     | 5 +++--
 dlls/mshtml/tests/es5.js | 7 +++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/jscript/array.c b/dlls/jscript/array.c
index 0c54fc0..a5acfdf 100644
--- a/dlls/jscript/array.c
+++ b/dlls/jscript/array.c
@@ -1074,11 +1074,12 @@ static HRESULT Array_map(script_ctx_t *ctx, vdisp_t *vthis, WORD flags, unsigned
     callback = get_object(argv[0]);
 
     if(argc > 1) {
-        if(!is_object_instance(argv[1]) || !get_object(argv[1])) {
+        if(is_object_instance(argv[1]) && get_object(argv[1])) {
+            context_this = get_object(argv[1]);
+        }else if(!is_undefined(argv[1])) {
             FIXME("Unsupported context this %s\n", debugstr_jsval(argv[1]));
             return E_NOTIMPL;
         }
-        context_this = get_object(argv[1]);
     }
 
     hres = create_array(ctx, length, &array);
diff --git a/dlls/mshtml/tests/es5.js b/dlls/mshtml/tests/es5.js
index 8e5b846..7afdf97 100644
--- a/dlls/mshtml/tests/es5.js
+++ b/dlls/mshtml/tests/es5.js
@@ -178,6 +178,13 @@ function test_array_map() {
     ok(calls === "0:1,1:3,2:5,", "calls = " + calls);
     ok(m.join() === "0,2,4", "m = " + m);
 
+    [1,2].map(function() {
+        ok(this === window, "this != window");
+    });
+    [1,2].map(function() {
+        ok(this === window, "this != window");
+    }, undefined);
+
     next_test();
 }
 




More information about the wine-cvs mailing list