Title: [183371] trunk
Revision
183371
Author
[email protected]
Date
2015-04-26 15:54:21 -0700 (Sun, 26 Apr 2015)

Log Message

Set#forEach does not pass "key" or "set" arguments to callback.
https://bugs.webkit.org/show_bug.cgi?id=144188

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

Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.foreach
Set#forEach should pass 3 arguments to the callback.

* runtime/SetPrototype.cpp:
(JSC::setProtoFuncForEach):

Modified Paths

Added Paths

Diff

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


--- trunk/LayoutTests/js/script-tests/set-foreach-calls-back-with-right-args.js	                        (rev 0)
+++ trunk/LayoutTests/js/script-tests/set-foreach-calls-back-with-right-args.js	2015-04-26 22:54:21 UTC (rev 183371)
@@ -0,0 +1,18 @@
+description("Tests to make sure we call forEach callback with right arguments");
+var s = new Set();
+s.add('value');
+var called = false;
+var receiver = { receiver: true };
+var actual = {};
+s.forEach(function (value, key, set) {
+    called = true;
+    actual.value = value;
+    actual.key = key;
+    actual.set = set;
+    actual.receiver = this;
+}, receiver);
+shouldBeTrue("called");
+shouldBe("actual.value", "'value'");
+shouldBe("actual.key", "'value'");
+shouldBe("actual.set", "s");
+shouldBeTrue("actual.receiver === receiver");

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


--- trunk/LayoutTests/js/set-foreach-calls-back-with-right-args-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/set-foreach-calls-back-with-right-args-expected.txt	2015-04-26 22:54:21 UTC (rev 183371)
@@ -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 'value'
+PASS actual.set is s
+PASS actual.receiver === receiver is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

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


--- trunk/LayoutTests/js/set-foreach-calls-back-with-right-args.html	                        (rev 0)
+++ trunk/LayoutTests/js/set-foreach-calls-back-with-right-args.html	2015-04-26 22:54:21 UTC (rev 183371)
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (183370 => 183371)


--- trunk/Source/_javascript_Core/ChangeLog	2015-04-26 22:44:11 UTC (rev 183370)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-04-26 22:54:21 UTC (rev 183371)
@@ -1,3 +1,16 @@
+2015-04-26  Jordan Harband  <[email protected]>
+
+        Set#forEach does not pass "key" or "set" arguments to callback.
+        https://bugs.webkit.org/show_bug.cgi?id=144188
+
+        Reviewed by Darin Adler.
+
+        Per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.foreach
+        Set#forEach should pass 3 arguments to the callback.
+
+        * runtime/SetPrototype.cpp:
+        (JSC::setProtoFuncForEach):
+
 2015-04-26  Benjamin Poulain  <[email protected]>
 
         [JSC] Implement Math.clz32(), remove Number.clz()

Modified: trunk/Source/_javascript_Core/runtime/SetPrototype.cpp (183370 => 183371)


--- trunk/Source/_javascript_Core/runtime/SetPrototype.cpp	2015-04-26 22:44:11 UTC (rev 183370)
+++ trunk/Source/_javascript_Core/runtime/SetPrototype.cpp	2015-04-26 22:54:21 UTC (rev 183371)
@@ -133,10 +133,12 @@
     JSValue key;
     if (callType == CallTypeJS) {
         JSFunction* function = jsCast<JSFunction*>(callBack);
-        CachedCall cachedCall(callFrame, function, 1);
+        CachedCall cachedCall(callFrame, function, 3);
         while (iterator->next(callFrame, key) && !vm->exception()) {
             cachedCall.setThis(thisValue);
             cachedCall.setArgument(0, key);
+            cachedCall.setArgument(1, key);
+            cachedCall.setArgument(2, set);
             cachedCall.call();
         }
         iterator->finish();
@@ -144,6 +146,8 @@
         while (iterator->next(callFrame, key) && !vm->exception()) {
             MarkedArgumentBuffer args;
             args.append(key);
+            args.append(key);
+            args.append(set);
             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