Title: [183374] trunk
Revision
183374
Author
[email protected]
Date
2015-04-26 17:33:48 -0700 (Sun, 26 Apr 2015)

Log Message

Map#forEach does not pass "map" argument to callback.
https://bugs.webkit.org/show_bug.cgi?id=144187

Patch by Jordan Harband <[email protected]> on 2015-04-26
Reviewed by Darin Adler.

Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map.prototype.foreach
step 7.a.i., the callback should be called with three arguments.

* runtime/MapPrototype.cpp:
(JSC::mapProtoFuncForEach):

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/js/map-foreach-calls-back-with-right-args-expected.txt (0 => 183374)


--- trunk/LayoutTests/js/map-foreach-calls-back-with-right-args-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/map-foreach-calls-back-with-right-args-expected.txt	2015-04-27 00:33:48 UTC (rev 183374)
@@ -0,0 +1,14 @@
+Tests to make sure we call forEach callback with right arguments
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS called is true
+PASS actual.value is 'value'
+PASS actual.key is 'key'
+PASS actual.map is m
+PASS actual.receiver is receiver
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/map-foreach-calls-back-with-right-args.html (0 => 183374)


--- trunk/LayoutTests/js/map-foreach-calls-back-with-right-args.html	                        (rev 0)
+++ trunk/LayoutTests/js/map-foreach-calls-back-with-right-args.html	2015-04-27 00:33:48 UTC (rev 183374)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/js/script-tests/map-foreach-calls-back-with-right-args.js (0 => 183374)


--- trunk/LayoutTests/js/script-tests/map-foreach-calls-back-with-right-args.js	                        (rev 0)
+++ trunk/LayoutTests/js/script-tests/map-foreach-calls-back-with-right-args.js	2015-04-27 00:33:48 UTC (rev 183374)
@@ -0,0 +1,18 @@
+description("Tests to make sure we call forEach callback with right arguments");
+var m = new Map();
+m.set('key', 'value');
+var called = false;
+var actual = {};
+var receiver = { receiver: true };
+m.forEach(function (value, key, map) {
+    called = true;
+    actual.value = value;
+    actual.key = key;
+    actual.map = map;
+    actual.receiver = this;
+}, receiver);
+shouldBeTrue("called");
+shouldBe("actual.value", "'value'");
+shouldBe("actual.key", "'key'");
+shouldBe("actual.map", "m");
+shouldBe("actual.receiver", "receiver");

Modified: trunk/Source/_javascript_Core/ChangeLog (183373 => 183374)


--- trunk/Source/_javascript_Core/ChangeLog	2015-04-27 00:27:28 UTC (rev 183373)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-04-27 00:33:48 UTC (rev 183374)
@@ -1,3 +1,16 @@
+2015-04-26  Jordan Harband  <[email protected]>
+
+        Map#forEach does not pass "map" argument to callback.
+        https://bugs.webkit.org/show_bug.cgi?id=144187
+
+        Reviewed by Darin Adler.
+
+        Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map.prototype.foreach
+        step 7.a.i., the callback should be called with three arguments.
+
+        * runtime/MapPrototype.cpp:
+        (JSC::mapProtoFuncForEach):
+
 2015-04-26  Yusuke Suzuki  <[email protected]>
 
         [ES6] Implement ES6 template literals

Modified: trunk/Source/_javascript_Core/runtime/MapPrototype.cpp (183373 => 183374)


--- trunk/Source/_javascript_Core/runtime/MapPrototype.cpp	2015-04-27 00:27:28 UTC (rev 183373)
+++ trunk/Source/_javascript_Core/runtime/MapPrototype.cpp	2015-04-27 00:33:48 UTC (rev 183374)
@@ -125,11 +125,12 @@
     JSValue key, value;
     if (callType == CallTypeJS) {
         JSFunction* function = jsCast<JSFunction*>(callBack);
-        CachedCall cachedCall(callFrame, function, 2);
+        CachedCall cachedCall(callFrame, function, 3);
         while (iterator->nextKeyValue(key, value) && !vm->exception()) {
             cachedCall.setThis(thisValue);
             cachedCall.setArgument(0, value);
             cachedCall.setArgument(1, key);
+            cachedCall.setArgument(2, map);
             cachedCall.call();
         }
         iterator->finish();
@@ -138,6 +139,7 @@
             MarkedArgumentBuffer args;
             args.append(value);
             args.append(key);
+            args.append(map);
             JSC::call(callFrame, callBack, callType, callData, thisValue, args);
         }
         iterator->finish();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to