Bug 159211

Summary: Iterable interfaces should have their related prototype @@iterator property writable
Product: WebKit Reporter: youenn fablet <youennf>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, cgarcia, commit-queue, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: http://heycam.github.io/webidl/#es-iterator
Attachments:
Description Flags
Patch
none
Patch for landing none

Description youenn fablet 2016-06-28 05:25:25 PDT
Currently the property is read-only, which is not consistent with JSC iterators.
Comment 1 youenn fablet 2016-06-28 05:53:13 PDT
Created attachment 282245 [details]
Patch
Comment 2 Chris Dumez 2016-06-28 10:52:12 PDT
Comment on attachment 282245 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=282245&action=review

R=me with comments

> Source/WebCore/ChangeLog:5
> +

<rdar://problem/26950766>

> Source/WebCore/ChangeLog:7
> +

Please link to the spec:
http://heycam.github.io/webidl/#es-iterator

> Source/WebCore/ChangeLog:8
> +        Related to radar 26950766.

Move this to the top.
Comment 3 Chris Dumez 2016-06-28 10:52:53 PDT
<rdar://problem/26950766>
Comment 4 Chris Dumez 2016-06-28 10:56:15 PDT
Comment on attachment 282245 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=282245&action=review

> LayoutTests/fast/dom/nodeListIterator.html:90
> +            shouldNotThrow('NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];');

Please also add a check for the value returned by Object.getOwnPropertyDescriptor(NodeList.prototype, Symbol.iterator) to make sure writable is true, enumerable is false and configurable is true. As per the Web IDL spec.
Comment 5 youenn fablet 2016-06-28 12:28:49 PDT
Thanks for the review.

> > Source/WebCore/ChangeLog:5
> > +
> 
> <rdar://problem/26950766>

OK.

> > Source/WebCore/ChangeLog:7
> > +
> 
> Please link to the spec:
> http://heycam.github.io/webidl/#es-iterator

OK.

> > Source/WebCore/ChangeLog:8
> > +        Related to radar 26950766.
> 
> Move this to the top.

OK

> > LayoutTests/fast/dom/nodeListIterator.html:90
> > +            shouldNotThrow('NodeList.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];');
> 
> Please also add a check for the value returned by
> Object.getOwnPropertyDescriptor(NodeList.prototype, Symbol.iterator) to make
> sure writable is true, enumerable is false and configurable is true. As per
> the Web IDL spec.

OK
FWIW, I plan to beef-up wpt idlharness.js to have thorough testing of iterable and setlike.
Comment 6 youenn fablet 2016-06-28 12:49:40 PDT
Created attachment 282271 [details]
Patch for landing
Comment 7 WebKit Commit Bot 2016-06-28 13:19:22 PDT
Comment on attachment 282271 [details]
Patch for landing

Clearing flags on attachment: 282271

Committed r202583: <http://trac.webkit.org/changeset/202583>
Comment 8 WebKit Commit Bot 2016-06-28 13:19:26 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 youenn fablet 2016-06-29 03:35:22 PDT
> FWIW, I plan to beef-up wpt idlharness.js to have thorough testing of
> iterable and setlike.

Related PR is https://github.com/w3c/testharness.js/pull/201