Commit 9427d325 authored by bmeurer's avatar bmeurer Committed by Commit bot

[es6] Fix invalid ToObject in String/Array iterator next.

The spec says that the "this value" has to be an Object.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/1325023003

Cr-Commit-Position: refs/heads/master@{#30533}
parent fb44484f
......@@ -76,9 +76,10 @@ function ArrayIteratorIterator() {
// 15.4.5.2.2 ArrayIterator.prototype.next( )
function ArrayIteratorNext() {
var iterator = TO_OBJECT(this);
var iterator = this;
if (!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
if (!IS_SPEC_OBJECT(iterator) ||
!HAS_DEFINED_PRIVATE(iterator, arrayIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'Array Iterator.prototype.next', this);
}
......
......@@ -41,9 +41,10 @@ function CreateStringIterator(string) {
// 21.1.5.2.1 %StringIteratorPrototype%.next( )
function StringIteratorNext() {
var iterator = TO_OBJECT(this);
var iterator = this;
if (!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
if (!IS_SPEC_OBJECT(iterator) ||
!HAS_DEFINED_PRIVATE(iterator, stringIteratorNextIndexSymbol)) {
throw MakeTypeError(kIncompatibleMethodReceiver,
'String Iterator.prototype.next');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment