DescriptionMake pair iterators inherit from %IteratorPrototype%.
Adjust the prototype chain for iterator objects returned by interfaces that
have pair iterators.
The WebIDL spec says when an interface has pair iterators the iterators it
returns must be instances of the "default iterator object" whose
[[Prototype]] points to an "iterator prototype object" whose [[Prototype]],
on its turn, points to %IteratorPrototype%. next() must be implemented in
the "iterator prototype object", while %IteratorPrototype% provides
@@iterator.
In practice, this means the following should return true but was returning
false:
Object.getPrototypeOf(Object.getPrototypeOf(new Headers().entries())) === Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))
Previously, we just had the Iterator interface with both next() and
@@iterator added to its prototype object, which just inherited from
Object.prototype. We now adhere to the spec by making Iterator's prototype
object inherit by %IteratorPrototype% (which then inherits from
Object.prototype) instead. It also allows us to remove support for the
non-standard "Iterable" extended attribute we had in Blink.
The way we do it is not very pretty though: when the code for the Iterator
interface is generated, we create another function template with no
prototype and set the "prototype" property of its function object. When
|interfaceTemplate| is instantiated, its prototype.__proto__ will point to
the value of the "prototype" property we set, which is exactly what we want.
BUG=689576
R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org
Review-Url: https://codereview.chromium.org/2777183004
Cr-Commit-Position: refs/heads/master@{#463224}
Committed: https://chromium.googlesource.com/chromium/src/+/6579200aa9189bce1cd61c05fb6eb4493f2302d8
Patch Set 1 #Patch Set 2 : Rebased patch with tests #
Total comments: 6
Patch Set 3 : Address Yuki's comments #
Total comments: 1
Patch Set 4 : Fix typo in comment #Patch Set 5 : Rebase after The Blink Rename #Patch Set 6 : Fix the build after The Blink Rename #Messages
Total messages: 28 (11 generated)
|