Title: [202956] trunk
Revision
202956
Author
[email protected]
Date
2016-07-07 21:10:00 -0700 (Thu, 07 Jul 2016)

Log Message

[JSC] String.prototype[Symbol.iterator] needs a name
https://bugs.webkit.org/show_bug.cgi?id=159541

Reviewed by Yusuke Suzuki.

Source/_javascript_Core:

A man needs a name.
Spec: https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator

* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):

LayoutTests:

* js/script-tests/string-iterator.js: Added.
* js/string-iterator-expected.txt: Added.
* js/string-iterator.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202955 => 202956)


--- trunk/LayoutTests/ChangeLog	2016-07-08 03:47:59 UTC (rev 202955)
+++ trunk/LayoutTests/ChangeLog	2016-07-08 04:10:00 UTC (rev 202956)
@@ -1,3 +1,14 @@
+2016-07-07  Benjamin Poulain  <[email protected]>
+
+        [JSC] String.prototype[Symbol.iterator] needs a name
+        https://bugs.webkit.org/show_bug.cgi?id=159541
+
+        Reviewed by Yusuke Suzuki.
+
+        * js/script-tests/string-iterator.js: Added.
+        * js/string-iterator-expected.txt: Added.
+        * js/string-iterator.html: Added.
+
 2016-07-07  Joseph Pecoraro  <[email protected]>
 
         Unexpected "Out of memory" error for "x".repeat(-1)

Added: trunk/LayoutTests/js/script-tests/string-iterator.js (0 => 202956)


--- trunk/LayoutTests/js/script-tests/string-iterator.js	                        (rev 0)
+++ trunk/LayoutTests/js/script-tests/string-iterator.js	2016-07-08 04:10:00 UTC (rev 202956)
@@ -0,0 +1,41 @@
+"use strict"
+
+description("Verify the various properties of String.prototype[Symbol.iterator]");
+
+
+debug("Iterator object properties");
+shouldBeEqualToString("typeof String.prototype[Symbol.iterator]", "function");
+shouldBeEqualToString("String.prototype[Symbol.iterator].name", "[Symbol.iterator]");
+shouldBe("String.prototype[Symbol.iterator].length", "0");
+shouldBeTrue("Object.getOwnPropertyDescriptor(String.prototype, Symbol.iterator).configurable");
+shouldBeFalse("Object.getOwnPropertyDescriptor(String.prototype, Symbol.iterator).enumerable");
+shouldBeTrue("Object.getOwnPropertyDescriptor(String.prototype, Symbol.iterator).writable");
+shouldBeFalse("String.prototype[Symbol.iterator]() === String.prototype[Symbol.iterator]()");
+
+debug("Iterating a simple string.");
+let iterator = "WebKit"[Symbol.iterator]();
+
+let next = iterator.next();
+shouldBeEqualToString("next.value", "W");
+shouldBeFalse("next.done");
+next = iterator.next();
+shouldBeEqualToString("next.value", "e");
+shouldBeFalse("next.done");
+next = iterator.next();
+shouldBeEqualToString("next.value", "b");
+shouldBeFalse("next.done");
+next = iterator.next();
+shouldBeEqualToString("next.value", "K");
+shouldBeFalse("next.done");
+next = iterator.next();
+shouldBeEqualToString("next.value", "i");
+shouldBeFalse("next.done");
+next = iterator.next();
+shouldBeEqualToString("next.value", "t");
+shouldBeFalse("next.done");
+next = iterator.next();
+shouldBe("next.value", "undefined");
+shouldBeTrue("next.done");
+next = iterator.next();
+shouldBe("next.value", "undefined");
+shouldBeTrue("next.done");

Added: trunk/LayoutTests/js/string-iterator-expected.txt (0 => 202956)


--- trunk/LayoutTests/js/string-iterator-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/js/string-iterator-expected.txt	2016-07-08 04:10:00 UTC (rev 202956)
@@ -0,0 +1,34 @@
+Verify the various properties of String.prototype[Symbol.iterator]
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Iterator object properties
+PASS typeof String.prototype[Symbol.iterator] is "function"
+PASS String.prototype[Symbol.iterator].name is "[Symbol.iterator]"
+PASS String.prototype[Symbol.iterator].length is 0
+PASS Object.getOwnPropertyDescriptor(String.prototype, Symbol.iterator).configurable is true
+PASS Object.getOwnPropertyDescriptor(String.prototype, Symbol.iterator).enumerable is false
+PASS Object.getOwnPropertyDescriptor(String.prototype, Symbol.iterator).writable is true
+PASS String.prototype[Symbol.iterator]() === String.prototype[Symbol.iterator]() is false
+Iterating a simple string.
+PASS next.value is "W"
+PASS next.done is false
+PASS next.value is "e"
+PASS next.done is false
+PASS next.value is "b"
+PASS next.done is false
+PASS next.value is "K"
+PASS next.done is false
+PASS next.value is "i"
+PASS next.done is false
+PASS next.value is "t"
+PASS next.done is false
+PASS next.value is undefined
+PASS next.done is true
+PASS next.value is undefined
+PASS next.done is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/js/string-iterator.html (0 => 202956)


--- trunk/LayoutTests/js/string-iterator.html	                        (rev 0)
+++ trunk/LayoutTests/js/string-iterator.html	2016-07-08 04:10:00 UTC (rev 202956)
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script src=""
+<script src=""
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (202955 => 202956)


--- trunk/Source/_javascript_Core/ChangeLog	2016-07-08 03:47:59 UTC (rev 202955)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-07-08 04:10:00 UTC (rev 202956)
@@ -1,3 +1,16 @@
+2016-07-07  Benjamin Poulain  <[email protected]>
+
+        [JSC] String.prototype[Symbol.iterator] needs a name
+        https://bugs.webkit.org/show_bug.cgi?id=159541
+
+        Reviewed by Yusuke Suzuki.
+
+        A man needs a name.
+        Spec: https://tc39.github.io/ecma262/#sec-string.prototype-@@iterator
+
+        * runtime/StringPrototype.cpp:
+        (JSC::StringPrototype::finishCreation):
+
 2016-07-07  Michael Saboff  <[email protected]>
 
         REGRESSION(184445): Need to insert a StoreBarrier when we don't know child's epoch

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (202955 => 202956)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2016-07-08 03:47:59 UTC (rev 202955)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2016-07-08 04:10:00 UTC (rev 202956)
@@ -174,10 +174,11 @@
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("endsWith", stringProtoFuncEndsWith, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("includes", stringProtoFuncIncludes, DontEnum, 1);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("normalize", stringProtoFuncNormalize, DontEnum, 0);
-    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->iteratorSymbol, stringProtoFuncIterator, DontEnum, 0);
-
     JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().charCodeAtPrivateName(), stringProtoFuncCharCodeAt, DontEnum, 1, CharCodeAtIntrinsic);
 
+    JSFunction* iteratorFunction = JSFunction::create(vm, globalObject, 0, ASCIILiteral("[Symbol.iterator]"), stringProtoFuncIterator, NoIntrinsic);
+    putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, iteratorFunction, DontEnum);
+
     // The constructor will be added later, after StringConstructor has been built
     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(0), DontDelete | ReadOnly | DontEnum);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to