RESOLVED FIXED185197
Iterator of Array.keys() returns object in wrong order
https://bugs.webkit.org/show_bug.cgi?id=185197
Summary Iterator of Array.keys() returns object in wrong order
Amanda Ferraz
Reported 2018-05-02 07:02:57 PDT
Hi everyone, according to ES6 specification (https://www.ecma-international.org/ecma-262/8.0/index.html#sec-createiterresultobject), the Iterator of a TypedArray.keys() or an Array.keys() should return an object on this order {value: Integer, done: Boolean}. Step to reproduce: var arr = new Int8Array([1,2,3]); var iterator = arr.keys(); var a = iterator.next(); var toString = JSON.stringify(a); // just to check if it is the same string if (!(toString === JSON.stringify({value: 0, done: false}))) throw new Error('expected {"value": 0, "done": false}, got ' + toString) Actual results: Error: expected {"value": 0, "done": false}, got {"done": false, "value": 0} Expected results: Pass without failures Other JavaScript engines such as V8, SpiderMonkey and Chakra works as expected.
Attachments
Patch (12.84 KB, patch)
2018-07-11 01:10 PDT, Yusuke Suzuki
no flags
Archive of layout-test-results from ews204 for win-future (12.88 MB, application/zip)
2018-07-11 10:43 PDT, EWS Watchlist
no flags
Amanda Ferraz
Comment 1 2018-05-02 07:15:50 PDT
Additional information (versions): OS: Ubuntu 17.04 Version (tag): 606.1.9.4
Yusuke Suzuki
Comment 2 2018-07-11 01:10:44 PDT
Keith Miller
Comment 3 2018-07-11 08:55:07 PDT
Comment on attachment 344759 [details] Patch r=me.
Joseph Pecoraro
Comment 4 2018-07-11 10:27:46 PDT
Comment on attachment 344759 [details] Patch Neat!. Was this covered by test262?
EWS Watchlist
Comment 5 2018-07-11 10:43:11 PDT
Comment on attachment 344759 [details] Patch Attachment 344759 [details] did not pass win-ews (win): Output: https://webkit-queues.webkit.org/results/8505610 New failing tests: http/tests/security/canvas-remote-read-remote-video-localhost.html
EWS Watchlist
Comment 6 2018-07-11 10:43:23 PDT
Created attachment 344769 [details] Archive of layout-test-results from ews204 for win-future The attached test failures were seen while running run-webkit-tests on the win-ews. Bot: ews204 Port: win-future Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Yusuke Suzuki
Comment 7 2018-07-11 13:01:31 PDT
(In reply to Joseph Pecoraro from comment #4) > Comment on attachment 344759 [details] > Patch > > Neat!. Was this covered by test262? Interestingly, no! It would be fine if we can add it to test262 :D
Saam Barati
Comment 8 2018-07-11 13:13:58 PDT
(In reply to Yusuke Suzuki from comment #7) > (In reply to Joseph Pecoraro from comment #4) > > Comment on attachment 344759 [details] > > Patch > > > > Neat!. Was this covered by test262? > > Interestingly, no! It would be fine if we can add it to test262 :D Is this even specified behavior? I thought ordering of properties was implementation dependent?
WebKit Commit Bot
Comment 9 2018-07-11 13:29:53 PDT
Comment on attachment 344759 [details] Patch Clearing flags on attachment: 344759 Committed r233740: <https://trac.webkit.org/changeset/233740>
WebKit Commit Bot
Comment 10 2018-07-11 13:29:55 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 11 2018-07-11 13:32:17 PDT
Yusuke Suzuki
Comment 12 2018-07-12 01:36:04 PDT
(In reply to Saam Barati from comment #8) > (In reply to Yusuke Suzuki from comment #7) > > (In reply to Joseph Pecoraro from comment #4) > > > Comment on attachment 344759 [details] > > > Patch > > > > > > Neat!. Was this covered by test262? > > > > Interestingly, no! It would be fine if we can add it to test262 :D > > Is this even specified behavior? I thought ordering of properties was > implementation dependent? I'm not sure The spec defines properties in particular order. https://www.ecma-international.org/ecma-262/8.0/index.html#sec-createiterresultobject I don't know whether this definition order would be visible in Object properties definition order. While object needs to show properties in definition order, it is not related to that the above abstract operation requires that behavior (it just describes abstract operation as a example). IMO, this is not required by the spec and this should be implementation dependent thing. But anyway, aligning to the example algorithm in the spec here would be no harm (even if it is an implementation dependent). If it becomes related to the performance problem, we should consider about it seriously (whether it is required in the spec).
Keith Miller
Comment 13 2018-07-12 10:32:32 PDT
(In reply to Yusuke Suzuki from comment #12) > (In reply to Saam Barati from comment #8) > > (In reply to Yusuke Suzuki from comment #7) > > > (In reply to Joseph Pecoraro from comment #4) > > > > Comment on attachment 344759 [details] > > > > Patch > > > > > > > > Neat!. Was this covered by test262? > > > > > > Interestingly, no! It would be fine if we can add it to test262 :D > > > > Is this even specified behavior? I thought ordering of properties was > > implementation dependent? > > I'm not sure The spec defines properties in particular order. > https://www.ecma-international.org/ecma-262/8.0/index.html#sec- > createiterresultobject > I don't know whether this definition order would be visible in Object > properties definition order. > While object needs to show properties in definition order, it is not related > to that the above abstract operation requires that behavior (it just > describes abstract operation as a example). > IMO, this is not required by the spec and this should be implementation > dependent thing. > > But anyway, aligning to the example algorithm in the spec here would be no > harm (even if it is an implementation dependent). > If it becomes related to the performance problem, we should consider about > it seriously (whether it is required in the spec). I'm pretty sure we were wrong because of the way https://tc39.github.io/ecma262/#sec-ordinaryownpropertykeys works. We are be expected to enumerate the named properties in chronological order. Since createIteratorResultObject puts value first value should be enumerated first.
isol2
Comment 14 2018-08-08 08:59:07 PDT
cinfuzz
Note You need to log in before you can comment on or make changes to this bug.